Class: Retab::WorkflowTestRuns

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowTestRuns

Returns a new instance of WorkflowTestRuns.



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

def initialize(client)
  @client = client
end

Instance Method Details

#cancel(run_id:, request_options: {}) ⇒ Retab::WorkflowTestRun

Cancel Test Execution Run

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/retab/workflow_test_runs.rb', line 173

def cancel(
  run_id:,
  request_options: {}
)
  response = @client.request(
    method: :post,
    path: "/v1/workflows/tests/runs/#{Retab::Util.encode_path(run_id)}/cancel",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowTestRun.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(workflow_id:, scope: nil, request_options: {}) ⇒ Retab::WorkflowTestRun

Create Test Run

Parameters:

Returns:



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/retab/workflow_test_runs.rb', line 121

def create(
  workflow_id:,
  scope: nil,
  request_options: {}
)
  body = {
    "workflow_id" => workflow_id,
    "scope" => scope
  }.compact
  response = @client.request(
    method: :post,
    path: "/v1/workflows/tests/runs",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowTestRun.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(run_id:, request_options: {}) ⇒ Retab::WorkflowTestRun

Get Test Execution Run

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/retab/workflow_test_runs.rb', line 150

def get(
  run_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/tests/runs/#{Retab::Util.encode_path(run_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowTestRun.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: nil, test_id: nil, target_block_id: nil, status: nil, statuses: nil, exclude_status: nil, trigger_type: nil, trigger_types: nil, from_date: nil, to_date: nil, sort_by: "created_at", before: nil, after: nil, limit: 50, order: "desc", request_options: {}) ⇒ Retab::PaginatedList<Retab::WorkflowTestRun>

List Test Execution Runs

Parameters:

  • workflow_id (String, nil) (defaults to: nil)
  • test_id (String, nil) (defaults to: nil)
  • target_block_id (String, nil) (defaults to: nil)
  • status (String, nil) (defaults to: nil)
  • statuses (Array<String>, nil) (defaults to: nil)
  • exclude_status (String, nil) (defaults to: nil)
  • trigger_type (String, nil) (defaults to: nil)
  • trigger_types (Array<String>, nil) (defaults to: nil)
  • from_date (String, nil) (defaults to: nil)
  • to_date (String, nil) (defaults to: nil)
  • sort_by (String, nil) (defaults to: "created_at")
  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: 50)
  • order (Retab::Types::WorkflowTestRunsOrder, nil) (defaults to: "desc")
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/retab/workflow_test_runs.rb', line 31

def list(
  workflow_id: nil,
  test_id: nil,
  target_block_id: nil,
  status: nil,
  statuses: nil,
  exclude_status: nil,
  trigger_type: nil,
  trigger_types: nil,
  from_date: nil,
  to_date: nil,
  sort_by: "created_at",
  before: nil,
  after: nil,
  limit: 50,
  order: "desc",
  request_options: {}
)
  params = {
    "workflow_id" => workflow_id,
    "test_id" => test_id,
    "target_block_id" => target_block_id,
    "status" => status,
    "statuses" => statuses,
    "exclude_status" => exclude_status,
    "trigger_type" => trigger_type,
    "trigger_types" => trigger_types,
    "from_date" => from_date,
    "to_date" => to_date,
    "sort_by" => sort_by,
    "before" => before,
    "after" => after,
    "limit" => limit,
    "order" => order
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/workflows/tests/runs",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list(
      workflow_id: workflow_id,
      test_id: test_id,
      target_block_id: target_block_id,
      status: status,
      statuses: statuses,
      exclude_status: exclude_status,
      trigger_type: trigger_type,
      trigger_types: trigger_types,
      from_date: from_date,
      to_date: to_date,
      sort_by: sort_by,
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::WorkflowTestRun,
    filters: {
      workflow_id: workflow_id,
      test_id: test_id,
      target_block_id: target_block_id,
      status: status,
      statuses: statuses,
      exclude_status: exclude_status,
      trigger_type: trigger_type,
      trigger_types: trigger_types,
      from_date: from_date,
      to_date: to_date,
      sort_by: sort_by,
      before: before,
      limit: limit,
      order: order
    },
    fetch_next: fetch_next
  )
end