/*
 * 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/dscNodeOperationsMappers";
import * as Parameters from "../models/parameters";
import { AutomationClientContext } from "../automationClientContext";

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

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

  /**
   * Delete the dsc node identified by node id.
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param [options] The optional parameters
   * @returns Promise<Models.DscNodeDeleteMethodResponse>
   */
  deleteMethod(resourceGroupName: string, automationAccountName: string, nodeId: string, options?: msRest.RequestOptionsBase): Promise<Models.DscNodeDeleteMethodResponse>;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param callback The callback
   */
  deleteMethod(resourceGroupName: string, automationAccountName: string, nodeId: string, callback: msRest.ServiceCallback<Models.DscNode>): void;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param options The optional parameters
   * @param callback The callback
   */
  deleteMethod(resourceGroupName: string, automationAccountName: string, nodeId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.DscNode>): void;
  deleteMethod(resourceGroupName: string, automationAccountName: string, nodeId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DscNode>, callback?: msRest.ServiceCallback<Models.DscNode>): Promise<Models.DscNodeDeleteMethodResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        automationAccountName,
        nodeId,
        options
      },
      deleteMethodOperationSpec,
      callback) as Promise<Models.DscNodeDeleteMethodResponse>;
  }

  /**
   * Retrieve the dsc node identified by node id.
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param [options] The optional parameters
   * @returns Promise<Models.DscNodeGetResponse>
   */
  get(resourceGroupName: string, automationAccountName: string, nodeId: string, options?: msRest.RequestOptionsBase): Promise<Models.DscNodeGetResponse>;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param callback The callback
   */
  get(resourceGroupName: string, automationAccountName: string, nodeId: string, callback: msRest.ServiceCallback<Models.DscNode>): void;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId The node id.
   * @param options The optional parameters
   * @param callback The callback
   */
  get(resourceGroupName: string, automationAccountName: string, nodeId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.DscNode>): void;
  get(resourceGroupName: string, automationAccountName: string, nodeId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DscNode>, callback?: msRest.ServiceCallback<Models.DscNode>): Promise<Models.DscNodeGetResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        automationAccountName,
        nodeId,
        options
      },
      getOperationSpec,
      callback) as Promise<Models.DscNodeGetResponse>;
  }

  /**
   * Update the dsc node.
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId Parameters supplied to the update dsc node.
   * @param dscNodeUpdateParameters Parameters supplied to the update dsc node.
   * @param [options] The optional parameters
   * @returns Promise<Models.DscNodeUpdateResponse>
   */
  update(resourceGroupName: string, automationAccountName: string, nodeId: string, dscNodeUpdateParameters: Models.DscNodeUpdateParameters, options?: msRest.RequestOptionsBase): Promise<Models.DscNodeUpdateResponse>;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId Parameters supplied to the update dsc node.
   * @param dscNodeUpdateParameters Parameters supplied to the update dsc node.
   * @param callback The callback
   */
  update(resourceGroupName: string, automationAccountName: string, nodeId: string, dscNodeUpdateParameters: Models.DscNodeUpdateParameters, callback: msRest.ServiceCallback<Models.DscNode>): void;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param nodeId Parameters supplied to the update dsc node.
   * @param dscNodeUpdateParameters Parameters supplied to the update dsc node.
   * @param options The optional parameters
   * @param callback The callback
   */
  update(resourceGroupName: string, automationAccountName: string, nodeId: string, dscNodeUpdateParameters: Models.DscNodeUpdateParameters, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.DscNode>): void;
  update(resourceGroupName: string, automationAccountName: string, nodeId: string, dscNodeUpdateParameters: Models.DscNodeUpdateParameters, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DscNode>, callback?: msRest.ServiceCallback<Models.DscNode>): Promise<Models.DscNodeUpdateResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        automationAccountName,
        nodeId,
        dscNodeUpdateParameters,
        options
      },
      updateOperationSpec,
      callback) as Promise<Models.DscNodeUpdateResponse>;
  }

  /**
   * Retrieve a list of dsc nodes.
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param [options] The optional parameters
   * @returns Promise<Models.DscNodeListByAutomationAccountResponse>
   */
  listByAutomationAccount(resourceGroupName: string, automationAccountName: string, options?: Models.DscNodeListByAutomationAccountOptionalParams): Promise<Models.DscNodeListByAutomationAccountResponse>;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param callback The callback
   */
  listByAutomationAccount(resourceGroupName: string, automationAccountName: string, callback: msRest.ServiceCallback<Models.DscNodeListResult>): void;
  /**
   * @param resourceGroupName Name of an Azure Resource group.
   * @param automationAccountName The name of the automation account.
   * @param options The optional parameters
   * @param callback The callback
   */
  listByAutomationAccount(resourceGroupName: string, automationAccountName: string, options: Models.DscNodeListByAutomationAccountOptionalParams, callback: msRest.ServiceCallback<Models.DscNodeListResult>): void;
  listByAutomationAccount(resourceGroupName: string, automationAccountName: string, options?: Models.DscNodeListByAutomationAccountOptionalParams | msRest.ServiceCallback<Models.DscNodeListResult>, callback?: msRest.ServiceCallback<Models.DscNodeListResult>): Promise<Models.DscNodeListByAutomationAccountResponse> {
    return this.client.sendOperationRequest(
      {
        resourceGroupName,
        automationAccountName,
        options
      },
      listByAutomationAccountOperationSpec,
      callback) as Promise<Models.DscNodeListByAutomationAccountResponse>;
  }

  /**
   * Retrieve a list of dsc nodes.
   * @param nextPageLink The NextLink from the previous successful call to List operation.
   * @param [options] The optional parameters
   * @returns Promise<Models.DscNodeListByAutomationAccountNextResponse>
   */
  listByAutomationAccountNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise<Models.DscNodeListByAutomationAccountNextResponse>;
  /**
   * @param nextPageLink The NextLink from the previous successful call to List operation.
   * @param callback The callback
   */
  listByAutomationAccountNext(nextPageLink: string, callback: msRest.ServiceCallback<Models.DscNodeListResult>): void;
  /**
   * @param nextPageLink The NextLink from the previous successful call to List operation.
   * @param options The optional parameters
   * @param callback The callback
   */
  listByAutomationAccountNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.DscNodeListResult>): void;
  listByAutomationAccountNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DscNodeListResult>, callback?: msRest.ServiceCallback<Models.DscNodeListResult>): Promise<Models.DscNodeListByAutomationAccountNextResponse> {
    return this.client.sendOperationRequest(
      {
        nextPageLink,
        options
      },
      listByAutomationAccountNextOperationSpec,
      callback) as Promise<Models.DscNodeListByAutomationAccountNextResponse>;
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const deleteMethodOperationSpec: msRest.OperationSpec = {
  httpMethod: "DELETE",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.automationAccountName,
    Parameters.nodeId,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  responses: {
    200: {
      bodyMapper: Mappers.DscNode
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};

const getOperationSpec: msRest.OperationSpec = {
  httpMethod: "GET",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.automationAccountName,
    Parameters.nodeId,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  responses: {
    200: {
      bodyMapper: Mappers.DscNode
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};

const updateOperationSpec: msRest.OperationSpec = {
  httpMethod: "PATCH",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes/{nodeId}",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.automationAccountName,
    Parameters.nodeId,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "dscNodeUpdateParameters",
    mapper: {
      ...Mappers.DscNodeUpdateParameters,
      required: true
    }
  },
  responses: {
    200: {
      bodyMapper: Mappers.DscNode
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};

const listByAutomationAccountOperationSpec: msRest.OperationSpec = {
  httpMethod: "GET",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/nodes",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.automationAccountName,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.filter,
    Parameters.skip0,
    Parameters.top0,
    Parameters.inlinecount,
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  responses: {
    200: {
      bodyMapper: Mappers.DscNodeListResult
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};

const listByAutomationAccountNextOperationSpec: msRest.OperationSpec = {
  httpMethod: "GET",
  baseUrl: "https://management.azure.com",
  path: "{nextLink}",
  urlParameters: [
    Parameters.nextPageLink
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  responses: {
    200: {
      bodyMapper: Mappers.DscNodeListResult
    },
    default: {
      bodyMapper: Mappers.ErrorResponse
    }
  },
  serializer
};
