Module: Grafeas
- Defined in:
- lib/grafeas.rb,
lib/grafeas/version.rb
Constant Summary collapse
- VERSION =
"1.8.0"
Class Method Summary collapse
-
.grafeas(version: :v1, &block) ⇒ ::Object
Create a new client object for Grafeas.
-
.grafeas_available?(version: :v1) ⇒ boolean
Determines whether the Grafeas service is supported by the current client.
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.
Raises an exception if the currently installed versioned client gem for the given API version does not support the Grafeas service. You can determine whether the method will succeed by calling grafeas_available?.
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.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/grafeas.rb', line 65 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 |
.grafeas_available?(version: :v1) ⇒ boolean
Determines whether the Grafeas service is supported by the current client. If true, you can retrieve a client object by calling grafeas. If false, that method will raise an exception. This could happen if the given API version does not exist or does not support the Grafeas service, or if the versioned client gem needs an update to support the Grafeas service.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/grafeas.rb', line 87 def self.grafeas_available? version: :v1 require "grafeas/#{version.to_s.downcase}" package_name = Grafeas .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first return false unless package_name service_module = Grafeas.const_get package_name return false unless service_module.const_defined? :Grafeas service_module = service_module.const_get :Grafeas service_module.const_defined? :Client rescue ::LoadError false end |