// This file was generated by liblab | https://liblab.com/ import { z } from 'zod'; import { BaseService } from '../base-service'; import { ContentType, HttpResponse } from '../../http'; import { RequestConfig } from '../../http/types'; import { DeleteDeviceOkResponse, DevicePut, GetDeviceOkResponse, GetDevicesOkResponse, UpdateDeviceOkResponse, deleteDeviceOkResponseResponse, devicePutRequest, getDeviceOkResponseResponse, getDevicesOkResponseResponse, updateDeviceOkResponseResponse, } from './models'; export class DeviceService extends BaseService { /** * List all available devices * @returns {Promise>} Device Success Response */ async getDevices(requestConfig?: RequestConfig): Promise> { const path = '/clip/v2/resource/device'; const options: any = { responseSchema: getDevicesOkResponseResponse, requestSchema: z.any(), headers: {}, requestContentType: ContentType.Json, responseContentType: ContentType.Json, retry: requestConfig?.retry, config: this.config, }; return this.client.get(path, options); } /** * Get details of a single device from its given `{deviceId}`. * @param {string} deviceId - ID of the device * @returns {Promise>} Device Success Response */ async getDevice(deviceId: string, requestConfig?: RequestConfig): Promise> { const path = this.client.buildPath('/clip/v2/resource/device/{deviceId}', { deviceId: deviceId }); const options: any = { responseSchema: getDeviceOkResponseResponse, requestSchema: z.any(), headers: {}, requestContentType: ContentType.Json, responseContentType: ContentType.Json, retry: requestConfig?.retry, config: this.config, }; return this.client.get(path, options); } /** * Update a single device from its given `{deviceId}`. * @param {string} deviceId - ID of the device * @returns {Promise>} Success */ async updateDevice( deviceId: string, body: DevicePut, requestConfig?: RequestConfig, ): Promise> { const path = this.client.buildPath('/clip/v2/resource/device/{deviceId}', { deviceId: deviceId }); const options: any = { responseSchema: updateDeviceOkResponseResponse, requestSchema: devicePutRequest, body: body as any, headers: { 'Content-Type': 'application/json', }, requestContentType: ContentType.Json, responseContentType: ContentType.Json, retry: requestConfig?.retry, config: this.config, }; return this.client.put(path, options); } /** * Delete a single Device from its given `{deviceId}`. The `bridge` device cannot be deleted. * @param {string} deviceId - ID of the Device * @returns {Promise>} Success */ async deleteDevice(deviceId: string, requestConfig?: RequestConfig): Promise> { const path = this.client.buildPath('/clip/v2/resource/device/{deviceId}', { deviceId: deviceId }); const options: any = { responseSchema: deleteDeviceOkResponseResponse, requestSchema: z.any(), headers: {}, requestContentType: ContentType.Json, responseContentType: ContentType.Json, retry: requestConfig?.retry, config: this.config, }; return this.client.delete(path, options); } }