Class: WorkOS::Agents
- Inherits:
-
Object
- Object
- WorkOS::Agents
- Defined in:
- lib/workos/agents.rb
Instance Method Summary collapse
-
#create_blueprint(name:, description: nil, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {}) ⇒ WorkOS::AgentBlueprint
Create an agent blueprint.
-
#create_blueprint_token(agent_blueprint_id:, type:, user_access_token: nil, intent: nil, organization_id: nil, agent_access_token: nil, refresh_token: nil, request_options: {}) ⇒ WorkOS::AgentToken
Mint an agent token.
-
#create_validate(type:, credential:, audience: nil, request_options: {}) ⇒ WorkOS::AgentCredentialValidation
Validate an agent credential.
-
#delete_blueprint(agent_blueprint_id:, request_options: {}) ⇒ void
Delete an agent blueprint.
-
#delete_instance(agent_instance_id:, request_options: {}) ⇒ void
Delete an agent instance.
-
#get_blueprint(agent_blueprint_id:, request_options: {}) ⇒ WorkOS::AgentBlueprint
Get an agent blueprint.
-
#get_instance(agent_instance_id:, request_options: {}) ⇒ WorkOS::AgentInstance
Get an agent instance.
-
#get_registration(id:, request_options: {}) ⇒ WorkOS::AgentRegistration
Get an agent registration.
-
#get_session(agent_instance_session_id:, request_options: {}) ⇒ WorkOS::AgentInstanceSession
Get an agent instance session.
-
#initialize(client) ⇒ Agents
constructor
A new instance of Agents.
-
#list_blueprints(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentBlueprint>
List agent blueprints.
-
#list_instances(before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentInstance>
List agent instances.
-
#list_sessions(before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, agent_instance_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentInstanceSession>
List agent instance sessions.
-
#revoke_registration(id:, request_options: {}) ⇒ WorkOS::AgentRegistration
Revoke an agent registration.
-
#revoke_session(agent_instance_session_id:, request_options: {}) ⇒ WorkOS::AgentInstanceSession
Revoke an agent instance session.
-
#update_attempts(type:, claim_attempt_token:, user:, organization_id: nil, request_options: {}) ⇒ WorkOS::ClaimViewResponse
Link a claim attempt to an external user.
-
#update_blueprint(agent_blueprint_id:, name: nil, description: WorkOS::OMIT, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {}) ⇒ WorkOS::AgentBlueprint
Update an agent blueprint.
-
#validate_blueprint_token(agent_blueprint_id:, agent_access_token:, request_options: {}) ⇒ WorkOS::AgentTokenValidation
Validate an agent token.
Constructor Details
#initialize(client) ⇒ Agents
Returns a new instance of Agents.
9 10 11 |
# File 'lib/workos/agents.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create_blueprint(name:, description: nil, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {}) ⇒ WorkOS::AgentBlueprint
Create an agent blueprint
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/workos/agents.rb', line 66 def create_blueprint( name:, description: nil, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {} ) body = { "name" => name, "description" => description, "permissions" => , "invocable_by" => invocable_by, "invocable_as" => invocable_as, "session_settings" => session_settings }.compact response = @client.request( method: :post, path: "/agents/blueprints", auth: true, body: body, request_options: ) result = WorkOS::AgentBlueprint.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_blueprint_token(agent_blueprint_id:, type:, user_access_token: nil, intent: nil, organization_id: nil, agent_access_token: nil, refresh_token: nil, request_options: {}) ⇒ WorkOS::AgentToken
Mint an agent token
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/workos/agents.rb', line 181 def create_blueprint_token( agent_blueprint_id:, type:, user_access_token: nil, intent: nil, organization_id: nil, agent_access_token: nil, refresh_token: nil, request_options: {} ) body = { "type" => type, "user_access_token" => user_access_token, "intent" => intent, "organization_id" => organization_id, "agent_access_token" => agent_access_token, "refresh_token" => refresh_token }.compact response = @client.request( method: :post, path: "/agents/blueprints/#{WorkOS::Util.encode_path(agent_blueprint_id)}/tokens", auth: true, body: body, request_options: ) result = WorkOS::AgentToken.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#create_validate(type:, credential:, audience: nil, request_options: {}) ⇒ WorkOS::AgentCredentialValidation
Validate an agent credential
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/workos/agents.rb', line 274 def create_validate( type:, credential:, audience: nil, request_options: {} ) body = { "type" => type, "credential" => credential, "audience" => audience }.compact response = @client.request( method: :post, path: "/agents/credentials/validate", auth: true, body: body, request_options: ) result = WorkOS::AgentCredentialValidation.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#delete_blueprint(agent_blueprint_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete an agent blueprint
158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/workos/agents.rb', line 158 def delete_blueprint( agent_blueprint_id:, request_options: {} ) @client.request( method: :delete, path: "/agents/blueprints/#{WorkOS::Util.encode_path(agent_blueprint_id)}", auth: true, request_options: ) nil end |
#delete_instance(agent_instance_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete an agent instance
410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/workos/agents.rb', line 410 def delete_instance( agent_instance_id:, request_options: {} ) @client.request( method: :delete, path: "/agents/instances/#{WorkOS::Util.encode_path(agent_instance_id)}", auth: true, request_options: ) nil end |
#get_blueprint(agent_blueprint_id:, request_options: {}) ⇒ WorkOS::AgentBlueprint
Get an agent blueprint
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/workos/agents.rb', line 99 def get_blueprint( agent_blueprint_id:, request_options: {} ) response = @client.request( method: :get, path: "/agents/blueprints/#{WorkOS::Util.encode_path(agent_blueprint_id)}", auth: true, request_options: ) result = WorkOS::AgentBlueprint.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_instance(agent_instance_id:, request_options: {}) ⇒ WorkOS::AgentInstance
Get an agent instance
391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/workos/agents.rb', line 391 def get_instance( agent_instance_id:, request_options: {} ) response = @client.request( method: :get, path: "/agents/instances/#{WorkOS::Util.encode_path(agent_instance_id)}", auth: true, request_options: ) result = WorkOS::AgentInstance.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_registration(id:, request_options: {}) ⇒ WorkOS::AgentRegistration
Get an agent registration
301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/workos/agents.rb', line 301 def get_registration( id:, request_options: {} ) response = @client.request( method: :get, path: "/agents/registrations/#{WorkOS::Util.encode_path(id)}", auth: true, request_options: ) result = WorkOS::AgentRegistration.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#get_session(agent_instance_session_id:, request_options: {}) ⇒ WorkOS::AgentInstanceSession
Get an agent instance session
483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/workos/agents.rb', line 483 def get_session( agent_instance_session_id:, request_options: {} ) response = @client.request( method: :get, path: "/agents/sessions/#{WorkOS::Util.encode_path(agent_instance_session_id)}", auth: true, request_options: ) result = WorkOS::AgentInstanceSession.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#list_blueprints(before: nil, after: nil, limit: 10, order: "desc", request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentBlueprint>
List agent blueprints
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/workos/agents.rb', line 20 def list_blueprints( before: nil, after: nil, limit: 10, order: "desc", request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order }.compact response = @client.request( method: :get, path: "/agents/blueprints", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_blueprints( before: before, after: cursor, limit: limit, order: order, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AgentBlueprint, filters: {before: before, limit: limit, order: order}, fetch_next: fetch_next ) end |
#list_instances(before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentInstance>
List agent instances
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/workos/agents.rb', line 344 def list_instances( before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization_id" => organization_id, "agent_blueprint_id" => agent_blueprint_id }.compact response = @client.request( method: :get, path: "/agents/instances", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_instances( before: before, after: cursor, limit: limit, order: order, organization_id: organization_id, agent_blueprint_id: agent_blueprint_id, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AgentInstance, filters: {before: before, limit: limit, order: order, organization_id: organization_id, agent_blueprint_id: agent_blueprint_id}, fetch_next: fetch_next ) end |
#list_sessions(before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, agent_instance_id: nil, request_options: {}) ⇒ WorkOS::Types::ListStruct<WorkOS::AgentInstanceSession>
List agent instance sessions
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/workos/agents.rb', line 433 def list_sessions( before: nil, after: nil, limit: 10, order: "desc", organization_id: nil, agent_blueprint_id: nil, agent_instance_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "organization_id" => organization_id, "agent_blueprint_id" => agent_blueprint_id, "agent_instance_id" => agent_instance_id }.compact response = @client.request( method: :get, path: "/agents/sessions", auth: true, params: params, request_options: ) fetch_next = ->(cursor) { list_sessions( before: before, after: cursor, limit: limit, order: order, organization_id: organization_id, agent_blueprint_id: agent_blueprint_id, agent_instance_id: agent_instance_id, request_options: ) } WorkOS::Types::ListStruct.from_response( response, model: WorkOS::AgentInstanceSession, filters: {before: before, limit: limit, order: order, organization_id: organization_id, agent_blueprint_id: agent_blueprint_id, agent_instance_id: agent_instance_id}, fetch_next: fetch_next ) end |
#revoke_registration(id:, request_options: {}) ⇒ WorkOS::AgentRegistration
Revoke an agent registration
320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/workos/agents.rb', line 320 def revoke_registration( id:, request_options: {} ) response = @client.request( method: :post, path: "/agents/registrations/#{WorkOS::Util.encode_path(id)}/revoke", auth: true, request_options: ) result = WorkOS::AgentRegistration.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#revoke_session(agent_instance_session_id:, request_options: {}) ⇒ WorkOS::AgentInstanceSession
Revoke an agent instance session
502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/workos/agents.rb', line 502 def revoke_session( agent_instance_session_id:, request_options: {} ) response = @client.request( method: :post, path: "/agents/sessions/#{WorkOS::Util.encode_path(agent_instance_session_id)}/revoke", auth: true, request_options: ) result = WorkOS::AgentInstanceSession.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#update_attempts(type:, claim_attempt_token:, user:, organization_id: nil, request_options: {}) ⇒ WorkOS::ClaimViewResponse
Link a claim attempt to an external user
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/workos/agents.rb', line 243 def update_attempts( type:, claim_attempt_token:, user:, organization_id: nil, request_options: {} ) body = { "type" => type, "claim_attempt_token" => claim_attempt_token, "user" => user, "organization_id" => organization_id }.compact response = @client.request( method: :patch, path: "/agents/claims/attempts", auth: true, body: body, request_options: ) result = WorkOS::ClaimViewResponse.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#update_blueprint(agent_blueprint_id:, name: nil, description: WorkOS::OMIT, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {}) ⇒ WorkOS::AgentBlueprint
Update an agent blueprint
124 125 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 |
# File 'lib/workos/agents.rb', line 124 def update_blueprint( agent_blueprint_id:, name: nil, description: WorkOS::OMIT, permissions: nil, invocable_by: nil, invocable_as: nil, session_settings: nil, request_options: {} ) body = { "name" => name, "permissions" => , "invocable_by" => invocable_by, "invocable_as" => invocable_as, "session_settings" => session_settings }.compact body["description"] = description unless description.equal?(WorkOS::OMIT) response = @client.request( method: :patch, path: "/agents/blueprints/#{WorkOS::Util.encode_path(agent_blueprint_id)}", auth: true, body: body, request_options: ) result = WorkOS::AgentBlueprint.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |
#validate_blueprint_token(agent_blueprint_id:, agent_access_token:, request_options: {}) ⇒ WorkOS::AgentTokenValidation
Validate an agent token
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/workos/agents.rb', line 216 def validate_blueprint_token( agent_blueprint_id:, agent_access_token:, request_options: {} ) body = { "agent_access_token" => agent_access_token } response = @client.request( method: :post, path: "/agents/blueprints/#{WorkOS::Util.encode_path(agent_blueprint_id)}/tokens/validate", auth: true, body: body, request_options: ) result = WorkOS::AgentTokenValidation.new(response.body) result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"]) result end |