import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { Subnets } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { NetworkManagementClient } from "../networkManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { Subnet , SubnetsListNextOptionalParams , SubnetsListOptionalParams , SubnetsDeleteOptionalParams , SubnetsGetOptionalParams , SubnetsGetResponse , SubnetsCreateOrUpdateOptionalParams , SubnetsCreateOrUpdateResponse , PrepareNetworkPoliciesRequest , SubnetsPrepareNetworkPoliciesOptionalParams , UnprepareNetworkPoliciesRequest , SubnetsUnprepareNetworkPoliciesOptionalParams , SubnetsListResponse , SubnetsListNextResponse } from "../models" ; /** Class containing Subnets operations. */ export class SubnetsImpl implements Subnets { private readonly client : NetworkManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param virtualNetworkName param options public list ( resourceGroupName , virtualNetworkName , options ? ) { const iter = this . listPagingAll ( resourceGroupName , virtualNetworkName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( resourceGroupName , virtualNetworkName , options ) ; } } ; } private async * listPagingPage ( resourceGroupName , virtualNetworkName , options ? ) { let result = await this . _list ( resourceGroupName , virtualNetworkName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( resourceGroupName , virtualNetworkName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( resourceGroupName , virtualNetworkName , options ? ) { for await ( const page of this . listPagingPage ( resourceGroupName , virtualNetworkName , options ) ) { yield * page ; } } param resourceGroupName param virtualNetworkName param subnetName param options async beginDelete ( resourceGroupName , virtualNetworkName , subnetName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... args . options , onResponse : callback } } ; const flatResponse = await directSendOperation ( updatedArgs , spec ) ; return { flatResponse , rawResponse : { statusCode : currentRawResponse ! . status , body : currentRawResponse ! . parsedBody , headers : currentRawResponse ! . headers . toJSON ( ) } } ; } ; const lro = new LroImpl ( sendOperation , { resourceGroupName , virtualNetworkName , subnetName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param virtualNetworkName param subnetName param options async beginDeleteAndWait ( resourceGroupName , virtualNetworkName , subnetName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , virtualNetworkName , subnetName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param virtualNetworkName param subnetName param options get ( resourceGroupName , virtualNetworkName , subnetName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , virtualNetworkName , subnetName , options } , getOperationSpec ) ; } param resourceGroupName param virtualNetworkName param subnetName param subnetParameters param options async beginCreateOrUpdate ( resourceGroupName , virtualNetworkName , subnetName , subnetParameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < SubnetsCreateOrUpdateResponse > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... args . options , onResponse : callback } } ; const flatResponse = await directSendOperation ( updatedArgs , spec ) ; return { flatResponse , rawResponse : { statusCode : currentRawResponse ! . status , body : currentRawResponse ! . parsedBody , headers : currentRawResponse ! . headers . toJSON ( ) } } ; } ; const lro = new LroImpl ( sendOperation , { resourceGroupName , virtualNetworkName , subnetName , subnetParameters , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "azure-async-operation" } ) ; } param resourceGroupName param virtualNetworkName param subnetName param subnetParameters param options async beginCreateOrUpdateAndWait ( resourceGroupName , virtualNetworkName , subnetName , subnetParameters , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , virtualNetworkName , subnetName , subnetParameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param virtualNetworkName param subnetName param prepareNetworkPoliciesRequestParameters param options async beginPrepareNetworkPolicies ( resourceGroupName , virtualNetworkName , subnetName , prepareNetworkPoliciesRequestParameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... args . options , onResponse : callback } } ; const flatResponse = await directSendOperation ( updatedArgs , spec ) ; return { flatResponse , rawResponse : { statusCode : currentRawResponse ! . status , body : currentRawResponse ! . parsedBody , headers : currentRawResponse ! . headers . toJSON ( ) } } ; } ; const lro = new LroImpl ( sendOperation , { resourceGroupName , virtualNetworkName , subnetName , prepareNetworkPoliciesRequestParameters , options } , prepareNetworkPoliciesOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param virtualNetworkName param subnetName param prepareNetworkPoliciesRequestParameters param options async beginPrepareNetworkPoliciesAndWait ( resourceGroupName , virtualNetworkName , subnetName , prepareNetworkPoliciesRequestParameters , options ? ) { const poller = await this . beginPrepareNetworkPolicies ( resourceGroupName , virtualNetworkName , subnetName , prepareNetworkPoliciesRequestParameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param virtualNetworkName param subnetName param unprepareNetworkPoliciesRequestParameters param options async beginUnprepareNetworkPolicies ( resourceGroupName , virtualNetworkName , subnetName , unprepareNetworkPoliciesRequestParameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = async ( args , spec ) => { let currentRawResponse = undefined ; const providedCallback = args . options ?. onResponse ; const callback = ( rawResponse , flatResponse ) => { currentRawResponse = rawResponse ; providedCallback ?. ( rawResponse , flatResponse ) ; } ; const updatedArgs = { ... args , options : { ... args . options , onResponse : callback } } ; const flatResponse = await directSendOperation ( updatedArgs , spec ) ; return { flatResponse , rawResponse : { statusCode : currentRawResponse ! . status , body : currentRawResponse ! . parsedBody , headers : currentRawResponse ! . headers . toJSON ( ) } } ; } ; const lro = new LroImpl ( sendOperation , { resourceGroupName , virtualNetworkName , subnetName , unprepareNetworkPoliciesRequestParameters , options } , unprepareNetworkPoliciesOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param virtualNetworkName param subnetName param unprepareNetworkPoliciesRequestParameters param options async beginUnprepareNetworkPoliciesAndWait ( resourceGroupName , virtualNetworkName , subnetName , unprepareNetworkPoliciesRequestParameters , options ? ) { const poller = await this . beginUnprepareNetworkPolicies ( resourceGroupName , virtualNetworkName , subnetName , unprepareNetworkPoliciesRequestParameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param virtualNetworkName param options private _list ( resourceGroupName , virtualNetworkName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , virtualNetworkName , options } , listOperationSpec ) ; } param resourceGroupName param virtualNetworkName param nextLink param options private _listNext ( resourceGroupName , virtualNetworkName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , virtualNetworkName , nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName , Parameters . subnetName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . Subnet } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . expand ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName , Parameters . subnetName ] , headerParameters : [ Parameters . accept ] , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . Subnet } , 201 : { bodyMapper : Mappers . Subnet } , 202 : { bodyMapper : Mappers . Subnet } , 204 : { bodyMapper : Mappers . Subnet } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . subnetParameters , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName , Parameters . subnetName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const prepareNetworkPoliciesOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/PrepareNetworkPolicies" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . prepareNetworkPoliciesRequestParameters , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName , Parameters . subnetName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const unprepareNetworkPoliciesOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/UnprepareNetworkPolicies" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . unprepareNetworkPoliciesRequestParameters , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName , Parameters . subnetName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SubnetListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . virtualNetworkName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . SubnetListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . virtualNetworkName ] , headerParameters : [ Parameters . accept ] , serializer } ;