Class: Retab::WorkflowArtifacts

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowArtifacts

Returns a new instance of WorkflowArtifacts.



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

def initialize(client)
  @client = client
end

Instance Method Details

#get(artifact_id:, request_options: {}) ⇒ Retab::ExtractionWorkflowArtifact, ...

Get Workflow Artifact By Id



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/retab/workflow_artifacts.rb', line 17

def get(
  artifact_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/artifacts/#{Retab::Util.encode_path(artifact_id)}",
    auth: true,
    request_options: request_options
  )
  JSON.parse(response.body)
end

#list(run_id: nil, operation: nil, block_id: nil, step_id: nil, before: nil, after: nil, limit: 100, request_options: {}) ⇒ Retab::Types::ListStruct<Retab::WorkflowArtifact>

List Workflow Artifacts

Parameters:

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

    Workflow run ID whose artifacts should be listed. Required unless “step_id“ is provided.

  • operation (Retab::Types::WorkflowArtifactsOperation, nil) (defaults to: nil)

    Optional artifact operation filter

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

    Optional block_id or step_id filter

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

    Optional step id filter. When provided, returns the single artifact attached to that step (or an empty list if the step has no artifact). “run_id“ is not required when “step_id“ is set — it is resolved from the step record.

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

    Step id cursor: return the page before this step (mutually exclusive with “after“). Ignored when “step_id“ is set.

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

    Step id cursor: return the page after this step (mutually exclusive with “before“). Ignored when “step_id“ is set.

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

    Maximum number of artifacts to return per page (1-200). Ignored when “step_id“ is set (that path returns the single attached artifact).

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

    (see Retab::Types::RequestOptions)

Returns:



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

def list(
  run_id: nil,
  operation: nil,
  block_id: nil,
  step_id: nil,
  before: nil,
  after: nil,
  limit: 100,
  request_options: {}
)
  params = {
    'run_id' => run_id,
    'operation' => operation,
    'block_id' => block_id,
    'step_id' => step_id,
    'before' => before,
    'after' => after,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/artifacts',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      run_id: run_id,
      operation: operation,
      block_id: block_id,
      step_id: step_id,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::WorkflowArtifact,
    filters: { run_id: run_id, operation: operation, block_id: block_id, step_id: step_id, before: before, limit: limit },
    fetch_next: fetch_next
  )
end