Class: Retab::Usage

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Usage

Returns a new instance of Usage.



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

def initialize(client)
  @client = client
end

Instance Method Details

#list_blocks(limit: 20, order: "desc", before: nil, after: nil, workflow_id: nil, block_type: nil, from_date: nil, to_date: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::UsageBlockRecord>

List Usage Blocks

Parameters:

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

    Maximum number of block rows to return.

  • order (Retab::Types::UsageOrder, nil) (defaults to: "desc")

    Sort direction on block id.

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

    Return blocks before this cursor (opaque token from a prior page's list_metadata).

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

    Return blocks after this cursor (opaque token from a prior page's list_metadata).

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

    Filter to a single workflow id.

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

    Filter by block type (e.g. extract, classify, split, parse, edit, partition).

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

    Inclusive activity lower bound (YYYY-MM-DD, UTC).

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

    Inclusive activity upper bound (YYYY-MM-DD, UTC).

  • 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/retab/usage.rb', line 24

def list_blocks(
  limit: 20,
  order: "desc",
  before: nil,
  after: nil,
  workflow_id: nil,
  block_type: nil,
  from_date: nil,
  to_date: nil,
  request_options: {}
)
  params = {
    "limit" => limit,
    "order" => order,
    "before" => before,
    "after" => after,
    "workflow_id" => workflow_id,
    "block_type" => block_type,
    "from_date" => from_date,
    "to_date" => to_date
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/usage/blocks",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list_blocks(
      limit: limit,
      order: order,
      before: before,
      after: cursor,
      workflow_id: workflow_id,
      block_type: block_type,
      from_date: from_date,
      to_date: to_date,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::UsageBlockRecord,
    filters: {
      limit: limit,
      order: order,
      before: before,
      workflow_id: workflow_id,
      block_type: block_type,
      from_date: from_date,
      to_date: to_date
    },
    fetch_next: fetch_next
  )
end

#list_primitives(limit: 20, order: "desc", before: nil, after: nil, environment_id: nil, workflow_id: nil, project_id: nil, api_key_id: nil, access_token_id: nil, user_id: nil, run_id: nil, block_id: nil, operation: nil, status: nil, metadata: nil, from_date: nil, to_date: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::UsagePrimitiveRecord>

List Usage Primitives

Parameters:

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

    Maximum number of execution rows to return.

  • order (Retab::Types::UsageOrder, nil) (defaults to: "desc")

    Sort direction on execution created_at.

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

    Return executions before this primitive-execution id (keyset cursor).

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

    Return executions after this primitive-execution id (keyset cursor).

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

    Scope the export to this environment id within the caller's organization. Defaults to the authenticated identity's environment.

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

    Filter to a single workflow id (origin workflow).

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

    Filter to executions owned by a single project id.

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

    Filter to executions triggered by a single API key id (the api_key_id returned under triggered_by).

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

    Filter to executions triggered by a single access token id (the access_token_id returned under triggered_by).

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

    Filter to executions triggered by a single user id (the user_id returned under triggered_by).

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

    Filter to a single workflow run id (origin run).

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

    Filter to a single workflow block id (origin block).

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

    Filter by operation (extraction, classify, split, parse, edit, schema_generation).

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

    Filter by execution lifecycle status.

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

    Filter by metadata equality: a JSON object of string key/value pairs (e.g. "tenant":"acme"). Pairs AND together.

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

    Inclusive created_at lower bound (YYYY-MM-DD, UTC).

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

    Inclusive created_at upper bound (YYYY-MM-DD, UTC).

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

    (see Retab::Types::RequestOptions)

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/retab/usage.rb', line 101

def list_primitives(
  limit: 20,
  order: "desc",
  before: nil,
  after: nil,
  environment_id: nil,
  workflow_id: nil,
  project_id: nil,
  api_key_id: nil,
  access_token_id: nil,
  user_id: nil,
  run_id: nil,
  block_id: nil,
  operation: nil,
  status: nil,
  metadata: nil,
  from_date: nil,
  to_date: nil,
  request_options: {}
)
  params = {
    "limit" => limit,
    "order" => order,
    "before" => before,
    "after" => after,
    "environment_id" => environment_id,
    "workflow_id" => workflow_id,
    "project_id" => project_id,
    "api_key_id" => api_key_id,
    "access_token_id" => access_token_id,
    "user_id" => user_id,
    "run_id" => run_id,
    "block_id" => block_id,
    "operation" => operation,
    "status" => status,
    "metadata" => ,
    "from_date" => from_date,
    "to_date" => to_date
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/usage/primitives",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list_primitives(
      limit: limit,
      order: order,
      before: before,
      after: cursor,
      environment_id: environment_id,
      workflow_id: workflow_id,
      project_id: project_id,
      api_key_id: api_key_id,
      access_token_id: access_token_id,
      user_id: user_id,
      run_id: run_id,
      block_id: block_id,
      operation: operation,
      status: status,
      metadata: ,
      from_date: from_date,
      to_date: to_date,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::UsagePrimitiveRecord,
    filters: {
      limit: limit,
      order: order,
      before: before,
      environment_id: environment_id,
      workflow_id: workflow_id,
      project_id: project_id,
      api_key_id: api_key_id,
      access_token_id: access_token_id,
      user_id: user_id,
      run_id: run_id,
      block_id: block_id,
      operation: operation,
      status: status,
      metadata: ,
      from_date: from_date,
      to_date: to_date
    },
    fetch_next: fetch_next
  )
end

#list_runs(limit: 20, order: "desc", before: nil, after: nil, workflow_id: nil, status: nil, trigger_type: nil, from_date: nil, to_date: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::UsageRunRecord>

List Usage Runs

Parameters:

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

    Maximum number of run rows to return.

  • order (Retab::Types::UsageOrder, nil) (defaults to: "desc")

    Sort direction on run created_at.

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

    Return runs before this run id (keyset cursor).

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

    Return runs after this run id (keyset cursor).

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

    Filter to a single workflow id.

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

    Filter by lifecycle status: pending, queued, running, completed, error, failed, awaiting_review, or cancelled.

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

    Filter by trigger type: manual, api, schedule, webhook, email, or restart.

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

    Inclusive created_at lower bound (YYYY-MM-DD, UTC).

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

    Inclusive created_at upper bound (YYYY-MM-DD, UTC).

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

    (see Retab::Types::RequestOptions)

Returns:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/retab/usage.rb', line 206

def list_runs(
  limit: 20,
  order: "desc",
  before: nil,
  after: nil,
  workflow_id: nil,
  status: nil,
  trigger_type: nil,
  from_date: nil,
  to_date: nil,
  request_options: {}
)
  params = {
    "limit" => limit,
    "order" => order,
    "before" => before,
    "after" => after,
    "workflow_id" => workflow_id,
    "status" => status,
    "trigger_type" => trigger_type,
    "from_date" => from_date,
    "to_date" => to_date
  }.compact
  response = @client.request(
    method: :get,
    path: "/v1/usage/runs",
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = -> (cursor) {
    list_runs(
      limit: limit,
      order: order,
      before: before,
      after: cursor,
      workflow_id: workflow_id,
      status: status,
      trigger_type: trigger_type,
      from_date: from_date,
      to_date: to_date,
      request_options: request_options
    )
  }
  Retab::PaginatedList.from_response(
    response,
    model: Retab::UsageRunRecord,
    filters: {
      limit: limit,
      order: order,
      before: before,
      workflow_id: workflow_id,
      status: status,
      trigger_type: trigger_type,
      from_date: from_date,
      to_date: to_date
    },
    fetch_next: fetch_next
  )
end