# 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::StorSimple8000Series::Mgmt::V2017_06_01
  #
  # Devices
  #
  class Devices
    include MsRestAzure

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

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

    #
    # Complete minimal setup before using the device.
    #
    # @param parameters [ConfigureDeviceRequest] The minimal properties to
    # configure a device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def configure(parameters, resource_group_name, manager_name, custom_headers:nil)
      response = configure_async(parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param parameters [ConfigureDeviceRequest] The minimal properties to
    # configure a device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 configure_async(parameters, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_configure_async(parameters, resource_group_name, manager_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

    #
    # Returns the list of devices for the specified manager.
    #
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [DeviceList] operation results.
    #
    def list_by_manager(resource_group_name, manager_name, expand:nil, custom_headers:nil)
      response = list_by_manager_async(resource_group_name, manager_name, expand:expand, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Returns the list of devices for the specified manager.
    #
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @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_manager_with_http_info(resource_group_name, manager_name, expand:nil, custom_headers:nil)
      list_by_manager_async(resource_group_name, manager_name, expand:expand, custom_headers:custom_headers).value!
    end

    #
    # Returns the list of devices for the specified manager.
    #
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @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_manager_async(resource_group_name, manager_name, expand:nil, custom_headers:nil)
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          query_params: {'$expand' => expand},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::DeviceList.mapper()
            result.body = @client.deserialize(result_mapper, parsed_response)
          rescue Exception => e
            fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
          end
        end

        result
      end

      promise.execute
    end

    #
    # Returns the properties of the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Device] operation results.
    #
    def get(device_name, resource_group_name, manager_name, expand:nil, custom_headers:nil)
      response = get_async(device_name, resource_group_name, manager_name, expand:expand, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Returns the properties of the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def get_with_http_info(device_name, resource_group_name, manager_name, expand:nil, custom_headers:nil)
      get_async(device_name, resource_group_name, manager_name, expand:expand, custom_headers:custom_headers).value!
    end

    #
    # Returns the properties of the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param expand [String] Specify $expand=details to populate additional fields
    # related to the device or $expand=rolloverdetails to populate additional
    # fields related to the service data encryption key rollover on device
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def get_async(device_name, resource_group_name, manager_name, expand:nil, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          query_params: {'$expand' => expand},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::Device.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 device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def delete(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = delete_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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(device_name, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_delete_async(device_name, resource_group_name, manager_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

    #
    # Patches the device.
    #
    # @param device_name [String] The device name
    # @param parameters [DevicePatch] Patch representation of the device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Device] operation results.
    #
    def update(device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      response = update_async(device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Patches the device.
    #
    # @param device_name [String] The device name
    # @param parameters [DevicePatch] Patch representation of the device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
    #
    def update_with_http_info(device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      update_async(device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Patches the device.
    #
    # @param device_name [String] The device name
    # @param parameters [DevicePatch] Patch representation of the device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param [Hash{String => String}] A hash of custom headers that will be added
    # to the HTTP request.
    #
    # @return [Concurrent::Promise] Promise object which holds the HTTP response.
    #
    def update_async(device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, 'parameters is nil' if parameters.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      # Serialize Request
      request_mapper = Azure::StorSimple8000Series::Mgmt::V2017_06_01::Models::DevicePatch.mapper()
      request_content = @client.serialize(request_mapper,  parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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
          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::StorSimple8000Series::Mgmt::V2017_06_01::Models::Device.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

    #
    # Authorizes the specified device for service data encryption key rollover.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def authorize_for_service_encryption_key_rollover(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = authorize_for_service_encryption_key_rollover_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Authorizes the specified device for service data encryption key rollover.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 authorize_for_service_encryption_key_rollover_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      authorize_for_service_encryption_key_rollover_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Authorizes the specified device for service data encryption key rollover.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 authorize_for_service_encryption_key_rollover_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Deactivates the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def deactivate(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = deactivate_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 deactivate_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_deactivate_async(device_name, resource_group_name, manager_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

    #
    # Downloads and installs the updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def install_updates(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = install_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 install_updates_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_install_updates_async(device_name, resource_group_name, manager_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

    #
    # Returns all failover sets for a given device and their eligibility for
    # participating in a failover. A failover set refers to a set of volume
    # containers that need to be failed-over as a single unit to maintain data
    # integrity.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [FailoverSetsList] operation results.
    #
    def list_failover_sets(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = list_failover_sets_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Returns all failover sets for a given device and their eligibility for
    # participating in a failover. A failover set refers to a set of volume
    # containers that need to be failed-over as a single unit to maintain data
    # integrity.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_sets_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      list_failover_sets_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Returns all failover sets for a given device and their eligibility for
    # participating in a failover. A failover set refers to a set of volume
    # containers that need to be failed-over as a single unit to maintain data
    # integrity.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_sets_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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?
        # Deserialize Response
        if status_code == 200
          begin
            parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
            result_mapper = Azure::StorSimple8000Series::Mgmt::V2017_06_01::Models::FailoverSetsList.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

    #
    # Gets the metrics for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param filter [String] OData Filter options
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MetricList] operation results.
    #
    def list_metrics(device_name, resource_group_name, manager_name, filter, custom_headers:nil)
      response = list_metrics_async(device_name, resource_group_name, manager_name, filter, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets the metrics for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param filter [String] OData Filter options
    # @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_metrics_with_http_info(device_name, resource_group_name, manager_name, filter, custom_headers:nil)
      list_metrics_async(device_name, resource_group_name, manager_name, filter, custom_headers:custom_headers).value!
    end

    #
    # Gets the metrics for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param filter [String] OData Filter options
    # @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_metrics_async(device_name, resource_group_name, manager_name, filter, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
      fail ArgumentError, 'filter is nil' if filter.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.StorSimple/managers/{managerName}/devices/{deviceName}/metrics'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          query_params: {'$filter' => filter},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::MetricList.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

    #
    # Gets the metric definitions for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [MetricDefinitionList] operation results.
    #
    def list_metric_definition(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = list_metric_definition_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Gets the metric definitions for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_metric_definition_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      list_metric_definition_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Gets the metric definitions for the specified device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_metric_definition_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::MetricDefinitionList.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

    #
    # Scans for updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def scan_for_updates(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = scan_for_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 scan_for_updates_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_scan_for_updates_async(device_name, resource_group_name, manager_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

    #
    # Returns the update summary of the specified device name.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [Updates] operation results.
    #
    def get_update_summary(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = get_update_summary_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Returns the update summary of the specified device name.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_update_summary_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      get_update_summary_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Returns the update summary of the specified device name.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_update_summary_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

      # Set Headers
      request_headers['x-ms-client-request-id'] = SecureRandom.uuid
      request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/updateSummary/default'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::Updates.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

    #
    # Failovers a set of volume containers from a specified source device to a
    # target device.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [FailoverRequest] FailoverRequest containing the source
    # device and the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    def failover(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      response = failover_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [FailoverRequest] FailoverRequest containing the source
    # device and the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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 failover_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      # Send request
      promise = begin_failover_async(source_device_name, parameters, resource_group_name, manager_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

    #
    # Given a list of volume containers to be failed over from a source device,
    # this method returns the eligibility result, as a failover target, for all
    # devices under that resource.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [ListFailoverTargetsRequest] ListFailoverTargetsRequest
    # containing the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    # @return [FailoverTargetsList] operation results.
    #
    def list_failover_targets(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      response = list_failover_targets_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      response.body unless response.nil?
    end

    #
    # Given a list of volume containers to be failed over from a source device,
    # this method returns the eligibility result, as a failover target, for all
    # devices under that resource.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [ListFailoverTargetsRequest] ListFailoverTargetsRequest
    # containing the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_targets_with_http_info(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      list_failover_targets_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Given a list of volume containers to be failed over from a source device,
    # this method returns the eligibility result, as a failover target, for all
    # devices under that resource.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [ListFailoverTargetsRequest] ListFailoverTargetsRequest
    # containing the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_targets_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'source_device_name is nil' if source_device_name.nil?
      fail ArgumentError, 'parameters is nil' if parameters.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      # Serialize Request
      request_mapper = Azure::StorSimple8000Series::Mgmt::V2017_06_01::Models::ListFailoverTargetsRequest.mapper()
      request_content = @client.serialize(request_mapper,  parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/listFailoverTargets'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'sourceDeviceName' => source_device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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::StorSimple8000Series::Mgmt::V2017_06_01::Models::FailoverTargetsList.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

    #
    # Complete minimal setup before using the device.
    #
    # @param parameters [ConfigureDeviceRequest] The minimal properties to
    # configure a device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_configure(parameters, resource_group_name, manager_name, custom_headers:nil)
      response = begin_configure_async(parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Complete minimal setup before using the device.
    #
    # @param parameters [ConfigureDeviceRequest] The minimal properties to
    # configure a device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_configure_with_http_info(parameters, resource_group_name, manager_name, custom_headers:nil)
      begin_configure_async(parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Complete minimal setup before using the device.
    #
    # @param parameters [ConfigureDeviceRequest] The minimal properties to
    # configure a device.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_configure_async(parameters, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'parameters is nil' if parameters.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      # Serialize Request
      request_mapper = Azure::StorSimple8000Series::Mgmt::V2017_06_01::Models::ConfigureDeviceRequest.mapper()
      request_content = @client.serialize(request_mapper,  parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/configureDevice'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Deletes the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_delete(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = begin_delete_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Deletes the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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(device_name, resource_group_name, manager_name, custom_headers:nil)
      begin_delete_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Deletes the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Deactivates the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_deactivate(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = begin_deactivate_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Deactivates the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_deactivate_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      begin_deactivate_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Deactivates the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_deactivate_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Downloads and installs the updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_install_updates(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = begin_install_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Downloads and installs the updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_install_updates_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      begin_install_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Downloads and installs the updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_install_updates_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Scans for updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_scan_for_updates(device_name, resource_group_name, manager_name, custom_headers:nil)
      response = begin_scan_for_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Scans for updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_scan_for_updates_with_http_info(device_name, resource_group_name, manager_name, custom_headers:nil)
      begin_scan_for_updates_async(device_name, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Scans for updates on the device.
    #
    # @param device_name [String] The device name
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_scan_for_updates_async(device_name, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'device_name is nil' if device_name.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'deviceName' => device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

    #
    # Failovers a set of volume containers from a specified source device to a
    # target device.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [FailoverRequest] FailoverRequest containing the source
    # device and the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @param custom_headers [Hash{String => String}] A hash of custom headers that
    # will be added to the HTTP request.
    #
    #
    def begin_failover(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      response = begin_failover_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
      nil
    end

    #
    # Failovers a set of volume containers from a specified source device to a
    # target device.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [FailoverRequest] FailoverRequest containing the source
    # device and the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_with_http_info(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      begin_failover_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:custom_headers).value!
    end

    #
    # Failovers a set of volume containers from a specified source device to a
    # target device.
    #
    # @param source_device_name [String] The source device name on which failover
    # is performed.
    # @param parameters [FailoverRequest] FailoverRequest containing the source
    # device and the list of volume containers to be failed over.
    # @param resource_group_name [String] The resource group name
    # @param manager_name [String] The manager name
    # @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_failover_async(source_device_name, parameters, resource_group_name, manager_name, custom_headers:nil)
      fail ArgumentError, 'source_device_name is nil' if source_device_name.nil?
      fail ArgumentError, 'parameters is nil' if parameters.nil?
      fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
      fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
      fail ArgumentError, 'manager_name is nil' if manager_name.nil?
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MaxLength': '50'" if !manager_name.nil? && manager_name.length > 50
      fail ArgumentError, "'manager_name' should satisfy the constraint - 'MinLength': '2'" if !manager_name.nil? && manager_name.length < 2
      fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

      # Serialize Request
      request_mapper = Azure::StorSimple8000Series::Mgmt::V2017_06_01::Models::FailoverRequest.mapper()
      request_content = @client.serialize(request_mapper,  parameters)
      request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

      path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/failover'

      request_url = @base_url || @client.base_url

      options = {
          middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
          skip_encoding_path_params: {'sourceDeviceName' => source_device_name,'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'managerName' => manager_name},
          skip_encoding_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 == 202 || status_code == 204
          error_model = JSON.load(response_content)
          fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
        end

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

        result
      end

      promise.execute
    end

  end
end
