Class: Retab::Workflows
- Inherits:
-
Object
- Object
- Retab::Workflows
- Defined in:
- lib/retab/workflows.rb
Instance Method Summary collapse
-
#apply(yaml_definition:, project_id: nil, workflow_id: nil, request_options: {}) ⇒ Retab::DeclarativeApplyResponse
Apply Workflow Spec.
- #artifacts ⇒ Object
- #blocks ⇒ Object
-
#create(project_id:, name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow
Create Workflow.
-
#create_version_restore(workflow_version_id:, workflow_id:, request_options: {}) ⇒ Retab::Workflow
Restore Workflow Version.
-
#delete(workflow_id:, request_options: {}) ⇒ void
Delete Workflow.
-
#discard_draft(workflow_id:, request_options: {}) ⇒ Retab::Workflow
Discard Draft Workflow.
- #edges ⇒ Object
- #experiments ⇒ Object
-
#get(workflow_id:, request_options: {}) ⇒ Retab::Workflow
Get Workflow.
-
#get_version(workflow_version_id:, workflow_id:, request_options: {}) ⇒ Retab::WorkflowGraphVersion
Get Workflow Version.
-
#initialize(client) ⇒ Workflows
constructor
A new instance of Workflows.
-
#list(before: nil, after: nil, limit: 10, order: "desc", sort_by: "updated_at", project_id: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Workflow>
List Workflows.
-
#list_diff(workflow_id:, from_workflow_version_id:, to_workflow_version_id:, request_options: {}) ⇒ Retab::WorkflowGraphVersionDiff
Diff Workflow Versions.
-
#list_versions(workflow_id:, before: nil, after: nil, limit: 50, request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowGraphVersion>
List Workflow Versions.
-
#plan(yaml_definition:, project_id: nil, workflow_id: nil, request_options: {}) ⇒ Retab::DeclarativePlanResponse
Plan Workflow Spec.
-
#publish(workflow_id:, description: nil, request_options: {}) ⇒ Retab::Workflow
Publish Workflow.
- #reviews ⇒ Object
- #runs ⇒ Object
- #spec ⇒ Object
- #steps ⇒ Object
- #tests ⇒ Object
-
#update(workflow_id:, name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow
Update Workflow.
Constructor Details
#initialize(client) ⇒ Workflows
Returns a new instance of Workflows.
9 10 11 |
# File 'lib/retab/workflows.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#apply(yaml_definition:, project_id: nil, workflow_id: nil, request_options: {}) ⇒ Retab::DeclarativeApplyResponse
Apply Workflow Spec
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 |
# File 'lib/retab/workflows.rb', line 139 def apply( yaml_definition:, project_id: nil, workflow_id: nil, request_options: {} ) path = workflow_id.nil? ? "/v1/workflows/spec/apply" : "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/spec/apply" body = { "yaml_definition" => yaml_definition, "project_id" => project_id }.compact response = @client.request( method: :post, path: path, auth: true, body: body, request_options: ) result = Retab::DeclarativeApplyResponse.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#artifacts ⇒ Object
13 14 15 |
# File 'lib/retab/workflows.rb', line 13 def artifacts @artifacts ||= Retab::WorkflowArtifacts.new(@client) end |
#blocks ⇒ Object
17 18 19 |
# File 'lib/retab/workflows.rb', line 17 def blocks @blocks ||= Retab::WorkflowBlocks.new(@client) end |
#create(project_id:, name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow
Create Workflow
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/retab/workflows.rb', line 107 def create( project_id:, name: nil, description: nil, request_options: {} ) body = { "name" => name, "description" => description, "project_id" => project_id }.compact response = @client.request( method: :post, path: "/v1/workflows", auth: true, body: body, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::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_version_restore(workflow_version_id:, workflow_id:, request_options: {}) ⇒ Retab::Workflow
Restore Workflow Version
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/retab/workflows.rb', line 309 def create_version_restore( workflow_version_id:, workflow_id:, request_options: {} ) params = { "workflow_id" => workflow_id } response = @client.request( method: :post, path: "/v1/workflows/versions/#{Retab::Util.encode_path(workflow_version_id)}/restore", auth: true, params: params, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::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(workflow_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete Workflow
392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/retab/workflows.rb', line 392 def delete( workflow_id:, request_options: {} ) @client.request( method: :delete, path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}", auth: true, request_options: ) nil end |
#discard_draft(workflow_id:, request_options: {}) ⇒ Retab::Workflow
Discard Draft Workflow
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/retab/workflows.rb', line 409 def discard_draft( workflow_id:, request_options: {} ) response = @client.request( method: :post, path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/discard-draft", auth: true, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#edges ⇒ Object
21 22 23 |
# File 'lib/retab/workflows.rb', line 21 def edges @edges ||= Retab::WorkflowEdges.new(@client) end |
#experiments ⇒ Object
25 26 27 |
# File 'lib/retab/workflows.rb', line 25 def experiments @experiments ||= Retab::WorkflowExperiments.new(@client) end |
#get(workflow_id:, request_options: {}) ⇒ Retab::Workflow
Get Workflow
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/retab/workflows.rb', line 337 def get( workflow_id:, request_options: {} ) response = @client.request( method: :get, path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}", auth: true, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::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_version(workflow_version_id:, workflow_id:, request_options: {}) ⇒ Retab::WorkflowGraphVersion
Get Workflow Version
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/retab/workflows.rb', line 280 def get_version( workflow_version_id:, workflow_id:, request_options: {} ) params = { "workflow_id" => workflow_id } response = @client.request( method: :get, path: "/v1/workflows/versions/#{Retab::Util.encode_path(workflow_version_id)}", auth: true, params: params, request_options: ) result = Retab::WorkflowGraphVersion.new(response.body) result.last_response = Retab::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(before: nil, after: nil, limit: 10, order: "desc", sort_by: "updated_at", project_id: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Workflow>
List Workflows
58 59 60 61 62 63 64 65 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 94 95 96 97 98 99 |
# File 'lib/retab/workflows.rb', line 58 def list( before: nil, after: nil, limit: 10, order: "desc", sort_by: "updated_at", project_id: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "sort_by" => sort_by, "project_id" => project_id }.compact response = @client.request( method: :get, path: "/v1/workflows", auth: true, params: params, request_options: ) fetch_next = -> (cursor) { list( before: before, after: cursor, limit: limit, order: order, sort_by: sort_by, project_id: project_id, request_options: ) } Retab::PaginatedList.from_response( response, model: Retab::Workflow, filters: {before: before, limit: limit, order: order, sort_by: sort_by, project_id: project_id}, fetch_next: fetch_next ) end |
#list_diff(workflow_id:, from_workflow_version_id:, to_workflow_version_id:, request_options: {}) ⇒ Retab::WorkflowGraphVersionDiff
Diff Workflow Versions
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/retab/workflows.rb', line 248 def list_diff( workflow_id:, from_workflow_version_id:, to_workflow_version_id:, request_options: {} ) params = { "workflow_id" => workflow_id, "from_workflow_version_id" => from_workflow_version_id, "to_workflow_version_id" => to_workflow_version_id } response = @client.request( method: :get, path: "/v1/workflows/versions/diff", auth: true, params: params, request_options: ) result = Retab::WorkflowGraphVersionDiff.new(response.body) result.last_response = Retab::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_versions(workflow_id:, before: nil, after: nil, limit: 50, request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowGraphVersion>
List Workflow Versions
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/retab/workflows.rb', line 205 def list_versions( workflow_id:, before: nil, after: nil, limit: 50, request_options: {} ) params = { "workflow_id" => workflow_id, "before" => before, "after" => after, "limit" => limit }.compact response = @client.request( method: :get, path: "/v1/workflows/versions", auth: true, params: params, request_options: ) fetch_next = -> (cursor) { list_versions( workflow_id: workflow_id, before: before, after: cursor, limit: limit, request_options: ) } Retab::PaginatedList.from_response( response, model: Retab::WorkflowGraphVersion, filters: {workflow_id: workflow_id, before: before, limit: limit}, fetch_next: fetch_next ) end |
#plan(yaml_definition:, project_id: nil, workflow_id: nil, request_options: {}) ⇒ Retab::DeclarativePlanResponse
Plan Workflow Spec
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/retab/workflows.rb', line 171 def plan( yaml_definition:, project_id: nil, workflow_id: nil, request_options: {} ) path = workflow_id.nil? ? "/v1/workflows/spec/plan" : "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/spec/plan" body = { "yaml_definition" => yaml_definition, "project_id" => project_id }.compact response = @client.request( method: :post, path: path, auth: true, body: body, request_options: ) result = Retab::DeclarativePlanResponse.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#publish(workflow_id:, description: nil, request_options: {}) ⇒ Retab::Workflow
Publish Workflow
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/retab/workflows.rb', line 433 def publish( workflow_id:, description: nil, request_options: {} ) body = { "description" => description }.compact response = @client.request( method: :post, path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/publish", auth: true, body: body, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#reviews ⇒ Object
29 30 31 |
# File 'lib/retab/workflows.rb', line 29 def reviews @reviews ||= Retab::WorkflowReviews.new(@client) end |
#runs ⇒ Object
33 34 35 |
# File 'lib/retab/workflows.rb', line 33 def runs @runs ||= Retab::WorkflowRuns.new(@client) end |
#spec ⇒ Object
37 38 39 |
# File 'lib/retab/workflows.rb', line 37 def spec @spec ||= Retab::WorkflowSpec.new(@client) end |
#steps ⇒ Object
41 42 43 |
# File 'lib/retab/workflows.rb', line 41 def steps @steps ||= Retab::WorkflowSteps.new(@client) end |
#tests ⇒ Object
45 46 47 |
# File 'lib/retab/workflows.rb', line 45 def tests @tests ||= Retab::WorkflowTests.new(@client) end |
#update(workflow_id:, name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow
Update Workflow
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/retab/workflows.rb', line 362 def update( workflow_id:, name: nil, description: nil, request_options: {} ) body = { "name" => name, "description" => description }.compact response = @client.request( method: :patch, path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}", auth: true, body: body, request_options: ) result = Retab::Workflow.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |