export type Driver = {Name: string, Options?: {[key: string]: string} | undefined}; export type SecretSpec = {Name?: string | undefined, Labels?: {[key: string]: string} | undefined, Data?: string | undefined, Driver?: Driver | undefined, Templating?: Driver | undefined}; export type CreateApiSecretsIdUpdateArgs = {id: string, version: number, body: SecretSpec}; export type CreateApiSecretsIdUpdateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update a Secret * * POST /secrets/{id}/update */ export const createApiSecretsIdUpdate = async (args: CreateApiSecretsIdUpdateArgs, options: CreateApiSecretsIdUpdateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.version != null) query.append("version", String(args.version)) const url = `${baseUrl.replace(/\/+$/, '')}/secrets/${encodeURIComponent(String(args.id))}/update${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };