conductor_ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +142 -0
- data/LICENSE +190 -0
- data/README.md +517 -0
- data/examples/agentic_workflows/llm_chat.rb +106 -0
- data/examples/dynamic_workflow.rb +177 -0
- data/examples/event_handler.rb +94 -0
- data/examples/event_listener_examples.rb +430 -0
- data/examples/helloworld/greetings_worker.rb +24 -0
- data/examples/helloworld/helloworld.rb +99 -0
- data/examples/kitchensink.rb +213 -0
- data/examples/metadata_journey.rb +189 -0
- data/examples/metrics_example.rb +284 -0
- data/examples/new_dsl_demo.rb +141 -0
- data/examples/orkes/http_poll.rb +83 -0
- data/examples/orkes/secrets_example.rb +69 -0
- data/examples/orkes/wait_for_webhook.rb +90 -0
- data/examples/prompt_journey.rb +245 -0
- data/examples/rag_workflow.rb +167 -0
- data/examples/schedule_journey.rb +244 -0
- data/examples/simple_worker.rb +125 -0
- data/examples/simple_workflow.rb +89 -0
- data/examples/task_context_example.rb +257 -0
- data/examples/task_listener_example.rb +192 -0
- data/examples/worker_configuration_example.rb +282 -0
- data/examples/workflow_dsl.rb +316 -0
- data/examples/workflow_ops.rb +305 -0
- data/lib/conductor/client/authorization_client.rb +238 -0
- data/lib/conductor/client/integration_client.rb +108 -0
- data/lib/conductor/client/metadata_client.rb +139 -0
- data/lib/conductor/client/prompt_client.rb +58 -0
- data/lib/conductor/client/scheduler_client.rb +132 -0
- data/lib/conductor/client/schema_client.rb +32 -0
- data/lib/conductor/client/secret_client.rb +48 -0
- data/lib/conductor/client/task_client.rb +168 -0
- data/lib/conductor/client/workflow_client.rb +242 -0
- data/lib/conductor/configuration/authentication_settings.rb +17 -0
- data/lib/conductor/configuration.rb +103 -0
- data/lib/conductor/exceptions.rb +86 -0
- data/lib/conductor/http/api/application_resource_api.rb +107 -0
- data/lib/conductor/http/api/authorization_resource_api.rb +56 -0
- data/lib/conductor/http/api/event_resource_api.rb +133 -0
- data/lib/conductor/http/api/gateway_auth_resource_api.rb +48 -0
- data/lib/conductor/http/api/group_resource_api.rb +76 -0
- data/lib/conductor/http/api/integration_resource_api.rb +145 -0
- data/lib/conductor/http/api/metadata_resource_api.rb +231 -0
- data/lib/conductor/http/api/prompt_resource_api.rb +81 -0
- data/lib/conductor/http/api/role_resource_api.rb +60 -0
- data/lib/conductor/http/api/scheduler_resource_api.rb +211 -0
- data/lib/conductor/http/api/schema_resource_api.rb +82 -0
- data/lib/conductor/http/api/secret_resource_api.rb +134 -0
- data/lib/conductor/http/api/task_resource_api.rb +321 -0
- data/lib/conductor/http/api/token_resource_api.rb +42 -0
- data/lib/conductor/http/api/user_resource_api.rb +59 -0
- data/lib/conductor/http/api/workflow_bulk_resource_api.rb +91 -0
- data/lib/conductor/http/api/workflow_resource_api.rb +451 -0
- data/lib/conductor/http/api_client.rb +437 -0
- data/lib/conductor/http/models/authentication_config.rb +67 -0
- data/lib/conductor/http/models/authorization_request.rb +39 -0
- data/lib/conductor/http/models/base_model.rb +162 -0
- data/lib/conductor/http/models/bulk_response.rb +39 -0
- data/lib/conductor/http/models/conductor_application.rb +39 -0
- data/lib/conductor/http/models/conductor_user.rb +53 -0
- data/lib/conductor/http/models/create_or_update_application_request.rb +24 -0
- data/lib/conductor/http/models/create_or_update_role_request.rb +27 -0
- data/lib/conductor/http/models/event_handler.rb +130 -0
- data/lib/conductor/http/models/generate_token_request.rb +27 -0
- data/lib/conductor/http/models/group.rb +36 -0
- data/lib/conductor/http/models/integration.rb +70 -0
- data/lib/conductor/http/models/integration_api.rb +53 -0
- data/lib/conductor/http/models/integration_api_update.rb +43 -0
- data/lib/conductor/http/models/integration_update.rb +36 -0
- data/lib/conductor/http/models/permission.rb +24 -0
- data/lib/conductor/http/models/poll_data.rb +33 -0
- data/lib/conductor/http/models/prompt_template.rb +59 -0
- data/lib/conductor/http/models/prompt_template_test_request.rb +43 -0
- data/lib/conductor/http/models/rerun_workflow_request.rb +37 -0
- data/lib/conductor/http/models/role.rb +27 -0
- data/lib/conductor/http/models/schema_def.rb +59 -0
- data/lib/conductor/http/models/search_result.rb +187 -0
- data/lib/conductor/http/models/skip_task_request.rb +27 -0
- data/lib/conductor/http/models/start_workflow_request.rb +68 -0
- data/lib/conductor/http/models/subject_ref.rb +35 -0
- data/lib/conductor/http/models/tag_object.rb +36 -0
- data/lib/conductor/http/models/target_ref.rb +39 -0
- data/lib/conductor/http/models/task.rb +156 -0
- data/lib/conductor/http/models/task_def.rb +95 -0
- data/lib/conductor/http/models/task_exec_log.rb +30 -0
- data/lib/conductor/http/models/task_result.rb +115 -0
- data/lib/conductor/http/models/task_result_status.rb +24 -0
- data/lib/conductor/http/models/token.rb +33 -0
- data/lib/conductor/http/models/upsert_group_request.rb +30 -0
- data/lib/conductor/http/models/upsert_user_request.rb +39 -0
- data/lib/conductor/http/models/workflow.rb +202 -0
- data/lib/conductor/http/models/workflow_def.rb +73 -0
- data/lib/conductor/http/models/workflow_schedule.rb +100 -0
- data/lib/conductor/http/models/workflow_state_update.rb +30 -0
- data/lib/conductor/http/models/workflow_status_constants.rb +57 -0
- data/lib/conductor/http/models/workflow_task.rb +169 -0
- data/lib/conductor/http/models/workflow_test_request.rb +67 -0
- data/lib/conductor/http/rest_client.rb +211 -0
- data/lib/conductor/orkes/models/access_key.rb +56 -0
- data/lib/conductor/orkes/models/granted_permission.rb +27 -0
- data/lib/conductor/orkes/models/metadata_tag.rb +15 -0
- data/lib/conductor/orkes/models/rate_limit_tag.rb +15 -0
- data/lib/conductor/orkes/orkes_clients.rb +69 -0
- data/lib/conductor/version.rb +5 -0
- data/lib/conductor/worker/events/conductor_event.rb +40 -0
- data/lib/conductor/worker/events/global_dispatcher.rb +37 -0
- data/lib/conductor/worker/events/http_events.rb +25 -0
- data/lib/conductor/worker/events/listener_registry.rb +40 -0
- data/lib/conductor/worker/events/listeners.rb +34 -0
- data/lib/conductor/worker/events/sync_event_dispatcher.rb +78 -0
- data/lib/conductor/worker/events/task_runner_events.rb +271 -0
- data/lib/conductor/worker/events/workflow_events.rb +49 -0
- data/lib/conductor/worker/fiber_executor.rb +532 -0
- data/lib/conductor/worker/ractor_task_runner.rb +501 -0
- data/lib/conductor/worker/task_context.rb +114 -0
- data/lib/conductor/worker/task_definition_registrar.rb +322 -0
- data/lib/conductor/worker/task_handler.rb +360 -0
- data/lib/conductor/worker/task_in_progress.rb +60 -0
- data/lib/conductor/worker/task_runner.rb +538 -0
- data/lib/conductor/worker/telemetry/metrics_collector.rb +196 -0
- data/lib/conductor/worker/telemetry/prometheus_backend.rb +224 -0
- data/lib/conductor/worker/worker.rb +355 -0
- data/lib/conductor/worker/worker_config.rb +154 -0
- data/lib/conductor/worker/worker_registry.rb +71 -0
- data/lib/conductor/workflow/dsl/input_ref.rb +37 -0
- data/lib/conductor/workflow/dsl/output_ref.rb +44 -0
- data/lib/conductor/workflow/dsl/parallel_builder.rb +49 -0
- data/lib/conductor/workflow/dsl/switch_builder.rb +74 -0
- data/lib/conductor/workflow/dsl/task_ref.rb +178 -0
- data/lib/conductor/workflow/dsl/workflow_builder.rb +1016 -0
- data/lib/conductor/workflow/dsl/workflow_definition.rb +150 -0
- data/lib/conductor/workflow/llm/chat_message.rb +47 -0
- data/lib/conductor/workflow/llm/embedding_model.rb +19 -0
- data/lib/conductor/workflow/llm/tool_call.rb +43 -0
- data/lib/conductor/workflow/llm/tool_spec.rb +46 -0
- data/lib/conductor/workflow/task_type.rb +68 -0
- data/lib/conductor/workflow/timeout_policy.rb +31 -0
- data/lib/conductor/workflow/workflow_executor.rb +373 -0
- data/lib/conductor.rb +192 -0
- metadata +359 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Workflow Operations Example
|
|
5
|
+
# ============================
|
|
6
|
+
#
|
|
7
|
+
# Demonstrates various workflow lifecycle operations and control mechanisms.
|
|
8
|
+
#
|
|
9
|
+
# What it does:
|
|
10
|
+
# -------------
|
|
11
|
+
# - Start workflow: Create and execute a new workflow instance
|
|
12
|
+
# - Pause workflow: Temporarily halt workflow execution
|
|
13
|
+
# - Resume workflow: Continue paused workflow
|
|
14
|
+
# - Terminate workflow: Force stop a running workflow
|
|
15
|
+
# - Restart workflow: Restart from a specific task
|
|
16
|
+
# - Rerun workflow: Re-execute from beginning with same/different inputs
|
|
17
|
+
# - Update task: Manually update task status and output
|
|
18
|
+
# - Search workflows: Find workflows by correlation ID or query
|
|
19
|
+
#
|
|
20
|
+
# Use Cases:
|
|
21
|
+
# ----------
|
|
22
|
+
# - Workflow lifecycle management (start, pause, resume, terminate)
|
|
23
|
+
# - Manual intervention in workflow execution
|
|
24
|
+
# - Debugging and testing workflows
|
|
25
|
+
# - Implementing human-in-the-loop patterns
|
|
26
|
+
# - External event handling via task updates
|
|
27
|
+
# - Recovery from failures (restart, rerun)
|
|
28
|
+
#
|
|
29
|
+
# Key Operations:
|
|
30
|
+
# ---------------
|
|
31
|
+
# - start_workflow(): Launch new workflow instance
|
|
32
|
+
# - pause_workflow(): Halt at current task
|
|
33
|
+
# - resume_workflow(): Continue from pause
|
|
34
|
+
# - terminate_workflow(): Force stop with reason
|
|
35
|
+
# - restart_workflow(): Resume from failed task
|
|
36
|
+
# - rerun_workflow(): Start fresh with new/same inputs
|
|
37
|
+
# - update_task(): Manually complete tasks
|
|
38
|
+
#
|
|
39
|
+
# Usage:
|
|
40
|
+
# bundle exec ruby examples/workflow_ops.rb
|
|
41
|
+
|
|
42
|
+
require 'securerandom'
|
|
43
|
+
require_relative '../lib/conductor'
|
|
44
|
+
|
|
45
|
+
# Include workflow DSL
|
|
46
|
+
include Conductor::Workflow
|
|
47
|
+
|
|
48
|
+
def start_demo_workflow(workflow_executor, workflow_client)
|
|
49
|
+
# Create a workflow with wait tasks for demonstrating operations
|
|
50
|
+
workflow = ConductorWorkflow.new(workflow_client, 'workflow_ops_demo', version: 1, executor: workflow_executor)
|
|
51
|
+
|
|
52
|
+
# Wait for 2 seconds
|
|
53
|
+
wait_for_two_sec = WaitTask.new('wait_for_2_sec', wait_for_seconds: 2)
|
|
54
|
+
|
|
55
|
+
# Wait for external signal (no timeout - waits indefinitely until updated)
|
|
56
|
+
wait_for_signal = WaitTask.new('wait_for_signal')
|
|
57
|
+
|
|
58
|
+
# HTTP call
|
|
59
|
+
http_call = HttpTask.new('call_remote_api', {
|
|
60
|
+
'uri' => 'https://orkes-api-tester.orkesconductor.com/api'
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
# Build workflow
|
|
64
|
+
workflow >> wait_for_two_sec >> wait_for_signal >> http_call
|
|
65
|
+
|
|
66
|
+
# Register the workflow
|
|
67
|
+
workflow_executor.register_workflow(workflow, overwrite: true)
|
|
68
|
+
|
|
69
|
+
# Start workflow with a correlation ID
|
|
70
|
+
request = Conductor::Http::Models::StartWorkflowRequest.new(
|
|
71
|
+
name: 'workflow_ops_demo',
|
|
72
|
+
version: 1,
|
|
73
|
+
input: {},
|
|
74
|
+
correlation_id: 'correlation_123'
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
workflow_executor.start_workflow(request)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def main
|
|
81
|
+
# Configuration from environment variables
|
|
82
|
+
config = Conductor::Configuration.new
|
|
83
|
+
|
|
84
|
+
puts '=' * 70
|
|
85
|
+
puts 'Conductor Ruby SDK - Workflow Operations Example'
|
|
86
|
+
puts '=' * 70
|
|
87
|
+
puts
|
|
88
|
+
puts "Server: #{config.server_url}"
|
|
89
|
+
puts
|
|
90
|
+
|
|
91
|
+
# Create clients
|
|
92
|
+
clients = Conductor::Orkes::OrkesClients.new(config)
|
|
93
|
+
workflow_client = clients.get_workflow_client
|
|
94
|
+
task_client = clients.get_task_client
|
|
95
|
+
workflow_executor = clients.get_workflow_executor
|
|
96
|
+
|
|
97
|
+
# ============================================================================
|
|
98
|
+
# START WORKFLOW
|
|
99
|
+
# ============================================================================
|
|
100
|
+
|
|
101
|
+
workflow_id = start_demo_workflow(workflow_executor, workflow_client)
|
|
102
|
+
puts "Started workflow with ID: #{workflow_id}"
|
|
103
|
+
puts "Monitor at: #{config.ui_host}/execution/#{workflow_id}"
|
|
104
|
+
puts
|
|
105
|
+
|
|
106
|
+
# ============================================================================
|
|
107
|
+
# GET WORKFLOW STATUS
|
|
108
|
+
# ============================================================================
|
|
109
|
+
|
|
110
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
111
|
+
last_task = workflow['tasks'].last
|
|
112
|
+
puts "Workflow status: #{workflow['status']}"
|
|
113
|
+
puts "Currently running task: #{last_task['referenceTaskName']}"
|
|
114
|
+
puts
|
|
115
|
+
|
|
116
|
+
# ============================================================================
|
|
117
|
+
# WAIT FOR TIMED WAIT TO COMPLETE
|
|
118
|
+
# ============================================================================
|
|
119
|
+
|
|
120
|
+
puts 'Waiting 3 seconds for the timed wait task to complete...'
|
|
121
|
+
sleep 3
|
|
122
|
+
|
|
123
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
124
|
+
last_task = workflow['tasks'].last
|
|
125
|
+
puts "Workflow status: #{workflow['status']}"
|
|
126
|
+
puts "Currently running task: #{last_task['referenceTaskName']}"
|
|
127
|
+
puts
|
|
128
|
+
|
|
129
|
+
# ============================================================================
|
|
130
|
+
# TERMINATE WORKFLOW
|
|
131
|
+
# ============================================================================
|
|
132
|
+
|
|
133
|
+
puts 'Terminating workflow...'
|
|
134
|
+
workflow_client.terminate_workflow(workflow_id, reason: 'testing termination')
|
|
135
|
+
|
|
136
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
137
|
+
last_task = workflow['tasks'].last
|
|
138
|
+
puts "Workflow status: #{workflow['status']}"
|
|
139
|
+
puts "Last task status: #{last_task['status']}"
|
|
140
|
+
puts
|
|
141
|
+
|
|
142
|
+
# ============================================================================
|
|
143
|
+
# RETRY WORKFLOW
|
|
144
|
+
# ============================================================================
|
|
145
|
+
|
|
146
|
+
puts 'Retrying workflow...'
|
|
147
|
+
workflow_client.retry_workflow(workflow_id)
|
|
148
|
+
|
|
149
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
150
|
+
last_task = workflow['tasks'].last
|
|
151
|
+
puts "Workflow status: #{workflow['status']}"
|
|
152
|
+
puts "Last task: #{last_task['referenceTaskName']} (status: #{last_task['status']})"
|
|
153
|
+
puts
|
|
154
|
+
|
|
155
|
+
# ============================================================================
|
|
156
|
+
# MANUALLY COMPLETE WAIT TASK
|
|
157
|
+
# ============================================================================
|
|
158
|
+
|
|
159
|
+
puts 'Manually completing the wait_for_signal task...'
|
|
160
|
+
|
|
161
|
+
# Create task result to complete the WAIT task
|
|
162
|
+
task_result = Conductor::Http::Models::TaskResult.new(
|
|
163
|
+
workflow_instance_id: workflow_id,
|
|
164
|
+
task_id: last_task['taskId'],
|
|
165
|
+
status: 'COMPLETED',
|
|
166
|
+
output_data: { 'greetings' => 'hello from Conductor Ruby SDK' }
|
|
167
|
+
)
|
|
168
|
+
task_client.update_task(task_result)
|
|
169
|
+
|
|
170
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
171
|
+
last_task = workflow['tasks'].last
|
|
172
|
+
puts "Workflow status: #{workflow['status']}"
|
|
173
|
+
puts "Last task: #{last_task['referenceTaskName']} (status: #{last_task['status']})"
|
|
174
|
+
|
|
175
|
+
# Wait for HTTP task to complete
|
|
176
|
+
sleep 2
|
|
177
|
+
|
|
178
|
+
# ============================================================================
|
|
179
|
+
# RERUN WORKFLOW
|
|
180
|
+
# ============================================================================
|
|
181
|
+
|
|
182
|
+
puts
|
|
183
|
+
puts 'Re-running workflow from the second task...'
|
|
184
|
+
|
|
185
|
+
# Get the workflow again to find the second task
|
|
186
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
187
|
+
|
|
188
|
+
if workflow['tasks'].length > 1
|
|
189
|
+
second_task_id = workflow['tasks'][1]['taskId']
|
|
190
|
+
|
|
191
|
+
rerun_request = {
|
|
192
|
+
're_run_from_task_id' => second_task_id
|
|
193
|
+
}
|
|
194
|
+
workflow_client.rerun_workflow(workflow_id, rerun_request)
|
|
195
|
+
|
|
196
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
197
|
+
puts "Workflow status after rerun: #{workflow['status']}"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# ============================================================================
|
|
201
|
+
# RESTART WORKFLOW
|
|
202
|
+
# ============================================================================
|
|
203
|
+
|
|
204
|
+
puts
|
|
205
|
+
puts 'Terminating and restarting workflow...'
|
|
206
|
+
|
|
207
|
+
workflow_client.terminate_workflow(workflow_id, reason: 'terminating so we can restart')
|
|
208
|
+
workflow_client.restart_workflow(workflow_id)
|
|
209
|
+
|
|
210
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
211
|
+
puts "Workflow status after restart: #{workflow['status']}"
|
|
212
|
+
|
|
213
|
+
# ============================================================================
|
|
214
|
+
# PAUSE AND RESUME WORKFLOW
|
|
215
|
+
# ============================================================================
|
|
216
|
+
|
|
217
|
+
puts
|
|
218
|
+
puts 'Pausing workflow...'
|
|
219
|
+
workflow_client.pause_workflow(workflow_id)
|
|
220
|
+
|
|
221
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
222
|
+
puts "Workflow status: #{workflow['status']}"
|
|
223
|
+
|
|
224
|
+
puts 'Waiting 3 seconds while paused...'
|
|
225
|
+
sleep 3
|
|
226
|
+
|
|
227
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
228
|
+
# While paused, wait task may complete but no new tasks scheduled
|
|
229
|
+
wait_task = workflow['tasks'].first
|
|
230
|
+
puts "Wait task status: #{wait_task['status']}"
|
|
231
|
+
puts "Number of tasks: #{workflow['tasks'].length} (should be limited while paused)"
|
|
232
|
+
|
|
233
|
+
puts
|
|
234
|
+
puts 'Resuming workflow...'
|
|
235
|
+
workflow_client.resume_workflow(workflow_id)
|
|
236
|
+
|
|
237
|
+
sleep 1
|
|
238
|
+
workflow = workflow_client.get_workflow(workflow_id, include_tasks: true)
|
|
239
|
+
puts "Workflow status after resume: #{workflow['status']}"
|
|
240
|
+
puts "Number of tasks after resume: #{workflow['tasks'].length}"
|
|
241
|
+
|
|
242
|
+
# ============================================================================
|
|
243
|
+
# SEARCH WORKFLOWS
|
|
244
|
+
# ============================================================================
|
|
245
|
+
|
|
246
|
+
puts
|
|
247
|
+
puts 'Searching for workflows with correlation_id "correlation_123"...'
|
|
248
|
+
|
|
249
|
+
search_results = workflow_client.search(
|
|
250
|
+
start: 0,
|
|
251
|
+
size: 100,
|
|
252
|
+
free_text: '*',
|
|
253
|
+
query: 'correlationId = "correlation_123"'
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
puts "Found #{search_results['results']&.length || 0} workflow(s) with correlation_id 'correlation_123'"
|
|
257
|
+
|
|
258
|
+
# Search for a random correlation ID (should find nothing)
|
|
259
|
+
random_correlation_id = SecureRandom.uuid
|
|
260
|
+
search_results = workflow_client.search(
|
|
261
|
+
start: 0,
|
|
262
|
+
size: 100,
|
|
263
|
+
free_text: '*',
|
|
264
|
+
query: "status IN (RUNNING) AND correlationId = \"#{random_correlation_id}\""
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
puts "Found #{search_results['results']&.length || 0} workflow(s) with random correlation_id (expected: 0)"
|
|
268
|
+
|
|
269
|
+
# ============================================================================
|
|
270
|
+
# CLEANUP
|
|
271
|
+
# ============================================================================
|
|
272
|
+
|
|
273
|
+
puts
|
|
274
|
+
puts 'Terminating workflow for cleanup...'
|
|
275
|
+
workflow_client.terminate_workflow(workflow_id, reason: 'cleanup after demo')
|
|
276
|
+
|
|
277
|
+
puts
|
|
278
|
+
puts '-' * 70
|
|
279
|
+
puts 'Workflow Operations Demo Complete!'
|
|
280
|
+
puts '-' * 70
|
|
281
|
+
puts
|
|
282
|
+
puts 'Operations demonstrated:'
|
|
283
|
+
puts ' - Start workflow'
|
|
284
|
+
puts ' - Get workflow status'
|
|
285
|
+
puts ' - Terminate workflow'
|
|
286
|
+
puts ' - Retry workflow'
|
|
287
|
+
puts ' - Update task manually'
|
|
288
|
+
puts ' - Rerun workflow from task'
|
|
289
|
+
puts ' - Restart workflow'
|
|
290
|
+
puts ' - Pause workflow'
|
|
291
|
+
puts ' - Resume workflow'
|
|
292
|
+
puts ' - Search workflows'
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
if __FILE__ == $PROGRAM_NAME
|
|
296
|
+
begin
|
|
297
|
+
main
|
|
298
|
+
rescue Conductor::ApiError => e
|
|
299
|
+
puts "API Error: #{e.message}"
|
|
300
|
+
puts e.backtrace.first(5).join("\n")
|
|
301
|
+
rescue StandardError => e
|
|
302
|
+
puts "Error: #{e.message}"
|
|
303
|
+
puts e.backtrace.first(5).join("\n")
|
|
304
|
+
end
|
|
305
|
+
end
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Client
|
|
5
|
+
# AuthorizationClient - High-level client for authorization operations (Orkes)
|
|
6
|
+
# Delegates to 6 resource APIs: application, user, group, authorization, role, token, gateway_auth
|
|
7
|
+
class AuthorizationClient
|
|
8
|
+
def initialize(api_client)
|
|
9
|
+
@application_api = Http::Api::ApplicationResourceApi.new(api_client)
|
|
10
|
+
@user_api = Http::Api::UserResourceApi.new(api_client)
|
|
11
|
+
@group_api = Http::Api::GroupResourceApi.new(api_client)
|
|
12
|
+
@authorization_api = Http::Api::AuthorizationResourceApi.new(api_client)
|
|
13
|
+
@role_api = Http::Api::RoleResourceApi.new(api_client)
|
|
14
|
+
@token_api = Http::Api::TokenResourceApi.new(api_client)
|
|
15
|
+
@gateway_auth_api = Http::Api::GatewayAuthResourceApi.new(api_client)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# === Applications ===
|
|
19
|
+
|
|
20
|
+
def create_application(request)
|
|
21
|
+
@application_api.create_application(request)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_application(application_id)
|
|
25
|
+
@application_api.get_application(application_id)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def list_applications
|
|
29
|
+
@application_api.list_applications
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update_application(request, application_id)
|
|
33
|
+
@application_api.update_application(request, application_id)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def delete_application(application_id)
|
|
37
|
+
@application_api.delete_application(application_id)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def add_role_to_application_user(application_id, role)
|
|
41
|
+
@application_api.add_role_to_application_user(application_id, role)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def remove_role_from_application_user(application_id, role)
|
|
45
|
+
@application_api.remove_role_from_application_user(application_id, role)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def set_application_tags(tags, application_id)
|
|
49
|
+
@application_api.put_tags_for_application(tags, application_id)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_application_tags(application_id)
|
|
53
|
+
@application_api.get_tags_for_application(application_id)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def delete_application_tags(tags, application_id)
|
|
57
|
+
@application_api.delete_tags_for_application(tags, application_id)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def create_access_key(application_id)
|
|
61
|
+
@application_api.create_access_key(application_id)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def get_access_keys(application_id)
|
|
65
|
+
@application_api.get_access_keys(application_id)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def toggle_access_key_status(application_id, key_id)
|
|
69
|
+
@application_api.toggle_access_key_status(application_id, key_id)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def delete_access_key(application_id, key_id)
|
|
73
|
+
@application_api.delete_access_key(application_id, key_id)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def get_app_by_access_key_id(access_key_id)
|
|
77
|
+
@application_api.get_app_by_access_key_id(access_key_id)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# === Users ===
|
|
81
|
+
|
|
82
|
+
def upsert_user(request, user_id)
|
|
83
|
+
@user_api.upsert_user(request, user_id)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def get_user(user_id)
|
|
87
|
+
@user_api.get_user(user_id)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def list_users(apps: false)
|
|
91
|
+
@user_api.list_users(apps: apps)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def delete_user(user_id)
|
|
95
|
+
@user_api.delete_user(user_id)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def check_permissions(user_id, target_type, target_id)
|
|
99
|
+
@user_api.check_permissions(user_id, target_type, target_id)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def get_granted_permissions_for_user(user_id)
|
|
103
|
+
@user_api.get_granted_permissions(user_id)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# === Groups ===
|
|
107
|
+
|
|
108
|
+
def upsert_group(request, group_id)
|
|
109
|
+
@group_api.upsert_group(request, group_id)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def get_group(group_id)
|
|
113
|
+
@group_api.get_group(group_id)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def list_groups
|
|
117
|
+
@group_api.list_groups
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def delete_group(group_id)
|
|
121
|
+
@group_api.delete_group(group_id)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def add_user_to_group(group_id, user_id)
|
|
125
|
+
@group_api.add_user_to_group(group_id, user_id)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def get_users_in_group(group_id)
|
|
129
|
+
@group_api.get_users_in_group(group_id)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def remove_user_from_group(group_id, user_id)
|
|
133
|
+
@group_api.remove_user_from_group(group_id, user_id)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def add_users_to_group(group_id, user_ids)
|
|
137
|
+
@group_api.add_users_to_group(group_id, user_ids)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def remove_users_from_group(group_id, user_ids)
|
|
141
|
+
@group_api.remove_users_from_group(group_id, user_ids)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def get_granted_permissions_for_group(group_id)
|
|
145
|
+
@group_api.get_granted_permissions(group_id)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# === Permissions ===
|
|
149
|
+
|
|
150
|
+
def grant_permissions(subject, target, access)
|
|
151
|
+
request = Http::Models::AuthorizationRequest.new(
|
|
152
|
+
subject: subject, target: target, access: access
|
|
153
|
+
)
|
|
154
|
+
@authorization_api.grant_permissions(request)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def get_permissions(target)
|
|
158
|
+
@authorization_api.get_permissions(target.type, target.id)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def remove_permissions(subject, target, access)
|
|
162
|
+
request = Http::Models::AuthorizationRequest.new(
|
|
163
|
+
subject: subject, target: target, access: access
|
|
164
|
+
)
|
|
165
|
+
@authorization_api.remove_permissions(request)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# === Tokens ===
|
|
169
|
+
|
|
170
|
+
def generate_token(key_id, key_secret)
|
|
171
|
+
request = Http::Models::GenerateTokenRequest.new(
|
|
172
|
+
key_id: key_id, key_secret: key_secret
|
|
173
|
+
)
|
|
174
|
+
@token_api.generate_token(request)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def get_user_info_from_token
|
|
178
|
+
@token_api.get_user_info
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# === Roles ===
|
|
182
|
+
|
|
183
|
+
def list_all_roles
|
|
184
|
+
@role_api.list_all_roles
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def list_system_roles
|
|
188
|
+
@role_api.list_system_roles
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def list_custom_roles
|
|
192
|
+
@role_api.list_custom_roles
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def list_available_permissions
|
|
196
|
+
@role_api.list_available_permissions
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def create_role(request)
|
|
200
|
+
@role_api.create_role(request)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def get_role(role_name)
|
|
204
|
+
@role_api.get_role(role_name)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def update_role(role_name, request)
|
|
208
|
+
@role_api.update_role(role_name, request)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def delete_role(role_name)
|
|
212
|
+
@role_api.delete_role(role_name)
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# === Gateway Auth Config ===
|
|
216
|
+
|
|
217
|
+
def create_gateway_auth_config(auth_config)
|
|
218
|
+
@gateway_auth_api.create_config(auth_config)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def get_gateway_auth_config(config_id)
|
|
222
|
+
@gateway_auth_api.get_config(config_id)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def list_gateway_auth_configs
|
|
226
|
+
@gateway_auth_api.list_configs
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def update_gateway_auth_config(config_id, auth_config)
|
|
230
|
+
@gateway_auth_api.update_config(config_id, auth_config)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def delete_gateway_auth_config(config_id)
|
|
234
|
+
@gateway_auth_api.delete_config(config_id)
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Client
|
|
5
|
+
# IntegrationClient - High-level client for integration management operations (Orkes)
|
|
6
|
+
class IntegrationClient
|
|
7
|
+
def initialize(api_client)
|
|
8
|
+
@integration_api = Http::Api::IntegrationResourceApi.new(api_client)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# === Integration Providers ===
|
|
12
|
+
|
|
13
|
+
def save_integration(integration_name, integration_details)
|
|
14
|
+
@integration_api.save_integration(integration_details, integration_name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_integration(integration_name)
|
|
18
|
+
@integration_api.get_integration(integration_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get_integrations
|
|
22
|
+
@integration_api.get_integrations
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete_integration(integration_name)
|
|
26
|
+
@integration_api.delete_integration(integration_name)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# === Integration APIs ===
|
|
30
|
+
|
|
31
|
+
def save_integration_api(integration_name, api_name, api_details)
|
|
32
|
+
@integration_api.save_integration_api(api_details, integration_name, api_name)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_integration_api(api_name, integration_name)
|
|
36
|
+
@integration_api.get_integration_api(integration_name, api_name)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_integration_apis(integration_name)
|
|
40
|
+
@integration_api.get_integration_apis(integration_name)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def delete_integration_api(api_name, integration_name)
|
|
44
|
+
@integration_api.delete_integration_api(integration_name, api_name)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# === Prompts ===
|
|
48
|
+
|
|
49
|
+
def associate_prompt_with_integration(ai_integration, model_name, prompt_name)
|
|
50
|
+
@integration_api.associate_prompt_with_integration(ai_integration, model_name, prompt_name)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def get_prompts_with_integration(ai_integration, model_name)
|
|
54
|
+
@integration_api.get_prompts_with_integration(ai_integration, model_name)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# === Token Usage ===
|
|
58
|
+
|
|
59
|
+
def get_token_usage_for_integration(name, integration_name)
|
|
60
|
+
@integration_api.get_token_usage_for_integration(name, integration_name)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def get_token_usage_for_integration_provider(name)
|
|
64
|
+
@integration_api.get_token_usage_for_integration_provider(name)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# === Tags ===
|
|
68
|
+
|
|
69
|
+
def put_tag_for_integration(body, name, integration_name)
|
|
70
|
+
@integration_api.put_tag_for_integration(body, name, integration_name)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def get_tags_for_integration(name, integration_name)
|
|
74
|
+
@integration_api.get_tags_for_integration(name, integration_name)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def delete_tag_for_integration(body, name, integration_name)
|
|
78
|
+
@integration_api.delete_tag_for_integration(body, name, integration_name)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def put_tag_for_integration_provider(body, name)
|
|
82
|
+
@integration_api.put_tag_for_integration_provider(body, name)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def get_tags_for_integration_provider(name)
|
|
86
|
+
@integration_api.get_tags_for_integration_provider(name)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def delete_tag_for_integration_provider(body, name)
|
|
90
|
+
@integration_api.delete_tag_for_integration_provider(body, name)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# === Discovery ===
|
|
94
|
+
|
|
95
|
+
def get_integration_available_apis(integration_name)
|
|
96
|
+
@integration_api.get_integration_available_apis(integration_name)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def get_integration_provider_defs
|
|
100
|
+
@integration_api.get_integration_provider_defs
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def get_providers_and_integrations
|
|
104
|
+
@integration_api.get_providers_and_integrations
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|