UNPKG

@azure/arm-security

Version:
218 lines 8.22 kB
/* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; /// <reference lib="esnext.asynciterable" /> /** Class containing DeviceSecurityGroups operations. */ export class DeviceSecurityGroupsImpl { /** * Initialize a new instance of the class DeviceSecurityGroups class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Use this method get the list of device security groups for the specified IoT Hub resource. * @param resourceId The identifier of the resource. * @param options The options parameters. */ list(resourceId, options) { const iter = this.listPagingAll(resourceId, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listPagingPage(resourceId, options); } }; } listPagingPage(resourceId, options) { return __asyncGenerator(this, arguments, function* listPagingPage_1() { let result = yield __await(this._list(resourceId, options)); yield yield __await(result.value || []); let continuationToken = result.nextLink; while (continuationToken) { result = yield __await(this._listNext(resourceId, continuationToken, options)); continuationToken = result.nextLink; yield yield __await(result.value || []); } }); } listPagingAll(resourceId, options) { return __asyncGenerator(this, arguments, function* listPagingAll_1() { var e_1, _a; try { for (var _b = __asyncValues(this.listPagingPage(resourceId, options)), _c; _c = yield __await(_b.next()), !_c.done;) { const page = _c.value; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b)); } finally { if (e_1) throw e_1.error; } } }); } /** * Use this method get the list of device security groups for the specified IoT Hub resource. * @param resourceId The identifier of the resource. * @param options The options parameters. */ _list(resourceId, options) { return this.client.sendOperationRequest({ resourceId, options }, listOperationSpec); } /** * Use this method to get the device security group for the specified IoT Hub resource. * @param resourceId The identifier of the resource. * @param deviceSecurityGroupName The name of the device security group. Note that the name of the * device security group is case insensitive. * @param options The options parameters. */ get(resourceId, deviceSecurityGroupName, options) { return this.client.sendOperationRequest({ resourceId, deviceSecurityGroupName, options }, getOperationSpec); } /** * Use this method to creates or updates the device security group on a specified IoT Hub resource. * @param resourceId The identifier of the resource. * @param deviceSecurityGroupName The name of the device security group. Note that the name of the * device security group is case insensitive. * @param deviceSecurityGroup Security group object. * @param options The options parameters. */ createOrUpdate(resourceId, deviceSecurityGroupName, deviceSecurityGroup, options) { return this.client.sendOperationRequest({ resourceId, deviceSecurityGroupName, deviceSecurityGroup, options }, createOrUpdateOperationSpec); } /** * User this method to deletes the device security group. * @param resourceId The identifier of the resource. * @param deviceSecurityGroupName The name of the device security group. Note that the name of the * device security group is case insensitive. * @param options The options parameters. */ delete(resourceId, deviceSecurityGroupName, options) { return this.client.sendOperationRequest({ resourceId, deviceSecurityGroupName, options }, deleteOperationSpec); } /** * ListNext * @param resourceId The identifier of the resource. * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ _listNext(resourceId, nextLink, options) { return this.client.sendOperationRequest({ resourceId, nextLink, options }, listNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DeviceSecurityGroupList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion5], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept], serializer }; const getOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DeviceSecurityGroup }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion5], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.deviceSecurityGroupName ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.DeviceSecurityGroup }, 201: { bodyMapper: Mappers.DeviceSecurityGroup }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.deviceSecurityGroup, queryParameters: [Parameters.apiVersion5], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.deviceSecurityGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const deleteOperationSpec = { path: "/{resourceId}/providers/Microsoft.Security/deviceSecurityGroups/{deviceSecurityGroupName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion5], urlParameters: [ Parameters.$host, Parameters.resourceId, Parameters.deviceSecurityGroupName ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DeviceSecurityGroupList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion5], urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.resourceId], headerParameters: [Parameters.accept], serializer }; //# sourceMappingURL=deviceSecurityGroups.js.map