export type UpdateApiFilesDefaultFileKeyArgs = {fileKey: string, Host: string, 'Content-Length': string, 'Content-Type': string, 'Content-Encoding'?: string | undefined, 'Content-Language'?: string | undefined, body: BodyInit}; export type UpdateApiFilesDefaultFileKeyOptions = {baseUrl?: string | undefined, oAuth2ClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Archive a file * * PUT /files/default/{fileKey} */ export const updateApiFilesDefaultFileKey = async (args: UpdateApiFilesDefaultFileKeyArgs, options?: UpdateApiFilesDefaultFileKeyOptions) => { const {baseUrl = "https://eventfeed.api.globalrelay.com/v2", fetch: fetchFn = fetch, oAuth2ClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (args.Host != null) headers.set("Host", String(args.Host)) if (args['Content-Length'] != null) headers.set("Content-Length", String(args['Content-Length'])) if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args['Content-Encoding'] != null) headers.set("Content-Encoding", String(args['Content-Encoding'])) if (args['Content-Language'] != null) headers.set("Content-Language", String(args['Content-Language'])) if (oAuth2ClientCredentials !== undefined) headers.set('authorization', `Bearer ${oAuth2ClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/files/default/${encodeURIComponent(String(args.fileKey))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };