Class: Retab::WorkflowBlocks

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowBlocks

Returns a new instance of WorkflowBlocks.



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

def initialize(client)
  @client = client
end

Instance Method Details

#create(workflow_id:, type:, id: nil, label: nil, position_x: nil, position_y: nil, width: nil, height: nil, config: nil, parent_id: nil, request_options: {}) ⇒ Retab::WorkflowBlock

Create Block

Parameters:

  • workflow_id (String)

    Workflow to create the block in.

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

    Block ID. Omit to let the server generate one (recommended). Block IDs must be unique across your organization, not just within a workflow — reusing a custom id like ‘block_extract’ in more than one workflow fails with 409.

  • type (Retab::Types::WorkflowBlockCreateRequestType)

    Block type

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

    Display label

  • position_x (Float, nil) (defaults to: nil)

    X position

  • position_y (Float, nil) (defaults to: nil)

    Y position

  • width (Float, nil) (defaults to: nil)

    Block width

  • height (Float, nil) (defaults to: nil)

    Block height

  • config (Hash{String => Object}, nil) (defaults to: nil)

    Block configuration

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

    ID of parent container block (while_loop, for_each)

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

    (see Retab::Types::RequestOptions)

Returns:



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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/retab/workflow_blocks.rb', line 74

def create(
  workflow_id:,
  type:,
  id: nil,
  label: nil,
  position_x: nil,
  position_y: nil,
  width: nil,
  height: nil,
  config: nil,
  parent_id: nil,
  request_options: {}
)
  body = {
    "workflow_id" => workflow_id,
    "id" => id,
    "type" => type,
    "label" => label,
    "position_x" => position_x,
    "position_y" => position_y,
    "width" => width,
    "height" => height,
    "config" => config,
    "parent_id" => parent_id
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/blocks",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowBlock.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_block_validate_config(block_id:, config:, config_mode: nil, workflow_id: nil, request_options: {}) ⇒ Retab::ValidateWorkflowBlockConfigResponse

Validate Block Config

Parameters:

  • block_id (String)
  • config (Hash{String => Object})

    Assembled block config to validate.

  • config_mode (Retab::Types::ValidateWorkflowBlockConfigRequestConfigMode, nil) (defaults to: nil)

    How to apply the config before validation. ‘replace’ validates the config as the full block config; ‘merge’ validates the result of merging it into the existing block config.

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

    Workflow ID to disambiguate legacy duplicate block IDs. Omit for normal server-generated block IDs.

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

    (see Retab::Types::RequestOptions)

Returns:



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/retab/workflow_blocks.rb', line 364

def create_block_validate_config(
  block_id:,
  config:,
  config_mode: nil,
  workflow_id: nil,
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id
  }.compact
  body = {
    "config" => config,
    "config_mode" => config_mode
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/blocks/#{Retab::Util.encode_path(block_id)}/validate-config",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = Retab::ValidateWorkflowBlockConfigResponse.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(block_version_id:, request_options: {}) ⇒ Retab::WorkflowBlock

Restore Block Version

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/retab/workflow_blocks.rb', line 230

def create_version_restore(
  block_version_id:,
  request_options: {}
)
  response = @client.request(
    method: :post,
    path: "/v1/workflows/blocks/versions/#{Retab::Util.encode_path(block_version_id)}/restore",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowBlock.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(block_id:, workflow_id: nil, request_options: {}) ⇒ void

This method returns an undefined value.

Delete Block

Parameters:

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

    Disambiguates a block id that is shared by more than one workflow. Required only when the block id is not unique within your organization.

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

    (see Retab::Types::RequestOptions)



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/retab/workflow_blocks.rb', line 339

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

#executionsObject



13
14
15
# File 'lib/retab/workflow_blocks.rb', line 13

def executions
  @executions ||= Retab::WorkflowBlockExecutions.new(@client)
end

#get(block_id:, workflow_id: nil, request_options: {}) ⇒ Retab::WorkflowBlock

Get Block

Parameters:

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

    Disambiguates a block id that is shared by more than one workflow. Required only when the block id is not unique within your organization — otherwise the call returns 409 listing the colliding workflow_ids. Server-generated block IDs are always unique and never need this.

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

    (see Retab::Types::RequestOptions)

Returns:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/retab/workflow_blocks.rb', line 254

def get(
  block_id:,
  workflow_id: nil,
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/workflows/blocks/#{Retab::Util.encode_path(block_id)}",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Retab::WorkflowBlock.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(block_version_id:, request_options: {}) ⇒ Retab::WorkflowBlockVersion

Get Block Version

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/retab/workflow_blocks.rb', line 207

def get_version(
  block_version_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/blocks/versions/#{Retab::Util.encode_path(block_version_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowBlockVersion.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(workflow_id:, before: nil, after: nil, limit: 100, request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowBlock>

List Blocks

Parameters:

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

    Block id cursor: return the page before this id (mutually exclusive with ‘after`).

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

    Block id cursor: return the page after this id (mutually exclusive with ‘before`).

  • limit (Integer, nil) (defaults to: 100)

    Maximum number of blocks to return per page (1-200).

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

    (see Retab::Types::RequestOptions)

Returns:



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/workflow_blocks.rb', line 24

def list(
  workflow_id:,
  before: nil,
  after: nil,
  limit: 100,
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id,
    "before" => before,
    "after" => after,
    "limit" => limit
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/workflows/blocks",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list(
      workflow_id: workflow_id,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::WorkflowBlock,
    filters: {workflow_id: workflow_id, before: before, limit: limit},
    fetch_next: fetch_next
  )
end

#list_diff(from_block_version_id:, to_block_version_id:, request_options: {}) ⇒ Retab::WorkflowBlockVersionDiff

Diff Block Versions

Parameters:

  • from_block_version_id (String)
  • to_block_version_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/retab/workflow_blocks.rb', line 178

def list_diff(
  from_block_version_id:,
  to_block_version_id:,
  request_options: {}
)
  params = {
    "from_block_version_id" => from_block_version_id,
    "to_block_version_id" => to_block_version_id
  }
  response = @client.request(
    method: :get,
    path: "/v1/workflows/blocks/versions/diff",
    auth: true,
    params: params,
    request_options: request_options
  )
  result = Retab::WorkflowBlockVersionDiff.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:, block_id: nil, workflow_version_id: nil, before: nil, after: nil, limit: 50, request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowBlockVersion>

List Block Versions

Parameters:

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

    Filter by stable block ID

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

    Filter by workflow version ID

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

    Block version cursor before

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

    Block version cursor after

  • limit (Integer, nil) (defaults to: 50)

    Maximum number of block versions to return

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

    (see Retab::Types::RequestOptions)

Returns:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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
165
166
167
168
169
170
171
# File 'lib/retab/workflow_blocks.rb', line 124

def list_versions(
  workflow_id:,
  block_id: nil,
  workflow_version_id: nil,
  before: nil,
  after: nil,
  limit: 50,
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id,
    "block_id" => block_id,
    "workflow_version_id" => workflow_version_id,
    "before" => before,
    "after" => after,
    "limit" => limit
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/workflows/blocks/versions",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list_versions(
      workflow_id: workflow_id,
      block_id: block_id,
      workflow_version_id: workflow_version_id,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::WorkflowBlockVersion,
    filters: {
      workflow_id: workflow_id,
      block_id: block_id,
      workflow_version_id: workflow_version_id,
      before: before,
      limit: limit
    },
    fetch_next: fetch_next
  )
end

#update(block_id:, label: nil, position_x: nil, position_y: nil, width: nil, height: nil, config: nil, parent_id: nil, config_mode: nil, workflow_id: nil, request_options: {}) ⇒ Retab::WorkflowBlock

Update Block

Parameters:

  • block_id (String)
  • label (String, nil) (defaults to: nil)
  • position_x (Float, nil) (defaults to: nil)
  • position_y (Float, nil) (defaults to: nil)
  • width (Float, nil) (defaults to: nil)
  • height (Float, nil) (defaults to: nil)
  • config (Hash{String => Object}, nil) (defaults to: nil)
  • parent_id (String, nil) (defaults to: nil)
  • config_mode (Retab::Types::UpdateWorkflowBlockRequestConfigMode, nil) (defaults to: nil)

    How to apply the ‘config` field. ’merge’ (default) deep-merges the patch into the existing config with null-as-delete; ‘replace’ uses the patch as the full new config.

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

    Disambiguates a block id that is shared by more than one workflow. Required only when the block id is not unique within your organization.

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

    (see Retab::Types::RequestOptions)

Returns:



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/retab/workflow_blocks.rb', line 291

def update(
  block_id:,
  label: nil,
  position_x: nil,
  position_y: nil,
  width: nil,
  height: nil,
  config: nil,
  parent_id: nil,
  config_mode: nil,
  workflow_id: nil,
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id
  }.compact
  body = {
    "label" => label,
    "position_x" => position_x,
    "position_y" => position_y,
    "width" => width,
    "height" => height,
    "config" => config,
    "parent_id" => parent_id,
    "config_mode" => config_mode
  }.compact
  response = @client.request(
    method: :patch,
    path: "/v1/workflows/blocks/#{Retab::Util.encode_path(block_id)}",
    auth: true,
    params: params,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowBlock.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