# 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::AnalysisServices::Mgmt::V2017_07_14
  #
  # The Azure Analysis Services Web API provides a RESTful set of web services
  # that enables users to create, retrieve, update, and delete Analysis
  # Services servers
  #
  class Servers
    include MsRestAzure

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

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

    #
    # Gets details about the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServer] operation results.
    #
    def get_details(resource_group_name, server_name, custom_headers:nil)
      response = get_details_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets details about the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @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_details_with_http_info(resource_group_name, server_name, custom_headers:nil)
      get_details_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Gets details about the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @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_details_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.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

    #
    # Provisions the specified Analysis Services server based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param server_parameters [AnalysisServicesServer] Contains the information
    # used to provision the Analysis Services server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServer] operation results.
    #
    def create(resource_group_name, server_name, server_parameters, custom_headers:nil)
      response = create_async(resource_group_name, server_name, server_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param server_parameters [AnalysisServicesServer] Contains the information
    # used to provision the Analysis Services server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Concurrent::Promise] promise which provides async access to http
    # response.
    #
    def create_async(resource_group_name, server_name, server_parameters, custom_headers:nil)
      # Send request
      promise = begin_create_async(resource_group_name, server_name, server_parameters, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
          result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.mapper()
          parsed_response = @client.deserialize(result_mapper, parsed_response)
        end

        # Waiting for response.
        @client.get_long_running_operation_result(response, deserialize_method)
      end

      promise
    end

    #
    # Deletes the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def delete(resource_group_name, server_name, custom_headers:nil)
      response = delete_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Concurrent::Promise] promise which provides async access to http
    # response.
    #
    def delete_async(resource_group_name, server_name, custom_headers:nil)
      # Send request
      promise = begin_delete_async(resource_group_name, server_name, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
        end

        # Waiting for response.
        @client.get_long_running_operation_result(response, deserialize_method)
      end

      promise
    end

    #
    # Updates the current state of the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param server_update_parameters [AnalysisServicesServerUpdateParameters]
    # Request object that contains the updated information for the server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServer] operation results.
    #
    def update(resource_group_name, server_name, server_update_parameters, custom_headers:nil)
      response = update_async(resource_group_name, server_name, server_update_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param server_update_parameters [AnalysisServicesServerUpdateParameters]
    # Request object that contains the updated information for the server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Concurrent::Promise] promise which provides async access to http
    # response.
    #
    def update_async(resource_group_name, server_name, server_update_parameters, custom_headers:nil)
      # Send request
      promise = begin_update_async(resource_group_name, server_name, server_update_parameters, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
          result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.mapper()
          parsed_response = @client.deserialize(result_mapper, parsed_response)
        end

        # Waiting for response.
        @client.get_long_running_operation_result(response, deserialize_method)
      end

      promise
    end

    #
    # Supends operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def suspend(resource_group_name, server_name, custom_headers:nil)
      response = suspend_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Concurrent::Promise] promise which provides async access to http
    # response.
    #
    def suspend_async(resource_group_name, server_name, custom_headers:nil)
      # Send request
      promise = begin_suspend_async(resource_group_name, server_name, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
        end

        # Waiting for response.
        @client.get_long_running_operation_result(response, deserialize_method)
      end

      promise
    end

    #
    # Resumes operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def resume(resource_group_name, server_name, custom_headers:nil)
      response = resume_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Concurrent::Promise] promise which provides async access to http
    # response.
    #
    def resume_async(resource_group_name, server_name, custom_headers:nil)
      # Send request
      promise = begin_resume_async(resource_group_name, server_name, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
        end

        # Waiting for response.
        @client.get_long_running_operation_result(response, deserialize_method)
      end

      promise
    end

    #
    # Gets all the Analysis Services servers for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServers] operation results.
    #
    def list_by_resource_group(resource_group_name, custom_headers:nil)
      response = list_by_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets all the Analysis Services servers for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @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(resource_group_name, custom_headers:nil)
      list_by_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
    end

    #
    # Gets all the Analysis Services servers for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @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(resource_group_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServers.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

    #
    # Lists all the Analysis Services servers for the given subscription.
    #
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServers] operation results.
    #
    def list(custom_headers:nil)
      response = list_async(custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists all the Analysis Services servers for the given subscription.
    #
    # @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(custom_headers:nil)
      list_async(custom_headers:custom_headers).value!
    end

    #
    # Lists all the Analysis Services servers for the given subscription.
    #
    # @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(custom_headers:nil)
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServers.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

    #
    # Lists eligible SKUs for Analysis Services resource provider.
    #
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [SkuEnumerationForNewResourceResult] operation results.
    #
    def list_skus_for_new(custom_headers:nil)
      response = list_skus_for_new_async(custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists eligible SKUs for Analysis Services resource provider.
    #
    # @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_skus_for_new_with_http_info(custom_headers:nil)
      list_skus_for_new_async(custom_headers:custom_headers).value!
    end

    #
    # Lists eligible SKUs for Analysis Services resource provider.
    #
    # @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_skus_for_new_async(custom_headers:nil)
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/skus'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::SkuEnumerationForNewResourceResult.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

    #
    # Lists eligible SKUs for an Analysis Services resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [SkuEnumerationForExistingResourceResult] operation results.
    #
    def list_skus_for_existing(resource_group_name, server_name, custom_headers:nil)
      response = list_skus_for_existing_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists eligible SKUs for an Analysis Services resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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_skus_for_existing_with_http_info(resource_group_name, server_name, custom_headers:nil)
      list_skus_for_existing_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Lists eligible SKUs for an Analysis Services resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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_skus_for_existing_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}/skus'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::SkuEnumerationForExistingResourceResult.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

    #
    # Return the gateway status of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [GatewayListStatusLive] operation results.
    #
    def list_gateway_status(resource_group_name, server_name, custom_headers:nil)
      response = list_gateway_status_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Return the gateway status of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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_gateway_status_with_http_info(resource_group_name, server_name, custom_headers:nil)
      list_gateway_status_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Return the gateway status of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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_gateway_status_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}/listGatewayStatus'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.api_version},
          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 MsRest::HttpOperationError.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::GatewayListStatusLive.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

    #
    # Dissociates a Unified Gateway associated with the server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def dissociate_gateway(resource_group_name, server_name, custom_headers:nil)
      response = dissociate_gateway_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Dissociates a Unified Gateway associated with the server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 dissociate_gateway_with_http_info(resource_group_name, server_name, custom_headers:nil)
      dissociate_gateway_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Dissociates a Unified Gateway associated with the server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 dissociate_gateway_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}/dissociateGateway'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.api_version},
          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
      end

      promise.execute
    end

    #
    # Check the name availability in the target location.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param server_parameters [CheckServerNameAvailabilityParameters] Contains the
    # information used to provision the Analysis Services server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CheckServerNameAvailabilityResult] operation results.
    #
    def check_name_availability(location, server_parameters, custom_headers:nil)
      response = check_name_availability_async(location, server_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Check the name availability in the target location.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param server_parameters [CheckServerNameAvailabilityParameters] Contains the
    # information used to provision the Analysis Services server.
    # @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 check_name_availability_with_http_info(location, server_parameters, custom_headers:nil)
      check_name_availability_async(location, server_parameters, custom_headers:custom_headers).value!
    end

    #
    # Check the name availability in the target location.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param server_parameters [CheckServerNameAvailabilityParameters] Contains the
    # information used to provision the Analysis Services server.
    # @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 check_name_availability_async(location, server_parameters, custom_headers:nil)
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'server_parameters is nil' if server_parameters.nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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::AnalysisServices::Mgmt::V2017_07_14::Models::CheckServerNameAvailabilityParameters.mapper()
      request_content = @client.serialize(request_mapper,  server_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.AnalysisServices/locations/{location}/checkNameAvailability'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'location' => location,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::CheckServerNameAvailabilityResult.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 the result of the specified operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def list_operation_results(location, operation_id, custom_headers:nil)
      response = list_operation_results_async(location, operation_id, custom_headers:custom_headers).value!
      nil
    end

    #
    # List the result of the specified operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @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_operation_results_with_http_info(location, operation_id, custom_headers:nil)
      list_operation_results_async(location, operation_id, custom_headers:custom_headers).value!
    end

    #
    # List the result of the specified operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @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_operation_results_async(location, operation_id, custom_headers:nil)
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'operation_id is nil' if operation_id.nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/locations/{location}/operationresults/{operationId}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'location' => location,'operationId' => operation_id,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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 || status_code == 202
          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
      end

      promise.execute
    end

    #
    # List the status of operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [OperationStatus] operation results.
    #
    def list_operation_statuses(location, operation_id, custom_headers:nil)
      response = list_operation_statuses_async(location, operation_id, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # List the status of operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @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_operation_statuses_with_http_info(location, operation_id, custom_headers:nil)
      list_operation_statuses_async(location, operation_id, custom_headers:custom_headers).value!
    end

    #
    # List the status of operation.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param operation_id [String] The target operation Id.
    # @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_operation_statuses_async(location, operation_id, custom_headers:nil)
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'operation_id is nil' if operation_id.nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/locations/{location}/operationstatuses/{operationId}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'location' => location,'operationId' => operation_id,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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 || status_code == 202
          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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::OperationStatus.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
        # Deserialize Response
        if status_code == 202
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::OperationStatus.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

    #
    # Provisions the specified Analysis Services server based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param server_parameters [AnalysisServicesServer] Contains the information
    # used to provision the Analysis Services server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServer] operation results.
    #
    def begin_create(resource_group_name, server_name, server_parameters, custom_headers:nil)
      response = begin_create_async(resource_group_name, server_name, server_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Provisions the specified Analysis Services server based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param server_parameters [AnalysisServicesServer] Contains the information
    # used to provision the Analysis Services server.
    # @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 begin_create_with_http_info(resource_group_name, server_name, server_parameters, custom_headers:nil)
      begin_create_async(resource_group_name, server_name, server_parameters, custom_headers:custom_headers).value!
    end

    #
    # Provisions the specified Analysis Services server based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be a minimum of 3 characters, and a maximum of 63.
    # @param server_parameters [AnalysisServicesServer] Contains the information
    # used to provision the Analysis Services server.
    # @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 begin_create_async(resource_group_name, server_name, server_parameters, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, 'server_parameters is nil' if server_parameters.nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.mapper()
      request_content = @client.serialize(request_mapper,  server_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AnalysisServices/servers/{serverName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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 || status_code == 201
          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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.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
        # Deserialize Response
        if status_code == 201
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.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

    #
    # Deletes the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_delete(resource_group_name, server_name, custom_headers:nil)
      response = begin_delete_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Deletes the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_delete_with_http_info(resource_group_name, server_name, custom_headers:nil)
      begin_delete_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Deletes the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_delete_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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 || status_code == 202
          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
      end

      promise.execute
    end

    #
    # Updates the current state of the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param server_update_parameters [AnalysisServicesServerUpdateParameters]
    # Request object that contains the updated information for the server.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [AnalysisServicesServer] operation results.
    #
    def begin_update(resource_group_name, server_name, server_update_parameters, custom_headers:nil)
      response = begin_update_async(resource_group_name, server_name, server_update_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Updates the current state of the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param server_update_parameters [AnalysisServicesServerUpdateParameters]
    # Request object that contains the updated information for the server.
    # @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 begin_update_with_http_info(resource_group_name, server_name, server_update_parameters, custom_headers:nil)
      begin_update_async(resource_group_name, server_name, server_update_parameters, custom_headers:custom_headers).value!
    end

    #
    # Updates the current state of the specified Analysis Services server.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param server_update_parameters [AnalysisServicesServerUpdateParameters]
    # Request object that contains the updated information for the server.
    # @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 begin_update_async(resource_group_name, server_name, server_update_parameters, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, 'server_update_parameters is nil' if server_update_parameters.nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServerUpdateParameters.mapper()
      request_content = @client.serialize(request_mapper,  server_update_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AnalysisServices/servers/{serverName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.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 || status_code == 202
          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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.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
        # Deserialize Response
        if status_code == 202
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::AnalysisServices::Mgmt::V2017_07_14::Models::AnalysisServicesServer.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

    #
    # Supends operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_suspend(resource_group_name, server_name, custom_headers:nil)
      response = begin_suspend_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Supends operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_suspend_with_http_info(resource_group_name, server_name, custom_headers:nil)
      begin_suspend_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Supends operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_suspend_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}/suspend'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.api_version},
          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 || status_code == 202
          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
      end

      promise.execute
    end

    #
    # Resumes operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_resume(resource_group_name, server_name, custom_headers:nil)
      response = begin_resume_async(resource_group_name, server_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Resumes operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_resume_with_http_info(resource_group_name, server_name, custom_headers:nil)
      begin_resume_async(resource_group_name, server_name, custom_headers:custom_headers).value!
    end

    #
    # Resumes operation of the specified Analysis Services server instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given Analysis Services server is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param server_name [String] The name of the Analysis Services server. It must
    # be at least 3 characters in length, and no more than 63.
    # @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 begin_resume_async(resource_group_name, server_name, custom_headers:nil)
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
      fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
      fail ArgumentError, 'server_name is nil' if server_name.nil?
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MaxLength': '63'" if !server_name.nil? && server_name.length > 63
      fail ArgumentError, "'server_name' should satisfy the constraint - 'MinLength': '3'" if !server_name.nil? && server_name.length < 3
      fail ArgumentError, "'server_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !server_name.nil? && server_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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.AnalysisServices/servers/{serverName}/resume'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'serverName' => server_name,'subscriptionId' => @client.subscription_id},
          query_params: {'api-version' => @client.api_version},
          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 || status_code == 202
          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
      end

      promise.execute
    end

  end
end
