export type UpdateApiApiEnvironmentKeyArgs = {key: string, body: BodyInit}; export type UpdateApiApiEnvironmentKeyOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or update an environment variable (requires metadata or admin role) * * PUT /api/environment/{key} */ export const updateApiApiEnvironmentKey = async (args: UpdateApiApiEnvironmentKeyArgs, options?: UpdateApiApiEnvironmentKeyOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "text/plain") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/environment/${encodeURIComponent(String(args.key))}${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 };