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,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_model'
|
|
4
|
+
|
|
5
|
+
module Conductor
|
|
6
|
+
module Http
|
|
7
|
+
module Models
|
|
8
|
+
# Task model representing a task in a workflow
|
|
9
|
+
class Task < BaseModel
|
|
10
|
+
SWAGGER_TYPES = {
|
|
11
|
+
task_type: 'String',
|
|
12
|
+
status: 'String',
|
|
13
|
+
input_data: 'Hash<String, Object>',
|
|
14
|
+
reference_task_name: 'String',
|
|
15
|
+
retry_count: 'Integer',
|
|
16
|
+
seq: 'Integer',
|
|
17
|
+
correlation_id: 'String',
|
|
18
|
+
poll_count: 'Integer',
|
|
19
|
+
task_def_name: 'String',
|
|
20
|
+
scheduled_time: 'Integer',
|
|
21
|
+
start_time: 'Integer',
|
|
22
|
+
end_time: 'Integer',
|
|
23
|
+
update_time: 'Integer',
|
|
24
|
+
start_delay_in_seconds: 'Integer',
|
|
25
|
+
retried_task_id: 'String',
|
|
26
|
+
retried: 'Boolean',
|
|
27
|
+
executed: 'Boolean',
|
|
28
|
+
callback_from_worker: 'Boolean',
|
|
29
|
+
response_timeout_seconds: 'Integer',
|
|
30
|
+
workflow_instance_id: 'String',
|
|
31
|
+
workflow_type: 'String',
|
|
32
|
+
task_id: 'String',
|
|
33
|
+
reason_for_incompletion: 'String',
|
|
34
|
+
callback_after_seconds: 'Integer',
|
|
35
|
+
worker_id: 'String',
|
|
36
|
+
output_data: 'Hash<String, Object>',
|
|
37
|
+
workflow_task: 'WorkflowTask',
|
|
38
|
+
domain: 'String',
|
|
39
|
+
rate_limit_per_frequency: 'Integer',
|
|
40
|
+
rate_limit_frequency_in_seconds: 'Integer',
|
|
41
|
+
external_input_payload_storage_path: 'String',
|
|
42
|
+
external_output_payload_storage_path: 'String',
|
|
43
|
+
workflow_priority: 'Integer',
|
|
44
|
+
execution_name_space: 'String',
|
|
45
|
+
isolation_group_id: 'String',
|
|
46
|
+
iteration: 'Integer',
|
|
47
|
+
sub_workflow_id: 'String',
|
|
48
|
+
subworkflow_changed: 'Boolean',
|
|
49
|
+
parent_task_id: 'String',
|
|
50
|
+
first_start_time: 'Integer',
|
|
51
|
+
loop_over_task: 'Boolean',
|
|
52
|
+
task_definition: 'TaskDef',
|
|
53
|
+
queue_wait_time: 'Integer'
|
|
54
|
+
}.freeze
|
|
55
|
+
|
|
56
|
+
ATTRIBUTE_MAP = {
|
|
57
|
+
task_type: :taskType,
|
|
58
|
+
status: :status,
|
|
59
|
+
input_data: :inputData,
|
|
60
|
+
reference_task_name: :referenceTaskName,
|
|
61
|
+
retry_count: :retryCount,
|
|
62
|
+
seq: :seq,
|
|
63
|
+
correlation_id: :correlationId,
|
|
64
|
+
poll_count: :pollCount,
|
|
65
|
+
task_def_name: :taskDefName,
|
|
66
|
+
scheduled_time: :scheduledTime,
|
|
67
|
+
start_time: :startTime,
|
|
68
|
+
end_time: :endTime,
|
|
69
|
+
update_time: :updateTime,
|
|
70
|
+
start_delay_in_seconds: :startDelayInSeconds,
|
|
71
|
+
retried_task_id: :retriedTaskId,
|
|
72
|
+
retried: :retried,
|
|
73
|
+
executed: :executed,
|
|
74
|
+
callback_from_worker: :callbackFromWorker,
|
|
75
|
+
response_timeout_seconds: :responseTimeoutSeconds,
|
|
76
|
+
workflow_instance_id: :workflowInstanceId,
|
|
77
|
+
workflow_type: :workflowType,
|
|
78
|
+
task_id: :taskId,
|
|
79
|
+
reason_for_incompletion: :reasonForIncompletion,
|
|
80
|
+
callback_after_seconds: :callbackAfterSeconds,
|
|
81
|
+
worker_id: :workerId,
|
|
82
|
+
output_data: :outputData,
|
|
83
|
+
workflow_task: :workflowTask,
|
|
84
|
+
domain: :domain,
|
|
85
|
+
rate_limit_per_frequency: :rateLimitPerFrequency,
|
|
86
|
+
rate_limit_frequency_in_seconds: :rateLimitFrequencyInSeconds,
|
|
87
|
+
external_input_payload_storage_path: :externalInputPayloadStoragePath,
|
|
88
|
+
external_output_payload_storage_path: :externalOutputPayloadStoragePath,
|
|
89
|
+
workflow_priority: :workflowPriority,
|
|
90
|
+
execution_name_space: :executionNameSpace,
|
|
91
|
+
isolation_group_id: :isolationGroupId,
|
|
92
|
+
iteration: :iteration,
|
|
93
|
+
sub_workflow_id: :subWorkflowId,
|
|
94
|
+
subworkflow_changed: :subworkflowChanged,
|
|
95
|
+
parent_task_id: :parentTaskId,
|
|
96
|
+
first_start_time: :firstStartTime,
|
|
97
|
+
loop_over_task: :loopOverTask,
|
|
98
|
+
task_definition: :taskDefinition,
|
|
99
|
+
queue_wait_time: :queueWaitTime
|
|
100
|
+
}.freeze
|
|
101
|
+
|
|
102
|
+
attr_accessor :task_type, :status, :input_data, :reference_task_name,
|
|
103
|
+
:retry_count, :seq, :correlation_id, :poll_count, :task_def_name,
|
|
104
|
+
:scheduled_time, :start_time, :end_time, :update_time,
|
|
105
|
+
:start_delay_in_seconds, :retried_task_id, :retried, :executed,
|
|
106
|
+
:callback_from_worker, :response_timeout_seconds, :workflow_instance_id,
|
|
107
|
+
:workflow_type, :task_id, :reason_for_incompletion,
|
|
108
|
+
:callback_after_seconds, :worker_id, :output_data, :workflow_task,
|
|
109
|
+
:domain, :rate_limit_per_frequency, :rate_limit_frequency_in_seconds,
|
|
110
|
+
:external_input_payload_storage_path, :external_output_payload_storage_path,
|
|
111
|
+
:workflow_priority, :execution_name_space, :isolation_group_id,
|
|
112
|
+
:iteration, :sub_workflow_id, :subworkflow_changed, :parent_task_id,
|
|
113
|
+
:first_start_time, :loop_over_task, :task_definition, :queue_wait_time
|
|
114
|
+
|
|
115
|
+
# Initialize a new Task
|
|
116
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
117
|
+
def initialize(attributes = {})
|
|
118
|
+
return unless attributes.is_a?(Hash)
|
|
119
|
+
|
|
120
|
+
# Set all attributes from the hash
|
|
121
|
+
SWAGGER_TYPES.each_key do |key|
|
|
122
|
+
send("#{key}=", attributes[key]) if attributes.key?(key)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Set default values for collections
|
|
126
|
+
@input_data ||= {}
|
|
127
|
+
@output_data ||= {}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Check if task is in terminal state
|
|
131
|
+
# @return [Boolean] true if task is completed, failed, or cancelled
|
|
132
|
+
def terminal?
|
|
133
|
+
%w[COMPLETED FAILED FAILED_WITH_TERMINAL_ERROR CANCELED TIMED_OUT SKIPPED].include?(status)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Check if task completed successfully
|
|
137
|
+
# @return [Boolean] true if task status is COMPLETED
|
|
138
|
+
def completed?
|
|
139
|
+
status == 'COMPLETED'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Check if task failed
|
|
143
|
+
# @return [Boolean] true if task status is FAILED or FAILED_WITH_TERMINAL_ERROR
|
|
144
|
+
def failed?
|
|
145
|
+
%w[FAILED FAILED_WITH_TERMINAL_ERROR].include?(status)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Check if task is in progress
|
|
149
|
+
# @return [Boolean] true if task status is IN_PROGRESS or SCHEDULED
|
|
150
|
+
def in_progress?
|
|
151
|
+
%w[IN_PROGRESS SCHEDULED].include?(status)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Http
|
|
5
|
+
module Models
|
|
6
|
+
# Retry logic options for task definitions
|
|
7
|
+
module RetryLogic
|
|
8
|
+
FIXED = 'FIXED'
|
|
9
|
+
EXPONENTIAL_BACKOFF = 'EXPONENTIAL_BACKOFF'
|
|
10
|
+
LINEAR_BACKOFF = 'LINEAR_BACKOFF'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Timeout policy for task definitions
|
|
14
|
+
module TaskTimeoutPolicy
|
|
15
|
+
RETRY = 'RETRY'
|
|
16
|
+
TIME_OUT_WF = 'TIME_OUT_WF'
|
|
17
|
+
ALERT_ONLY = 'ALERT_ONLY'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Task definition model for registering task types with Conductor
|
|
21
|
+
class TaskDef < BaseModel
|
|
22
|
+
SWAGGER_TYPES = {
|
|
23
|
+
name: 'String',
|
|
24
|
+
description: 'String',
|
|
25
|
+
retry_count: 'Integer',
|
|
26
|
+
timeout_seconds: 'Integer',
|
|
27
|
+
input_keys: 'Array<String>',
|
|
28
|
+
output_keys: 'Array<String>',
|
|
29
|
+
timeout_policy: 'String',
|
|
30
|
+
retry_logic: 'String',
|
|
31
|
+
retry_delay_seconds: 'Integer',
|
|
32
|
+
response_timeout_seconds: 'Integer',
|
|
33
|
+
concurrent_exec_limit: 'Integer',
|
|
34
|
+
rate_limit_per_frequency: 'Integer',
|
|
35
|
+
rate_limit_frequency_in_seconds: 'Integer',
|
|
36
|
+
isolation_group_id: 'String',
|
|
37
|
+
execution_name_space: 'String',
|
|
38
|
+
owner_email: 'String',
|
|
39
|
+
poll_timeout_seconds: 'Integer',
|
|
40
|
+
backoff_scale_factor: 'Integer'
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
43
|
+
ATTRIBUTE_MAP = {
|
|
44
|
+
name: :name,
|
|
45
|
+
description: :description,
|
|
46
|
+
retry_count: :retryCount,
|
|
47
|
+
timeout_seconds: :timeoutSeconds,
|
|
48
|
+
input_keys: :inputKeys,
|
|
49
|
+
output_keys: :outputKeys,
|
|
50
|
+
timeout_policy: :timeoutPolicy,
|
|
51
|
+
retry_logic: :retryLogic,
|
|
52
|
+
retry_delay_seconds: :retryDelaySeconds,
|
|
53
|
+
response_timeout_seconds: :responseTimeoutSeconds,
|
|
54
|
+
concurrent_exec_limit: :concurrentExecLimit,
|
|
55
|
+
rate_limit_per_frequency: :rateLimitPerFrequency,
|
|
56
|
+
rate_limit_frequency_in_seconds: :rateLimitFrequencyInSeconds,
|
|
57
|
+
isolation_group_id: :isolationGroupId,
|
|
58
|
+
execution_name_space: :executionNameSpace,
|
|
59
|
+
owner_email: :ownerEmail,
|
|
60
|
+
poll_timeout_seconds: :pollTimeoutSeconds,
|
|
61
|
+
backoff_scale_factor: :backoffScaleFactor
|
|
62
|
+
}.freeze
|
|
63
|
+
|
|
64
|
+
attr_accessor :name, :description, :retry_count, :timeout_seconds,
|
|
65
|
+
:input_keys, :output_keys, :timeout_policy, :retry_logic,
|
|
66
|
+
:retry_delay_seconds, :response_timeout_seconds,
|
|
67
|
+
:concurrent_exec_limit, :rate_limit_per_frequency,
|
|
68
|
+
:rate_limit_frequency_in_seconds, :isolation_group_id,
|
|
69
|
+
:execution_name_space, :owner_email, :poll_timeout_seconds,
|
|
70
|
+
:backoff_scale_factor
|
|
71
|
+
|
|
72
|
+
def initialize(params = {})
|
|
73
|
+
@name = params[:name]
|
|
74
|
+
@description = params[:description]
|
|
75
|
+
@retry_count = params[:retry_count] || 3
|
|
76
|
+
@timeout_seconds = params[:timeout_seconds] || 3600
|
|
77
|
+
@input_keys = params[:input_keys] || []
|
|
78
|
+
@output_keys = params[:output_keys] || []
|
|
79
|
+
@timeout_policy = params[:timeout_policy] || TaskTimeoutPolicy::TIME_OUT_WF
|
|
80
|
+
@retry_logic = params[:retry_logic] || RetryLogic::FIXED
|
|
81
|
+
@retry_delay_seconds = params[:retry_delay_seconds] || 60
|
|
82
|
+
@response_timeout_seconds = params[:response_timeout_seconds] || 600
|
|
83
|
+
@concurrent_exec_limit = params[:concurrent_exec_limit]
|
|
84
|
+
@rate_limit_per_frequency = params[:rate_limit_per_frequency]
|
|
85
|
+
@rate_limit_frequency_in_seconds = params[:rate_limit_frequency_in_seconds]
|
|
86
|
+
@isolation_group_id = params[:isolation_group_id]
|
|
87
|
+
@execution_name_space = params[:execution_name_space]
|
|
88
|
+
@owner_email = params[:owner_email]
|
|
89
|
+
@poll_timeout_seconds = params[:poll_timeout_seconds]
|
|
90
|
+
@backoff_scale_factor = params[:backoff_scale_factor] || 1
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Http
|
|
5
|
+
module Models
|
|
6
|
+
# Task execution log entry
|
|
7
|
+
class TaskExecLog < BaseModel
|
|
8
|
+
SWAGGER_TYPES = {
|
|
9
|
+
log: 'String',
|
|
10
|
+
task_id: 'String',
|
|
11
|
+
created_time: 'Integer'
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
ATTRIBUTE_MAP = {
|
|
15
|
+
log: :log,
|
|
16
|
+
task_id: :taskId,
|
|
17
|
+
created_time: :createdTime
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
attr_accessor :log, :task_id, :created_time
|
|
21
|
+
|
|
22
|
+
def initialize(params = {})
|
|
23
|
+
@log = params[:log]
|
|
24
|
+
@task_id = params[:task_id]
|
|
25
|
+
@created_time = params[:created_time]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_model'
|
|
4
|
+
require_relative 'task_result_status'
|
|
5
|
+
|
|
6
|
+
module Conductor
|
|
7
|
+
module Http
|
|
8
|
+
module Models
|
|
9
|
+
# TaskResult model representing the result of task execution
|
|
10
|
+
class TaskResult < BaseModel
|
|
11
|
+
SWAGGER_TYPES = {
|
|
12
|
+
workflow_instance_id: 'String',
|
|
13
|
+
task_id: 'String',
|
|
14
|
+
reason_for_incompletion: 'String',
|
|
15
|
+
callback_after_seconds: 'Integer',
|
|
16
|
+
worker_id: 'String',
|
|
17
|
+
status: 'String',
|
|
18
|
+
output_data: 'Hash<String, Object>',
|
|
19
|
+
logs: 'Array<TaskExecLog>',
|
|
20
|
+
external_output_payload_storage_path: 'String',
|
|
21
|
+
sub_workflow_id: 'String',
|
|
22
|
+
extend_lease: 'Boolean'
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
ATTRIBUTE_MAP = {
|
|
26
|
+
workflow_instance_id: :workflowInstanceId,
|
|
27
|
+
task_id: :taskId,
|
|
28
|
+
reason_for_incompletion: :reasonForIncompletion,
|
|
29
|
+
callback_after_seconds: :callbackAfterSeconds,
|
|
30
|
+
worker_id: :workerId,
|
|
31
|
+
status: :status,
|
|
32
|
+
output_data: :outputData,
|
|
33
|
+
logs: :logs,
|
|
34
|
+
external_output_payload_storage_path: :externalOutputPayloadStoragePath,
|
|
35
|
+
sub_workflow_id: :subWorkflowId,
|
|
36
|
+
extend_lease: :extendLease
|
|
37
|
+
}.freeze
|
|
38
|
+
|
|
39
|
+
attr_accessor :workflow_instance_id, :task_id, :reason_for_incompletion,
|
|
40
|
+
:callback_after_seconds, :worker_id, :status, :output_data,
|
|
41
|
+
:logs, :external_output_payload_storage_path, :sub_workflow_id,
|
|
42
|
+
:extend_lease
|
|
43
|
+
|
|
44
|
+
# Initialize a new TaskResult
|
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
46
|
+
def initialize(attributes = {})
|
|
47
|
+
return unless attributes.is_a?(Hash)
|
|
48
|
+
|
|
49
|
+
self.workflow_instance_id = attributes[:workflow_instance_id] if attributes.key?(:workflow_instance_id)
|
|
50
|
+
self.task_id = attributes[:task_id] if attributes.key?(:task_id)
|
|
51
|
+
self.reason_for_incompletion = attributes[:reason_for_incompletion] if attributes.key?(:reason_for_incompletion)
|
|
52
|
+
self.callback_after_seconds = attributes[:callback_after_seconds] if attributes.key?(:callback_after_seconds)
|
|
53
|
+
self.worker_id = attributes[:worker_id] if attributes.key?(:worker_id)
|
|
54
|
+
self.status = attributes[:status] if attributes.key?(:status)
|
|
55
|
+
self.output_data = attributes[:output_data] || {}
|
|
56
|
+
self.logs = attributes[:logs] || []
|
|
57
|
+
if attributes.key?(:external_output_payload_storage_path)
|
|
58
|
+
self.external_output_payload_storage_path = attributes[:external_output_payload_storage_path]
|
|
59
|
+
end
|
|
60
|
+
self.sub_workflow_id = attributes[:sub_workflow_id] if attributes.key?(:sub_workflow_id)
|
|
61
|
+
self.extend_lease = attributes[:extend_lease] || false
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Add a key-value pair to output_data
|
|
65
|
+
# @param [String] key The key
|
|
66
|
+
# @param [Object] value The value
|
|
67
|
+
# @return [TaskResult] self for chaining
|
|
68
|
+
def add_output_data(key, value)
|
|
69
|
+
@output_data ||= {}
|
|
70
|
+
@output_data[key] = value
|
|
71
|
+
self
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Add a log message
|
|
75
|
+
# @param [String] log_message The log message
|
|
76
|
+
# @return [TaskResult] self for chaining
|
|
77
|
+
def log(log_message)
|
|
78
|
+
@logs ||= []
|
|
79
|
+
@logs << log_message
|
|
80
|
+
self
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Create a COMPLETED task result
|
|
84
|
+
# @return [TaskResult]
|
|
85
|
+
def self.complete
|
|
86
|
+
new(status: TaskResultStatus::COMPLETED)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Create a FAILED task result
|
|
90
|
+
# @param [String] failure_reason Optional failure reason
|
|
91
|
+
# @return [TaskResult]
|
|
92
|
+
def self.failed(failure_reason = nil)
|
|
93
|
+
result = new(status: TaskResultStatus::FAILED)
|
|
94
|
+
result.reason_for_incompletion = failure_reason if failure_reason
|
|
95
|
+
result
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Create an IN_PROGRESS task result
|
|
99
|
+
# @return [TaskResult]
|
|
100
|
+
def self.in_progress
|
|
101
|
+
new(status: TaskResultStatus::IN_PROGRESS)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Create a FAILED_WITH_TERMINAL_ERROR task result
|
|
105
|
+
# @param [String] failure_reason Optional failure reason
|
|
106
|
+
# @return [TaskResult]
|
|
107
|
+
def self.failed_with_terminal_error(failure_reason = nil)
|
|
108
|
+
result = new(status: TaskResultStatus::FAILED_WITH_TERMINAL_ERROR)
|
|
109
|
+
result.reason_for_incompletion = failure_reason if failure_reason
|
|
110
|
+
result
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Http
|
|
5
|
+
module Models
|
|
6
|
+
# TaskResultStatus enum representing the status of task execution
|
|
7
|
+
module TaskResultStatus
|
|
8
|
+
COMPLETED = 'COMPLETED'
|
|
9
|
+
FAILED = 'FAILED'
|
|
10
|
+
FAILED_WITH_TERMINAL_ERROR = 'FAILED_WITH_TERMINAL_ERROR'
|
|
11
|
+
IN_PROGRESS = 'IN_PROGRESS'
|
|
12
|
+
|
|
13
|
+
ALL = [COMPLETED, FAILED, FAILED_WITH_TERMINAL_ERROR, IN_PROGRESS].freeze
|
|
14
|
+
|
|
15
|
+
# Check if the given status is valid
|
|
16
|
+
# @param [String] status The status to validate
|
|
17
|
+
# @return [Boolean] true if valid, false otherwise
|
|
18
|
+
def self.valid?(status)
|
|
19
|
+
ALL.include?(status)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_model'
|
|
4
|
+
|
|
5
|
+
module Conductor
|
|
6
|
+
module Http
|
|
7
|
+
module Models
|
|
8
|
+
# Token model representing the authentication token response from Conductor server
|
|
9
|
+
class Token < BaseModel
|
|
10
|
+
SWAGGER_TYPES = {
|
|
11
|
+
token: 'String',
|
|
12
|
+
user_id: 'String'
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
ATTRIBUTE_MAP = {
|
|
16
|
+
token: :token,
|
|
17
|
+
user_id: :userId
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
attr_accessor :token, :user_id
|
|
21
|
+
|
|
22
|
+
# Initialize a new Token
|
|
23
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
24
|
+
def initialize(attributes = {})
|
|
25
|
+
return unless attributes.is_a?(Hash)
|
|
26
|
+
|
|
27
|
+
self.token = attributes[:token] if attributes.key?(:token)
|
|
28
|
+
self.user_id = attributes[:user_id] if attributes.key?(:user_id)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Http
|
|
5
|
+
module Models
|
|
6
|
+
# UpsertGroupRequest model - request to create or update a group
|
|
7
|
+
class UpsertGroupRequest < BaseModel
|
|
8
|
+
SWAGGER_TYPES = {
|
|
9
|
+
default_access: 'Hash<String, Array<String>>',
|
|
10
|
+
description: 'String',
|
|
11
|
+
roles: 'Array<String>'
|
|
12
|
+
}.freeze
|
|
13
|
+
|
|
14
|
+
ATTRIBUTE_MAP = {
|
|
15
|
+
default_access: :defaultAccess,
|
|
16
|
+
description: :description,
|
|
17
|
+
roles: :roles
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
attr_accessor :default_access, :description, :roles
|
|
21
|
+
|
|
22
|
+
def initialize(params = {})
|
|
23
|
+
@default_access = params[:default_access]
|
|
24
|
+
@description = params[:description]
|
|
25
|
+
@roles = params[:roles]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Conductor
|
|
4
|
+
module Http
|
|
5
|
+
module Models
|
|
6
|
+
# User role constants
|
|
7
|
+
module UserRole
|
|
8
|
+
ADMIN = 'ADMIN'
|
|
9
|
+
USER = 'USER'
|
|
10
|
+
WORKER = 'WORKER'
|
|
11
|
+
METADATA_MANAGER = 'METADATA_MANAGER'
|
|
12
|
+
WORKFLOW_MANAGER = 'WORKFLOW_MANAGER'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# UpsertUserRequest model - request to create or update a user
|
|
16
|
+
class UpsertUserRequest < BaseModel
|
|
17
|
+
SWAGGER_TYPES = {
|
|
18
|
+
name: 'String',
|
|
19
|
+
roles: 'Array<String>',
|
|
20
|
+
groups: 'Array<String>'
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
ATTRIBUTE_MAP = {
|
|
24
|
+
name: :name,
|
|
25
|
+
roles: :roles,
|
|
26
|
+
groups: :groups
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
attr_accessor :name, :roles, :groups
|
|
30
|
+
|
|
31
|
+
def initialize(params = {})
|
|
32
|
+
@name = params[:name]
|
|
33
|
+
@roles = params[:roles]
|
|
34
|
+
@groups = params[:groups]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|