//native
type Vectara = {
apiKey: string
}
/**
* Update a corpus
* Enable, disable, or update the name and description of a corpus. This lets you
manage data availability without deleting the corpus, which is useful for
maintenance and security purposes. The `corpus_key` uniquely identifies the corpus.
For more information, see [Corpus Key Definition](https://docs.vectara.com/docs/api-reference/search-apis/search#corpus-key-definition).
Update the name and description of a corpus dynamically to help keep your data
aligned with changing business needs.
*/
export async function main(
auth: Vectara,
corpus_key: string,
body: { enabled?: false | true; name?: string; description?: string }
) {
const url = new URL(`https://api.vectara.io/v2/corpora/${corpus_key}`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'x-api-key': auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 581 days ago