/* * 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 { SubnetServiceAssociationLink } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { ContainerInstanceManagementClient } from "../containerInstanceManagementClient"; import { SimplePollerLike, OperationState, createHttpPoller } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl"; import { SubnetServiceAssociationLinkDeleteOptionalParams } from "../models"; /** Class containing SubnetServiceAssociationLink operations. */ export class SubnetServiceAssociationLinkImpl implements SubnetServiceAssociationLink { private readonly client: ContainerInstanceManagementClient; /** * Initialize a new instance of the class SubnetServiceAssociationLink class. * @param client Reference to the service client */ constructor(client: ContainerInstanceManagementClient) { this.client = client; } /** * Delete container group virtual network association links. The operation does not delete other * resources provided by the user. * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. * @param options The options parameters. */ async beginDelete( resourceGroupName: string, virtualNetworkName: string, subnetName: string, options?: SubnetServiceAssociationLinkDeleteOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { let currentRawResponse: | coreClient.FullOperationResponse | undefined = undefined; const providedCallback = args.options?.onResponse; const callback: coreClient.RawResponseCallback = ( rawResponse: coreClient.FullOperationResponse, flatResponse: unknown ) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, virtualNetworkName, subnetName, options }, spec: deleteOperationSpec }); const poller = await createHttpPoller>(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Delete container group virtual network association links. The operation does not delete other * resources provided by the user. * @param resourceGroupName The name of the resource group. * @param virtualNetworkName The name of the virtual network. * @param subnetName The name of the subnet. * @param options The options parameters. */ async beginDeleteAndWait( resourceGroupName: string, virtualNetworkName: string, subnetName: string, options?: SubnetServiceAssociationLinkDeleteOptionalParams ): Promise { const poller = await this.beginDelete( resourceGroupName, virtualNetworkName, subnetName, options ); return poller.pollUntilDone(); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const deleteOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}/providers/Microsoft.ContainerInstance/serviceAssociationLinks/default", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.virtualNetworkName, Parameters.subnetName ], headerParameters: [Parameters.accept], serializer };