Class: Grafeas::V1::GrafeasClient

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

Returns a new instance of GrafeasClient.

Parameters:

  • credentials (Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc) (defaults to: nil)

    Provides the means for authenticating requests made by the client. This parameter can be many types. A Google::Auth::Credentials uses a the properties of its represented keyfile for authenticating requests made by this client. A String will be treated as the path to the keyfile to be used for the construction of credentials for this client. A Hash will be treated as the contents of a keyfile to be used for the construction of credentials for this client. A GRPC::Core::Channel will be used to make calls through. A GRPC::Core::ChannelCredentials for the setting up the RPC client. The channel credentials should already be composed with a GRPC::Core::CallCredentials object. A Proc will be used as an updater_proc for the Grpc channel. The proc transforms the metadata for requests, generally, to give OAuth credentials.

  • scopes (Array<String>) (defaults to: ALL_SCOPES)

    The OAuth scopes for this service. This parameter is ignored if an updater_proc is supplied.

  • client_config (Hash) (defaults to: {})

    A Hash for call options for each method. See Google::Gax#construct_settings for the structure of this data. Falls back to the default config if not specified or the specified config is missing data points.

  • timeout (Numeric) (defaults to: DEFAULT_TIMEOUT)

    The default timeout, in seconds, for calls made through this client.

  • metadata (Hash) (defaults to: nil)

    Default metadata to be sent with each request. This can be overridden on a per call basis.

  • service_address (String) (defaults to: nil)

    Override for the service hostname, or nil to leave as the default.

  • service_port (Integer) (defaults to: nil)

    Override for the service port, or nil to leave as the default.

  • exception_transformer (Proc) (defaults to: nil)

    An optional proc that intercepts any exceptions raised during an API call to inject custom error handling.



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.

Parameters:

  • project (String)
  • note (String)

Returns:

  • (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.

Parameters:

  • project (String)
  • occurrence (String)

Returns:

  • (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.

Parameters:

  • project (String)

Returns:

  • (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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# TODO: Initialize `notes`:
notes = {}
response = grafeas_client.batch_create_notes(formatted_parent, notes)

Parameters:

  • parent (String)

    The name of the project in the form of projects/[PROJECT_ID], under which the notes are to be created.

  • notes (Hash{String => Grafeas::V1::Note | Hash})

    The notes to create. Max allowed length is 1000. A hash of the same form as Grafeas::V1::Note can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#batch_create_occurrences(parent, occurrences, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::BatchCreateOccurrencesResponse

Creates new occurrences in batch.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# TODO: Initialize `occurrences`:
occurrences = []
response = grafeas_client.batch_create_occurrences(formatted_parent, occurrences)

Parameters:

  • parent (String)

    The name of the project in the form of projects/[PROJECT_ID], under which the occurrences are to be created.

  • occurrences (Array<Grafeas::V1::Occurrence | Hash>)

    The occurrences to create. Max allowed length is 1000. A hash of the same form as Grafeas::V1::Occurrence can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#create_note(parent, note_id, note, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note

Creates a new note.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# TODO: Initialize `note_id`:
note_id = ''

# TODO: Initialize `note`:
note = {}
response = grafeas_client.create_note(formatted_parent, note_id, note)

Parameters:

  • parent (String)

    The name of the project in the form of projects/[PROJECT_ID], under which the note is to be created.

  • note_id (String)

    The ID to use for this note.

  • note (Grafeas::V1::Note | Hash)

    The note to create. A hash of the same form as Grafeas::V1::Note can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#create_occurrence(parent, occurrence, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence

Creates a new occurrence.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# TODO: Initialize `occurrence`:
occurrence = {}
response = grafeas_client.create_occurrence(formatted_parent, occurrence)

Parameters:

  • parent (String)

    The name of the project in the form of projects/[PROJECT_ID], under which the occurrence is to be created.

  • occurrence (Grafeas::V1::Occurrence | Hash)

    The occurrence to create. A hash of the same form as Grafeas::V1::Occurrence can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#delete_note(name, options: nil) {|result, operation| ... } ⇒ Object

Deletes the specified note.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
grafeas_client.delete_note(formatted_name)

Parameters:

  • name (String)

    The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
grafeas_client.delete_occurrence(formatted_name)

Parameters:

  • name (String)

    The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result

    []

  • operation (GRPC::ActiveCall::Operation)

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
  nil
end

#get_note(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note

Gets the specified note.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
response = grafeas_client.get_note(formatted_name)

Parameters:

  • name (String)

    The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#get_occurrence(name, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence

Gets the specified occurrence.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
response = grafeas_client.get_occurrence(formatted_name)

Parameters:

  • name (String)

    The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
response = grafeas_client.get_occurrence_note(formatted_name)

Parameters:

  • name (String)

    The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")

# Iterate over all results.
grafeas_client.list_note_occurrences(formatted_name).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
grafeas_client.list_note_occurrences(formatted_name).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • name (String)

    The name of the note to list occurrences for in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

  • filter (String) (defaults to: nil)

    The filter expression.

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>)

    An enumerable of Grafeas::V1::Occurrence instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# Iterate over all results.
grafeas_client.list_notes(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
grafeas_client.list_notes(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The name of the project to list notes for in the form of projects/[PROJECT_ID].

  • filter (String) (defaults to: nil)

    The filter expression.

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

  • result (Google::Gax::PagedEnumerable<Grafeas::V1::Note>)
  • operation (GRPC::ActiveCall::Operation)

Returns:

  • (Google::Gax::PagedEnumerable<Grafeas::V1::Note>)

    An enumerable of Grafeas::V1::Note instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &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.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")

# Iterate over all results.
grafeas_client.list_occurrences(formatted_parent).each do |element|
  # Process element.
end

# Or iterate over results one page at a time.
grafeas_client.list_occurrences(formatted_parent).each_page do |page|
  # Process each page at a time.
  page.each do |element|
    # Process element.
  end
end

Parameters:

  • parent (String)

    The name of the project to list occurrences for in the form of projects/[PROJECT_ID].

  • filter (String) (defaults to: nil)

    The filter expression.

  • page_size (Integer) (defaults to: nil)

    The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

  • (Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>)

    An enumerable of Grafeas::V1::Occurrence instances. See Google::Gax::PagedEnumerable documentation for other operations such as per-page iteration or access to the response object.

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#update_note(name, note, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Note

Updates the specified note.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")

# TODO: Initialize `note`:
note = {}
response = grafeas_client.update_note(formatted_name, note)

Parameters:

  • name (String)

    The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

  • note (Grafeas::V1::Note | Hash)

    The updated note. A hash of the same form as Grafeas::V1::Note can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    The fields to update. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end

#update_occurrence(name, occurrence, update_mask: nil, options: nil) {|result, operation| ... } ⇒ Grafeas::V1::Occurrence

Updates the specified occurrence.

Examples:

require "grafeas"

grafeas_client = Grafeas.new(version: :v1)
formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")

# TODO: Initialize `occurrence`:
occurrence = {}
response = grafeas_client.update_occurrence(formatted_name, occurrence)

Parameters:

  • name (String)

    The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

  • occurrence (Grafeas::V1::Occurrence | Hash)

    The updated occurrence. A hash of the same form as Grafeas::V1::Occurrence can also be provided.

  • update_mask (Google::Protobuf::FieldMask | Hash) (defaults to: nil)

    The fields to update. A hash of the same form as Google::Protobuf::FieldMask can also be provided.

  • options (Google::Gax::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries, etc.

Yields:

  • (result, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (Google::Gax::GaxError)

    if the RPC is aborted.



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, options, &block)
end