export type JobStoreValue = {secret: boolean, value: string}; export type UpdateApi0JobsJobStoreNameArgs = {job: string, name: string, body: JobStoreValue}; export type UpdateApi0JobsJobStoreNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * PUT /0/jobs/{job}/store/{name} */ export const updateApi0JobsJobStoreName = async (args: UpdateApi0JobsJobStoreNameArgs, options: UpdateApi0JobsJobStoreNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/0/jobs/${encodeURIComponent(String(args.job))}/store/${encodeURIComponent(String(args.name))}${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 };