Module: Oz
- Defined in:
- lib/oz.rb,
lib/oz/model.rb,
lib/oz/client.rb,
lib/oz/errors.rb,
lib/oz/version.rb,
lib/oz/cursor_page.rb,
lib/oz/configuration.rb,
lib/oz/resources/base.rb,
lib/oz/resources/runs.rb,
lib/oz/resources/agent.rb,
lib/oz/resources/sessions.rb,
lib/oz/resources/schedules.rb,
lib/oz/resources/identities.rb,
lib/oz/resources/conversations.rb
Overview
Ruby SDK for the Oz API — Warp’s cloud agent platform.
require "oz"
client = Oz::Client.new(api_key: ENV["WARP_API_KEY"])
run = client.agent.run(prompt: "Fix the bug in auth.rb")
puts run.run_id
Or configure once and use the shared client:
Oz.configure { |c| c.api_key = ENV["WARP_API_KEY"] }
Oz.client.agent.runs.list(limit: 20).each { |r| puts r.title }
Defined Under Namespace
Modules: Resources Classes: APIConnectionError, APIError, APIStatusError, APITimeoutError, AuthenticationError, BadRequestError, Client, Configuration, ConfigurationError, ConflictError, CursorPage, Error, InternalServerError, Model, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError
Constant Summary collapse
- OzAPI =
Alias matching the Python/TypeScript SDKs’
OzAPIclass name. Client- STATUS_ERROR_CLASSES =
Maps an HTTP status code to the most specific error class.
{ 400 => BadRequestError, 401 => AuthenticationError, 403 => PermissionDeniedError, 404 => NotFoundError, 409 => ConflictError, 422 => UnprocessableEntityError, 429 => RateLimitError }.freeze
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.client ⇒ Oz::Client
A lazily-built shared client using the global configuration / environment.
-
.configuration ⇒ Oz::Configuration
The global configuration singleton.
-
.configure {|config| ... } ⇒ Oz::Configuration
Yields the global Configuration for mutation.
-
.error_class_for(status) ⇒ Object
Returns the error class that should be raised for
status. -
.new(**kwargs) ⇒ Oz::Client
Builds a new Client.
-
.reset_client! ⇒ nil
Replaces the shared client (mainly for tests).
-
.reset_configuration! ⇒ Oz::Configuration
Resets global configuration (mainly for tests).
Class Method Details
.client ⇒ Oz::Client
A lazily-built shared client using the global configuration / environment.
62 63 64 |
# File 'lib/oz.rb', line 62 def client @client ||= Client.new end |
.configuration ⇒ Oz::Configuration
Returns the global configuration singleton.
43 44 45 |
# File 'lib/oz.rb', line 43 def configuration @configuration ||= Configuration.new end |
.configure {|config| ... } ⇒ Oz::Configuration
Yields the global Configuration for mutation.
37 38 39 40 |
# File 'lib/oz.rb', line 37 def configure yield(configuration) if block_given? configuration end |
.error_class_for(status) ⇒ Object
Returns the error class that should be raised for status.
69 70 71 |
# File 'lib/oz/errors.rb', line 69 def self.error_class_for(status) STATUS_ERROR_CLASSES[status] || (status >= 500 ? InternalServerError : APIStatusError) end |
.new(**kwargs) ⇒ Oz::Client
Builds a new Client. Accepts the same keyword arguments as Oz::Client#initialize.
56 57 58 |
# File 'lib/oz.rb', line 56 def new(**kwargs) Client.new(**kwargs) end |
.reset_client! ⇒ nil
Replaces the shared client (mainly for tests).
68 69 70 |
# File 'lib/oz.rb', line 68 def reset_client! @client = nil end |
.reset_configuration! ⇒ Oz::Configuration
Resets global configuration (mainly for tests).
49 50 51 |
# File 'lib/oz.rb', line 49 def reset_configuration! @configuration = Configuration.new end |