Class: ImageInspectorClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/image-inspector-client.rb

Overview

module entry point

Instance Method Summary collapse

Constructor Details

#initialize(uri, version = 'v1', ssl_options: { client_cert: nil, client_key: nil, ca_file: nil, cert_store: nil, verify_ssl: OpenSSL::SSL::VERIFY_PEER }, auth_options: { username: nil, password: nil, bearer_token: nil }) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/image-inspector-client.rb', line 9

def initialize(
  uri,
  version = 'v1',
  ssl_options: {
    client_cert: nil,
    client_key:  nil,
    ca_file:     nil,
    cert_store:  nil,
    verify_ssl:  OpenSSL::SSL::VERIFY_PEER
  },
  auth_options: {
    username:          nil,
    password:          nil,
    bearer_token:      nil
  }
)
  @endpoint = URI.parse("#{uri}/api/#{version}")
  @auth_options = auth_options
  @ssl_options = ssl_options
  @headers = {}
end

Instance Method Details

#fetch_metadataObject



37
38
39
40
41
42
43
44
45
# File 'lib/image-inspector-client.rb', line 37

def 
  exception_handler do
    RecursiveOpenStruct.new(
      JSON.parse(
        RestClient::Resource.new(@endpoint, http_options)['metadata'].get(http_headers)
      )
    )
  end
end

#fetch_oscap_arfObject



31
32
33
34
35
# File 'lib/image-inspector-client.rb', line 31

def fetch_oscap_arf
  exception_handler do
    RestClient::Resource.new(@endpoint, http_options)['openscap'].get(http_headers).body
  end
end