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

#artifactsObject



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

def artifacts
  @artifacts ||= Retab::WorkflowArtifacts.new(@client)
end

#blocksObject



17
18
19
# File 'lib/retab/workflows.rb', line 17

def blocks
  @blocks ||= Retab::WorkflowBlocks.new(@client)
end

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



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/retab/workflows.rb', line 102

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)



186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/retab/workflows.rb', line 186

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

#edgesObject



21
22
23
# File 'lib/retab/workflows.rb', line 21

def edges
  @edges ||= Retab::WorkflowEdges.new(@client)
end

#experimentsObject



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

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/retab/workflows.rb', line 131

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



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

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



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

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

#reviewsObject



29
30
31
# File 'lib/retab/workflows.rb', line 29

def reviews
  @reviews ||= Retab::WorkflowReviews.new(@client)
end

#runsObject



33
34
35
# File 'lib/retab/workflows.rb', line 33

def runs
  @runs ||= Retab::WorkflowRuns.new(@client)
end

#specObject



37
38
39
# File 'lib/retab/workflows.rb', line 37

def spec
  @spec ||= Retab::WorkflowSpec.new(@client)
end

#stepsObject



41
42
43
# File 'lib/retab/workflows.rb', line 41

def steps
  @steps ||= Retab::WorkflowSteps.new(@client)
end

#testsObject



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

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:



156
157
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 156

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