export type RemoteStateConsumerRelationship = {id: string, type: 'workspaces'}; export type RemoteStateConsumerRelationshipFieldsetsListingDocument = {data?: Array | undefined, included?: Array> | undefined, links?: {[key: string]: string} | undefined, meta?: Record | undefined}; export type CreateApiWorkspacesWorkspaceRelationshipsRemoteStateConsumersArgs = {workspace: string, body: RemoteStateConsumerRelationshipFieldsetsListingDocument}; export type CreateApiWorkspacesWorkspaceRelationshipsRemoteStateConsumersOptions = {baseUrl?: string | undefined, APIKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add remote state consumers * * POST /workspaces/{workspace}/relationships/remote-state-consumers */ export const createApiWorkspacesWorkspaceRelationshipsRemoteStateConsumers = async (args: CreateApiWorkspacesWorkspaceRelationshipsRemoteStateConsumersArgs, options?: CreateApiWorkspacesWorkspaceRelationshipsRemoteStateConsumersOptions) => { const {baseUrl = "https://example.scalr.io/api/iacp/v3", fetch: fetchFn = fetch, APIKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") if (APIKey !== undefined) headers.set('authorization', `Bearer ${APIKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/workspaces/${encodeURIComponent(String(args.workspace))}/relationships/remote-state-consumers${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 };