export type GetApiEnvironmentsArgs = {name?: string | undefined}; export type GetApiEnvironmentsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * List available environment * * GET /environments */ export const getApiEnvironments = async (args: GetApiEnvironmentsArgs, options?: GetApiEnvironmentsOptions) => { const {baseUrl = "http://localhost:8080/v1", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.name != null) query.append("name", String(args.name)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/environments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };