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:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/retab/workflow_test_runs.rb', line 143

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(request_options: {}) ⇒ Retab::WorkflowTestRun

Create Test Run

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



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

def create(request_options: {})
  response = @client.request(
    method: :post,
    path: '/v1/workflows/tests/runs',
    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

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



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

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', fields: nil, before: nil, after: nil, limit: 50, order: 'desc', request_options: {}) ⇒ Retab::Types::ListStruct<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')
  • fields (String, nil) (defaults to: nil)
  • 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:



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

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',
  fields: nil,
  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,
    'fields' => fields,
    '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,
      fields: fields,
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.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, fields: fields, before: before, limit: limit, order: order },
    fetch_next: fetch_next
  )
end