Class: Retab::WorkflowEdges

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowEdges

Returns a new instance of WorkflowEdges.



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

def initialize(client)
  @client = client
end

Instance Method Details

#create(workflow_id:, source_block:, target_block:, id: nil, source_handle: nil, target_handle: nil, request_options: {}) ⇒ Retab::WorkflowEdgeDoc

Create Edge

Parameters:

  • workflow_id (String)

    Workflow to create the edge in.

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

    Opaque edge ID. Omit to let the server generate one.

  • source_block (String)

    Source block ID

  • target_block (String)

    Target block ID

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

    Output handle

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

    Input handle

  • 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
# File 'lib/retab/workflow_edges.rb', line 74

def create(
  workflow_id:,
  source_block:,
  target_block:,
  id: nil,
  source_handle: nil,
  target_handle: nil,
  request_options: {}
)
  body = {
    'workflow_id' => workflow_id,
    'id' => id,
    'source_block' => source_block,
    'target_block' => target_block,
    'source_handle' => source_handle,
    'target_handle' => target_handle
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/workflows/edges',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowEdgeDoc.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(edge_id:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete Edge

Parameters:

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

    (see Retab::Types::RequestOptions)



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/retab/workflow_edges.rb', line 126

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

#get(edge_id:, request_options: {}) ⇒ Retab::WorkflowEdgeDoc

Get Edge

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/retab/workflow_edges.rb', line 107

def get(
  edge_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/edges/#{Retab::Util.encode_path(edge_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowEdgeDoc.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:, source_block: nil, target_block: nil, before: nil, after: nil, limit: 100, request_options: {}) ⇒ Retab::Types::ListStruct<Retab::WorkflowEdgeDoc>

List Edges

Parameters:

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

    Filter by source block ID

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

    Filter by target block ID

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

    Edge id cursor: return the page before this id (mutually exclusive with “after“).

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

    Edge id cursor: return the page after this id (mutually exclusive with “before“).

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

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

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

    (see Retab::Types::RequestOptions)

Returns:



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
60
61
62
63
# File 'lib/retab/workflow_edges.rb', line 22

def list(
  workflow_id:,
  source_block: nil,
  target_block: nil,
  before: nil,
  after: nil,
  limit: 100,
  request_options: {}
)
  params = {
    'workflow_id' => workflow_id,
    'source_block' => source_block,
    'target_block' => target_block,
    'before' => before,
    'after' => after,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/edges',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      workflow_id: workflow_id,
      source_block: source_block,
      target_block: target_block,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::WorkflowEdgeDoc,
    filters: { workflow_id: workflow_id, source_block: source_block, target_block: target_block, before: before, limit: limit },
    fetch_next: fetch_next
  )
end