Class: Grafeas::V1::GrafeasClient
- Inherits:
-
Object
- Object
- Grafeas::V1::GrafeasClient
- Defined in:
- lib/grafeas/v1/grafeas_client.rb
Overview
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.
Constant Summary collapse
- SERVICE_ADDRESS =
The default address of the service.
"containeranalysis.googleapis.com".freeze
- DEFAULT_SERVICE_PORT =
The default port of the service.
443
- GRPC_INTERCEPTORS =
The default set of gRPC interceptors.
[]
- DEFAULT_TIMEOUT =
30
- ALL_SCOPES =
The scopes needed to make gRPC calls to all of the methods defined in this service.
[ "https://www.googleapis.com/auth/cloud-platform" ].freeze
Class Method Summary collapse
-
.note_path(project, note) ⇒ String
Returns a fully-qualified note resource name string.
-
.occurrence_path(project, occurrence) ⇒ String
Returns a fully-qualified occurrence resource name string.
-
.project_path(project) ⇒ String
Returns a fully-qualified project resource name string.
Instance Method Summary collapse
-
#batch_create_notes(parent, notes, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::BatchCreateNotesResponse
Creates new notes in batch.
-
#batch_create_occurrences(parent, occurrences, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::BatchCreateOccurrencesResponse
Creates new occurrences in batch.
-
#create_note(parent, note_id, note, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Creates a new note.
-
#create_occurrence(parent, occurrence, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Creates a new occurrence.
-
#delete_note(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes the specified note.
-
#delete_occurrence(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes the specified occurrence.
-
#get_note(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Gets the specified note.
-
#get_occurrence(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Gets the specified occurrence.
-
#get_occurrence_note(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Gets the note attached to the specified occurrence.
-
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, service_address: nil, service_port: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ GrafeasClient
constructor
A new instance of GrafeasClient.
-
#list_note_occurrences(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>
Lists occurrences referencing the specified note.
-
#list_notes(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Note>
Lists notes for the specified project.
-
#list_occurrences(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>
Lists occurrences for the specified project.
-
#update_note(name, note, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Updates the specified note.
-
#update_occurrence(name, occurrence, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Updates the specified occurrence.
Constructor Details
#initialize(credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, service_address: nil, service_port: nil, exception_transformer: nil, lib_name: nil, lib_version: "") ⇒ GrafeasClient
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 172 def initialize \ credentials: nil, scopes: ALL_SCOPES, client_config: {}, timeout: DEFAULT_TIMEOUT, metadata: nil, service_address: nil, service_port: nil, exception_transformer: nil, lib_name: nil, lib_version: "" # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "google/gax/grpc" require "grafeas/v1/grafeas_services_pb" credentials ||= Grafeas::V1::Credentials.default if credentials.is_a?(String) || credentials.is_a?(Hash) updater_proc = Grafeas::V1::Credentials.new(credentials).updater_proc end if credentials.is_a?(GRPC::Core::Channel) channel = credentials end if credentials.is_a?(GRPC::Core::ChannelCredentials) chan_creds = credentials end if credentials.is_a?(Proc) updater_proc = credentials end if credentials.is_a?(Google::Auth::Credentials) updater_proc = credentials.updater_proc end package_version = Grafeas::VERSION google_api_client = "gl-ruby/#{RUBY_VERSION}" google_api_client << " #{lib_name}/#{lib_version}" if lib_name google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}" google_api_client << " grpc/#{GRPC::VERSION}" google_api_client.freeze headers = { :"x-goog-api-client" => google_api_client } headers.merge!() unless .nil? client_config_file = Pathname.new(__dir__).join( "grafeas_client_config.json" ) defaults = client_config_file.open do |f| Google::Gax.construct_settings( "grafeas.v1.Grafeas", JSON.parse(f.read), client_config, Google::Gax::Grpc::STATUS_CODE_NAMES, timeout, page_descriptors: PAGE_DESCRIPTORS, errors: Google::Gax::Grpc::API_ERRORS, metadata: headers ) end # Allow overriding the service path/port in subclasses. service_path = service_address || self.class::SERVICE_ADDRESS port = service_port || self.class::DEFAULT_SERVICE_PORT interceptors = self.class::GRPC_INTERCEPTORS @grafeas_stub = Google::Gax::Grpc.create_stub( service_path, port, chan_creds: chan_creds, channel: channel, updater_proc: updater_proc, scopes: scopes, interceptors: interceptors, &Grafeas::V1::GrafeasService::Stub.method(:new) ) @get_occurrence = Google::Gax.create_api_call( @grafeas_stub.method(:get_occurrence), defaults["get_occurrence"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @list_occurrences = Google::Gax.create_api_call( @grafeas_stub.method(:list_occurrences), defaults["list_occurrences"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @delete_occurrence = Google::Gax.create_api_call( @grafeas_stub.method(:delete_occurrence), defaults["delete_occurrence"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @create_occurrence = Google::Gax.create_api_call( @grafeas_stub.method(:create_occurrence), defaults["create_occurrence"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @batch_create_occurrences = Google::Gax.create_api_call( @grafeas_stub.method(:batch_create_occurrences), defaults["batch_create_occurrences"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @update_occurrence = Google::Gax.create_api_call( @grafeas_stub.method(:update_occurrence), defaults["update_occurrence"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_occurrence_note = Google::Gax.create_api_call( @grafeas_stub.method(:get_occurrence_note), defaults["get_occurrence_note"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @get_note = Google::Gax.create_api_call( @grafeas_stub.method(:get_note), defaults["get_note"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @list_notes = Google::Gax.create_api_call( @grafeas_stub.method(:list_notes), defaults["list_notes"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @delete_note = Google::Gax.create_api_call( @grafeas_stub.method(:delete_note), defaults["delete_note"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @create_note = Google::Gax.create_api_call( @grafeas_stub.method(:create_note), defaults["create_note"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @batch_create_notes = Google::Gax.create_api_call( @grafeas_stub.method(:batch_create_notes), defaults["batch_create_notes"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'parent' => request.parent} end ) @update_note = Google::Gax.create_api_call( @grafeas_stub.method(:update_note), defaults["update_note"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) @list_note_occurrences = Google::Gax.create_api_call( @grafeas_stub.method(:list_note_occurrences), defaults["list_note_occurrences"], exception_transformer: exception_transformer, params_extractor: proc do |request| {'name' => request.name} end ) end |
Class Method Details
.note_path(project, note) ⇒ String
Returns a fully-qualified note resource name string.
112 113 114 115 116 117 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 112 def self.note_path project, note NOTE_PATH_TEMPLATE.render( :"project" => project, :"note" => note ) end |
.occurrence_path(project, occurrence) ⇒ String
Returns a fully-qualified occurrence resource name string.
123 124 125 126 127 128 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 123 def self.occurrence_path project, occurrence OCCURRENCE_PATH_TEMPLATE.render( :"project" => project, :"occurrence" => occurrence ) end |
.project_path(project) ⇒ String
Returns a fully-qualified project resource name string.
133 134 135 136 137 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 133 def self.project_path project PROJECT_PATH_TEMPLATE.render( :"project" => project ) end |
Instance Method Details
#batch_create_notes(parent, notes, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::BatchCreateNotesResponse
Creates new notes in batch.
840 841 842 843 844 845 846 847 848 849 850 851 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 840 def batch_create_notes \ parent, notes, options: nil, &block req = { parent: parent, notes: notes }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateNotesRequest) @batch_create_notes.call(req, , &block) end |
#batch_create_occurrences(parent, occurrences, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::BatchCreateOccurrencesResponse
Creates new occurrences in batch.
554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 554 def batch_create_occurrences \ parent, occurrences, options: nil, &block req = { parent: parent, occurrences: occurrences }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateOccurrencesRequest) @batch_create_occurrences.call(req, , &block) end |
#create_note(parent, note_id, note, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Creates a new note.
798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 798 def create_note \ parent, note_id, note, options: nil, &block req = { parent: parent, note_id: note_id, note: note }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::CreateNoteRequest) @create_note.call(req, , &block) end |
#create_occurrence(parent, occurrence, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Creates a new occurrence.
514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 514 def create_occurrence \ parent, occurrence, options: nil, &block req = { parent: parent, occurrence: occurrence }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::CreateOccurrenceRequest) @create_occurrence.call(req, , &block) end |
#delete_note(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes the specified note.
754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 754 def delete_note \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::DeleteNoteRequest) @delete_note.call(req, , &block) nil end |
#delete_occurrence(name, options: nil) {|result, operation| ... } ⇒ Object
Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
475 476 477 478 479 480 481 482 483 484 485 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 475 def delete_occurrence \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::DeleteOccurrenceRequest) @delete_occurrence.call(req, , &block) nil end |
#get_note(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Gets the specified note.
665 666 667 668 669 670 671 672 673 674 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 665 def get_note \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::GetNoteRequest) @get_note.call(req, , &block) end |
#get_occurrence(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Gets the specified occurrence.
384 385 386 387 388 389 390 391 392 393 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 384 def get_occurrence \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceRequest) @get_occurrence.call(req, , &block) end |
#get_occurrence_note(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
634 635 636 637 638 639 640 641 642 643 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 634 def get_occurrence_note \ name, options: nil, &block req = { name: name }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceNoteRequest) @get_occurrence_note.call(req, , &block) end |
#list_note_occurrences(name, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>
Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
945 946 947 948 949 950 951 952 953 954 955 956 957 958 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 945 def list_note_occurrences \ name, filter: nil, page_size: nil, options: nil, &block req = { name: name, filter: filter, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::ListNoteOccurrencesRequest) @list_note_occurrences.call(req, , &block) end |
#list_notes(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Note>
Lists notes for the specified project.
720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 720 def list_notes \ parent, filter: nil, page_size: nil, options: nil, &block req = { parent: parent, filter: filter, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::ListNotesRequest) @list_notes.call(req, , &block) end |
#list_occurrences(parent, filter: nil, page_size: nil, options: nil) {|result, operation| ... } ⇒ Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>
Lists occurrences for the specified project.
439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 439 def list_occurrences \ parent, filter: nil, page_size: nil, options: nil, &block req = { parent: parent, filter: filter, page_size: page_size }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::ListOccurrencesRequest) @list_occurrences.call(req, , &block) end |
#update_note(name, note, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note
Updates the specified note.
884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 884 def update_note \ name, note, update_mask: nil, options: nil, &block req = { name: name, note: note, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::UpdateNoteRequest) @update_note.call(req, , &block) end |
#update_occurrence(name, occurrence, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence
Updates the specified occurrence.
598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/grafeas/v1/grafeas_client.rb', line 598 def update_occurrence \ name, occurrence, update_mask: nil, options: nil, &block req = { name: name, occurrence: occurrence, update_mask: update_mask }.delete_if { |_, v| v.nil? } req = Google::Gax::to_proto(req, Grafeas::V1::UpdateOccurrenceRequest) @update_occurrence.call(req, , &block) end |