@azure/arm-compute
Version:
A generated SDK for ComputeManagementClient.
175 lines • 7.07 kB
JavaScript
// 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 CommunityGalleryImageVersions operations. */
export class CommunityGalleryImageVersionsImpl {
client;
/**
* Initialize a new instance of the class CommunityGalleryImageVersions class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* List community gallery image versions inside an image.
* @param location The name of Azure region.
* @param publicGalleryName The public name of the community gallery.
* @param galleryImageName The name of the community gallery image definition.
* @param options The options parameters.
*/
list(location, publicGalleryName, galleryImageName, options) {
const iter = this.listPagingAll(location, publicGalleryName, galleryImageName, 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.listPagingPage(location, publicGalleryName, galleryImageName, options, settings);
},
};
}
async *listPagingPage(location, publicGalleryName, galleryImageName, options, settings) {
let result;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._list(location, publicGalleryName, galleryImageName, options);
const page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listNext(location, publicGalleryName, galleryImageName, continuationToken, options);
continuationToken = result.nextLink;
const page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
async *listPagingAll(location, publicGalleryName, galleryImageName, options) {
for await (const page of this.listPagingPage(location, publicGalleryName, galleryImageName, options)) {
yield* page;
}
}
/**
* List community gallery image versions inside an image.
* @param location The name of Azure region.
* @param publicGalleryName The public name of the community gallery.
* @param galleryImageName The name of the community gallery image definition.
* @param options The options parameters.
*/
_list(location, publicGalleryName, galleryImageName, options) {
return this.client.sendOperationRequest({ location, publicGalleryName, galleryImageName, options }, listOperationSpec);
}
/**
* Get a community gallery image version.
* @param location The name of Azure region.
* @param publicGalleryName The public name of the community gallery.
* @param galleryImageName The name of the community gallery image definition.
* @param galleryImageVersionName The name of the community gallery image version. Needs to follow
* semantic version name pattern: The allowed characters are digit and period. Digits must be within
* the range of a 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>
* @param options The options parameters.
*/
get(location, publicGalleryName, galleryImageName, galleryImageVersionName, options) {
return this.client.sendOperationRequest({
location,
publicGalleryName,
galleryImageName,
galleryImageVersionName,
options,
}, getOperationSpec);
}
/**
* ListNext
* @param location The name of Azure region.
* @param publicGalleryName The public name of the community gallery.
* @param galleryImageName The name of the community gallery image definition.
* @param nextLink The nextLink from the previous successful call to the List method.
* @param options The options parameters.
*/
_listNext(location, publicGalleryName, galleryImageName, nextLink, options) {
return this.client.sendOperationRequest({ location, publicGalleryName, galleryImageName, nextLink, options }, listNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CommunityGalleryImageVersionList,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion3],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.location,
Parameters.publicGalleryName,
Parameters.galleryImageName,
],
headerParameters: [Parameters.accept],
serializer,
};
const getOperationSpec = {
path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CommunityGalleryImageVersion,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion3],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.location,
Parameters.publicGalleryName,
Parameters.galleryImageName,
Parameters.galleryImageVersionName,
],
headerParameters: [Parameters.accept],
serializer,
};
const listNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.CommunityGalleryImageVersionList,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
urlParameters: [
Parameters.$host,
Parameters.nextLink,
Parameters.subscriptionId,
Parameters.location,
Parameters.publicGalleryName,
Parameters.galleryImageName,
],
headerParameters: [Parameters.accept],
serializer,
};
//# sourceMappingURL=communityGalleryImageVersions.js.map