/*
 * 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 { ExportConfigurations } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { AppCenterClient } from "../appCenterClient";
import {
  ExportConfigurationsEnableOptionalParams,
  ExportConfigurationsDisableOptionalParams,
  ExportConfigurationsGetOptionalParams,
  ExportConfigurationsGetResponse,
  PathsEhcfgaV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdPatchRequestbodyContentApplicationJsonSchema,
  ExportConfigurationsPartialUpdateOptionalParams,
  ExportConfigurationsPartialUpdateResponse,
  ExportConfigurationsDeleteOptionalParams,
  ExportConfigurationsListOptionalParams,
  ExportConfigurationsListResponse,
  Paths1QllskkV01AppsOwnerNameAppNameExportConfigurationsPostRequestbodyContentApplicationJsonSchema,
  ExportConfigurationsCreateOptionalParams,
  ExportConfigurationsCreateResponse
} from "../models";

/** Class containing ExportConfigurations operations. */
export class ExportConfigurationsImpl implements ExportConfigurations {
  private readonly client: AppCenterClient;

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

  /**
   * Enable export configuration.
   * @param exportConfigurationId The id of the export configuration.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  enable(
    exportConfigurationId: string,
    ownerName: string,
    appName: string,
    options?: ExportConfigurationsEnableOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { exportConfigurationId, ownerName, appName, options },
      enableOperationSpec
    );
  }

  /**
   * Disable export configuration.
   * @param exportConfigurationId The id of the export configuration.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  disable(
    exportConfigurationId: string,
    ownerName: string,
    appName: string,
    options?: ExportConfigurationsDisableOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { exportConfigurationId, ownerName, appName, options },
      disableOperationSpec
    );
  }

  /**
   * Get export configuration.
   * @param exportConfigurationId The id of the export configuration.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  get(
    exportConfigurationId: string,
    ownerName: string,
    appName: string,
    options?: ExportConfigurationsGetOptionalParams
  ): Promise<ExportConfigurationsGetResponse> {
    return this.client.sendOperationRequest(
      { exportConfigurationId, ownerName, appName, options },
      getOperationSpec
    );
  }

  /**
   * Partially update export configuration.
   * @param exportConfigurationId The id of the export configuration.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param properties Export configurations.
   * @param options The options parameters.
   */
  partialUpdate(
    exportConfigurationId: string,
    ownerName: string,
    appName: string,
    properties: PathsEhcfgaV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdPatchRequestbodyContentApplicationJsonSchema,
    options?: ExportConfigurationsPartialUpdateOptionalParams
  ): Promise<ExportConfigurationsPartialUpdateResponse> {
    return this.client.sendOperationRequest(
      { exportConfigurationId, ownerName, appName, properties, options },
      partialUpdateOperationSpec
    );
  }

  /**
   * Delete export configuration.
   * @param exportConfigurationId The id of the export configuration.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  delete(
    exportConfigurationId: string,
    ownerName: string,
    appName: string,
    options?: ExportConfigurationsDeleteOptionalParams
  ): Promise<void> {
    return this.client.sendOperationRequest(
      { exportConfigurationId, ownerName, appName, options },
      deleteOperationSpec
    );
  }

  /**
   * List export configurations.
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param options The options parameters.
   */
  list(
    ownerName: string,
    appName: string,
    options?: ExportConfigurationsListOptionalParams
  ): Promise<ExportConfigurationsListResponse> {
    return this.client.sendOperationRequest(
      { ownerName, appName, options },
      listOperationSpec
    );
  }

  /**
   * Create new export configuration
   * @param ownerName The name of the owner
   * @param appName The name of the application
   * @param properties Export configurations.
   * @param options The options parameters.
   */
  create(
    ownerName: string,
    appName: string,
    properties: Paths1QllskkV01AppsOwnerNameAppNameExportConfigurationsPostRequestbodyContentApplicationJsonSchema,
    options?: ExportConfigurationsCreateOptionalParams
  ): Promise<ExportConfigurationsCreateResponse> {
    return this.client.sendOperationRequest(
      { ownerName, appName, properties, options },
      createOperationSpec
    );
  }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);

