=begin
#Daytona Toolbox API

#Daytona Toolbox API

The version of the OpenAPI document: v0.0.0-dev

Generated by: https://openapi-generator.tech
Generator version: 7.21.0

=end

require 'cgi'

module DaytonaToolboxApiClient
  class InterpreterApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create a new interpreter context
    # Creates a new isolated interpreter context with optional working directory and language
    # @param request [CreateContextRequest] Context configuration
    # @param [Hash] opts the optional parameters
    # @return [InterpreterContext]
    def create_interpreter_context(request, opts = {})
      data, _status_code, _headers = create_interpreter_context_with_http_info(request, opts)
      data
    end

    # Create a new interpreter context
    # Creates a new isolated interpreter context with optional working directory and language
    # @param request [CreateContextRequest] Context configuration
    # @param [Hash] opts the optional parameters
    # @return [Array<(InterpreterContext, Integer, Hash)>] InterpreterContext data, response status code and response headers
    def create_interpreter_context_with_http_info(request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: InterpreterApi.create_interpreter_context ...'
      end
      # verify the required parameter 'request' is set
      if @api_client.config.client_side_validation && request.nil?
        fail ArgumentError, "Missing the required parameter 'request' when calling InterpreterApi.create_interpreter_context"
      end
      # resource path
      local_var_path = '/process/interpreter/context'

      # 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

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

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

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

      # auth_names
      auth_names = opts[:debug_auth_names] || []

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

    # Delete an interpreter context
    # Deletes an interpreter context and shuts down its worker process
    # @param id [String] Context ID
    # @param [Hash] opts the optional parameters
    # @return [Hash<String, String>]
    def delete_interpreter_context(id, opts = {})
      data, _status_code, _headers = delete_interpreter_context_with_http_info(id, opts)
      data
    end

    # Delete an interpreter context
    # Deletes an interpreter context and shuts down its worker process
    # @param id [String] Context ID
    # @param [Hash] opts the optional parameters
    # @return [Array<(Hash<String, String>, Integer, Hash)>] Hash<String, String> data, response status code and response headers
    def delete_interpreter_context_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: InterpreterApi.delete_interpreter_context ...'
      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 InterpreterApi.delete_interpreter_context"
      end
      # resource path
      local_var_path = '/process/interpreter/context/{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']

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

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

      # return_type
      return_type = opts[:debug_return_type] || 'Hash<String, String>'

      # auth_names
      auth_names = opts[:debug_auth_names] || []

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

    # Execute code in an interpreter context
    # Executes code in a specified context (or default context if not specified) via WebSocket streaming
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def execute_interpreter_code(opts = {})
      execute_interpreter_code_with_http_info(opts)
      nil
    end

    # Execute code in an interpreter context
    # Executes code in a specified context (or default context if not specified) via WebSocket streaming
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def execute_interpreter_code_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: InterpreterApi.execute_interpreter_code ...'
      end
      # resource path
      local_var_path = '/process/interpreter/execute'

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

      # 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] || []

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

    # List all user-created interpreter contexts
    # Returns information about all user-created interpreter contexts (excludes default context)
    # @param [Hash] opts the optional parameters
    # @return [ListContextsResponse]
    def list_interpreter_contexts(opts = {})
      data, _status_code, _headers = list_interpreter_contexts_with_http_info(opts)
      data
    end

    # List all user-created interpreter contexts
    # Returns information about all user-created interpreter contexts (excludes default context)
    # @param [Hash] opts the optional parameters
    # @return [Array<(ListContextsResponse, Integer, Hash)>] ListContextsResponse data, response status code and response headers
    def list_interpreter_contexts_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: InterpreterApi.list_interpreter_contexts ...'
      end
      # resource path
      local_var_path = '/process/interpreter/context'

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

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

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

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

      # auth_names
      auth_names = opts[:debug_auth_names] || []

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