=begin
#Daytona

#Daytona AI platform API Docs

The version of the OpenAPI document: 1.0
Contact: support@daytona.com
Generated by: https://openapi-generator.tech
Generator version: 7.21.0

=end

require 'cgi'

module DaytonaApiClient
  class VolumesApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create a new volume
    # @param create_volume [CreateVolume] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [VolumeDto]
    def create_volume(create_volume, opts = {})
      data, _status_code, _headers = create_volume_with_http_info(create_volume, opts)
      data
    end

    # Create a new volume
    # @param create_volume [CreateVolume] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(VolumeDto, Integer, Hash)>] VolumeDto data, response status code and response headers
    def create_volume_with_http_info(create_volume, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.create_volume ...'
      end
      # verify the required parameter 'create_volume' is set
      if @api_client.config.client_side_validation && create_volume.nil?
        fail ArgumentError, "Missing the required parameter 'create_volume' when calling VolumesApi.create_volume"
      end
      # resource path
      local_var_path = '/volumes'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end
      header_params[:'X-Daytona-Organization-ID'] = opts[:'x_daytona_organization_id'] if !opts[:'x_daytona_organization_id'].nil?

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

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

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

      # auth_names
      auth_names = opts[:debug_auth_names] || ['bearer', 'oauth2']

      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

    # Delete volume
    # @param volume_id [String] ID of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [nil]
    def delete_volume(volume_id, opts = {})
      delete_volume_with_http_info(volume_id, opts)
      nil
    end

    # Delete volume
    # @param volume_id [String] ID of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def delete_volume_with_http_info(volume_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.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.delete_volume"
      end
      # resource path
      local_var_path = '/volumes/{volumeId}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      header_params[:'X-Daytona-Organization-ID'] = opts[:'x_daytona_organization_id'] if !opts[:'x_daytona_organization_id'].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] || ['bearer', 'oauth2']

      new_options = opts.merge(
        :operation => :"VolumesApi.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#delete_volume\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get volume details
    # @param volume_id [String] ID of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [VolumeDto]
    def get_volume(volume_id, opts = {})
      data, _status_code, _headers = get_volume_with_http_info(volume_id, opts)
      data
    end

    # Get volume details
    # @param volume_id [String] ID of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(VolumeDto, Integer, Hash)>] VolumeDto 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 = '/volumes/{volumeId}'.sub('{' + 'volumeId' + '}', CGI.escape(volume_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      header_params[:'X-Daytona-Organization-ID'] = opts[:'x_daytona_organization_id'] if !opts[:'x_daytona_organization_id'].nil?

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

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

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

      # auth_names
      auth_names = opts[:debug_auth_names] || ['bearer', 'oauth2']

      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

    # Get volume details by name
    # @param name [String] Name of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [VolumeDto]
    def get_volume_by_name(name, opts = {})
      data, _status_code, _headers = get_volume_by_name_with_http_info(name, opts)
      data
    end

    # Get volume details by name
    # @param name [String] Name of the volume
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(VolumeDto, Integer, Hash)>] VolumeDto data, response status code and response headers
    def get_volume_by_name_with_http_info(name, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.get_volume_by_name ...'
      end
      # verify the required parameter 'name' is set
      if @api_client.config.client_side_validation && name.nil?
        fail ArgumentError, "Missing the required parameter 'name' when calling VolumesApi.get_volume_by_name"
      end
      # resource path
      local_var_path = '/volumes/by-name/{name}'.sub('{' + 'name' + '}', CGI.escape(name.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      header_params[:'X-Daytona-Organization-ID'] = opts[:'x_daytona_organization_id'] if !opts[:'x_daytona_organization_id'].nil?

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

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

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

      # auth_names
      auth_names = opts[:debug_auth_names] || ['bearer', 'oauth2']

      new_options = opts.merge(
        :operation => :"VolumesApi.get_volume_by_name",
        :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_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List all volumes
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @option opts [Boolean] :include_deleted Include deleted volumes in the response
    # @return [Array<VolumeDto>]
    def list_volumes(opts = {})
      data, _status_code, _headers = list_volumes_with_http_info(opts)
      data
    end

    # List all volumes
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @option opts [Boolean] :include_deleted Include deleted volumes in the response
    # @return [Array<(Array<VolumeDto>, Integer, Hash)>] Array<VolumeDto> data, response status code and response headers
    def list_volumes_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: VolumesApi.list_volumes ...'
      end
      # resource path
      local_var_path = '/volumes'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'includeDeleted'] = opts[:'include_deleted'] if !opts[:'include_deleted'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      header_params[:'X-Daytona-Organization-ID'] = opts[:'x_daytona_organization_id'] if !opts[:'x_daytona_organization_id'].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<VolumeDto>'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['bearer', 'oauth2']

      new_options = opts.merge(
        :operation => :"VolumesApi.list_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#list_volumes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
