/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */

import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { AppServicePlans } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { WebSiteManagementClient } from "../webSiteManagementClient";
import {
  SimplePollerLike,
  OperationState,
  createHttpPoller
} from "@azure/core-lro";
import { createLroSpec } from "../lroImpl";
import {
  AppServicePlan,
  AppServicePlansListNextOptionalParams,
  AppServicePlansListOptionalParams,
  AppServicePlansListResponse,
  AppServicePlansListByResourceGroupNextOptionalParams,
  AppServicePlansListByResourceGroupOptionalParams,
  AppServicePlansListByResourceGroupResponse,
  AppServicePlansListWebAppsByHybridConnectionNextOptionalParams,
  AppServicePlansListWebAppsByHybridConnectionOptionalParams,
  AppServicePlansListWebAppsByHybridConnectionResponse,
  HybridConnection,
  AppServicePlansListHybridConnectionsNextOptionalParams,
  AppServicePlansListHybridConnectionsOptionalParams,
  AppServicePlansListHybridConnectionsResponse,
  Site,
  AppServicePlansListWebAppsNextOptionalParams,
  AppServicePlansListWebAppsOptionalParams,
  AppServicePlansListWebAppsResponse,
  CsmUsageQuota,
  AppServicePlansListUsagesNextOptionalParams,
  AppServicePlansListUsagesOptionalParams,
  AppServicePlansListUsagesResponse,
  AppServicePlansGetOptionalParams,
  AppServicePlansGetResponse,
  AppServicePlansCreateOrUpdateOptionalParams,
  AppServicePlansCreateOrUpdateResponse,
  AppServicePlansDeleteOptionalParams,
  AppServicePlanPatchResource,
  AppServicePlansUpdateOptionalParams,
  AppServicePlansUpdateResponse,
  AppServicePlansListCapabilitiesOptionalParams,
  AppServicePlansListCapabilitiesResponse,
  AppServicePlansGetHybridConnectionOptionalParams,
  AppServicePlansGetHybridConnectionResponse,
  AppServicePlansDeleteHybridConnectionOptionalParams,
  AppServicePlansListHybridConnectionKeysOptionalParams,
  AppServicePlansListHybridConnectionKeysResponse,
  AppServicePlansGetHybridConnectionPlanLimitOptionalParams,
  AppServicePlansGetHybridConnectionPlanLimitResponse,
  AppServicePlansRestartWebAppsOptionalParams,
  AppServicePlansGetServerFarmSkusOptionalParams,
  AppServicePlansGetServerFarmSkusResponse,
  AppServicePlansListVnetsOptionalParams,
  AppServicePlansListVnetsResponse,
  AppServicePlansGetVnetFromServerFarmOptionalParams,
  AppServicePlansGetVnetFromServerFarmResponse,
  AppServicePlansGetVnetGatewayOptionalParams,
  AppServicePlansGetVnetGatewayResponse,
  VnetGateway,
  AppServicePlansUpdateVnetGatewayOptionalParams,
  AppServicePlansUpdateVnetGatewayResponse,
  AppServicePlansListRoutesForVnetOptionalParams,
  AppServicePlansListRoutesForVnetResponse,
  AppServicePlansGetRouteForVnetOptionalParams,
  AppServicePlansGetRouteForVnetResponse,
  VnetRoute,
  AppServicePlansCreateOrUpdateVnetRouteOptionalParams,
  AppServicePlansCreateOrUpdateVnetRouteResponse,
  AppServicePlansDeleteVnetRouteOptionalParams,
  AppServicePlansUpdateVnetRouteOptionalParams,
  AppServicePlansUpdateVnetRouteResponse,
  AppServicePlansRebootWorkerOptionalParams,
  AppServicePlansListNextResponse,
  AppServicePlansListByResourceGroupNextResponse,
  AppServicePlansListWebAppsByHybridConnectionNextResponse,
  AppServicePlansListHybridConnectionsNextResponse,
  AppServicePlansListWebAppsNextResponse,
  AppServicePlansListUsagesNextResponse
} from "../models";

/// <reference lib="esnext.asynciterable" />
/** Class containing AppServicePlans operations. */
export class AppServicePlansImpl implements AppServicePlans {
  private readonly client: WebSiteManagementClient;

  /**
   * Initialize a new instance of the class AppServicePlans class.
   * @param client Reference to the service client
   */
  constructor(client: WebSiteManagementClient) {
    this.client = client;
  }

  /**
   * Description for Get all App Service plans for a subscription.
   * @param options The options parameters.
   */
  public list(
    options?: AppServicePlansListOptionalParams
  ): PagedAsyncIterableIterator<AppServicePlan> {
    const iter = this.listPagingAll(options);
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listPagingPage(options, settings);
      }
    };
  }

  private async *listPagingPage(
    options?: AppServicePlansListOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<AppServicePlan[]> {
    let result: AppServicePlansListResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._list(options);
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listNext(continuationToken, options);
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listPagingAll(
    options?: AppServicePlansListOptionalParams
  ): AsyncIterableIterator<AppServicePlan> {
    for await (const page of this.listPagingPage(options)) {
      yield* page;
    }
  }

  /**
   * Description for Get all App Service plans in a resource group.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param options The options parameters.
   */
  public listByResourceGroup(
    resourceGroupName: string,
    options?: AppServicePlansListByResourceGroupOptionalParams
  ): PagedAsyncIterableIterator<AppServicePlan> {
    const iter = this.listByResourceGroupPagingAll(resourceGroupName, options);
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listByResourceGroupPagingPage(
          resourceGroupName,
          options,
          settings
        );
      }
    };
  }

  private async *listByResourceGroupPagingPage(
    resourceGroupName: string,
    options?: AppServicePlansListByResourceGroupOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<AppServicePlan[]> {
    let result: AppServicePlansListByResourceGroupResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._listByResourceGroup(resourceGroupName, options);
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listByResourceGroupNext(
        resourceGroupName,
        continuationToken,
        options
      );
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listByResourceGroupPagingAll(
    resourceGroupName: string,
    options?: AppServicePlansListByResourceGroupOptionalParams
  ): AsyncIterableIterator<AppServicePlan> {
    for await (const page of this.listByResourceGroupPagingPage(
      resourceGroupName,
      options
    )) {
      yield* page;
    }
  }

  /**
   * Description for Get all apps that use a Hybrid Connection in an App Service Plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName Name of the Hybrid Connection namespace.
   * @param relayName Name of the Hybrid Connection relay.
   * @param options The options parameters.
   */
  public listWebAppsByHybridConnection(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansListWebAppsByHybridConnectionOptionalParams
  ): PagedAsyncIterableIterator<string> {
    const iter = this.listWebAppsByHybridConnectionPagingAll(
      resourceGroupName,
      name,
      namespaceName,
      relayName,
      options
    );
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listWebAppsByHybridConnectionPagingPage(
          resourceGroupName,
          name,
          namespaceName,
          relayName,
          options,
          settings
        );
      }
    };
  }

  private async *listWebAppsByHybridConnectionPagingPage(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansListWebAppsByHybridConnectionOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<string[]> {
    let result: AppServicePlansListWebAppsByHybridConnectionResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._listWebAppsByHybridConnection(
        resourceGroupName,
        name,
        namespaceName,
        relayName,
        options
      );
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listWebAppsByHybridConnectionNext(
        resourceGroupName,
        name,
        namespaceName,
        relayName,
        continuationToken,
        options
      );
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listWebAppsByHybridConnectionPagingAll(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansListWebAppsByHybridConnectionOptionalParams
  ): AsyncIterableIterator<string> {
    for await (const page of this.listWebAppsByHybridConnectionPagingPage(
      resourceGroupName,
      name,
      namespaceName,
      relayName,
      options
    )) {
      yield* page;
    }
  }

  /**
   * Description for Retrieve all Hybrid Connections in use in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  public listHybridConnections(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListHybridConnectionsOptionalParams
  ): PagedAsyncIterableIterator<HybridConnection> {
    const iter = this.listHybridConnectionsPagingAll(
      resourceGroupName,
      name,
      options
    );
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listHybridConnectionsPagingPage(
          resourceGroupName,
          name,
          options,
          settings
        );
      }
    };
  }

  private async *listHybridConnectionsPagingPage(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListHybridConnectionsOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<HybridConnection[]> {
    let result: AppServicePlansListHybridConnectionsResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._listHybridConnections(
        resourceGroupName,
        name,
        options
      );
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listHybridConnectionsNext(
        resourceGroupName,
        name,
        continuationToken,
        options
      );
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listHybridConnectionsPagingAll(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListHybridConnectionsOptionalParams
  ): AsyncIterableIterator<HybridConnection> {
    for await (const page of this.listHybridConnectionsPagingPage(
      resourceGroupName,
      name,
      options
    )) {
      yield* page;
    }
  }

  /**
   * Description for Get all apps associated with an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  public listWebApps(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListWebAppsOptionalParams
  ): PagedAsyncIterableIterator<Site> {
    const iter = this.listWebAppsPagingAll(resourceGroupName, name, options);
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listWebAppsPagingPage(
          resourceGroupName,
          name,
          options,
          settings
        );
      }
    };
  }

  private async *listWebAppsPagingPage(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListWebAppsOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<Site[]> {
    let result: AppServicePlansListWebAppsResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._listWebApps(resourceGroupName, name, options);
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listWebAppsNext(
        resourceGroupName,
        name,
        continuationToken,
        options
      );
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listWebAppsPagingAll(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListWebAppsOptionalParams
  ): AsyncIterableIterator<Site> {
    for await (const page of this.listWebAppsPagingPage(
      resourceGroupName,
      name,
      options
    )) {
      yield* page;
    }
  }

  /**
   * Description for Gets server farm usage information
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of App Service Plan
   * @param options The options parameters.
   */
  public listUsages(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListUsagesOptionalParams
  ): PagedAsyncIterableIterator<CsmUsageQuota> {
    const iter = this.listUsagesPagingAll(resourceGroupName, name, options);
    return {
      next() {
        return iter.next();
      },
      [Symbol.asyncIterator]() {
        return this;
      },
      byPage: (settings?: PageSettings) => {
        if (settings?.maxPageSize) {
          throw new Error("maxPageSize is not supported by this operation.");
        }
        return this.listUsagesPagingPage(
          resourceGroupName,
          name,
          options,
          settings
        );
      }
    };
  }

  private async *listUsagesPagingPage(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListUsagesOptionalParams,
    settings?: PageSettings
  ): AsyncIterableIterator<CsmUsageQuota[]> {
    let result: AppServicePlansListUsagesResponse;
    let continuationToken = settings?.continuationToken;
    if (!continuationToken) {
      result = await this._listUsages(resourceGroupName, name, options);
      let page = result.value || [];
      continuationToken = result.nextLink;
      setContinuationToken(page, continuationToken);
      yield page;
    }
    while (continuationToken) {
      result = await this._listUsagesNext(
        resourceGroupName,
        name,
        continuationToken,
        options
      );
      continuationToken = result.nextLink;
      let page = result.value || [];
      setContinuationToken(page, continuationToken);
      yield page;
    }
  }

  private async *listUsagesPagingAll(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListUsagesOptionalParams
  ): AsyncIterableIterator<CsmUsageQuota> {
    for await (const page of this.listUsagesPagingPage(
      resourceGroupName,
      name,
      options
    )) {
      yield* page;
    }
  }

  /**
   * Description for Get all App Service plans for a subscription.
   * @param options The options parameters.
   */
  private _list(
    options?: AppServicePlansListOptionalParams
  ): Promise<AppServicePlansListResponse> {
    return this.client.sendOperationRequest({ options }, listOperationSpec);
  }

  /**
   * Description for Get all App Service plans in a resource group.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param options The options parameters.
   */
  private _listByResourceGroup(
    resourceGroupName: string,
    options?: AppServicePlansListByResourceGroupOptionalParams
  ): Promise<AppServicePlansListByResourceGroupResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, options },
      listByResourceGroupOperationSpec
    );
  }

  /**
   * Description for Get an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  get(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansGetOptionalParams
  ): Promise<AppServicePlansGetResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      getOperationSpec
    );
  }

  /**
   * Description for Creates or updates an App Service Plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param appServicePlan Details of the App Service plan.
   * @param options The options parameters.
   */
  async beginCreateOrUpdate(
    resourceGroupName: string,
    name: string,
    appServicePlan: AppServicePlan,
    options?: AppServicePlansCreateOrUpdateOptionalParams
  ): Promise<
    SimplePollerLike<
      OperationState<AppServicePlansCreateOrUpdateResponse>,
      AppServicePlansCreateOrUpdateResponse
    >
  > {
    const directSendOperation = async (
      args: coreClient.OperationArguments,
      spec: coreClient.OperationSpec
    ): Promise<AppServicePlansCreateOrUpdateResponse> => {
      return this.client.sendOperationRequest(args, spec);
    };
    const sendOperationFn = async (
      args: coreClient.OperationArguments,
      spec: coreClient.OperationSpec
    ) => {
      let currentRawResponse:
        | coreClient.FullOperationResponse
        | undefined = undefined;
      const providedCallback = args.options?.onResponse;
      const callback: coreClient.RawResponseCallback = (
        rawResponse: coreClient.FullOperationResponse,
        flatResponse: unknown
      ) => {
        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, appServicePlan, options },
      spec: createOrUpdateOperationSpec
    });
    const poller = await createHttpPoller<
      AppServicePlansCreateOrUpdateResponse,
      OperationState<AppServicePlansCreateOrUpdateResponse>
    >(lro, {
      restoreFrom: options?.resumeFrom,
      intervalInMs: options?.updateIntervalInMs
    });
    await poller.poll();
    return poller;
  }

  /**
   * Description for Creates or updates an App Service Plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param appServicePlan Details of the App Service plan.
   * @param options The options parameters.
   */
  async beginCreateOrUpdateAndWait(
    resourceGroupName: string,
    name: string,
    appServicePlan: AppServicePlan,
    options?: AppServicePlansCreateOrUpdateOptionalParams
  ): Promise<AppServicePlansCreateOrUpdateResponse> {
    const poller = await this.beginCreateOrUpdate(
      resourceGroupName,
      name,
      appServicePlan,
      options
    );
    return poller.pollUntilDone();
  }

  /**
   * Description for Delete an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  delete(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansDeleteOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      deleteOperationSpec
    );
  }

  /**
   * Description for Creates or updates an App Service Plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param appServicePlan Details of the App Service plan.
   * @param options The options parameters.
   */
  update(
    resourceGroupName: string,
    name: string,
    appServicePlan: AppServicePlanPatchResource,
    options?: AppServicePlansUpdateOptionalParams
  ): Promise<AppServicePlansUpdateResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, appServicePlan, options },
      updateOperationSpec
    );
  }

  /**
   * Description for List all capabilities of an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  listCapabilities(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListCapabilitiesOptionalParams
  ): Promise<AppServicePlansListCapabilitiesResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      listCapabilitiesOperationSpec
    );
  }

  /**
   * Description for Retrieve a Hybrid Connection in use in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName Name of the Service Bus namespace.
   * @param relayName Name of the Service Bus relay.
   * @param options The options parameters.
   */
  getHybridConnection(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansGetHybridConnectionOptionalParams
  ): Promise<AppServicePlansGetHybridConnectionResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, namespaceName, relayName, options },
      getHybridConnectionOperationSpec
    );
  }

  /**
   * Description for Delete a Hybrid Connection in use in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName Name of the Service Bus namespace.
   * @param relayName Name of the Service Bus relay.
   * @param options The options parameters.
   */
  deleteHybridConnection(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansDeleteHybridConnectionOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, namespaceName, relayName, options },
      deleteHybridConnectionOperationSpec
    );
  }

  /**
   * Description for Get the send key name and value of a Hybrid Connection.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName The name of the Service Bus namespace.
   * @param relayName The name of the Service Bus relay.
   * @param options The options parameters.
   */
  listHybridConnectionKeys(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansListHybridConnectionKeysOptionalParams
  ): Promise<AppServicePlansListHybridConnectionKeysResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, namespaceName, relayName, options },
      listHybridConnectionKeysOperationSpec
    );
  }

  /**
   * Description for Get all apps that use a Hybrid Connection in an App Service Plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName Name of the Hybrid Connection namespace.
   * @param relayName Name of the Hybrid Connection relay.
   * @param options The options parameters.
   */
  private _listWebAppsByHybridConnection(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    options?: AppServicePlansListWebAppsByHybridConnectionOptionalParams
  ): Promise<AppServicePlansListWebAppsByHybridConnectionResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, namespaceName, relayName, options },
      listWebAppsByHybridConnectionOperationSpec
    );
  }

  /**
   * Description for Get the maximum number of Hybrid Connections allowed in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  getHybridConnectionPlanLimit(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansGetHybridConnectionPlanLimitOptionalParams
  ): Promise<AppServicePlansGetHybridConnectionPlanLimitResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      getHybridConnectionPlanLimitOperationSpec
    );
  }

  /**
   * Description for Retrieve all Hybrid Connections in use in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  private _listHybridConnections(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListHybridConnectionsOptionalParams
  ): Promise<AppServicePlansListHybridConnectionsResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      listHybridConnectionsOperationSpec
    );
  }

  /**
   * Description for Restart all apps in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  restartWebApps(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansRestartWebAppsOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      restartWebAppsOperationSpec
    );
  }

  /**
   * Description for Get all apps associated with an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  private _listWebApps(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListWebAppsOptionalParams
  ): Promise<AppServicePlansListWebAppsResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      listWebAppsOperationSpec
    );
  }

  /**
   * Description for Gets all selectable SKUs for a given App Service Plan
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of App Service Plan
   * @param options The options parameters.
   */
  getServerFarmSkus(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansGetServerFarmSkusOptionalParams
  ): Promise<AppServicePlansGetServerFarmSkusResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      getServerFarmSkusOperationSpec
    );
  }

  /**
   * Description for Gets server farm usage information
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of App Service Plan
   * @param options The options parameters.
   */
  private _listUsages(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListUsagesOptionalParams
  ): Promise<AppServicePlansListUsagesResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      listUsagesOperationSpec
    );
  }

  /**
   * Description for Get all Virtual Networks associated with an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param options The options parameters.
   */
  listVnets(
    resourceGroupName: string,
    name: string,
    options?: AppServicePlansListVnetsOptionalParams
  ): Promise<AppServicePlansListVnetsResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, options },
      listVnetsOperationSpec
    );
  }

  /**
   * Description for Get a Virtual Network associated with an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param options The options parameters.
   */
  getVnetFromServerFarm(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    options?: AppServicePlansGetVnetFromServerFarmOptionalParams
  ): Promise<AppServicePlansGetVnetFromServerFarmResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, options },
      getVnetFromServerFarmOperationSpec
    );
  }

  /**
   * Description for Get a Virtual Network gateway.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param gatewayName Name of the gateway. Only the 'primary' gateway is supported.
   * @param options The options parameters.
   */
  getVnetGateway(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    gatewayName: string,
    options?: AppServicePlansGetVnetGatewayOptionalParams
  ): Promise<AppServicePlansGetVnetGatewayResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, gatewayName, options },
      getVnetGatewayOperationSpec
    );
  }

  /**
   * Description for Update a Virtual Network gateway.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param gatewayName Name of the gateway. Only the 'primary' gateway is supported.
   * @param connectionEnvelope Definition of the gateway.
   * @param options The options parameters.
   */
  updateVnetGateway(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    gatewayName: string,
    connectionEnvelope: VnetGateway,
    options?: AppServicePlansUpdateVnetGatewayOptionalParams
  ): Promise<AppServicePlansUpdateVnetGatewayResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        name,
        vnetName,
        gatewayName,
        connectionEnvelope,
        options
      },
      updateVnetGatewayOperationSpec
    );
  }

  /**
   * Description for Get all routes that are associated with a Virtual Network in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param options The options parameters.
   */
  listRoutesForVnet(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    options?: AppServicePlansListRoutesForVnetOptionalParams
  ): Promise<AppServicePlansListRoutesForVnetResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, options },
      listRoutesForVnetOperationSpec
    );
  }

  /**
   * Description for Get a Virtual Network route in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param routeName Name of the Virtual Network route.
   * @param options The options parameters.
   */
  getRouteForVnet(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    routeName: string,
    options?: AppServicePlansGetRouteForVnetOptionalParams
  ): Promise<AppServicePlansGetRouteForVnetResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, routeName, options },
      getRouteForVnetOperationSpec
    );
  }

  /**
   * Description for Create or update a Virtual Network route in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param routeName Name of the Virtual Network route.
   * @param route Definition of the Virtual Network route.
   * @param options The options parameters.
   */
  createOrUpdateVnetRoute(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    routeName: string,
    route: VnetRoute,
    options?: AppServicePlansCreateOrUpdateVnetRouteOptionalParams
  ): Promise<AppServicePlansCreateOrUpdateVnetRouteResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, routeName, route, options },
      createOrUpdateVnetRouteOperationSpec
    );
  }

  /**
   * Description for Delete a Virtual Network route in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param routeName Name of the Virtual Network route.
   * @param options The options parameters.
   */
  deleteVnetRoute(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    routeName: string,
    options?: AppServicePlansDeleteVnetRouteOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, routeName, options },
      deleteVnetRouteOperationSpec
    );
  }

  /**
   * Description for Create or update a Virtual Network route in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param vnetName Name of the Virtual Network.
   * @param routeName Name of the Virtual Network route.
   * @param route Definition of the Virtual Network route.
   * @param options The options parameters.
   */
  updateVnetRoute(
    resourceGroupName: string,
    name: string,
    vnetName: string,
    routeName: string,
    route: VnetRoute,
    options?: AppServicePlansUpdateVnetRouteOptionalParams
  ): Promise<AppServicePlansUpdateVnetRouteResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, vnetName, routeName, route, options },
      updateVnetRouteOperationSpec
    );
  }

  /**
   * Description for Reboot a worker machine in an App Service plan.
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param workerName Name of worker machine, which typically starts with RD.
   * @param options The options parameters.
   */
  rebootWorker(
    resourceGroupName: string,
    name: string,
    workerName: string,
    options?: AppServicePlansRebootWorkerOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, workerName, options },
      rebootWorkerOperationSpec
    );
  }

  /**
   * ListNext
   * @param nextLink The nextLink from the previous successful call to the List method.
   * @param options The options parameters.
   */
  private _listNext(
    nextLink: string,
    options?: AppServicePlansListNextOptionalParams
  ): Promise<AppServicePlansListNextResponse> {
    return this.client.sendOperationRequest(
      { nextLink, options },
      listNextOperationSpec
    );
  }

  /**
   * 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.
   */
  private _listByResourceGroupNext(
    resourceGroupName: string,
    nextLink: string,
    options?: AppServicePlansListByResourceGroupNextOptionalParams
  ): Promise<AppServicePlansListByResourceGroupNextResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, nextLink, options },
      listByResourceGroupNextOperationSpec
    );
  }

  /**
   * ListWebAppsByHybridConnectionNext
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param namespaceName Name of the Hybrid Connection namespace.
   * @param relayName Name of the Hybrid Connection relay.
   * @param nextLink The nextLink from the previous successful call to the ListWebAppsByHybridConnection
   *                 method.
   * @param options The options parameters.
   */
  private _listWebAppsByHybridConnectionNext(
    resourceGroupName: string,
    name: string,
    namespaceName: string,
    relayName: string,
    nextLink: string,
    options?: AppServicePlansListWebAppsByHybridConnectionNextOptionalParams
  ): Promise<AppServicePlansListWebAppsByHybridConnectionNextResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, namespaceName, relayName, nextLink, options },
      listWebAppsByHybridConnectionNextOperationSpec
    );
  }

  /**
   * ListHybridConnectionsNext
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param nextLink The nextLink from the previous successful call to the ListHybridConnections method.
   * @param options The options parameters.
   */
  private _listHybridConnectionsNext(
    resourceGroupName: string,
    name: string,
    nextLink: string,
    options?: AppServicePlansListHybridConnectionsNextOptionalParams
  ): Promise<AppServicePlansListHybridConnectionsNextResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, nextLink, options },
      listHybridConnectionsNextOperationSpec
    );
  }

  /**
   * ListWebAppsNext
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of the App Service plan.
   * @param nextLink The nextLink from the previous successful call to the ListWebApps method.
   * @param options The options parameters.
   */
  private _listWebAppsNext(
    resourceGroupName: string,
    name: string,
    nextLink: string,
    options?: AppServicePlansListWebAppsNextOptionalParams
  ): Promise<AppServicePlansListWebAppsNextResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, nextLink, options },
      listWebAppsNextOperationSpec
    );
  }

  /**
   * ListUsagesNext
   * @param resourceGroupName Name of the resource group to which the resource belongs.
   * @param name Name of App Service Plan
   * @param nextLink The nextLink from the previous successful call to the ListUsages method.
   * @param options The options parameters.
   */
  private _listUsagesNext(
    resourceGroupName: string,
    name: string,
    nextLink: string,
    options?: AppServicePlansListUsagesNextOptionalParams
  ): Promise<AppServicePlansListUsagesNextResponse> {
    return this.client.sendOperationRequest(
      { resourceGroupName, name, nextLink, options },
      listUsagesNextOperationSpec
    );
  }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);

