export type RestSetSecretRequest = {value: string}; export type UpdateApiApiProjectsIdSecretsKeyArgs = {id: number, key: string, body: RestSetSecretRequest}; export type UpdateApiApiProjectsIdSecretsKeyOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set a secret to a project * * PUT /api/projects/{id}/secrets/{key} */ export const updateApiApiProjectsIdSecretsKey = async (args: UpdateApiApiProjectsIdSecretsKeyArgs, options?: UpdateApiApiProjectsIdSecretsKeyOptions) => { const {baseUrl = "https://api-workflow.treasuredata.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuth !== undefined) headers.set('authorization', `TD1 ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/projects/${encodeURIComponent(String(args.id))}/secrets/${encodeURIComponent(String(args.key))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };