=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 DockerRegistryApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create registry
    # @param create_docker_registry [CreateDockerRegistry] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [DockerRegistry]
    def create_registry(create_docker_registry, opts = {})
      data, _status_code, _headers = create_registry_with_http_info(create_docker_registry, opts)
      data
    end

    # Create registry
    # @param create_docker_registry [CreateDockerRegistry] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(DockerRegistry, Integer, Hash)>] DockerRegistry data, response status code and response headers
    def create_registry_with_http_info(create_docker_registry, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.create_registry ...'
      end
      # verify the required parameter 'create_docker_registry' is set
      if @api_client.config.client_side_validation && create_docker_registry.nil?
        fail ArgumentError, "Missing the required parameter 'create_docker_registry' when calling DockerRegistryApi.create_registry"
      end
      # resource path
      local_var_path = '/docker-registry'

      # 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_docker_registry)

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

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

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

    # Delete registry
    # @param id [String] ID of the docker registry
    # @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_registry(id, opts = {})
      delete_registry_with_http_info(id, opts)
      nil
    end

    # Delete registry
    # @param id [String] ID of the docker registry
    # @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_registry_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.delete_registry ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling DockerRegistryApi.delete_registry"
      end
      # resource path
      local_var_path = '/docker-registry/{id}'.sub('{' + 'id' + '}', CGI.escape(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 => :"DockerRegistryApi.delete_registry",
        :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: DockerRegistryApi#delete_registry\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get registry
    # @param id [String] ID of the docker registry
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [DockerRegistry]
    def get_registry(id, opts = {})
      data, _status_code, _headers = get_registry_with_http_info(id, opts)
      data
    end

    # Get registry
    # @param id [String] ID of the docker registry
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(DockerRegistry, Integer, Hash)>] DockerRegistry data, response status code and response headers
    def get_registry_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.get_registry ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling DockerRegistryApi.get_registry"
      end
      # resource path
      local_var_path = '/docker-registry/{id}'.sub('{' + 'id' + '}', CGI.escape(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] || 'DockerRegistry'

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

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

    # Get temporary registry access for pushing snapshots
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @option opts [String] :region_id ID of the region where the snapshot will be available (defaults to organization default region)
    # @return [RegistryPushAccessDto]
    def get_transient_push_access(opts = {})
      data, _status_code, _headers = get_transient_push_access_with_http_info(opts)
      data
    end

    # Get temporary registry access for pushing snapshots
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @option opts [String] :region_id ID of the region where the snapshot will be available (defaults to organization default region)
    # @return [Array<(RegistryPushAccessDto, Integer, Hash)>] RegistryPushAccessDto data, response status code and response headers
    def get_transient_push_access_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.get_transient_push_access ...'
      end
      # resource path
      local_var_path = '/docker-registry/registry-push-access'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'regionId'] = opts[:'region_id'] if !opts[:'region_id'].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] || 'RegistryPushAccessDto'

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

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

    # List registries
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<DockerRegistry>]
    def list_registries(opts = {})
      data, _status_code, _headers = list_registries_with_http_info(opts)
      data
    end

    # List registries
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(Array<DockerRegistry>, Integer, Hash)>] Array<DockerRegistry> data, response status code and response headers
    def list_registries_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.list_registries ...'
      end
      # resource path
      local_var_path = '/docker-registry'

      # 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] || 'Array<DockerRegistry>'

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

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

    # Update registry
    # @param id [String] ID of the docker registry
    # @param update_docker_registry [UpdateDockerRegistry] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [DockerRegistry]
    def update_registry(id, update_docker_registry, opts = {})
      data, _status_code, _headers = update_registry_with_http_info(id, update_docker_registry, opts)
      data
    end

    # Update registry
    # @param id [String] ID of the docker registry
    # @param update_docker_registry [UpdateDockerRegistry] 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :x_daytona_organization_id Use with JWT to specify the organization ID
    # @return [Array<(DockerRegistry, Integer, Hash)>] DockerRegistry data, response status code and response headers
    def update_registry_with_http_info(id, update_docker_registry, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DockerRegistryApi.update_registry ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling DockerRegistryApi.update_registry"
      end
      # verify the required parameter 'update_docker_registry' is set
      if @api_client.config.client_side_validation && update_docker_registry.nil?
        fail ArgumentError, "Missing the required parameter 'update_docker_registry' when calling DockerRegistryApi.update_registry"
      end
      # resource path
      local_var_path = '/docker-registry/{id}'.sub('{' + 'id' + '}', CGI.escape(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']
      # 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(update_docker_registry)

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

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

      new_options = opts.merge(
        :operation => :"DockerRegistryApi.update_registry",
        :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(:PATCH, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: DockerRegistryApi#update_registry\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
