Class: BulkDataTestKit::BulkDataV200Client::Endpoints::Status

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
ServerProxy, URLs
Defined in:
lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb

Instance Method Summary collapse

Methods included from ServerProxy

#proxy_client, #request_headers, #rewrite_url_base

Methods included from URLs

#base_url, #fhir_url, #output_url, #resume_pass_url, #status_url, #suite_id

Instance Method Details

#job_idObject



61
62
63
# File 'lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb', line 61

def job_id
  request.params[:job_id]
end

#make_responseObject

Proxy the request to the reference server using the same ‘_jobId“ we received on kickoff, and respond with the current status. If the status is complete, return the output adjusted to point at Inferno.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb', line 22

def make_response
  server_response = proxy_client.get("$export-poll-status?_jobId=#{job_id}")

  case server_response.status
  when 202
    # In-Progress Status
    response.status = 202
    response.headers['retry-after'] = 120
  when 200
    # Complete Status
    body = JSON.parse(server_response.body)
    response.status = 200
    response.body = response_body(body).to_json
    response.format = :json
  else
    response.status = server_response.status
    response.body = server_response.body
  end
end

#response_body(body) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb', line 46

def response_body(body)
  output = body['output']&.map do |binary|
    binary['url'] = rewrite_url_base(binary['url'])
    binary
  end

  {
    transactionTime: DateTime.now.iso8601,
    request: rewrite_url_base(body['request']),
    requiresAccessToken: true,
    output: output || [],
    error: []
  }
end

#tagsObject



42
43
44
# File 'lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb', line 42

def tags
  [STATUS_TAG]
end

#test_run_identifierObject



11
12
13
14
15
16
17
# File 'lib/bulk_data_test_kit/v2.0.0_client/endpoints/status.rb', line 11

def test_run_identifier
  return request.params[:session_path] if request.params[:session_path].present?

  SMARTAppLaunch::MockSMARTServer.issued_token_to_client_id(
    request.headers['authorization']&.delete_prefix('Bearer ')
  )
end