Class: Retab::WorkflowSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/retab/workflow_spec.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowSpec

Returns a new instance of WorkflowSpec.



9
10
11
# File 'lib/retab/workflow_spec.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#get(workflow_id:, request_options: {}) ⇒ Retab::DeclarativeExportResponse

Export Workflow Spec

Parameters:

  • workflow_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/retab/workflow_spec.rb', line 47

def get(
  workflow_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/spec",
    auth: true,
    request_options: request_options
  )
  result = Retab::DeclarativeExportResponse.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

#validate(yaml_definition:, project_id: nil, request_options: {}) ⇒ Retab::DeclarativeValidationResponse

Validate Workflow Spec

Parameters:

  • yaml_definition (String)

    Workflow YAML definition

  • project_id (String, nil) (defaults to: nil)

    Project that should own a workflow created from this spec. Required when applying a spec that creates a new workflow.

  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/retab/workflow_spec.rb', line 18

def validate(
  yaml_definition:,
  project_id: nil,
  request_options: {}
)
  body = {
    "yaml_definition" => yaml_definition,
    "project_id" => project_id
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/spec/validate",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::DeclarativeValidationResponse.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