/* * 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, PageSettings } from "@azure/core-paging"; import { setContinuationToken } from "../pagingHelper"; import { Resources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { ResourceManagementClient } from "../resourceManagementClient"; import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; import { LroImpl } from "../lroImpl"; import { GenericResourceExpanded, ResourcesListByResourceGroupNextOptionalParams, ResourcesListByResourceGroupOptionalParams, ResourcesListByResourceGroupResponse, ResourcesListNextOptionalParams, ResourcesListOptionalParams, ResourcesListResponse, ResourcesMoveInfo, ResourcesMoveResourcesOptionalParams, ResourcesValidateMoveResourcesOptionalParams, ResourcesCheckExistenceOptionalParams, ResourcesCheckExistenceResponse, ResourcesDeleteOptionalParams, GenericResource, ResourcesCreateOrUpdateOptionalParams, ResourcesCreateOrUpdateResponse, ResourcesUpdateOptionalParams, ResourcesUpdateResponse, ResourcesGetOptionalParams, ResourcesGetResponse, ResourcesCheckExistenceByIdOptionalParams, ResourcesCheckExistenceByIdResponse, ResourcesDeleteByIdOptionalParams, ResourcesCreateOrUpdateByIdOptionalParams, ResourcesCreateOrUpdateByIdResponse, ResourcesUpdateByIdOptionalParams, ResourcesUpdateByIdResponse, ResourcesGetByIdOptionalParams, ResourcesGetByIdResponse, ResourcesListByResourceGroupNextResponse, ResourcesListNextResponse } from "../models"; /// /** Class containing Resources operations. */ export class ResourcesImpl implements Resources { private readonly client: ResourceManagementClient; /** * Initialize a new instance of the class Resources class. * @param client Reference to the service client */ constructor(client: ResourceManagementClient) { this.client = client; } /** * Get all the resources for a resource group. * @param resourceGroupName The resource group with the resources to get. * @param options The options parameters. */ public listByResourceGroup( resourceGroupName: string, options?: ResourcesListByResourceGroupOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings?: PageSettings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByResourceGroupPagingPage( resourceGroupName, options, settings ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, options?: ResourcesListByResourceGroupOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ResourcesListByResourceGroupResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByResourceGroup(resourceGroupName, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByResourceGroupPagingAll( resourceGroupName: string, options?: ResourcesListByResourceGroupOptionalParams ): AsyncIterableIterator { for await (const page of this.listByResourceGroupPagingPage( resourceGroupName, options )) { yield* page; } } /** * Get all the resources in a subscription. * @param options The options parameters. */ public list( options?: ResourcesListOptionalParams ): PagedAsyncIterableIterator { const iter = this.listPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings?: PageSettings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listPagingPage(options, settings); } }; } private async *listPagingPage( options?: ResourcesListOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ResourcesListResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._list(options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listPagingAll( options?: ResourcesListOptionalParams ): AsyncIterableIterator { for await (const page of this.listPagingPage(options)) { yield* page; } } /** * Get all the resources for a resource group. * @param resourceGroupName The resource group with the resources to get. * @param options The options parameters. */ private _listByResourceGroup( resourceGroupName: string, options?: ResourcesListByResourceGroupOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, options }, listByResourceGroupOperationSpec ); } /** * The resources to move must be in the same source resource group. The target resource group may be in * a different subscription. When moving resources, both the source group and the target group are * locked for the duration of the operation. Write and delete operations are blocked on the groups * until the move completes. * @param sourceResourceGroupName The name of the resource group containing the resources to move. * @param parameters Parameters for moving resources. * @param options The options parameters. */ async beginMoveResources( sourceResourceGroupName: string, parameters: ResourcesMoveInfo, options?: ResourcesMoveResourcesOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { sourceResourceGroupName, parameters, options }, moveResourcesOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * The resources to move must be in the same source resource group. The target resource group may be in * a different subscription. When moving resources, both the source group and the target group are * locked for the duration of the operation. Write and delete operations are blocked on the groups * until the move completes. * @param sourceResourceGroupName The name of the resource group containing the resources to move. * @param parameters Parameters for moving resources. * @param options The options parameters. */ async beginMoveResourcesAndWait( sourceResourceGroupName: string, parameters: ResourcesMoveInfo, options?: ResourcesMoveResourcesOptionalParams ): Promise { const poller = await this.beginMoveResources( sourceResourceGroupName, parameters, options ); return poller.pollUntilDone(); } /** * This operation checks whether the specified resources can be moved to the target. The resources to * move must be in the same source resource group. The target resource group may be in a different * subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation * fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the * Location header value to check the result of the long-running operation. * @param sourceResourceGroupName The name of the resource group containing the resources to validate * for move. * @param parameters Parameters for moving resources. * @param options The options parameters. */ async beginValidateMoveResources( sourceResourceGroupName: string, parameters: ResourcesMoveInfo, options?: ResourcesValidateMoveResourcesOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { sourceResourceGroupName, parameters, options }, validateMoveResourcesOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * This operation checks whether the specified resources can be moved to the target. The resources to * move must be in the same source resource group. The target resource group may be in a different * subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation * fails, it returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the * Location header value to check the result of the long-running operation. * @param sourceResourceGroupName The name of the resource group containing the resources to validate * for move. * @param parameters Parameters for moving resources. * @param options The options parameters. */ async beginValidateMoveResourcesAndWait( sourceResourceGroupName: string, parameters: ResourcesMoveInfo, options?: ResourcesValidateMoveResourcesOptionalParams ): Promise { const poller = await this.beginValidateMoveResources( sourceResourceGroupName, parameters, options ); return poller.pollUntilDone(); } /** * Get all the resources in a subscription. * @param options The options parameters. */ private _list( options?: ResourcesListOptionalParams ): Promise { return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Checks whether a resource exists. * @param resourceGroupName The name of the resource group containing the resource to check. The name * is case insensitive. * @param resourceProviderNamespace The resource provider of the resource to check. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type. * @param resourceName The name of the resource to check whether it exists. * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ checkExistence( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, options?: ResourcesCheckExistenceOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options }, checkExistenceOperationSpec ); } /** * Deletes a resource. * @param resourceGroupName The name of the resource group that contains the resource to delete. The * name is case insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type. * @param resourceName The name of the resource to delete. * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ async beginDelete( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, options?: ResourcesDeleteOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options }, deleteOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Deletes a resource. * @param resourceGroupName The name of the resource group that contains the resource to delete. The * name is case insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type. * @param resourceName The name of the resource to delete. * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ async beginDeleteAndWait( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, options?: ResourcesDeleteOptionalParams ): Promise { const poller = await this.beginDelete( resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options ); return poller.pollUntilDone(); } /** * Creates a resource. * @param resourceGroupName The name of the resource group for the resource. The name is case * insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type of the resource to create. * @param resourceName The name of the resource to create. * @param apiVersion The API version to use for the operation. * @param parameters Parameters for creating or updating the resource. * @param options The options parameters. */ async beginCreateOrUpdate( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, parameters: GenericResource, options?: ResourcesCreateOrUpdateOptionalParams ): Promise< PollerLike< PollOperationState, ResourcesCreateOrUpdateResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options }, createOrUpdateOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Creates a resource. * @param resourceGroupName The name of the resource group for the resource. The name is case * insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type of the resource to create. * @param resourceName The name of the resource to create. * @param apiVersion The API version to use for the operation. * @param parameters Parameters for creating or updating the resource. * @param options The options parameters. */ async beginCreateOrUpdateAndWait( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, parameters: GenericResource, options?: ResourcesCreateOrUpdateOptionalParams ): Promise { const poller = await this.beginCreateOrUpdate( resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options ); return poller.pollUntilDone(); } /** * Updates a resource. * @param resourceGroupName The name of the resource group for the resource. The name is case * insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type of the resource to update. * @param resourceName The name of the resource to update. * @param apiVersion The API version to use for the operation. * @param parameters Parameters for updating the resource. * @param options The options parameters. */ async beginUpdate( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, parameters: GenericResource, options?: ResourcesUpdateOptionalParams ): Promise< PollerLike< PollOperationState, ResourcesUpdateResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options }, updateOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Updates a resource. * @param resourceGroupName The name of the resource group for the resource. The name is case * insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type of the resource to update. * @param resourceName The name of the resource to update. * @param apiVersion The API version to use for the operation. * @param parameters Parameters for updating the resource. * @param options The options parameters. */ async beginUpdateAndWait( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, parameters: GenericResource, options?: ResourcesUpdateOptionalParams ): Promise { const poller = await this.beginUpdate( resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options ); return poller.pollUntilDone(); } /** * Gets a resource. * @param resourceGroupName The name of the resource group containing the resource to get. The name is * case insensitive. * @param resourceProviderNamespace The namespace of the resource provider. * @param parentResourcePath The parent resource identity. * @param resourceType The resource type of the resource. * @param resourceName The name of the resource to get. * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ get( resourceGroupName: string, resourceProviderNamespace: string, parentResourcePath: string, resourceType: string, resourceName: string, apiVersion: string, options?: ResourcesGetOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options }, getOperationSpec ); } /** * Checks by ID whether a resource exists. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ checkExistenceById( resourceId: string, apiVersion: string, options?: ResourcesCheckExistenceByIdOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceId, apiVersion, options }, checkExistenceByIdOperationSpec ); } /** * Deletes a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ async beginDeleteById( resourceId: string, apiVersion: string, options?: ResourcesDeleteByIdOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceId, apiVersion, options }, deleteByIdOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Deletes a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ async beginDeleteByIdAndWait( resourceId: string, apiVersion: string, options?: ResourcesDeleteByIdOptionalParams ): Promise { const poller = await this.beginDeleteById(resourceId, apiVersion, options); return poller.pollUntilDone(); } /** * Create a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param parameters Create or update resource parameters. * @param options The options parameters. */ async beginCreateOrUpdateById( resourceId: string, apiVersion: string, parameters: GenericResource, options?: ResourcesCreateOrUpdateByIdOptionalParams ): Promise< PollerLike< PollOperationState, ResourcesCreateOrUpdateByIdResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceId, apiVersion, parameters, options }, createOrUpdateByIdOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Create a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param parameters Create or update resource parameters. * @param options The options parameters. */ async beginCreateOrUpdateByIdAndWait( resourceId: string, apiVersion: string, parameters: GenericResource, options?: ResourcesCreateOrUpdateByIdOptionalParams ): Promise { const poller = await this.beginCreateOrUpdateById( resourceId, apiVersion, parameters, options ); return poller.pollUntilDone(); } /** * Updates a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param parameters Update resource parameters. * @param options The options parameters. */ async beginUpdateById( resourceId: string, apiVersion: string, parameters: GenericResource, options?: ResourcesUpdateByIdOptionalParams ): Promise< PollerLike< PollOperationState, ResourcesUpdateByIdResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = 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 = new LroImpl( sendOperation, { resourceId, apiVersion, parameters, options }, updateByIdOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Updates a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param parameters Update resource parameters. * @param options The options parameters. */ async beginUpdateByIdAndWait( resourceId: string, apiVersion: string, parameters: GenericResource, options?: ResourcesUpdateByIdOptionalParams ): Promise { const poller = await this.beginUpdateById( resourceId, apiVersion, parameters, options ); return poller.pollUntilDone(); } /** * Gets a resource by ID. * @param resourceId The fully qualified ID of the resource, including the resource name and resource * type. Use the format, * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name} * @param apiVersion The API version to use for the operation. * @param options The options parameters. */ getById( resourceId: string, apiVersion: string, options?: ResourcesGetByIdOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceId, apiVersion, options }, getByIdOperationSpec ); } /** * ListByResourceGroupNext * @param resourceGroupName The resource group with the resources to get. * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. * @param options The options parameters. */ private _listByResourceGroupNext( resourceGroupName: string, nextLink: string, options?: ResourcesListByResourceGroupNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec ); } /** * ListNext * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ private _listNext( nextLink: string, options?: ResourcesListNextOptionalParams ): Promise { return this.client.sendOperationRequest( { nextLink, options }, listNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByResourceGroupOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [ Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand ], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName ], headerParameters: [Parameters.accept], serializer }; const moveResourcesOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters4, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.sourceResourceGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const validateMoveResourcesOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters4, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.sourceResourceGroupName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const listOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resources", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [ Parameters.apiVersion, Parameters.filter, Parameters.top, Parameters.expand ], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const checkExistenceOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", httpMethod: "HEAD", responses: { 204: {}, 404: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.resourceProviderNamespace, Parameters.parentResourcePath, Parameters.resourceType, Parameters.resourceName ], headerParameters: [Parameters.accept], serializer }; const deleteOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.resourceProviderNamespace, Parameters.parentResourcePath, Parameters.resourceType, Parameters.resourceName ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.GenericResource }, 201: { bodyMapper: Mappers.GenericResource }, 202: { bodyMapper: Mappers.GenericResource }, 204: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.resourceProviderNamespace, Parameters.parentResourcePath, Parameters.resourceType, Parameters.resourceName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const updateOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.GenericResource }, 201: { bodyMapper: Mappers.GenericResource }, 202: { bodyMapper: Mappers.GenericResource }, 204: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.resourceProviderNamespace, Parameters.parentResourcePath, Parameters.resourceType, Parameters.resourceName ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.resourceProviderNamespace, Parameters.parentResourcePath, Parameters.resourceType, Parameters.resourceName ], headerParameters: [Parameters.accept], serializer }; const checkExistenceByIdOperationSpec: coreClient.OperationSpec = { path: "/{resourceId}", httpMethod: "HEAD", responses: { 204: {}, 404: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept], serializer }; const deleteByIdOperationSpec: coreClient.OperationSpec = { path: "/{resourceId}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept], serializer }; const createOrUpdateByIdOperationSpec: coreClient.OperationSpec = { path: "/{resourceId}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.GenericResource }, 201: { bodyMapper: Mappers.GenericResource }, 202: { bodyMapper: Mappers.GenericResource }, 204: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const updateByIdOperationSpec: coreClient.OperationSpec = { path: "/{resourceId}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.GenericResource }, 201: { bodyMapper: Mappers.GenericResource }, 202: { bodyMapper: Mappers.GenericResource }, 204: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer }; const getByIdOperationSpec: coreClient.OperationSpec = { path: "/{resourceId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GenericResource }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.resourceId], headerParameters: [Parameters.accept], serializer }; const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceListResult }, default: { bodyMapper: Mappers.CloudError } }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ResourceListResult }, default: { bodyMapper: Mappers.CloudError } }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId ], headerParameters: [Parameters.accept], serializer };