export type CWObjectPolicyStatement = {name?: string | undefined, effect?: string | undefined, actions?: Array | undefined, resources?: Array | undefined, principals?: Array | undefined}; export type CWObjectPolicy = {version?: string | undefined, name?: string | undefined, statements?: Array | undefined}; export type EnsureAccessPolicyRequest = {policy: CWObjectPolicy}; export type CreateApiV1CwobjectAccessPolicyArgs = {body: EnsureAccessPolicyRequest}; export type CreateApiV1CwobjectAccessPolicyOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Apply or update access policy * * POST /v1/cwobject/access-policy */ export const createApiV1CwobjectAccessPolicy = async (args: CreateApiV1CwobjectAccessPolicyArgs, options?: CreateApiV1CwobjectAccessPolicyOptions) => { const {baseUrl = "https://api.coreweave.com", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/cwobject/access-policy${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 };