export type LabelDto = {name: string, color: string}; export type DeviceModelDto = {modelId?: (string | null) | undefined, image?: (string | null) | undefined, name: string, description?: (string | null) | undefined, isBuiltin?: boolean | undefined, supportLoRaFeatures?: boolean | undefined, labels?: (Array | null) | undefined}; export type UpdateApiApiModelsArgs = {body: DeviceModelDto}; export type UpdateApiApiModelsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Updates the specified device model. * * PUT /api/models */ export const updateApiApiModels = async (args: UpdateApiApiModelsArgs, options: UpdateApiApiModelsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/models${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 };