export type CreateApiCollectionsCollectionIdPermissionArgs = {collectionId: string}; export type CreateApiCollectionsCollectionIdPermissionOptions = {baseUrl?: string | undefined, JWT?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Collection Permissions * * POST /collections/{collectionId}/permission * * Also accepts auth: BasicAuth */ export const createApiCollectionsCollectionIdPermission = async (args: CreateApiCollectionsCollectionIdPermissionArgs, options?: CreateApiCollectionsCollectionIdPermissionOptions) => { const {baseUrl = "https://api.planet.com/features/v1/ogc/my", fetch: fetchFn = fetch, JWT} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (JWT !== undefined) headers.set('authorization', `Bearer ${JWT}`) const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.collectionId))}/permission${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };