@azure/arm-compute
Version:
A generated SDK for ComputeManagementClient.
252 lines • 10.4 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";
import { createHttpPoller } from "@azure/core-lro";
import { createLroSpec } from "../lroImpl.js";
/// <reference lib="esnext.asynciterable" />
/** Class containing CloudServicesUpdateDomain operations. */
export class CloudServicesUpdateDomainImpl {
client;
/**
* Initialize a new instance of the class CloudServicesUpdateDomain class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Gets a list of all update domains in a cloud service.
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param options The options parameters.
*/
listUpdateDomains(resourceGroupName, cloudServiceName, options) {
const iter = this.listUpdateDomainsPagingAll(resourceGroupName, cloudServiceName, 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.listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options, settings);
},
};
}
async *listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options, settings) {
let result;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._listUpdateDomains(resourceGroupName, cloudServiceName, options);
const page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listUpdateDomainsNext(resourceGroupName, cloudServiceName, continuationToken, options);
continuationToken = result.nextLink;
const page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
async *listUpdateDomainsPagingAll(resourceGroupName, cloudServiceName, options) {
for await (const page of this.listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options)) {
yield* page;
}
}
/**
* Updates the role instances in the specified update domain.
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param updateDomain Specifies an integer value that identifies the update domain. Update domains are
* identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of
* 1, and so on.
* @param options The options parameters.
*/
async beginWalkUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options) {
const directSendOperation = async (args, spec) => {
return this.client.sendOperationRequest(args, spec);
};
const sendOperationFn = async (args, spec) => {
let currentRawResponse = undefined;
const providedCallback = args.options?.onResponse;
const callback = (rawResponse, flatResponse) => {
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, cloudServiceName, updateDomain, options },
spec: walkUpdateDomainOperationSpec,
});
const poller = await createHttpPoller(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs,
});
await poller.poll();
return poller;
}
/**
* Updates the role instances in the specified update domain.
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param updateDomain Specifies an integer value that identifies the update domain. Update domains are
* identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of
* 1, and so on.
* @param options The options parameters.
*/
async beginWalkUpdateDomainAndWait(resourceGroupName, cloudServiceName, updateDomain, options) {
const poller = await this.beginWalkUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options);
return poller.pollUntilDone();
}
/**
* Gets the specified update domain of a cloud service. Use nextLink property in the response to get
* the next page of update domains. Do this till nextLink is null to fetch all the update domains.
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param updateDomain Specifies an integer value that identifies the update domain. Update domains are
* identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of
* 1, and so on.
* @param options The options parameters.
*/
getUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options) {
return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, updateDomain, options }, getUpdateDomainOperationSpec);
}
/**
* Gets a list of all update domains in a cloud service.
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param options The options parameters.
*/
_listUpdateDomains(resourceGroupName, cloudServiceName, options) {
return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, options }, listUpdateDomainsOperationSpec);
}
/**
* ListUpdateDomainsNext
* @param resourceGroupName Name of the resource group.
* @param cloudServiceName Name of the cloud service.
* @param nextLink The nextLink from the previous successful call to the ListUpdateDomains method.
* @param options The options parameters.
*/
_listUpdateDomainsNext(resourceGroupName, cloudServiceName, nextLink, options) {
return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, nextLink, options }, listUpdateDomainsNextOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const walkUpdateDomainOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}",
httpMethod: "PUT",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError,
},
},
requestBody: Parameters.parameters40,
queryParameters: [Parameters.apiVersion4],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName1,
Parameters.cloudServiceName,
Parameters.updateDomain,
],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer,
};
const getUpdateDomainOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.UpdateDomain,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion4],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName1,
Parameters.cloudServiceName,
Parameters.updateDomain,
],
headerParameters: [Parameters.accept],
serializer,
};
const listUpdateDomainsOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.UpdateDomainListResult,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion4],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName1,
Parameters.cloudServiceName,
],
headerParameters: [Parameters.accept],
serializer,
};
const listUpdateDomainsNextOperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.UpdateDomainListResult,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
urlParameters: [
Parameters.$host,
Parameters.nextLink,
Parameters.subscriptionId,
Parameters.resourceGroupName1,
Parameters.cloudServiceName,
],
headerParameters: [Parameters.accept],
serializer,
};
//# sourceMappingURL=cloudServicesUpdateDomain.js.map