/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ import * as msRest from "@azure/ms-rest-js"; import * as Models from "../models"; import * as Mappers from "../models/modulesMappers"; import * as Parameters from "../models/parameters"; import { IotHubGatewayServiceAPIsContext } from "../iotHubGatewayServiceAPIsContext"; /** Class representing a Modules. */ export class Modules { private readonly client: IotHubGatewayServiceAPIsContext; /** * Create a Modules. * @param {IotHubGatewayServiceAPIsContext} client Reference to the service client. */ constructor(client: IotHubGatewayServiceAPIsContext) { this.client = client; } /** * Gets the module twin. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins * for more information. * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param [options] The optional parameters * @returns Promise */ getTwin(id: string, mid: string, options?: msRest.RequestOptionsBase): Promise; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param callback The callback */ getTwin(id: string, mid: string, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param options The optional parameters * @param callback The callback */ getTwin(id: string, mid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getTwin(id: string, mid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, options }, getTwinOperationSpec, callback) as Promise; } /** * Replaces the tags and desired properties of a module twin. See * https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info that will replace the existing info. * @param [options] The optional parameters * @returns Promise */ replaceTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options?: Models.ModulesReplaceTwinOptionalParams): Promise; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info that will replace the existing info. * @param callback The callback */ replaceTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info that will replace the existing info. * @param options The optional parameters * @param callback The callback */ replaceTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options: Models.ModulesReplaceTwinOptionalParams, callback: msRest.ServiceCallback): void; replaceTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options?: Models.ModulesReplaceTwinOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, deviceTwinInfo, options }, replaceTwinOperationSpec, callback) as Promise; } /** * Updates the tags and desired properties of a module twin. See * https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins for more information. * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info containing the tags and desired properties to be * updated. * @param [options] The optional parameters * @returns Promise */ updateTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options?: Models.ModulesUpdateTwinOptionalParams): Promise; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info containing the tags and desired properties to be * updated. * @param callback The callback */ updateTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param deviceTwinInfo The module twin info containing the tags and desired properties to be * updated. * @param options The optional parameters * @param callback The callback */ updateTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options: Models.ModulesUpdateTwinOptionalParams, callback: msRest.ServiceCallback): void; updateTwin(id: string, mid: string, deviceTwinInfo: Models.Twin, options?: Models.ModulesUpdateTwinOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, deviceTwinInfo, options }, updateTwinOperationSpec, callback) as Promise; } /** * Gets all the module identities on the device. * @param id The unique identifier of the device. * @param [options] The optional parameters * @returns Promise */ getModulesOnDevice(id: string, options?: msRest.RequestOptionsBase): Promise; /** * @param id The unique identifier of the device. * @param callback The callback */ getModulesOnDevice(id: string, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param options The optional parameters * @param callback The callback */ getModulesOnDevice(id: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getModulesOnDevice(id: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, options }, getModulesOnDeviceOperationSpec, callback) as Promise; } /** * Gets a module identity on the device. * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param [options] The optional parameters * @returns Promise */ getIdentity(id: string, mid: string, options?: msRest.RequestOptionsBase): Promise; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param callback The callback */ getIdentity(id: string, mid: string, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param options The optional parameters * @param callback The callback */ getIdentity(id: string, mid: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; getIdentity(id: string, mid: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, options }, getIdentityOperationSpec, callback) as Promise; } /** * Creates or updates the module identity for a device in the IoT Hub. The moduleId and * generationId cannot be updated by the user. * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param module The module identity. * @param [options] The optional parameters * @returns Promise */ createOrUpdateIdentity(id: string, mid: string, module: Models.Module, options?: Models.ModulesCreateOrUpdateIdentityOptionalParams): Promise; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param module The module identity. * @param callback The callback */ createOrUpdateIdentity(id: string, mid: string, module: Models.Module, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the device. * @param mid The unique identifier of the module. * @param module The module identity. * @param options The optional parameters * @param callback The callback */ createOrUpdateIdentity(id: string, mid: string, module: Models.Module, options: Models.ModulesCreateOrUpdateIdentityOptionalParams, callback: msRest.ServiceCallback): void; createOrUpdateIdentity(id: string, mid: string, module: Models.Module, options?: Models.ModulesCreateOrUpdateIdentityOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, module, options }, createOrUpdateIdentityOperationSpec, callback) as Promise; } /** * Deletes the module identity for a device in the IoT Hub. * @param id The unique identifier of the deivce. * @param mid The unique identifier of the module. * @param [options] The optional parameters * @returns Promise */ deleteIdentity(id: string, mid: string, options?: Models.ModulesDeleteIdentityOptionalParams): Promise; /** * @param id The unique identifier of the deivce. * @param mid The unique identifier of the module. * @param callback The callback */ deleteIdentity(id: string, mid: string, callback: msRest.ServiceCallback): void; /** * @param id The unique identifier of the deivce. * @param mid The unique identifier of the module. * @param options The optional parameters * @param callback The callback */ deleteIdentity(id: string, mid: string, options: Models.ModulesDeleteIdentityOptionalParams, callback: msRest.ServiceCallback): void; deleteIdentity(id: string, mid: string, options?: Models.ModulesDeleteIdentityOptionalParams | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { id, mid, options }, deleteIdentityOperationSpec, callback); } /** * Invokes a direct method on a module of a device. See * https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-direct-methods for more information. * @param deviceId The unique identifier of the device. * @param moduleId The unique identifier of the module. * @param directMethodRequest The parameters to execute a direct method on the module. * @param [options] The optional parameters * @returns Promise */ invokeMethod(deviceId: string, moduleId: string, directMethodRequest: Models.CloudToDeviceMethod, options?: msRest.RequestOptionsBase): Promise; /** * @param deviceId The unique identifier of the device. * @param moduleId The unique identifier of the module. * @param directMethodRequest The parameters to execute a direct method on the module. * @param callback The callback */ invokeMethod(deviceId: string, moduleId: string, directMethodRequest: Models.CloudToDeviceMethod, callback: msRest.ServiceCallback): void; /** * @param deviceId The unique identifier of the device. * @param moduleId The unique identifier of the module. * @param directMethodRequest The parameters to execute a direct method on the module. * @param options The optional parameters * @param callback The callback */ invokeMethod(deviceId: string, moduleId: string, directMethodRequest: Models.CloudToDeviceMethod, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; invokeMethod(deviceId: string, moduleId: string, directMethodRequest: Models.CloudToDeviceMethod, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { return this.client.sendOperationRequest( { deviceId, moduleId, directMethodRequest, options }, invokeMethodOperationSpec, callback) as Promise; } } // Operation Specifications const serializer = new msRest.Serializer(Mappers); const getTwinOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "twins/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], responses: { 200: { bodyMapper: Mappers.Twin }, default: {} }, serializer }; const replaceTwinOperationSpec: msRest.OperationSpec = { httpMethod: "PUT", path: "twins/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.ifMatch ], requestBody: { parameterPath: "deviceTwinInfo", mapper: { ...Mappers.Twin, required: true } }, responses: { 200: { bodyMapper: Mappers.Twin }, default: {} }, serializer }; const updateTwinOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "twins/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.ifMatch ], requestBody: { parameterPath: "deviceTwinInfo", mapper: { ...Mappers.Twin, required: true } }, responses: { 200: { bodyMapper: Mappers.Twin }, default: {} }, serializer }; const getModulesOnDeviceOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "devices/{id}/modules", urlParameters: [ Parameters.id ], queryParameters: [ Parameters.apiVersion ], responses: { 200: { bodyMapper: { serializedName: "parsedResponse", type: { name: "Sequence", element: { type: { name: "Composite", className: "Module" } } } } }, default: {} }, serializer }; const getIdentityOperationSpec: msRest.OperationSpec = { httpMethod: "GET", path: "devices/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], responses: { 200: { bodyMapper: Mappers.Module }, default: {} }, serializer }; const createOrUpdateIdentityOperationSpec: msRest.OperationSpec = { httpMethod: "PUT", path: "devices/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.ifMatch ], requestBody: { parameterPath: "module", mapper: { ...Mappers.Module, required: true } }, responses: { 200: { bodyMapper: Mappers.Module }, 201: { bodyMapper: Mappers.Module }, default: {} }, serializer }; const deleteIdentityOperationSpec: msRest.OperationSpec = { httpMethod: "DELETE", path: "devices/{id}/modules/{mid}", urlParameters: [ Parameters.id, Parameters.mid ], queryParameters: [ Parameters.apiVersion ], headerParameters: [ Parameters.ifMatch ], responses: { 204: {}, default: {} }, serializer }; const invokeMethodOperationSpec: msRest.OperationSpec = { httpMethod: "POST", path: "twins/{deviceId}/modules/{moduleId}/methods", urlParameters: [ Parameters.deviceId, Parameters.moduleId ], queryParameters: [ Parameters.apiVersion ], requestBody: { parameterPath: "directMethodRequest", mapper: { ...Mappers.CloudToDeviceMethod, required: true } }, responses: { 200: { bodyMapper: Mappers.CloudToDeviceMethodResult }, default: {} }, serializer };