Class: RunApi::Core::ClientOptions

Inherits:
Struct
  • Object
show all
Defined in:
lib/runapi/core/types.rb

Overview

Configuration options for API clients.

Examples:

options = ClientOptions.new(
  api_key: "your-api-key",
  base_url: "https://runapi.ai",
  timeout: 60,
  max_retries: 3
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ ClientOptions

Returns a new instance of ClientOptions.



51
52
53
54
55
56
57
58
# File 'lib/runapi/core/types.rb', line 51

def initialize(**kwargs)
  super
  self.base_url ||= RunApi.base_url
  self.timeout ||= Constants::TIMEOUTS[:http_request]
  self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
  self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
  self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
end

Instance Attribute Details

#api_keyString

Returns API key for authentication. Required.

Returns:

  • (String)

    API key for authentication. Required.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#base_urlString

Returns Base URL for API requests. Defaults to RunApi.base_url.

Returns:

  • (String)

    Base URL for API requests. Defaults to RunApi.base_url.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#http_clientObject?

Returns Custom HTTP transport object. Must respond to ‘#request(method, path, body:, options:)` with the same interface as HttpClient. When set, the SDK skips building its own HttpClient and delegates all HTTP calls to this object.

Returns:

  • (Object, nil)

    Custom HTTP transport object. Must respond to ‘#request(method, path, body:, options:)` with the same interface as HttpClient. When set, the SDK skips building its own HttpClient and delegates all HTTP calls to this object.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#max_retriesInteger

Returns Maximum number of retry attempts. Defaults to 2.

Returns:

  • (Integer)

    Maximum number of retry attempts. Defaults to 2.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#retry_base_delayFloat

Returns Base delay between retries in seconds. Defaults to 0.5.

Returns:

  • (Float)

    Base delay between retries in seconds. Defaults to 0.5.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#retry_max_delayFloat

Returns Maximum delay between retries in seconds. Defaults to 5.0.

Returns:

  • (Float)

    Maximum delay between retries in seconds. Defaults to 5.0.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end

#timeoutInteger

Returns Request timeout in seconds. Defaults to 900 (15 minutes).

Returns:

  • (Integer)

    Request timeout in seconds. Defaults to 900 (15 minutes).



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/runapi/core/types.rb', line 41

ClientOptions = Struct.new(
  :api_key,
  :base_url,
  :timeout,
  :max_retries,
  :retry_base_delay,
  :retry_max_delay,
  :http_client,
  keyword_init: true
) do
  def initialize(**kwargs)
    super
    self.base_url ||= RunApi.base_url
    self.timeout ||= Constants::TIMEOUTS[:http_request]
    self.max_retries ||= Constants::RETRY_CONFIG[:max_retries]
    self.retry_base_delay ||= Constants::RETRY_CONFIG[:base_delay]
    self.retry_max_delay ||= Constants::RETRY_CONFIG[:max_delay]
  end
end