UNPKG

@azure/arm-appservice

Version:
445 lines 16.8 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"; import { createHttpPoller } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing KubeEnvironments operations. */ export class KubeEnvironmentsImpl { client; /** * Initialize a new instance of the class KubeEnvironments class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Description for Get all Kubernetes Environments for a subscription. * @param options The options parameters. */ listBySubscription(options) { const iter = this.listBySubscriptionPagingAll(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.listBySubscriptionPagingPage(options, settings); }, }; } async *listBySubscriptionPagingPage(options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listBySubscription(options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listBySubscriptionPagingAll(options) { for await (const page of this.listBySubscriptionPagingPage(options)) { yield* page; } } /** * Description for Get all the Kubernetes Environments in a resource group. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param options The options parameters. */ listByResourceGroup(resourceGroupName, options) { const iter = this.listByResourceGroupPagingAll(resourceGroupName, 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.listByResourceGroupPagingPage(resourceGroupName, options, settings); }, }; } async *listByResourceGroupPagingPage(resourceGroupName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByResourceGroup(resourceGroupName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByResourceGroupNext(resourceGroupName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByResourceGroupPagingAll(resourceGroupName, options) { for await (const page of this.listByResourceGroupPagingPage(resourceGroupName, options)) { yield* page; } } /** * Description for Get all Kubernetes Environments for a subscription. * @param options The options parameters. */ _listBySubscription(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionOperationSpec); } /** * Description for Get all the Kubernetes Environments in a resource group. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param options The options parameters. */ _listByResourceGroup(resourceGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec); } /** * Description for Get the properties of a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param options The options parameters. */ get(resourceGroupName, name, options) { return this.client.sendOperationRequest({ resourceGroupName, name, options }, getOperationSpec); } /** * Description for Creates or updates a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param kubeEnvironmentEnvelope Configuration details of the Kubernetes Environment. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, name, kubeEnvironmentEnvelope, 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, name, kubeEnvironmentEnvelope, options }, spec: createOrUpdateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * Description for Creates or updates a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param kubeEnvironmentEnvelope Configuration details of the Kubernetes Environment. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, name, kubeEnvironmentEnvelope, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, name, kubeEnvironmentEnvelope, options); return poller.pollUntilDone(); } /** * Description for Delete a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param options The options parameters. */ async beginDelete(resourceGroupName, name, 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, name, options }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * Description for Delete a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, name, options) { const poller = await this.beginDelete(resourceGroupName, name, options); return poller.pollUntilDone(); } /** * Description for Creates or updates a Kubernetes Environment. * @param resourceGroupName Name of the resource group to which the resource belongs. * @param name Name of the Kubernetes Environment. * @param kubeEnvironmentEnvelope Configuration details of the Kubernetes Environment. * @param options The options parameters. */ update(resourceGroupName, name, kubeEnvironmentEnvelope, options) { return this.client.sendOperationRequest({ resourceGroupName, name, kubeEnvironmentEnvelope, options }, updateOperationSpec); } /** * ListBySubscriptionNext * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. * @param options The options parameters. */ _listBySubscriptionNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listBySubscriptionNextOperationSpec); } /** * ListByResourceGroupNext * @param resourceGroupName Name of the resource group to which the resource belongs. * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. * @param options The options parameters. */ _listByResourceGroupNext(resourceGroupName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listBySubscriptionOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Web/kubeEnvironments", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KubeEnvironmentCollection, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/kubeEnvironments", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KubeEnvironmentCollection, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/kubeEnvironments/{name}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KubeEnvironment, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.name, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/kubeEnvironments/{name}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.KubeEnvironment, }, 201: { bodyMapper: Mappers.KubeEnvironment, }, 202: { bodyMapper: Mappers.KubeEnvironment, }, 204: { bodyMapper: Mappers.KubeEnvironment, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, requestBody: Parameters.kubeEnvironmentEnvelope, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.name, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/kubeEnvironments/{name}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.name, ], headerParameters: [Parameters.accept], serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/kubeEnvironments/{name}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.KubeEnvironment, }, 201: { bodyMapper: Mappers.KubeEnvironment, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, requestBody: Parameters.kubeEnvironmentEnvelope1, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.name, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const listBySubscriptionNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KubeEnvironmentCollection, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.nextLink], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.KubeEnvironmentCollection, }, default: { bodyMapper: Mappers.DefaultErrorResponse, }, }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=kubeEnvironments.js.map