Class: OpenSandbox::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/open_sandbox/client.rb

Overview

Main entry point for the OpenSandbox SDK.

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, api_key: nil, timeout: nil, logger: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • base_url (String, nil) (defaults to: nil)

    override global config

  • api_key (String, nil) (defaults to: nil)

    override global config

  • timeout (Integer, nil) (defaults to: nil)

    override global config

  • logger (Logger, nil) (defaults to: nil)

    override global config



79
80
81
82
83
84
85
# File 'lib/open_sandbox/client.rb', line 79

def initialize(base_url: nil, api_key: nil, timeout: nil, logger: nil)
  cfg       = OpenSandbox.configuration
  @base_url = base_url || cfg.base_url
  @api_key  = api_key  || cfg.api_key
  @timeout  = timeout  || cfg.timeout
  @logger   = logger   || cfg.logger
end

Instance Method Details

#healthy?Boolean

Health check — returns true if the server responds successfully.

Returns:

  • (Boolean)


99
100
101
102
103
104
# File 'lib/open_sandbox/client.rb', line 99

def healthy?
  http.get("/health")
  true
rescue Error
  false
end

#poolsPools

Returns:



93
94
95
# File 'lib/open_sandbox/client.rb', line 93

def pools
  @pools ||= Pools.new(http)
end

#sandboxesSandboxes

Returns:



88
89
90
# File 'lib/open_sandbox/client.rb', line 88

def sandboxes
  @sandboxes ||= Sandboxes.new(http, logger: @logger)
end