UNPKG

@azure/arm-compute

Version:
287 lines 11.1 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 CloudServiceOperatingSystems operations. */ export class CloudServiceOperatingSystemsImpl { client; /** * Initialize a new instance of the class CloudServiceOperatingSystems class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets a list of all guest operating system versions available to be specified in the XML service * configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next * page of OS versions. Do this till nextLink is null to fetch all the OS versions. * @param location Name of the location that the OS versions pertain to. * @param options The options parameters. */ listOSVersions(location, options) { const iter = this.listOSVersionsPagingAll(location, 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.listOSVersionsPagingPage(location, options, settings); }, }; } async *listOSVersionsPagingPage(location, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listOSVersions(location, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listOSVersionsNext(location, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listOSVersionsPagingAll(location, options) { for await (const page of this.listOSVersionsPagingPage(location, options)) { yield* page; } } /** * Gets a list of all guest operating system families available to be specified in the XML service * configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next * page of OS Families. Do this till nextLink is null to fetch all the OS Families. * @param location Name of the location that the OS families pertain to. * @param options The options parameters. */ listOSFamilies(location, options) { const iter = this.listOSFamiliesPagingAll(location, 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.listOSFamiliesPagingPage(location, options, settings); }, }; } async *listOSFamiliesPagingPage(location, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listOSFamilies(location, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listOSFamiliesNext(location, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listOSFamiliesPagingAll(location, options) { for await (const page of this.listOSFamiliesPagingPage(location, options)) { yield* page; } } /** * Gets properties of a guest operating system version that can be specified in the XML service * configuration (.cscfg) for a cloud service. * @param location Name of the location that the OS version pertains to. * @param osVersionName Name of the OS version. * @param options The options parameters. */ getOSVersion(location, osVersionName, options) { return this.client.sendOperationRequest({ location, osVersionName, options }, getOSVersionOperationSpec); } /** * Gets a list of all guest operating system versions available to be specified in the XML service * configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next * page of OS versions. Do this till nextLink is null to fetch all the OS versions. * @param location Name of the location that the OS versions pertain to. * @param options The options parameters. */ _listOSVersions(location, options) { return this.client.sendOperationRequest({ location, options }, listOSVersionsOperationSpec); } /** * Gets properties of a guest operating system family that can be specified in the XML service * configuration (.cscfg) for a cloud service. * @param location Name of the location that the OS family pertains to. * @param osFamilyName Name of the OS family. * @param options The options parameters. */ getOSFamily(location, osFamilyName, options) { return this.client.sendOperationRequest({ location, osFamilyName, options }, getOSFamilyOperationSpec); } /** * Gets a list of all guest operating system families available to be specified in the XML service * configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next * page of OS Families. Do this till nextLink is null to fetch all the OS Families. * @param location Name of the location that the OS families pertain to. * @param options The options parameters. */ _listOSFamilies(location, options) { return this.client.sendOperationRequest({ location, options }, listOSFamiliesOperationSpec); } /** * ListOSVersionsNext * @param location Name of the location that the OS versions pertain to. * @param nextLink The nextLink from the previous successful call to the ListOSVersions method. * @param options The options parameters. */ _listOSVersionsNext(location, nextLink, options) { return this.client.sendOperationRequest({ location, nextLink, options }, listOSVersionsNextOperationSpec); } /** * ListOSFamiliesNext * @param location Name of the location that the OS families pertain to. * @param nextLink The nextLink from the previous successful call to the ListOSFamilies method. * @param options The options parameters. */ _listOSFamiliesNext(location, nextLink, options) { return this.client.sendOperationRequest({ location, nextLink, options }, listOSFamiliesNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getOSVersionOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSVersion, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.location1, Parameters.osVersionName, ], headerParameters: [Parameters.accept], serializer, }; const listOSVersionsOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSVersionListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.location1], headerParameters: [Parameters.accept], serializer, }; const getOSFamilyOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSFamily, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.location1, Parameters.osFamilyName, ], headerParameters: [Parameters.accept], serializer, }; const listOSFamiliesOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSFamilyListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.location1], headerParameters: [Parameters.accept], serializer, }; const listOSVersionsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSVersionListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.location1, ], headerParameters: [Parameters.accept], serializer, }; const listOSFamiliesNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OSFamilyListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.location1, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=cloudServiceOperatingSystems.js.map