//native
type Zuplo = {
apiKey: string
}
/**
* Lists keys
* Lists all keys for this consumer.
*/
export async function main(
auth: Zuplo,
accountName: string,
bucketName: string,
consumerName: string,
limit: string | undefined,
offset: string | undefined,
key_format: 'none' | 'visible' | 'masked' | undefined
) {
const url = new URL(
`https://dev.zuplo.com/v1/accounts/${accountName}/key-buckets/${bucketName}/consumers/${consumerName}/keys`
)
for (const [k, v] of [
['limit', limit],
['offset', offset],
['key-format', key_format]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago