/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

import * as msRest from "@azure/ms-rest-js";
import * as Models from "../models";
import * as Mappers from "../models/fieldsMappers";
import * as Parameters from "../models/parameters";
import { AutomationClientContext } from "../automationClientContext";

/** Class representing a Fields. */
export class Fields {
  private readonly client: AutomationClientContext;

  /**
   * Create a Fields.
   * @param {AutomationClientContext} client Reference to the service client.
   */
  constructor(client: AutomationClientContext) {
    this.client = client;
  }

  /**
   * Retrieve a list of fields of a given type identified by module name.
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param moduleName The name of module.
   * @param typeName The name of type.
   * @param [options] The optional parameters
   * @returns Promise<Models.FieldsListByTypeResponse>
   */
  listByType(resourceGroupName: string, automationAccountName: string, moduleName: string, typeName: string, options?: msRest.RequestOptionsBase): Promise<Models.FieldsListByTypeResponse>;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param moduleName The name of module.
   * @param typeName The name of type.
   * @param callback The callback
   */
  listByType(resourceGroupName: string, automationAccountName: string, moduleName: string, typeName: string, callback: msRest.ServiceCallback<Models.TypeFieldListResult>): void;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param moduleName The name of module.
   * @param typeName The name of type.
   * @param options The optional parameters
   * @param callback The callback
   */
  listByType(resourceGroupName: string, automationAccountName: string, moduleName: string, typeName: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.TypeFieldListResult>): void;
  listByType(resourceGroupName: string, automationAccountName: string, moduleName: string, typeName: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.TypeFieldListResult>, callback?: msRest.ServiceCallback<Models.TypeFieldListResult>): Promise<Models.FieldsListByTypeResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        automationAccountName,
        moduleName,
        typeName,
        options
      },
      listByTypeOperationSpec,
      callback) as Promise<Models.FieldsListByTypeResponse>;
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const listByTypeOperationSpec: msRest.OperationSpec = {
  httpMethod: "GET",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/modules/{moduleName}/types/{typeName}/fields",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.automationAccountName,
    Parameters.moduleName,
    Parameters.typeName,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion0
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  responses: {
    200: {
      bodyMapper: Mappers.TypeFieldListResult
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};
