//native
type Vectara = {
apiKey: string
}
/**
* List API keys
*
*/
export async function main(
auth: Vectara,
limit: string | undefined,
page_key: string | undefined,
corpus_key: string | undefined
) {
const url = new URL(`https://api.vectara.io/v2/api_keys`)
for (const [k, v] of [
['limit', limit],
['page_key', page_key],
['corpus_key', corpus_key]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
'x-api-key': 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 581 days ago