const listOperationSpec: coreClient.OperationSpec = {
  path: "/subscriptions/{subscriptionId}/providers/Microsoft.Web/serverfarms",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlanCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion, Parameters.detailed],
  urlParameters: [Parameters.$host, Parameters.subscriptionId],
  headerParameters: [Parameters.accept],
  serializer
};
const listByResourceGroupOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlanCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlan
    },
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const createOrUpdateOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}",
  httpMethod: "PUT",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlan
    },
    201: {
      bodyMapper: Mappers.AppServicePlan
    },
    202: {
      bodyMapper: Mappers.AppServicePlan
    },
    204: {
      bodyMapper: Mappers.AppServicePlan
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  requestBody: Parameters.appServicePlan,
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept, Parameters.contentType],
  mediaType: "json",
  serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}",
  httpMethod: "DELETE",
  responses: {
    200: {},
    204: {},
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const updateOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}",
  httpMethod: "PATCH",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlan
    },
    202: {
      bodyMapper: Mappers.AppServicePlan
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  requestBody: Parameters.appServicePlan1,
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept, Parameters.contentType],
  mediaType: "json",
  serializer
};
const listCapabilitiesOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/capabilities",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: {
          name: "Sequence",
          element: { type: { name: "Composite", className: "Capability" } }
        }
      }
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getHybridConnectionOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.HybridConnection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.namespaceName,
    Parameters.relayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const deleteHybridConnectionOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}",
  httpMethod: "DELETE",
  responses: {
    200: {},
    204: {},
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.namespaceName,
    Parameters.relayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listHybridConnectionKeysOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}/listKeys",
  httpMethod: "POST",
  responses: {
    200: {
      bodyMapper: Mappers.HybridConnectionKey
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.namespaceName,
    Parameters.relayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listWebAppsByHybridConnectionOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionNamespaces/{namespaceName}/relays/{relayName}/sites",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.ResourceCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.namespaceName,
    Parameters.relayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getHybridConnectionPlanLimitOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionPlanLimits/limit",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.HybridConnectionLimits
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listHybridConnectionsOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/hybridConnectionRelays",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.HybridConnectionCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const restartWebAppsOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/restartSites",
  httpMethod: "POST",
  responses: {
    204: {},
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion, Parameters.softRestart],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listWebAppsOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/sites",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.WebAppCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [
    Parameters.apiVersion,
    Parameters.filter,
    Parameters.skipToken,
    Parameters.top
  ],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getServerFarmSkusOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/skus",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: { name: "Dictionary", value: { type: { name: "any" } } }
      }
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listUsagesOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/usages",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.CsmUsageQuotaCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion, Parameters.filter],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listVnetsOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: {
          name: "Sequence",
          element: {
            type: { name: "Composite", className: "VnetInfoResource" }
          }
        }
      }
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getVnetFromServerFarmOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.VnetInfoResource
    },
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getVnetGatewayOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.VnetGateway
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.gatewayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const updateVnetGatewayOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/gateways/{gatewayName}",
  httpMethod: "PUT",
  responses: {
    200: {
      bodyMapper: Mappers.VnetGateway
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  requestBody: Parameters.connectionEnvelope,
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.gatewayName
  ],
  headerParameters: [Parameters.accept, Parameters.contentType],
  mediaType: "json",
  serializer
};
const listRoutesForVnetOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: {
          name: "Sequence",
          element: { type: { name: "Composite", className: "VnetRoute" } }
        }
      }
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getRouteForVnetOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: {
        type: {
          name: "Sequence",
          element: { type: { name: "Composite", className: "VnetRoute" } }
        }
      }
    },
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.routeName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const createOrUpdateVnetRouteOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}",
  httpMethod: "PUT",
  responses: {
    200: {
      bodyMapper: Mappers.VnetRoute
    },
    400: {
      isError: true
    },
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  requestBody: Parameters.route,
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.routeName
  ],
  headerParameters: [Parameters.accept, Parameters.contentType],
  mediaType: "json",
  serializer
};
const deleteVnetRouteOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}",
  httpMethod: "DELETE",
  responses: {
    200: {},
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.routeName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const updateVnetRouteOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/virtualNetworkConnections/{vnetName}/routes/{routeName}",
  httpMethod: "PATCH",
  responses: {
    200: {
      bodyMapper: Mappers.VnetRoute
    },
    400: {
      isError: true
    },
    404: {
      isError: true
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  requestBody: Parameters.route,
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.vnetName,
    Parameters.routeName
  ],
  headerParameters: [Parameters.accept, Parameters.contentType],
  mediaType: "json",
  serializer
};
const rebootWorkerOperationSpec: coreClient.OperationSpec = {
  path:
    "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{name}/workers/{workerName}/reboot",
  httpMethod: "POST",
  responses: {
    204: {},
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  queryParameters: [Parameters.apiVersion],
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.workerName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlanCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.nextLink
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.AppServicePlanCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.nextLink
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listWebAppsByHybridConnectionNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.ResourceCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.nextLink,
    Parameters.namespaceName,
    Parameters.relayName
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listHybridConnectionsNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.HybridConnectionCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.nextLink
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listWebAppsNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.WebAppCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.nextLink
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listUsagesNextOperationSpec: coreClient.OperationSpec = {
  path: "{nextLink}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper: Mappers.CsmUsageQuotaCollection
    },
    default: {
      bodyMapper: Mappers.DefaultErrorResponse
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.name,
    Parameters.nextLink
  ],
  headerParameters: [Parameters.accept],
  serializer
};
