export type Link = {href?: (string | null) | undefined, filename_properties?: (Array | null) | undefined, title?: (string | null) | undefined, templated?: boolean | undefined}; export type EntityResource = {id?: number | undefined, identifier?: (string | null) | undefined, cultures?: (Array | null) | undefined, properties?: ({[key: string]: Record | null} | null) | undefined, relations?: ({[key: string]: Record | null} | null) | undefined, created_by?: Link | undefined, created_on?: string | undefined, modified_by?: Link | undefined, modified_on?: string | undefined, locked_by?: Link | undefined, locked_on?: (string | null) | undefined, entitydefinition?: Link | undefined, copy?: Link | undefined, copyasync?: Link | undefined, permissions?: Link | undefined, requested_permissions?: ({[key: string]: boolean | null} | null) | undefined, lifecycle?: Link | undefined, saved_selections?: Link | undefined, roles?: Link | undefined, annotations?: Link | undefined, is_root_taxonomy_item?: (boolean | null) | undefined, is_path_root?: (boolean | null) | undefined, inherits_security?: boolean | undefined, is_system_owned?: boolean | undefined, version?: number | undefined, full?: Link | undefined, modules?: (Array | null) | undefined, self?: Link | undefined} | {[key: string]: unknown}; export type UpdateApiApiEntitiesIdentifierIdentifierArgs = {identifier: string, culture?: string | undefined, groups?: string | undefined, members?: string | undefined, body: EntityResource}; export type UpdateApiApiEntitiesIdentifierIdentifierOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update an entity using its identifier * * PUT /api/entities/identifier/{identifier} */ export const updateApiApiEntitiesIdentifierIdentifier = async (args: UpdateApiApiEntitiesIdentifierIdentifierArgs, options?: UpdateApiApiEntitiesIdentifierIdentifierOptions) => { const {baseUrl = "https://your-server", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.culture != null) query.append("culture", String(args.culture)) if (args.groups != null) query.append("groups", String(args.groups)) if (args.members != null) query.append("members", String(args.members)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/entities/identifier/${encodeURIComponent(String(args.identifier))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };