Cadenya Ruby SDK

The official Ruby client for the Cadenya API. Generated by redwood. Built on Faraday with typed model classes and Enumerable pages.

Install

gem install cadenya

Getting started

require "cadenya"

# Reads CADENYA_API_KEY (and CADENYA_WORKSPACE_ID) from the environment when
# arguments are omitted. Explicit blank values raise ArgumentError and
# never fall back to the environment.
client = Cadenya::Client.new

result = client.accounts.retrieve

Requests are snake_case throughout

Nested request hashes take snake_case keys (symbols or strings) and are translated to wire names at the HTTP boundary; your own data inside JSON/map fields is never rewritten.

client.api_keys.create(
  metadata: {"name" => "sample"},
  spec: {}
)

Errors

Non-2xx responses raise Cadenya::APIError (google.rpc Status: status_code, code, details). Protocol surprises raise APIResponseError; connection failures raise APIConnectionError.

Retries

Automatic retries apply only to idempotent methods (GET/HEAD/PUT/DELETE) and default to 0; counts normalize to a bounded 0–10 integer. Streaming requests never auto-retry, and a caller-supplied Faraday connection's timeout policy is authoritative.

Pagination

client.api_keys.list.each do |item|
  # iterating a page auto-fetches every page (also: auto_paging_each)
end

Streaming (SSE)

stream = client.objectives.stream_events(objective_id)
stream.each { |event| ... }

# Stop deterministically — from the consuming block or another thread.
# Iteration ends cleanly at the next received chunk (keep-alives included)
# and the HTTP response/socket is released. Streams are single-use:
# re-enumerating raises IOError.
stream.close

# Resume after a disconnect: the checkpoint persists per the SSE spec.
resumed = client.objectives.stream_events(objective_id, last_event_id: stream.last_event_id)
resumed.each { |event| ... }

close from another thread interrupts even a read blocked on a silent socket: the stream's cancel handle tears the transport down immediately.

Webhooks (no API key required)

Cadenya::Webhooks.verify(ENV.fetch("CADENYA_WEBHOOK_SECRET"), payload, headers)
# or, with typed decoding via a client: client.unwrap_webhook(payload, headers)

Verification follows Standard Webhooks (24–64 byte decoded secrets, integer timestamps, bounded tolerance).

Reference

The full method reference ships in the gem as api.md (also in the repository).