# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

=begin
#Nomad

#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: 1.1.4
Contact: support@hashicorp.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.2.0

=end

require 'cgi'

module NomadClient
  class VolumesApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # @param volume_id [String] Volume unique identifier.
    # @param action [String] The action to perform on the Volume (create, detach, delete).
    # @param csi_volume_create_request [CSIVolumeCreateRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [nil]
    def create_volume(volume_id, action, csi_volume_create_request, opts = {})
      create_volume_with_http_info(volume_id, action, csi_volume_create_request, opts)
      nil
    end

    # @param volume_id [String] Volume unique identifier.
    # @param action [String] The action to perform on the Volume (create, detach, delete).
    # @param csi_volume_create_request [CSIVolumeCreateRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def create_volume_with_http_info(volume_id, action, csi_volume_create_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.create_volume ...'
      end
      # verify the required parameter 'volume_id' is set
      if @api_client.config.client_side_validation && volume_id.nil?
        fail ArgumentError, "Missing the required parameter 'volume_id' when calling VolumesApi.create_volume"
      end
      # verify the required parameter 'action' is set
      if @api_client.config.client_side_validation && action.nil?
        fail ArgumentError, "Missing the required parameter 'action' when calling VolumesApi.create_volume"
      end
      # verify the required parameter 'csi_volume_create_request' is set
      if @api_client.config.client_side_validation && csi_volume_create_request.nil?
        fail ArgumentError, "Missing the required parameter 'csi_volume_create_request' when calling VolumesApi.create_volume"
      end
      # resource path
      local_var_path = '/volume/csi/{volumeId}/{action}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s)).sub('{' + 'action' + '}', CGI.escape(action.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(csi_volume_create_request)

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.create_volume",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#create_volume\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @option opts [String] :snapshot_id The ID of the snapshot to target.
    # @return [nil]
    def delete_snapshot(opts = {})
      delete_snapshot_with_http_info(opts)
      nil
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @option opts [String] :snapshot_id The ID of the snapshot to target.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def delete_snapshot_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.delete_snapshot ...'
      end
      # resource path
      local_var_path = '/volumes/snapshot'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?
      query_params[:'plugin_id'] = opts[:'plugin_id'] if !opts[:'plugin_id'].nil?
      query_params[:'snapshot_id'] = opts[:'snapshot_id'] if !opts[:'snapshot_id'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.delete_snapshot",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#delete_snapshot\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param volume_id [String] Volume unique identifier.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :force Used to force the de-registration of a volume.
    # @return [nil]
    def delete_volume_registration(volume_id, opts = {})
      delete_volume_registration_with_http_info(volume_id, opts)
      nil
    end

    # @param volume_id [String] Volume unique identifier.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :force Used to force the de-registration of a volume.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def delete_volume_registration_with_http_info(volume_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.delete_volume_registration ...'
      end
      # verify the required parameter 'volume_id' is set
      if @api_client.config.client_side_validation && volume_id.nil?
        fail ArgumentError, "Missing the required parameter 'volume_id' when calling VolumesApi.delete_volume_registration"
      end
      # resource path
      local_var_path = '/volume/csi/{volumeId}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?
      query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.delete_volume_registration",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#delete_volume_registration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param volume_id [String] Volume unique identifier.
    # @param action [String] The action to perform on the Volume (create, detach, delete).
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :node Specifies node to target volume operation for.
    # @return [nil]
    def detach_or_delete_volume(volume_id, action, opts = {})
      detach_or_delete_volume_with_http_info(volume_id, action, opts)
      nil
    end

    # @param volume_id [String] Volume unique identifier.
    # @param action [String] The action to perform on the Volume (create, detach, delete).
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @option opts [String] :node Specifies node to target volume operation for.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def detach_or_delete_volume_with_http_info(volume_id, action, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.detach_or_delete_volume ...'
      end
      # verify the required parameter 'volume_id' is set
      if @api_client.config.client_side_validation && volume_id.nil?
        fail ArgumentError, "Missing the required parameter 'volume_id' when calling VolumesApi.detach_or_delete_volume"
      end
      # verify the required parameter 'action' is set
      if @api_client.config.client_side_validation && action.nil?
        fail ArgumentError, "Missing the required parameter 'action' when calling VolumesApi.detach_or_delete_volume"
      end
      # resource path
      local_var_path = '/volume/csi/{volumeId}/{action}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s)).sub('{' + 'action' + '}', CGI.escape(action.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?
      query_params[:'node'] = opts[:'node'] if !opts[:'node'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.detach_or_delete_volume",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#detach_or_delete_volume\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @return [CSIVolumeListExternalResponse]
    def get_external_volumes(opts = {})
      data, _status_code, _headers = get_external_volumes_with_http_info(opts)
      data
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @return [Array<(CSIVolumeListExternalResponse, Integer, Hash)>] CSIVolumeListExternalResponse data, response status code and response headers
    def get_external_volumes_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.get_external_volumes ...'
      end
      # resource path
      local_var_path = '/volumes/external'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'wait'] = opts[:'wait'] if !opts[:'wait'].nil?
      query_params[:'stale'] = opts[:'stale'] if !opts[:'stale'].nil?
      query_params[:'prefix'] = opts[:'prefix'] if !opts[:'prefix'].nil?
      query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
      query_params[:'next_token'] = opts[:'next_token'] if !opts[:'next_token'].nil?
      query_params[:'plugin_id'] = opts[:'plugin_id'] if !opts[:'plugin_id'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params[:'index'] = opts[:'index'] if !opts[:'index'].nil?
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'CSIVolumeListExternalResponse'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.get_external_volumes",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#get_external_volumes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @return [CSISnapshotListResponse]
    def get_snapshots(opts = {})
      data, _status_code, _headers = get_snapshots_with_http_info(opts)
      data
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @return [Array<(CSISnapshotListResponse, Integer, Hash)>] CSISnapshotListResponse data, response status code and response headers
    def get_snapshots_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.get_snapshots ...'
      end
      # resource path
      local_var_path = '/volumes/snapshot'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'wait'] = opts[:'wait'] if !opts[:'wait'].nil?
      query_params[:'stale'] = opts[:'stale'] if !opts[:'stale'].nil?
      query_params[:'prefix'] = opts[:'prefix'] if !opts[:'prefix'].nil?
      query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
      query_params[:'next_token'] = opts[:'next_token'] if !opts[:'next_token'].nil?
      query_params[:'plugin_id'] = opts[:'plugin_id'] if !opts[:'plugin_id'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params[:'index'] = opts[:'index'] if !opts[:'index'].nil?
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'CSISnapshotListResponse'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.get_snapshots",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#get_snapshots\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param volume_id [String] Volume unique identifier.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @return [CSIVolume]
    def get_volume(volume_id, opts = {})
      data, _status_code, _headers = get_volume_with_http_info(volume_id, opts)
      data
    end

    # @param volume_id [String] Volume unique identifier.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @return [Array<(CSIVolume, Integer, Hash)>] CSIVolume data, response status code and response headers
    def get_volume_with_http_info(volume_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.get_volume ...'
      end
      # verify the required parameter 'volume_id' is set
      if @api_client.config.client_side_validation && volume_id.nil?
        fail ArgumentError, "Missing the required parameter 'volume_id' when calling VolumesApi.get_volume"
      end
      # resource path
      local_var_path = '/volume/csi/{volumeId}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'wait'] = opts[:'wait'] if !opts[:'wait'].nil?
      query_params[:'stale'] = opts[:'stale'] if !opts[:'stale'].nil?
      query_params[:'prefix'] = opts[:'prefix'] if !opts[:'prefix'].nil?
      query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
      query_params[:'next_token'] = opts[:'next_token'] if !opts[:'next_token'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params[:'index'] = opts[:'index'] if !opts[:'index'].nil?
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'CSIVolume'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.get_volume",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#get_volume\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :node_id Filters volume lists by node ID.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @option opts [String] :type Filters volume lists to a specific type.
    # @return [Array<CSIVolumeListStub>]
    def get_volumes(opts = {})
      data, _status_code, _headers = get_volumes_with_http_info(opts)
      data
    end

    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [Integer] :index If set, wait until query exceeds given index. Must be provided with WaitParam.
    # @option opts [String] :wait Provided with IndexParam to wait for change.
    # @option opts [String] :stale If present, results will include stale reads.
    # @option opts [String] :prefix Constrains results to jobs that start with the defined prefix
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [Integer] :per_page Maximum number of results to return.
    # @option opts [String] :next_token Indicates where to start paging for queries that support pagination.
    # @option opts [String] :node_id Filters volume lists by node ID.
    # @option opts [String] :plugin_id Filters volume lists by plugin ID.
    # @option opts [String] :type Filters volume lists to a specific type.
    # @return [Array<(Array<CSIVolumeListStub>, Integer, Hash)>] Array<CSIVolumeListStub> data, response status code and response headers
    def get_volumes_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.get_volumes ...'
      end
      # resource path
      local_var_path = '/volumes'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'wait'] = opts[:'wait'] if !opts[:'wait'].nil?
      query_params[:'stale'] = opts[:'stale'] if !opts[:'stale'].nil?
      query_params[:'prefix'] = opts[:'prefix'] if !opts[:'prefix'].nil?
      query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
      query_params[:'next_token'] = opts[:'next_token'] if !opts[:'next_token'].nil?
      query_params[:'node_id'] = opts[:'node_id'] if !opts[:'node_id'].nil?
      query_params[:'plugin_id'] = opts[:'plugin_id'] if !opts[:'plugin_id'].nil?
      query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      header_params[:'index'] = opts[:'index'] if !opts[:'index'].nil?
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Array<CSIVolumeListStub>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.get_volumes",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#get_volumes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param csi_snapshot_create_request [CSISnapshotCreateRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [CSISnapshotCreateResponse]
    def post_snapshot(csi_snapshot_create_request, opts = {})
      data, _status_code, _headers = post_snapshot_with_http_info(csi_snapshot_create_request, opts)
      data
    end

    # @param csi_snapshot_create_request [CSISnapshotCreateRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [Array<(CSISnapshotCreateResponse, Integer, Hash)>] CSISnapshotCreateResponse data, response status code and response headers
    def post_snapshot_with_http_info(csi_snapshot_create_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.post_snapshot ...'
      end
      # verify the required parameter 'csi_snapshot_create_request' is set
      if @api_client.config.client_side_validation && csi_snapshot_create_request.nil?
        fail ArgumentError, "Missing the required parameter 'csi_snapshot_create_request' when calling VolumesApi.post_snapshot"
      end
      # resource path
      local_var_path = '/volumes/snapshot'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(csi_snapshot_create_request)

      # return_type
      return_type = opts[:debug_return_type] || 'CSISnapshotCreateResponse'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.post_snapshot",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#post_snapshot\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param csi_volume_register_request [CSIVolumeRegisterRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [nil]
    def post_volume(csi_volume_register_request, opts = {})
      post_volume_with_http_info(csi_volume_register_request, opts)
      nil
    end

    # @param csi_volume_register_request [CSIVolumeRegisterRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def post_volume_with_http_info(csi_volume_register_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.post_volume ...'
      end
      # verify the required parameter 'csi_volume_register_request' is set
      if @api_client.config.client_side_validation && csi_volume_register_request.nil?
        fail ArgumentError, "Missing the required parameter 'csi_volume_register_request' when calling VolumesApi.post_volume"
      end
      # resource path
      local_var_path = '/volumes'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(csi_volume_register_request)

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.post_volume",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#post_volume\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # @param volume_id [String] Volume unique identifier.
    # @param csi_volume_register_request [CSIVolumeRegisterRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [nil]
    def post_volume_registration(volume_id, csi_volume_register_request, opts = {})
      post_volume_registration_with_http_info(volume_id, csi_volume_register_request, opts)
      nil
    end

    # @param volume_id [String] Volume unique identifier.
    # @param csi_volume_register_request [CSIVolumeRegisterRequest] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :region Filters results based on the specified region.
    # @option opts [String] :namespace Filters results based on the specified namespace.
    # @option opts [String] :x_nomad_token A Nomad ACL token.
    # @option opts [String] :idempotency_token Can be used to ensure operations are only run once.
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def post_volume_registration_with_http_info(volume_id, csi_volume_register_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.post_volume_registration ...'
      end
      # verify the required parameter 'volume_id' is set
      if @api_client.config.client_side_validation && volume_id.nil?
        fail ArgumentError, "Missing the required parameter 'volume_id' when calling VolumesApi.post_volume_registration"
      end
      # verify the required parameter 'csi_volume_register_request' is set
      if @api_client.config.client_side_validation && csi_volume_register_request.nil?
        fail ArgumentError, "Missing the required parameter 'csi_volume_register_request' when calling VolumesApi.post_volume_registration"
      end
      # resource path
      local_var_path = '/volume/csi/{volumeId}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'region'] = opts[:'region'] if !opts[:'region'].nil?
      query_params[:'namespace'] = opts[:'namespace'] if !opts[:'namespace'].nil?
      query_params[:'idempotency_token'] = opts[:'idempotency_token'] if !opts[:'idempotency_token'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
      header_params[:'X-Nomad-Token'] = opts[:'x_nomad_token'] if !opts[:'x_nomad_token'].nil?

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(csi_volume_register_request)

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['X-Nomad-Token']

      new_options = opts.merge(
        :operation => :"VolumesApi.post_volume_registration",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: VolumesApi#post_volume_registration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
