# 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::PowerBiDedicated::Mgmt::V2017_10_01
  #
  # PowerBI Dedicated Web API provides a RESTful set of web services that
  # enables users to create, retrieve, update, and delete Power BI dedicated
  # capacities
  #
  class Capacities
    include MsRestAzure

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

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

    #
    # Gets details about the specified dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the dedicated capacity.
    # 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 [DedicatedCapacity] operation results.
    #
    def get_details(resource_group_name, dedicated_capacity_name, custom_headers:nil)
      response = get_details_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets details about the specified dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      get_details_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
    end

    #
    # Gets details about the specified dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the dedicated capacity.
    # 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, dedicated_capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_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.PowerBIDedicated/capacities/{dedicatedCapacityName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'dedicatedCapacityName' => dedicated_capacity_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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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 Dedicated capacity based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be a minimum of 3 characters, and a maximum of 63.
    # @param capacity_parameters [DedicatedCapacity] Contains the information used
    # to provision the Dedicated capacity.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [DedicatedCapacity] operation results.
    #
    def create(resource_group_name, dedicated_capacity_name, capacity_parameters, custom_headers:nil)
      response = create_async(resource_group_name, dedicated_capacity_name, capacity_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 PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be a minimum of 3 characters, and a maximum of 63.
    # @param capacity_parameters [DedicatedCapacity] Contains the information used
    # to provision the Dedicated capacity.
    # @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, dedicated_capacity_name, capacity_parameters, custom_headers:nil)
      # Send request
      promise = begin_create_async(resource_group_name, dedicated_capacity_name, capacity_parameters, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
          result_mapper = Azure::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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 Dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = delete_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      # Send request
      promise = begin_delete_async(resource_group_name, dedicated_capacity_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 Dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be at least 3 characters in length, and no more than 63.
    # @param capacity_update_parameters [DedicatedCapacityUpdateParameters] Request
    # object that contains the updated information for the capacity.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [DedicatedCapacity] operation results.
    #
    def update(resource_group_name, dedicated_capacity_name, capacity_update_parameters, custom_headers:nil)
      response = update_async(resource_group_name, dedicated_capacity_name, capacity_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 PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be at least 3 characters in length, and no more than 63.
    # @param capacity_update_parameters [DedicatedCapacityUpdateParameters] Request
    # object that contains the updated information for the capacity.
    # @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, dedicated_capacity_name, capacity_update_parameters, custom_headers:nil)
      # Send request
      promise = begin_update_async(resource_group_name, dedicated_capacity_name, capacity_update_parameters, custom_headers:custom_headers)

      promise = promise.then do |response|
        # Defining deserialization method.
        deserialize_method = lambda do |parsed_response|
          result_mapper = Azure::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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

    #
    # Suspends operation of the specified dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = suspend_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      # Send request
      promise = begin_suspend_async(resource_group_name, dedicated_capacity_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 Dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = resume_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      # Send request
      promise = begin_resume_async(resource_group_name, dedicated_capacity_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 Dedicated capacities for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity 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 [DedicatedCapacities] 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 Dedicated capacities for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity 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 Dedicated capacities for the given resource group.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity 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.PowerBIDedicated/capacities'

      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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacities.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 Dedicated capacities for the given subscription.
    #
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [DedicatedCapacities] operation results.
    #
    def list(custom_headers:nil)
      response = list_async(custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists all the Dedicated capacities 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 Dedicated capacities 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.PowerBIDedicated/capacities'

      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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacities.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 PowerBI Dedicated 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(custom_headers:nil)
      response = list_skus_async(custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists eligible SKUs for PowerBI Dedicated 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_with_http_info(custom_headers:nil)
      list_skus_async(custom_headers:custom_headers).value!
    end

    #
    # Lists eligible SKUs for PowerBI Dedicated 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_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.PowerBIDedicated/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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::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 a PowerBI Dedicated resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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_capacity(resource_group_name, dedicated_capacity_name, custom_headers:nil)
      response = list_skus_for_capacity_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Lists eligible SKUs for a PowerBI Dedicated resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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_capacity_with_http_info(resource_group_name, dedicated_capacity_name, custom_headers:nil)
      list_skus_for_capacity_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
    end

    #
    # Lists eligible SKUs for a PowerBI Dedicated resource.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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_capacity_async(resource_group_name, dedicated_capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_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.PowerBIDedicated/capacities/{dedicatedCapacityName}/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,'dedicatedCapacityName' => dedicated_capacity_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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::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

    #
    # Check the name availability in the target location.
    #
    # @param location [String] The region name which the operation will lookup
    # into.
    # @param capacity_parameters [CheckCapacityNameAvailabilityParameters] The name
    # of the capacity.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [CheckCapacityNameAvailabilityResult] operation results.
    #
    def check_name_availability(location, capacity_parameters, custom_headers:nil)
      response = check_name_availability_async(location, capacity_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 capacity_parameters [CheckCapacityNameAvailabilityParameters] The name
    # of the capacity.
    # @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, capacity_parameters, custom_headers:nil)
      check_name_availability_async(location, capacity_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 capacity_parameters [CheckCapacityNameAvailabilityParameters] The name
    # of the capacity.
    # @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, capacity_parameters, custom_headers:nil)
      fail ArgumentError, 'location is nil' if location.nil?
      fail ArgumentError, 'capacity_parameters is nil' if capacity_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::PowerBiDedicated::Mgmt::V2017_10_01::Models::CheckCapacityNameAvailabilityParameters.mapper()
      request_content = @client.serialize(request_mapper,  capacity_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PowerBIDedicated/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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::CheckCapacityNameAvailabilityResult.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 Dedicated capacity based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be a minimum of 3 characters, and a maximum of 63.
    # @param capacity_parameters [DedicatedCapacity] Contains the information used
    # to provision the Dedicated capacity.
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [DedicatedCapacity] operation results.
    #
    def begin_create(resource_group_name, dedicated_capacity_name, capacity_parameters, custom_headers:nil)
      response = begin_create_async(resource_group_name, dedicated_capacity_name, capacity_parameters, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

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

    #
    # Provisions the specified Dedicated capacity based on the configuration
    # specified in the request.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be a minimum of 3 characters, and a maximum of 63.
    # @param capacity_parameters [DedicatedCapacity] Contains the information used
    # to provision the Dedicated capacity.
    # @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, dedicated_capacity_name, capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, 'capacity_parameters is nil' if capacity_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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.mapper()
      request_content = @client.serialize(request_mapper,  capacity_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'dedicatedCapacityName' => dedicated_capacity_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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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 Dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = begin_delete_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

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

    #
    # Deletes the specified Dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_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.PowerBIDedicated/capacities/{dedicatedCapacityName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'dedicatedCapacityName' => dedicated_capacity_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.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

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

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

    #
    # Updates the current state of the specified Dedicated capacity.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # It must be at least 3 characters in length, and no more than 63.
    # @param capacity_update_parameters [DedicatedCapacityUpdateParameters] Request
    # object that contains the updated information for the capacity.
    # @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, dedicated_capacity_name, capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.match(Regexp.new('^^[a-z][a-z0-9]*$$')).nil?
      fail ArgumentError, 'capacity_update_parameters is nil' if capacity_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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacityUpdateParameters.mapper()
      request_content = @client.serialize(request_mapper,  capacity_update_parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PowerBIDedicated/capacities/{dedicatedCapacityName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          path_params: {'resourceGroupName' => resource_group_name,'dedicatedCapacityName' => dedicated_capacity_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?
        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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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::PowerBiDedicated::Mgmt::V2017_10_01::Models::DedicatedCapacity.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

    #
    # Suspends operation of the specified dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = begin_suspend_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Suspends operation of the specified dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      begin_suspend_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
    end

    #
    # Suspends operation of the specified dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_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.PowerBIDedicated/capacities/{dedicatedCapacityName}/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,'dedicatedCapacityName' => dedicated_capacity_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.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

    #
    # Resumes operation of the specified Dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_name, custom_headers:nil)
      response = begin_resume_async(resource_group_name, dedicated_capacity_name, custom_headers:custom_headers).value!
      nil
    end

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

    #
    # Resumes operation of the specified Dedicated capacity instance.
    #
    # @param resource_group_name [String] The name of the Azure Resource group of
    # which a given PowerBIDedicated capacity is part. This name must be at least 1
    # character in length, and no more than 90.
    # @param dedicated_capacity_name [String] The name of the Dedicated capacity.
    # 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, dedicated_capacity_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, 'dedicated_capacity_name is nil' if dedicated_capacity_name.nil?
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MaxLength': '63'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length > 63
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'MinLength': '3'" if !dedicated_capacity_name.nil? && dedicated_capacity_name.length < 3
      fail ArgumentError, "'dedicated_capacity_name' should satisfy the constraint - 'Pattern': '^[a-z][a-z0-9]*$'" if !dedicated_capacity_name.nil? && dedicated_capacity_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.PowerBIDedicated/capacities/{dedicatedCapacityName}/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,'dedicatedCapacityName' => dedicated_capacity_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.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
