# encoding: utf-8
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.

module Azure::Web::Mgmt::V2016_06_01
  #
  # CustomApis
  #
  class CustomApis
    include MsRestAzure

    #
    # Creates and initializes a new instance of the CustomApis class.
    # @param client service class for accessing basic functionality.
    #
    def initialize(client)
      @client = client
    end

    # @return [LogicAppsManagementClient] reference to the LogicAppsManagementClient
    attr_reader :client

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs for a subscription id
    #
    # @param subscription_id [String] Subscription Id
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CustomApiDefinitionCollection] operation results.
    #
    def list(subscription_id, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      response = list_async(subscription_id, api_version, top:top, skiptoken:skiptoken, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs for a subscription id
    #
    # @param subscription_id [String] Subscription Id
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def list_with_http_info(subscription_id, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      list_async(subscription_id, api_version, top:top, skiptoken:skiptoken, custom_headers:custom_headers).value!
    end

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs for a subscription id
    #
    # @param subscription_id [String] Subscription Id
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def list_async(subscription_id, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Web/customApis'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id},
          query_params: {'api-version' => api_version,'$top' => top,'skiptoken' => skiptoken},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinitionCollection.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs in a subscription for a specific resource
    # group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CustomApiDefinitionCollection] operation results.
    #
    def list_by_resource_group(subscription_id, resource_group_name, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      response = list_by_resource_group_async(subscription_id, resource_group_name, api_version, top:top, skiptoken:skiptoken, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs in a subscription for a specific resource
    # group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def list_by_resource_group_with_http_info(subscription_id, resource_group_name, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      list_by_resource_group_async(subscription_id, resource_group_name, api_version, top:top, skiptoken:skiptoken, custom_headers:custom_headers).value!
    end

    #
    # List of custom APIs
    #
    # Gets a list of all custom APIs in a subscription for a specific resource
    # group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_version [String] API Version
    # @param top [Integer] The number of items to be included in the result
    # @param skiptoken [String] Skip Token
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def list_by_resource_group_async(subscription_id, resource_group_name, api_version, top:nil, skiptoken:nil, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name},
          query_params: {'api-version' => api_version,'$top' => top,'skiptoken' => skiptoken},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinitionCollection.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Get a custom API
    #
    # Gets a custom API by name for a specific subscription and resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CustomApiDefinition] operation results.
    #
    def get(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      response = get_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Get a custom API
    #
    # Gets a custom API by name for a specific subscription and resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_with_http_info(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      get_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:custom_headers).value!
    end

    #
    # Get a custom API
    #
    # Gets a custom API by name for a specific subscription and resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_name is nil' if api_name.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis/{apiName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'apiName' => api_name},
          query_params: {'api-version' => api_version},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:get, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinition.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Replaces an existing custom API
    #
    # Creates or updates an existing custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CustomApiDefinition] operation results.
    #
    def create_or_update(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      response = create_or_update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Replaces an existing custom API
    #
    # Creates or updates an existing custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def create_or_update_with_http_info(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      create_or_update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:custom_headers).value!
    end

    #
    # Replaces an existing custom API
    #
    # Creates or updates an existing custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def create_or_update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_name is nil' if api_name.nil?
      fail ArgumentError, 'custom_api is nil' if custom_api.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

      # Serialize Request
      request_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinition.mapper()
      request_content = @client.serialize(request_mapper,  custom_api)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis/{apiName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'apiName' => api_name},
          query_params: {'api-version' => api_version},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:put, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinition.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Update an existing custom API
    #
    # Updates an existing custom API's tags
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CustomApiDefinition] operation results.
    #
    def update(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      response = update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Update an existing custom API
    #
    # Updates an existing custom API's tags
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def update_with_http_info(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:custom_headers).value!
    end

    #
    # Update an existing custom API
    #
    # Updates an existing custom API's tags
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api [CustomApiDefinition] The custom API
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def update_async(subscription_id, resource_group_name, api_name, custom_api, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_name is nil' if api_name.nil?
      fail ArgumentError, 'custom_api is nil' if custom_api.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

      # Serialize Request
      request_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinition.mapper()
      request_content = @client.serialize(request_mapper,  custom_api)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis/{apiName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'apiName' => api_name},
          query_params: {'api-version' => api_version},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:patch, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiDefinition.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Delete a custom API
    #
    # Deletes a custom API from the resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def delete(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      response = delete_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:custom_headers).value!
      nil
    end

    #
    # Delete a custom API
    #
    # Deletes a custom API from the resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def delete_with_http_info(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      delete_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:custom_headers).value!
    end

    #
    # Delete a custom API
    #
    # Deletes a custom API from the resource group
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def delete_async(subscription_id, resource_group_name, api_name, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_name is nil' if api_name.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis/{apiName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'apiName' => api_name},
          query_params: {'api-version' => api_version},
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:delete, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

        result
      end

      promise.execute
    end

    #
    # Moves the custom API
    #
    # Moves a specific custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api_reference [CustomApiReference] The custom API reference
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def move(subscription_id, resource_group_name, api_name, custom_api_reference, api_version, custom_headers:nil)
      response = move_async(subscription_id, resource_group_name, api_name, custom_api_reference, api_version, custom_headers:custom_headers).value!
      nil
    end

    #
    # Moves the custom API
    #
    # Moves a specific custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api_reference [CustomApiReference] The custom API reference
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def move_with_http_info(subscription_id, resource_group_name, api_name, custom_api_reference, api_version, custom_headers:nil)
      move_async(subscription_id, resource_group_name, api_name, custom_api_reference, api_version, custom_headers:custom_headers).value!
    end

    #
    # Moves the custom API
    #
    # Moves a specific custom API
    #
    # @param subscription_id [String] Subscription Id
    # @param resource_group_name [String] The resource group
    # @param api_name [String] API name
    # @param custom_api_reference [CustomApiReference] The custom API reference
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def move_async(subscription_id, resource_group_name, api_name, custom_api_reference, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'api_name is nil' if api_name.nil?
      fail ArgumentError, 'custom_api_reference is nil' if custom_api_reference.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

      # Serialize Request
      request_mapper = Azure::Web::Mgmt::V2016_06_01::Models::CustomApiReference.mapper()
      request_content = @client.serialize(request_mapper,  custom_api_reference)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/customApis/{apiName}/move'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'apiName' => api_name},
          query_params: {'api-version' => api_version},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:post, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

        result
      end

      promise.execute
    end

    #
    # Lists WSDL interfaces
    #
    # This returns the list of interfaces in the WSDL
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [WsdlServiceCollection] operation results.
    #
    def list_wsdl_interfaces(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      response = list_wsdl_interfaces_async(subscription_id, location, wsdl_definition, api_version, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists WSDL interfaces
    #
    # This returns the list of interfaces in the WSDL
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def list_wsdl_interfaces_with_http_info(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      list_wsdl_interfaces_async(subscription_id, location, wsdl_definition, api_version, custom_headers:custom_headers).value!
    end

    #
    # Lists WSDL interfaces
    #
    # This returns the list of interfaces in the WSDL
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def list_wsdl_interfaces_async(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'wsdl_definition is nil' if wsdl_definition.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

      # Serialize Request
      request_mapper = Azure::Web::Mgmt::V2016_06_01::Models::WsdlDefinition.mapper()
      request_content = @client.serialize(request_mapper,  wsdl_definition)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/listWsdlInterfaces'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'location' => location},
          query_params: {'api-version' => api_version},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:post, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::Web::Mgmt::V2016_06_01::Models::WsdlServiceCollection.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Returns API definition from WSDL
    #
    # Parses the specified WSDL and extracts the API definition
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Object] operation results.
    #
    def extract_api_definition_from_wsdl(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      response = extract_api_definition_from_wsdl_async(subscription_id, location, wsdl_definition, api_version, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Returns API definition from WSDL
    #
    # Parses the specified WSDL and extracts the API definition
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def extract_api_definition_from_wsdl_with_http_info(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      extract_api_definition_from_wsdl_async(subscription_id, location, wsdl_definition, api_version, custom_headers:custom_headers).value!
    end

    #
    # Returns API definition from WSDL
    #
    # Parses the specified WSDL and extracts the API definition
    #
    # @param subscription_id [String] Subscription Id
    # @param location [String] The location
    # @param wsdl_definition [WsdlDefinition] WSDL definition
    # @param api_version [String] API Version
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def extract_api_definition_from_wsdl_async(subscription_id, location, wsdl_definition, api_version, custom_headers:nil)
      fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'wsdl_definition is nil' if wsdl_definition.nil?
      fail ArgumentError, 'api_version is nil' if api_version.nil?


      request_headers = {}
      request_headers['Content-Type'] = 'application/json; charset=utf-8'

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

      # Serialize Request
      request_mapper = Azure::Web::Mgmt::V2016_06_01::Models::WsdlDefinition.mapper()
      request_content = @client.serialize(request_mapper,  wsdl_definition)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/extractApiDefinitionFromWsdl'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => subscription_id,'location' => location},
          query_params: {'api-version' => api_version},
          body: request_content,
          headers: request_headers.merge(custom_headers || {}),
          base_url: request_url
      }
      promise = @client.make_request_async(:post, path_template, options)

      promise = promise.then do |result|
        http_response = result.response
        status_code = http_response.status
        response_content = http_response.body
        unless status_code == 200
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

        result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
        result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
        result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

        result
      end

      promise.execute
    end

  end
end
