UNPKG

@azure/arm-security

Version:
325 lines (309 loc) 10 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 { PagedAsyncIterableIterator } from "@azure/core-paging"; import { AllowedConnections } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { SecurityCenter } from "../securityCenter"; import { AllowedConnectionsResource, AllowedConnectionsListNextOptionalParams, AllowedConnectionsListOptionalParams, AllowedConnectionsListByHomeRegionNextOptionalParams, AllowedConnectionsListByHomeRegionOptionalParams, AllowedConnectionsListResponse, AllowedConnectionsListByHomeRegionResponse, ConnectionType, AllowedConnectionsGetOptionalParams, AllowedConnectionsGetResponse, AllowedConnectionsListNextResponse, AllowedConnectionsListByHomeRegionNextResponse } from "../models"; /// <reference lib="esnext.asynciterable" /> /** Class containing AllowedConnections operations. */ export class AllowedConnectionsImpl implements AllowedConnections { private readonly client: SecurityCenter; /** * Initialize a new instance of the class AllowedConnections class. * @param client Reference to the service client */ constructor(client: SecurityCenter) { this.client = client; } /** * Gets the list of all possible traffic between resources for the subscription * @param options The options parameters. */ public list( options?: AllowedConnectionsListOptionalParams ): PagedAsyncIterableIterator<AllowedConnectionsResource> { const iter = this.listPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listPagingPage(options); } }; } private async *listPagingPage( options?: AllowedConnectionsListOptionalParams ): AsyncIterableIterator<AllowedConnectionsResource[]> { let result = await this._list(options); yield result.value || []; let continuationToken = result.nextLink; while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; yield result.value || []; } } private async *listPagingAll( options?: AllowedConnectionsListOptionalParams ): AsyncIterableIterator<AllowedConnectionsResource> { for await (const page of this.listPagingPage(options)) { yield* page; } } /** * Gets the list of all possible traffic between resources for the subscription and location. * @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from * Get locations * @param options The options parameters. */ public listByHomeRegion( ascLocation: string, options?: AllowedConnectionsListByHomeRegionOptionalParams ): PagedAsyncIterableIterator<AllowedConnectionsResource> { const iter = this.listByHomeRegionPagingAll(ascLocation, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: () => { return this.listByHomeRegionPagingPage(ascLocation, options); } }; } private async *listByHomeRegionPagingPage( ascLocation: string, options?: AllowedConnectionsListByHomeRegionOptionalParams ): AsyncIterableIterator<AllowedConnectionsResource[]> { let result = await this._listByHomeRegion(ascLocation, options); yield result.value || []; let continuationToken = result.nextLink; while (continuationToken) { result = await this._listByHomeRegionNext( ascLocation, continuationToken, options ); continuationToken = result.nextLink; yield result.value || []; } } private async *listByHomeRegionPagingAll( ascLocation: string, options?: AllowedConnectionsListByHomeRegionOptionalParams ): AsyncIterableIterator<AllowedConnectionsResource> { for await (const page of this.listByHomeRegionPagingPage( ascLocation, options )) { yield* page; } } /** * Gets the list of all possible traffic between resources for the subscription * @param options The options parameters. */ private _list( options?: AllowedConnectionsListOptionalParams ): Promise<AllowedConnectionsListResponse> { return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Gets the list of all possible traffic between resources for the subscription and location. * @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from * Get locations * @param options The options parameters. */ private _listByHomeRegion( ascLocation: string, options?: AllowedConnectionsListByHomeRegionOptionalParams ): Promise<AllowedConnectionsListByHomeRegionResponse> { return this.client.sendOperationRequest( { ascLocation, options }, listByHomeRegionOperationSpec ); } /** * Gets the list of all possible traffic between resources for the subscription and location, based on * connection type. * @param resourceGroupName The name of the resource group within the user's subscription. The name is * case insensitive. * @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from * Get locations * @param connectionType The type of allowed connections (Internal, External) * @param options The options parameters. */ get( resourceGroupName: string, ascLocation: string, connectionType: ConnectionType, options?: AllowedConnectionsGetOptionalParams ): Promise<AllowedConnectionsGetResponse> { return this.client.sendOperationRequest( { resourceGroupName, ascLocation, connectionType, options }, getOperationSpec ); } /** * ListNext * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ private _listNext( nextLink: string, options?: AllowedConnectionsListNextOptionalParams ): Promise<AllowedConnectionsListNextResponse> { return this.client.sendOperationRequest( { nextLink, options }, listNextOperationSpec ); } /** * ListByHomeRegionNext * @param ascLocation The location where ASC stores the data of the subscription. can be retrieved from * Get locations * @param nextLink The nextLink from the previous successful call to the ListByHomeRegion method. * @param options The options parameters. */ private _listByHomeRegionNext( ascLocation: string, nextLink: string, options?: AllowedConnectionsListByHomeRegionNextOptionalParams ): Promise<AllowedConnectionsListByHomeRegionNextResponse> { return this.client.sendOperationRequest( { ascLocation, nextLink, options }, listByHomeRegionNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AllowedConnectionsList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion9], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const listByHomeRegionOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AllowedConnectionsList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion9], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.ascLocation ], headerParameters: [Parameters.accept], serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AllowedConnectionsResource }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion9], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.ascLocation, Parameters.connectionType ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AllowedConnectionsList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion9], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; const listByHomeRegionNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.AllowedConnectionsList }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion9], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.nextLink, Parameters.ascLocation ], headerParameters: [Parameters.accept], serializer };