export type PortRules = {recordOnActive?: boolean | undefined, icon?: ('siren' | 'light' | 'dot' | 'door' | 'bell' | null) | undefined, iconEnabled?: boolean | undefined}; export type Port = {id?: string | undefined, enabled?: boolean | undefined, name?: string | undefined, type?: ('input' | 'output') | undefined, idleCircuitState?: ('open' | 'closed') | undefined, rules?: PortRules | undefined}; export type PortStatusPatch = {state?: ('active' | 'idle') | undefined, durationSeconds?: number | undefined}; export type PortOutputPatch = {id?: string | undefined, enabled?: boolean | undefined, name?: string | undefined, type?: ('input' | 'output') | undefined, idleCircuitState?: ('open' | 'closed') | undefined, rules?: PortRules | undefined, status?: PortStatusPatch | undefined}; export type PortPatch = Port | PortOutputPatch; export type PatchApiCamerasCameraIdIoPortsPortIdArgs = {body: PortPatch}; export type PatchApiCamerasCameraIdIoPortsPortIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update the port configuration. Allowed properties depends on the port type. * * PATCH /cameras/{cameraId}/io/ports/{portId} */ export const patchApiCamerasCameraIdIoPortsPortId = async (args: PatchApiCamerasCameraIdIoPortsPortIdArgs, options?: PatchApiCamerasCameraIdIoPortsPortIdOptions) => { const {baseUrl = "https://api.cxxx.eagleeyenetworks.com/api/v3.0", 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(/\/+$/, '')}/cameras/${encodeURIComponent(String(args.cameraId))}/io/ports/${encodeURIComponent(String(args.portId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };