Class: Retab::Workflows

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

Instance Method Summary collapse

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

#create(name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow

Create Workflow

Parameters:

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

    The name of the workflow

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

    Description of the workflow

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

    (see Retab::Types::RequestOptions)

Returns:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/retab/workflows.rb', line 66

def create(
  name: nil,
  description: nil,
  request_options: {}
)
  body = {
    'name' => name,
    'description' => description
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/workflows',
    auth: true,
    body: body,
    request_options: 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

Parameters:

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

    (see Retab::Types::RequestOptions)



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/retab/workflows.rb', line 138

def delete(
  workflow_id:,
  request_options: {}
)
  response = @client.request(
    method: :delete,
    path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}",
    auth: true,
    request_options: request_options
  )
  nil
end

#diagnose(workflow_id:, blocks: nil, edges: nil, re_propagate: nil, request_options: {}) ⇒ Retab::WorkflowDiagnosisResponse

Diagnose Workflow Graph

Parameters:

  • workflow_id (String)
  • blocks (Array<Retab::WorkflowConfigBlock>, nil) (defaults to: nil)

    Blocks to diagnose; if omitted, the persisted draft is loaded server-side

  • edges (Array<Retab::WorkflowConfigEdge>, nil) (defaults to: nil)

    Edges to diagnose; if omitted, the persisted draft is loaded server-side

  • re_propagate (Boolean, nil) (defaults to: nil)

    Recompute derived schemas before validating the graph

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

    (see Retab::Types::RequestOptions)

Returns:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/retab/workflows.rb', line 158

def diagnose(
  workflow_id:,
  blocks: nil,
  edges: nil,
  re_propagate: nil,
  request_options: {}
)
  body = {
    'blocks' => blocks,
    'edges' => edges,
    're_propagate' => re_propagate
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/#{Retab::Util.encode_path(workflow_id)}/diagnose-graph",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowDiagnosisResponse.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(workflow_id:, request_options: {}) ⇒ Retab::Workflow

Get Workflow

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/retab/workflows.rb', line 91

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

#list(before: nil, after: nil, limit: 10, order: 'desc', sort_by: 'updated_at', request_options: {}) ⇒ Retab::Types::ListStruct<Retab::Workflow>

List Workflows

Parameters:

  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: 10)

    Items per page

  • order (Retab::Types::WorkflowsOrder, nil) (defaults to: 'desc')
  • sort_by (String, nil) (defaults to: 'updated_at')
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



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
56
57
58
59
# File 'lib/retab/workflows.rb', line 21

def list(
  before: nil,
  after: nil,
  limit: 10,
  order: 'desc',
  sort_by: 'updated_at',
  request_options: {}
)
  params = {
    'before' => before,
    'after' => after,
    'limit' => limit,
    'order' => order,
    'sort_by' => sort_by
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      sort_by: sort_by,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::Workflow,
    filters: { before: before, limit: limit, order: order, sort_by: sort_by },
    fetch_next: fetch_next
  )
end

#publish(workflow_id:, description: nil, request_options: {}) ⇒ Retab::Workflow

Publish Workflow

Parameters:

  • workflow_id (String)
  • description (String, nil) (defaults to: nil)

    Optional description for this published version

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

    (see Retab::Types::RequestOptions)

Returns:



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/retab/workflows.rb', line 187

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: 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

#update(workflow_id:, name: nil, description: nil, request_options: {}) ⇒ Retab::Workflow

Update Workflow

Parameters:

  • workflow_id (String)
  • name (String, nil) (defaults to: nil)

    The name of the workflow

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

    Description of the workflow

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

    (see Retab::Types::RequestOptions)

Returns:



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 112

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: 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