Class: Cadenya::Client
- Inherits:
-
Internal::Transport::BaseClient
- Object
- Internal::Transport::BaseClient
- Cadenya::Client
- Defined in:
- lib/cadenya/client.rb
Constant Summary collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
-
#account ⇒ Cadenya::Resources::Account
readonly
Manage the authenticated account.
-
#agents ⇒ Cadenya::Resources::Agents
readonly
Manage AI agents within a workspace.
- #api_key ⇒ String readonly
-
#api_keys ⇒ Cadenya::Resources::APIKeys
readonly
Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.
-
#bulk_workspace_resources ⇒ Cadenya::Resources::BulkWorkspaceResources
readonly
Apply a declarative bundle of workspace resources — tool sets, memory layers, agents, variations, assignments, and schedules — in a single asynchronous operation.
-
#memory_layers ⇒ Cadenya::Resources::MemoryLayers
readonly
Manage memory layers and their entries.
-
#models ⇒ Cadenya::Resources::Models
readonly
Manage LLM models available to a workspace.
- #objectives ⇒ Cadenya::Resources::Objectives readonly
- #search ⇒ Cadenya::Resources::Search readonly
-
#tool_sets ⇒ Cadenya::Resources::ToolSets
readonly
Manage tool sets and the tools they contain.
-
#uploads ⇒ Cadenya::Resources::Uploads
readonly
Issue short-lived presigned URLs for direct client-to-object-storage uploads.
- #webhook_key ⇒ String? readonly
- #webhooks ⇒ Cadenya::Resources::Webhooks readonly
-
#workspace_admin ⇒ Cadenya::Resources::WorkspaceAdmin
readonly
Administer workspaces across the account: create and archive workspaces and manage their membership.
- #workspace_secrets ⇒ Cadenya::Resources::WorkspaceSecrets readonly
-
#workspaces ⇒ Cadenya::Resources::Workspaces
readonly
Manage workspaces within an account.
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#initialize(api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
constructor
Creates and returns a new client for interacting with the API.
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/cadenya/client.rb', line 126 def initialize( api_key: ENV["CADENYA_API_KEY"], webhook_key: ENV["CADENYA_WEBHOOK_KEY"], base_url: ENV["CADENYA_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://api.cadenya.com" if api_key.nil? raise ArgumentError.new("api_key is required, and can be set via environ: \"CADENYA_API_KEY\"") end headers = {} custom_headers_env = ENV["CADENYA_CUSTOM_HEADERS"] unless custom_headers_env.nil? parsed = {} custom_headers_env.split("\n").each do |line| colon = line.index(":") unless colon.nil? parsed[line[0...colon].strip] = line[(colon + 1)..].strip end end headers = parsed.merge(headers) end @api_key = api_key.to_s @webhook_key = webhook_key&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @account = Cadenya::Resources::Account.new(client: self) @agents = Cadenya::Resources::Agents.new(client: self) @objectives = Cadenya::Resources::Objectives.new(client: self) @memory_layers = Cadenya::Resources::MemoryLayers.new(client: self) @uploads = Cadenya::Resources::Uploads.new(client: self) @models = Cadenya::Resources::Models.new(client: self) @search = Cadenya::Resources::Search.new(client: self) @tool_sets = Cadenya::Resources::ToolSets.new(client: self) @api_keys = Cadenya::Resources::APIKeys.new(client: self) @workspace_secrets = Cadenya::Resources::WorkspaceSecrets.new(client: self) @workspaces = Cadenya::Resources::Workspaces.new(client: self) @workspace_admin = Cadenya::Resources::WorkspaceAdmin.new(client: self) @webhooks = Cadenya::Resources::Webhooks.new(client: self) @bulk_workspace_resources = Cadenya::Resources::BulkWorkspaceResources.new(client: self) end |
Instance Attribute Details
#account ⇒ Cadenya::Resources::Account (readonly)
Manage the authenticated account. Accounts are the top-level organizational unit and contain one or more workspaces.
27 28 29 |
# File 'lib/cadenya/client.rb', line 27 def account @account end |
#agents ⇒ Cadenya::Resources::Agents (readonly)
Manage AI agents within a workspace. Agents define AI behavior and tool access.
31 32 33 |
# File 'lib/cadenya/client.rb', line 31 def agents @agents end |
#api_key ⇒ String (readonly)
19 20 21 |
# File 'lib/cadenya/client.rb', line 19 def api_key @api_key end |
#api_keys ⇒ Cadenya::Resources::APIKeys (readonly)
Issue, rotate, and revoke API keys for the account, and grant or revoke each key’s access to individual workspaces.
69 70 71 |
# File 'lib/cadenya/client.rb', line 69 def api_keys @api_keys end |
#bulk_workspace_resources ⇒ Cadenya::Resources::BulkWorkspaceResources (readonly)
Apply a declarative bundle of workspace resources — tool sets, memory layers, agents, variations, assignments, and schedules — in a single asynchronous operation.
99 100 101 |
# File 'lib/cadenya/client.rb', line 99 def bulk_workspace_resources @bulk_workspace_resources end |
#memory_layers ⇒ Cadenya::Resources::MemoryLayers (readonly)
Manage memory layers and their entries. Layers are named containers that can be composed into an objective’s memory stack; entries are the keyed values within a layer. System-managed layers (e.g., episodic layers created by the runtime) cannot be mutated through this API.
41 42 43 |
# File 'lib/cadenya/client.rb', line 41 def memory_layers @memory_layers end |
#models ⇒ Cadenya::Resources::Models (readonly)
Manage LLM models available to a workspace. Models represent provider and family pairs (e.g., “anthropic/claude-sonnet-4.6”). Workspaces are seeded with the supported models and you can enable or disable each one.
53 54 55 |
# File 'lib/cadenya/client.rb', line 53 def models @models end |
#objectives ⇒ Cadenya::Resources::Objectives (readonly)
34 35 36 |
# File 'lib/cadenya/client.rb', line 34 def objectives @objectives end |
#search ⇒ Cadenya::Resources::Search (readonly)
56 57 58 |
# File 'lib/cadenya/client.rb', line 56 def search @search end |
#tool_sets ⇒ Cadenya::Resources::ToolSets (readonly)
Manage tool sets and the tools they contain. Tool sets group related tools, and tools define specific capabilities available to agents.
When a tool set is managed, only API key actors can modify its tools; human (profile) actors cannot.
64 65 66 |
# File 'lib/cadenya/client.rb', line 64 def tool_sets @tool_sets end |
#uploads ⇒ Cadenya::Resources::Uploads (readonly)
Issue short-lived presigned URLs for direct client-to-object-storage uploads. Created uploads can be referenced by id when creating or updating resources that accept binary content (e.g., MemoryEntry).
47 48 49 |
# File 'lib/cadenya/client.rb', line 47 def uploads @uploads end |
#webhook_key ⇒ String? (readonly)
22 23 24 |
# File 'lib/cadenya/client.rb', line 22 def webhook_key @webhook_key end |
#webhooks ⇒ Cadenya::Resources::Webhooks (readonly)
93 94 95 |
# File 'lib/cadenya/client.rb', line 93 def webhooks @webhooks end |
#workspace_admin ⇒ Cadenya::Resources::WorkspaceAdmin (readonly)
Administer workspaces across the account: create and archive workspaces and manage their membership. These operations are account-scoped and require the admin role (a token whose profile holds the WorkOS admin role); they live under /v1/account/workspaces rather than the workspace-scoped /v1/workspaces tree so an admin can manage any workspace in the account, including ones they are not themselves a member of.
90 91 92 |
# File 'lib/cadenya/client.rb', line 90 def workspace_admin @workspace_admin end |
#workspace_secrets ⇒ Cadenya::Resources::WorkspaceSecrets (readonly)
72 73 74 |
# File 'lib/cadenya/client.rb', line 72 def workspace_secrets @workspace_secrets end |
#workspaces ⇒ Cadenya::Resources::Workspaces (readonly)
Manage workspaces within an account. Workspaces provide organizational grouping and isolation for resources such as agents, tools, and API keys.
This is the workspace-scoped, end-user surface. Administrative operations (create / archive workspaces, manage members) live in WorkspaceAdminService under /v1/account/workspaces and require the admin role.
81 82 83 |
# File 'lib/cadenya/client.rb', line 81 def workspaces @workspaces end |