Module: Grafeas

Defined in:
lib/grafeas.rb,
lib/grafeas/version.rb

Constant Summary collapse

VERSION =
"1.4.0"

Class Method Summary collapse

Class Method Details

.grafeas(version: :v1, &block) ⇒ ::Object

Create a new client object for Grafeas.

By default, this returns an instance of Grafeas::V1::Grafeas::Client for a gRPC client for version V1 of the API. However, you can specify a different API version by passing it in the version parameter. If the Grafeas service is supported by that API version, and the corresponding gem is available, the appropriate versioned client will be returned.

About Grafeas

Grafeas API.

Retrieves analysis results of Cloud components such as Docker container images.

Analysis results are stored as a series of occurrences. An Occurrence contains information about a specific analysis instance on a resource. An occurrence refers to a Note. A note contains details describing the analysis and is generally stored in a separate project, called a Provider. Multiple occurrences can refer to the same note.

For example, an SSL vulnerability could affect multiple images. In this case, there would be one note for the vulnerability and an occurrence for each image with the vulnerability referring to that note.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1)

    The API version to connect to. Optional. Defaults to :v1.

Returns:

  • (::Object)

    A client object for the specified version.



60
61
62
63
64
65
66
67
68
69
# File 'lib/grafeas.rb', line 60

def self.grafeas version: :v1, &block
  require "grafeas/#{version.to_s.downcase}"

  package_name = Grafeas
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  service_module = Grafeas.const_get(package_name).const_get(:Grafeas)
  service_module.const_get(:Client).new(&block)
end