const enableOperationSpec: coreClient.OperationSpec = {
  path:
    "/v0.1/apps/{owner_name}/{app_name}/export_configurations/{export_configuration_id}/enable",
  httpMethod: "POST",
  responses: {
    200: {},
    default: {
      bodyMapper:
        Mappers.Paths42AbxiV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdEnablePostResponsesDefaultContentApplicationJsonSchema
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.ownerName,
    Parameters.appName,
    Parameters.exportConfigurationId
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const disableOperationSpec: coreClient.OperationSpec = {
  path:
    "/v0.1/apps/{owner_name}/{app_name}/export_configurations/{export_configuration_id}/disable",
  httpMethod: "POST",
  responses: {
    200: {},
    default: {
      bodyMapper:
        Mappers.PathsNstgqpV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdDisablePostResponsesDefaultContentApplicationJsonSchema
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.ownerName,
    Parameters.appName,
    Parameters.exportConfigurationId
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const getOperationSpec: coreClient.OperationSpec = {
  path:
    "/v0.1/apps/{owner_name}/{app_name}/export_configurations/{export_configuration_id}",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper:
        Mappers.Paths1OysruzV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdGetResponses200ContentApplicationJsonSchema
    },
    default: {
      bodyMapper:
        Mappers.Paths1J8YtkwV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdGetResponsesDefaultContentApplicationJsonSchema
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.ownerName,
    Parameters.appName,
    Parameters.exportConfigurationId
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const partialUpdateOperationSpec: coreClient.OperationSpec = {
  path:
    "/v0.1/apps/{owner_name}/{app_name}/export_configurations/{export_configuration_id}",
  httpMethod: "PATCH",
  responses: {
    200: {
      bodyMapper:
        Mappers.Paths420JlyV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdPatchResponses200ContentApplicationJsonSchema
    },
    default: {
      bodyMapper:
        Mappers.Paths1Gnrj58V01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdPatchResponsesDefaultContentApplicationJsonSchema
    }
  },
  requestBody: Parameters.properties4,
  urlParameters: [
    Parameters.$host,
    Parameters.ownerName,
    Parameters.appName,
    Parameters.exportConfigurationId
  ],
  headerParameters: [Parameters.contentType, Parameters.accept],
  mediaType: "json",
  serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
  path:
    "/v0.1/apps/{owner_name}/{app_name}/export_configurations/{export_configuration_id}",
  httpMethod: "DELETE",
  responses: {
    200: {},
    default: {
      bodyMapper:
        Mappers.PathsVg92GuV01AppsOwnerNameAppNameExportConfigurationsExportConfigurationIdDeleteResponsesDefaultContentApplicationJsonSchema
    }
  },
  urlParameters: [
    Parameters.$host,
    Parameters.ownerName,
    Parameters.appName,
    Parameters.exportConfigurationId
  ],
  headerParameters: [Parameters.accept],
  serializer
};
const listOperationSpec: coreClient.OperationSpec = {
  path: "/v0.1/apps/{owner_name}/{app_name}/export_configurations",
  httpMethod: "GET",
  responses: {
    200: {
      bodyMapper:
        Mappers.Paths1FgwvpvV01AppsOwnerNameAppNameExportConfigurationsGetResponses200ContentApplicationJsonSchema
    },
    default: {
      bodyMapper:
        Mappers.Paths1QpjuboV01AppsOwnerNameAppNameExportConfigurationsGetResponsesDefaultContentApplicationJsonSchema
    }
  },
  urlParameters: [Parameters.$host, Parameters.ownerName, Parameters.appName],
  headerParameters: [Parameters.accept],
  serializer
};
const createOperationSpec: coreClient.OperationSpec = {
  path: "/v0.1/apps/{owner_name}/{app_name}/export_configurations",
  httpMethod: "POST",
  responses: {
    202: {
      bodyMapper:
        Mappers.Paths95VcrfV01AppsOwnerNameAppNameExportConfigurationsPostResponses202ContentApplicationJsonSchema
    },
    default: {
      bodyMapper:
        Mappers.PathsElutorV01AppsOwnerNameAppNameExportConfigurationsPostResponsesDefaultContentApplicationJsonSchema
    }
  },
  requestBody: Parameters.properties5,
  urlParameters: [Parameters.$host, Parameters.ownerName, Parameters.appName],
  headerParameters: [Parameters.contentType, Parameters.accept],
  mediaType: "json",
  serializer
};
