UNPKG

@azure/arm-compute

Version:
150 lines 6.62 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { setContinuationToken } from "../pagingHelper.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing SoftDeletedResource operations. */ export class SoftDeletedResourceImpl { client; /** * Initialize a new instance of the class SoftDeletedResource class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * List soft-deleted resources of an artifact in the gallery, such as soft-deleted gallery image * version of an image. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param artifactType The type of the artifact to be listed, such as gallery image version. * @param artifactName The artifact name to be listed. If artifact type is Images, then the artifact * name should be the gallery image name. * @param options The options parameters. */ listByArtifactName(resourceGroupName, galleryName, artifactType, artifactName, options) { const iter = this.listByArtifactNamePagingAll(resourceGroupName, galleryName, artifactType, artifactName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByArtifactNamePagingPage(resourceGroupName, galleryName, artifactType, artifactName, options, settings); }, }; } async *listByArtifactNamePagingPage(resourceGroupName, galleryName, artifactType, artifactName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByArtifactName(resourceGroupName, galleryName, artifactType, artifactName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByArtifactNameNext(resourceGroupName, galleryName, artifactType, artifactName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByArtifactNamePagingAll(resourceGroupName, galleryName, artifactType, artifactName, options) { for await (const page of this.listByArtifactNamePagingPage(resourceGroupName, galleryName, artifactType, artifactName, options)) { yield* page; } } /** * List soft-deleted resources of an artifact in the gallery, such as soft-deleted gallery image * version of an image. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param artifactType The type of the artifact to be listed, such as gallery image version. * @param artifactName The artifact name to be listed. If artifact type is Images, then the artifact * name should be the gallery image name. * @param options The options parameters. */ _listByArtifactName(resourceGroupName, galleryName, artifactType, artifactName, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, artifactType, artifactName, options }, listByArtifactNameOperationSpec); } /** * ListByArtifactNameNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param galleryName The name of the Shared Image Gallery. * @param artifactType The type of the artifact to be listed, such as gallery image version. * @param artifactName The artifact name to be listed. If artifact type is Images, then the artifact * name should be the gallery image name. * @param nextLink The nextLink from the previous successful call to the ListByArtifactName method. * @param options The options parameters. */ _listByArtifactNameNext(resourceGroupName, galleryName, artifactType, artifactName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, galleryName, artifactType, artifactName, nextLink, options, }, listByArtifactNameNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByArtifactNameOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/softdeletedartifacttypes/{artifactType}/artifacts/{artifactName}/versions", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GallerySoftDeletedResourceList, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.artifactType, Parameters.artifactName, ], headerParameters: [Parameters.accept], serializer, }; const listByArtifactNameNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.GallerySoftDeletedResourceList, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.galleryName, Parameters.artifactType, Parameters.artifactName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=softDeletedResource.js.map