grafeas-client 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -2
  3. data/README.md +4 -4
  4. data/lib/grafeas/client/version.rb +1 -2
  5. metadata +12 -73
  6. data/AUTHENTICATION.md +0 -199
  7. data/lib/grafeas.rb +0 -154
  8. data/lib/grafeas/v1.rb +0 -155
  9. data/lib/grafeas/v1/attestation_pb.rb +0 -27
  10. data/lib/grafeas/v1/build_pb.rb +0 -23
  11. data/lib/grafeas/v1/common_pb.rb +0 -34
  12. data/lib/grafeas/v1/credentials.rb +0 -37
  13. data/lib/grafeas/v1/cvss_pb.rb +0 -67
  14. data/lib/grafeas/v1/deployment_pb.rb +0 -35
  15. data/lib/grafeas/v1/discovery_pb.rb +0 -40
  16. data/lib/grafeas/v1/doc/google/protobuf/any.rb +0 -131
  17. data/lib/grafeas/v1/doc/google/protobuf/empty.rb +0 -29
  18. data/lib/grafeas/v1/doc/google/protobuf/field_mask.rb +0 -222
  19. data/lib/grafeas/v1/doc/google/protobuf/timestamp.rb +0 -113
  20. data/lib/grafeas/v1/doc/google/rpc/status.rb +0 -87
  21. data/lib/grafeas/v1/doc/grafeas/v1/attestation.rb +0 -64
  22. data/lib/grafeas/v1/doc/grafeas/v1/build.rb +0 -44
  23. data/lib/grafeas/v1/doc/grafeas/v1/common.rb +0 -105
  24. data/lib/grafeas/v1/doc/grafeas/v1/cvss.rb +0 -104
  25. data/lib/grafeas/v1/doc/grafeas/v1/deployment.rb +0 -64
  26. data/lib/grafeas/v1/doc/grafeas/v1/discovery.rb +0 -76
  27. data/lib/grafeas/v1/doc/grafeas/v1/grafeas.rb +0 -322
  28. data/lib/grafeas/v1/doc/grafeas/v1/image.rb +0 -79
  29. data/lib/grafeas/v1/doc/grafeas/v1/package.rb +0 -125
  30. data/lib/grafeas/v1/doc/grafeas/v1/provenance.rb +0 -248
  31. data/lib/grafeas/v1/doc/grafeas/v1/vulnerability.rb +0 -214
  32. data/lib/grafeas/v1/grafeas_client.rb +0 -961
  33. data/lib/grafeas/v1/grafeas_client_config.json +0 -96
  34. data/lib/grafeas/v1/grafeas_pb.rb +0 -163
  35. data/lib/grafeas/v1/grafeas_services_pb.rb +0 -86
  36. data/lib/grafeas/v1/image_pb.rb +0 -36
  37. data/lib/grafeas/v1/package_pb.rb +0 -59
  38. data/lib/grafeas/v1/provenance_pb.rb +0 -116
  39. data/lib/grafeas/v1/vulnerability_pb.rb +0 -81
@@ -1,961 +0,0 @@
1
- # Copyright 2019 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/grafeas/v1/grafeas.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "grafeas/v1/grafeas_pb"
29
- require "grafeas/v1/credentials"
30
- require "grafeas/client/version"
31
-
32
- module Grafeas
33
- module V1
34
- # [Grafeas](https://grafeas.io) API.
35
- #
36
- # Retrieves analysis results of Cloud components such as Docker container
37
- # images.
38
- #
39
- # Analysis results are stored as a series of occurrences. An `Occurrence`
40
- # contains information about a specific analysis instance on a resource. An
41
- # occurrence refers to a `Note`. A note contains details describing the
42
- # analysis and is generally stored in a separate project, called a `Provider`.
43
- # Multiple occurrences can refer to the same note.
44
- #
45
- # For example, an SSL vulnerability could affect multiple images. In this case,
46
- # there would be one note for the vulnerability and an occurrence for each
47
- # image with the vulnerability referring to that note.
48
- #
49
- # @!attribute [r] grafeas_stub
50
- # @return [Grafeas::V1::GrafeasService::Stub]
51
- class GrafeasClient
52
- # @private
53
- attr_reader :grafeas_stub
54
-
55
- # The default address of the service.
56
- SERVICE_ADDRESS = "containeranalysis.googleapis.com".freeze
57
-
58
- # The default port of the service.
59
- DEFAULT_SERVICE_PORT = 443
60
-
61
- # The default set of gRPC interceptors.
62
- GRPC_INTERCEPTORS = []
63
-
64
- DEFAULT_TIMEOUT = 30
65
-
66
- PAGE_DESCRIPTORS = {
67
- "list_occurrences" => Google::Gax::PageDescriptor.new(
68
- "page_token",
69
- "next_page_token",
70
- "occurrences"),
71
- "list_notes" => Google::Gax::PageDescriptor.new(
72
- "page_token",
73
- "next_page_token",
74
- "notes"),
75
- "list_note_occurrences" => Google::Gax::PageDescriptor.new(
76
- "page_token",
77
- "next_page_token",
78
- "occurrences")
79
- }.freeze
80
-
81
- private_constant :PAGE_DESCRIPTORS
82
-
83
- # The scopes needed to make gRPC calls to all of the methods defined in
84
- # this service.
85
- ALL_SCOPES = [
86
- "https://www.googleapis.com/auth/cloud-platform"
87
- ].freeze
88
-
89
-
90
- NOTE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
91
- "projects/{project}/notes/{note}"
92
- )
93
-
94
- private_constant :NOTE_PATH_TEMPLATE
95
-
96
- OCCURRENCE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
97
- "projects/{project}/occurrences/{occurrence}"
98
- )
99
-
100
- private_constant :OCCURRENCE_PATH_TEMPLATE
101
-
102
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
103
- "projects/{project}"
104
- )
105
-
106
- private_constant :PROJECT_PATH_TEMPLATE
107
-
108
- # Returns a fully-qualified note resource name string.
109
- # @param project [String]
110
- # @param note [String]
111
- # @return [String]
112
- def self.note_path project, note
113
- NOTE_PATH_TEMPLATE.render(
114
- :"project" => project,
115
- :"note" => note
116
- )
117
- end
118
-
119
- # Returns a fully-qualified occurrence resource name string.
120
- # @param project [String]
121
- # @param occurrence [String]
122
- # @return [String]
123
- def self.occurrence_path project, occurrence
124
- OCCURRENCE_PATH_TEMPLATE.render(
125
- :"project" => project,
126
- :"occurrence" => occurrence
127
- )
128
- end
129
-
130
- # Returns a fully-qualified project resource name string.
131
- # @param project [String]
132
- # @return [String]
133
- def self.project_path project
134
- PROJECT_PATH_TEMPLATE.render(
135
- :"project" => project
136
- )
137
- end
138
-
139
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
140
- # Provides the means for authenticating requests made by the client. This parameter can
141
- # be many types.
142
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
143
- # authenticating requests made by this client.
144
- # A `String` will be treated as the path to the keyfile to be used for the construction of
145
- # credentials for this client.
146
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
147
- # credentials for this client.
148
- # A `GRPC::Core::Channel` will be used to make calls through.
149
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
150
- # should already be composed with a `GRPC::Core::CallCredentials` object.
151
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
152
- # metadata for requests, generally, to give OAuth credentials.
153
- # @param scopes [Array<String>]
154
- # The OAuth scopes for this service. This parameter is ignored if
155
- # an updater_proc is supplied.
156
- # @param client_config [Hash]
157
- # A Hash for call options for each method. See
158
- # Google::Gax#construct_settings for the structure of
159
- # this data. Falls back to the default config if not specified
160
- # or the specified config is missing data points.
161
- # @param timeout [Numeric]
162
- # The default timeout, in seconds, for calls made through this client.
163
- # @param metadata [Hash]
164
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
165
- # @param service_address [String]
166
- # Override for the service hostname, or `nil` to leave as the default.
167
- # @param service_port [Integer]
168
- # Override for the service port, or `nil` to leave as the default.
169
- # @param exception_transformer [Proc]
170
- # An optional proc that intercepts any exceptions raised during an API call to inject
171
- # custom error handling.
172
- def initialize \
173
- credentials: nil,
174
- scopes: ALL_SCOPES,
175
- client_config: {},
176
- timeout: DEFAULT_TIMEOUT,
177
- metadata: nil,
178
- service_address: nil,
179
- service_port: nil,
180
- exception_transformer: nil,
181
- lib_name: nil,
182
- lib_version: ""
183
- # These require statements are intentionally placed here to initialize
184
- # the gRPC module only when it's required.
185
- # See https://github.com/googleapis/toolkit/issues/446
186
- require "google/gax/grpc"
187
- require "grafeas/v1/grafeas_services_pb"
188
-
189
- credentials ||= Grafeas::V1::Credentials.default
190
-
191
- if credentials.is_a?(String) || credentials.is_a?(Hash)
192
- updater_proc = Grafeas::V1::Credentials.new(credentials).updater_proc
193
- end
194
- if credentials.is_a?(GRPC::Core::Channel)
195
- channel = credentials
196
- end
197
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
198
- chan_creds = credentials
199
- end
200
- if credentials.is_a?(Proc)
201
- updater_proc = credentials
202
- end
203
- if credentials.is_a?(Google::Auth::Credentials)
204
- updater_proc = credentials.updater_proc
205
- end
206
-
207
- package_version = Grafeas::Client::VERSION
208
-
209
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
210
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
211
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
212
- google_api_client << " grpc/#{GRPC::VERSION}"
213
- google_api_client.freeze
214
-
215
- headers = { :"x-goog-api-client" => google_api_client }
216
- headers.merge!(metadata) unless metadata.nil?
217
- client_config_file = Pathname.new(__dir__).join(
218
- "grafeas_client_config.json"
219
- )
220
- defaults = client_config_file.open do |f|
221
- Google::Gax.construct_settings(
222
- "grafeas.v1.Grafeas",
223
- JSON.parse(f.read),
224
- client_config,
225
- Google::Gax::Grpc::STATUS_CODE_NAMES,
226
- timeout,
227
- page_descriptors: PAGE_DESCRIPTORS,
228
- errors: Google::Gax::Grpc::API_ERRORS,
229
- metadata: headers
230
- )
231
- end
232
-
233
- # Allow overriding the service path/port in subclasses.
234
- service_path = service_address || self.class::SERVICE_ADDRESS
235
- port = service_port || self.class::DEFAULT_SERVICE_PORT
236
- interceptors = self.class::GRPC_INTERCEPTORS
237
- @grafeas_stub = Google::Gax::Grpc.create_stub(
238
- service_path,
239
- port,
240
- chan_creds: chan_creds,
241
- channel: channel,
242
- updater_proc: updater_proc,
243
- scopes: scopes,
244
- interceptors: interceptors,
245
- &Grafeas::V1::GrafeasService::Stub.method(:new)
246
- )
247
-
248
- @get_occurrence = Google::Gax.create_api_call(
249
- @grafeas_stub.method(:get_occurrence),
250
- defaults["get_occurrence"],
251
- exception_transformer: exception_transformer,
252
- params_extractor: proc do |request|
253
- {'name' => request.name}
254
- end
255
- )
256
- @list_occurrences = Google::Gax.create_api_call(
257
- @grafeas_stub.method(:list_occurrences),
258
- defaults["list_occurrences"],
259
- exception_transformer: exception_transformer,
260
- params_extractor: proc do |request|
261
- {'parent' => request.parent}
262
- end
263
- )
264
- @delete_occurrence = Google::Gax.create_api_call(
265
- @grafeas_stub.method(:delete_occurrence),
266
- defaults["delete_occurrence"],
267
- exception_transformer: exception_transformer,
268
- params_extractor: proc do |request|
269
- {'name' => request.name}
270
- end
271
- )
272
- @create_occurrence = Google::Gax.create_api_call(
273
- @grafeas_stub.method(:create_occurrence),
274
- defaults["create_occurrence"],
275
- exception_transformer: exception_transformer,
276
- params_extractor: proc do |request|
277
- {'parent' => request.parent}
278
- end
279
- )
280
- @batch_create_occurrences = Google::Gax.create_api_call(
281
- @grafeas_stub.method(:batch_create_occurrences),
282
- defaults["batch_create_occurrences"],
283
- exception_transformer: exception_transformer,
284
- params_extractor: proc do |request|
285
- {'parent' => request.parent}
286
- end
287
- )
288
- @update_occurrence = Google::Gax.create_api_call(
289
- @grafeas_stub.method(:update_occurrence),
290
- defaults["update_occurrence"],
291
- exception_transformer: exception_transformer,
292
- params_extractor: proc do |request|
293
- {'name' => request.name}
294
- end
295
- )
296
- @get_occurrence_note = Google::Gax.create_api_call(
297
- @grafeas_stub.method(:get_occurrence_note),
298
- defaults["get_occurrence_note"],
299
- exception_transformer: exception_transformer,
300
- params_extractor: proc do |request|
301
- {'name' => request.name}
302
- end
303
- )
304
- @get_note = Google::Gax.create_api_call(
305
- @grafeas_stub.method(:get_note),
306
- defaults["get_note"],
307
- exception_transformer: exception_transformer,
308
- params_extractor: proc do |request|
309
- {'name' => request.name}
310
- end
311
- )
312
- @list_notes = Google::Gax.create_api_call(
313
- @grafeas_stub.method(:list_notes),
314
- defaults["list_notes"],
315
- exception_transformer: exception_transformer,
316
- params_extractor: proc do |request|
317
- {'parent' => request.parent}
318
- end
319
- )
320
- @delete_note = Google::Gax.create_api_call(
321
- @grafeas_stub.method(:delete_note),
322
- defaults["delete_note"],
323
- exception_transformer: exception_transformer,
324
- params_extractor: proc do |request|
325
- {'name' => request.name}
326
- end
327
- )
328
- @create_note = Google::Gax.create_api_call(
329
- @grafeas_stub.method(:create_note),
330
- defaults["create_note"],
331
- exception_transformer: exception_transformer,
332
- params_extractor: proc do |request|
333
- {'parent' => request.parent}
334
- end
335
- )
336
- @batch_create_notes = Google::Gax.create_api_call(
337
- @grafeas_stub.method(:batch_create_notes),
338
- defaults["batch_create_notes"],
339
- exception_transformer: exception_transformer,
340
- params_extractor: proc do |request|
341
- {'parent' => request.parent}
342
- end
343
- )
344
- @update_note = Google::Gax.create_api_call(
345
- @grafeas_stub.method(:update_note),
346
- defaults["update_note"],
347
- exception_transformer: exception_transformer,
348
- params_extractor: proc do |request|
349
- {'name' => request.name}
350
- end
351
- )
352
- @list_note_occurrences = Google::Gax.create_api_call(
353
- @grafeas_stub.method(:list_note_occurrences),
354
- defaults["list_note_occurrences"],
355
- exception_transformer: exception_transformer,
356
- params_extractor: proc do |request|
357
- {'name' => request.name}
358
- end
359
- )
360
- end
361
-
362
- # Service calls
363
-
364
- # Gets the specified occurrence.
365
- #
366
- # @param name [String]
367
- # The name of the occurrence in the form of
368
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
369
- # @param options [Google::Gax::CallOptions]
370
- # Overrides the default settings for this call, e.g, timeout,
371
- # retries, etc.
372
- # @yield [result, operation] Access the result along with the RPC operation
373
- # @yieldparam result [Grafeas::V1::Occurrence]
374
- # @yieldparam operation [GRPC::ActiveCall::Operation]
375
- # @return [Grafeas::V1::Occurrence]
376
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
377
- # @example
378
- # require "grafeas"
379
- #
380
- # grafeas_client = Grafeas.new(version: :v1)
381
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
382
- # response = grafeas_client.get_occurrence(formatted_name)
383
-
384
- def get_occurrence \
385
- name,
386
- options: nil,
387
- &block
388
- req = {
389
- name: name
390
- }.delete_if { |_, v| v.nil? }
391
- req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceRequest)
392
- @get_occurrence.call(req, options, &block)
393
- end
394
-
395
- # Lists occurrences for the specified project.
396
- #
397
- # @param parent [String]
398
- # The name of the project to list occurrences for in the form of
399
- # `projects/[PROJECT_ID]`.
400
- # @param filter [String]
401
- # The filter expression.
402
- # @param page_size [Integer]
403
- # The maximum number of resources contained in the underlying API
404
- # response. If page streaming is performed per-resource, this
405
- # parameter does not affect the return value. If page streaming is
406
- # performed per-page, this determines the maximum number of
407
- # resources in a page.
408
- # @param options [Google::Gax::CallOptions]
409
- # Overrides the default settings for this call, e.g, timeout,
410
- # retries, etc.
411
- # @yield [result, operation] Access the result along with the RPC operation
412
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
413
- # @yieldparam operation [GRPC::ActiveCall::Operation]
414
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
415
- # An enumerable of Grafeas::V1::Occurrence instances.
416
- # See Google::Gax::PagedEnumerable documentation for other
417
- # operations such as per-page iteration or access to the response
418
- # object.
419
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
420
- # @example
421
- # require "grafeas"
422
- #
423
- # grafeas_client = Grafeas.new(version: :v1)
424
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
425
- #
426
- # # Iterate over all results.
427
- # grafeas_client.list_occurrences(formatted_parent).each do |element|
428
- # # Process element.
429
- # end
430
- #
431
- # # Or iterate over results one page at a time.
432
- # grafeas_client.list_occurrences(formatted_parent).each_page do |page|
433
- # # Process each page at a time.
434
- # page.each do |element|
435
- # # Process element.
436
- # end
437
- # end
438
-
439
- def list_occurrences \
440
- parent,
441
- filter: nil,
442
- page_size: nil,
443
- options: nil,
444
- &block
445
- req = {
446
- parent: parent,
447
- filter: filter,
448
- page_size: page_size
449
- }.delete_if { |_, v| v.nil? }
450
- req = Google::Gax::to_proto(req, Grafeas::V1::ListOccurrencesRequest)
451
- @list_occurrences.call(req, options, &block)
452
- end
453
-
454
- # Deletes the specified occurrence. For example, use this method to delete an
455
- # occurrence when the occurrence is no longer applicable for the given
456
- # resource.
457
- #
458
- # @param name [String]
459
- # The name of the occurrence in the form of
460
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
461
- # @param options [Google::Gax::CallOptions]
462
- # Overrides the default settings for this call, e.g, timeout,
463
- # retries, etc.
464
- # @yield [result, operation] Access the result along with the RPC operation
465
- # @yieldparam result []
466
- # @yieldparam operation [GRPC::ActiveCall::Operation]
467
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
468
- # @example
469
- # require "grafeas"
470
- #
471
- # grafeas_client = Grafeas.new(version: :v1)
472
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
473
- # grafeas_client.delete_occurrence(formatted_name)
474
-
475
- def delete_occurrence \
476
- name,
477
- options: nil,
478
- &block
479
- req = {
480
- name: name
481
- }.delete_if { |_, v| v.nil? }
482
- req = Google::Gax::to_proto(req, Grafeas::V1::DeleteOccurrenceRequest)
483
- @delete_occurrence.call(req, options, &block)
484
- nil
485
- end
486
-
487
- # Creates a new occurrence.
488
- #
489
- # @param parent [String]
490
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
491
- # the occurrence is to be created.
492
- # @param occurrence [Grafeas::V1::Occurrence | Hash]
493
- # The occurrence to create.
494
- # A hash of the same form as `Grafeas::V1::Occurrence`
495
- # can also be provided.
496
- # @param options [Google::Gax::CallOptions]
497
- # Overrides the default settings for this call, e.g, timeout,
498
- # retries, etc.
499
- # @yield [result, operation] Access the result along with the RPC operation
500
- # @yieldparam result [Grafeas::V1::Occurrence]
501
- # @yieldparam operation [GRPC::ActiveCall::Operation]
502
- # @return [Grafeas::V1::Occurrence]
503
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
504
- # @example
505
- # require "grafeas"
506
- #
507
- # grafeas_client = Grafeas.new(version: :v1)
508
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
509
- #
510
- # # TODO: Initialize `occurrence`:
511
- # occurrence = {}
512
- # response = grafeas_client.create_occurrence(formatted_parent, occurrence)
513
-
514
- def create_occurrence \
515
- parent,
516
- occurrence,
517
- options: nil,
518
- &block
519
- req = {
520
- parent: parent,
521
- occurrence: occurrence
522
- }.delete_if { |_, v| v.nil? }
523
- req = Google::Gax::to_proto(req, Grafeas::V1::CreateOccurrenceRequest)
524
- @create_occurrence.call(req, options, &block)
525
- end
526
-
527
- # Creates new occurrences in batch.
528
- #
529
- # @param parent [String]
530
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
531
- # the occurrences are to be created.
532
- # @param occurrences [Array<Grafeas::V1::Occurrence | Hash>]
533
- # The occurrences to create. Max allowed length is 1000.
534
- # A hash of the same form as `Grafeas::V1::Occurrence`
535
- # can also be provided.
536
- # @param options [Google::Gax::CallOptions]
537
- # Overrides the default settings for this call, e.g, timeout,
538
- # retries, etc.
539
- # @yield [result, operation] Access the result along with the RPC operation
540
- # @yieldparam result [Grafeas::V1::BatchCreateOccurrencesResponse]
541
- # @yieldparam operation [GRPC::ActiveCall::Operation]
542
- # @return [Grafeas::V1::BatchCreateOccurrencesResponse]
543
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
544
- # @example
545
- # require "grafeas"
546
- #
547
- # grafeas_client = Grafeas.new(version: :v1)
548
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
549
- #
550
- # # TODO: Initialize `occurrences`:
551
- # occurrences = []
552
- # response = grafeas_client.batch_create_occurrences(formatted_parent, occurrences)
553
-
554
- def batch_create_occurrences \
555
- parent,
556
- occurrences,
557
- options: nil,
558
- &block
559
- req = {
560
- parent: parent,
561
- occurrences: occurrences
562
- }.delete_if { |_, v| v.nil? }
563
- req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateOccurrencesRequest)
564
- @batch_create_occurrences.call(req, options, &block)
565
- end
566
-
567
- # Updates the specified occurrence.
568
- #
569
- # @param name [String]
570
- # The name of the occurrence in the form of
571
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
572
- # @param occurrence [Grafeas::V1::Occurrence | Hash]
573
- # The updated occurrence.
574
- # A hash of the same form as `Grafeas::V1::Occurrence`
575
- # can also be provided.
576
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
577
- # The fields to update.
578
- # A hash of the same form as `Google::Protobuf::FieldMask`
579
- # can also be provided.
580
- # @param options [Google::Gax::CallOptions]
581
- # Overrides the default settings for this call, e.g, timeout,
582
- # retries, etc.
583
- # @yield [result, operation] Access the result along with the RPC operation
584
- # @yieldparam result [Grafeas::V1::Occurrence]
585
- # @yieldparam operation [GRPC::ActiveCall::Operation]
586
- # @return [Grafeas::V1::Occurrence]
587
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
588
- # @example
589
- # require "grafeas"
590
- #
591
- # grafeas_client = Grafeas.new(version: :v1)
592
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
593
- #
594
- # # TODO: Initialize `occurrence`:
595
- # occurrence = {}
596
- # response = grafeas_client.update_occurrence(formatted_name, occurrence)
597
-
598
- def update_occurrence \
599
- name,
600
- occurrence,
601
- update_mask: nil,
602
- options: nil,
603
- &block
604
- req = {
605
- name: name,
606
- occurrence: occurrence,
607
- update_mask: update_mask
608
- }.delete_if { |_, v| v.nil? }
609
- req = Google::Gax::to_proto(req, Grafeas::V1::UpdateOccurrenceRequest)
610
- @update_occurrence.call(req, options, &block)
611
- end
612
-
613
- # Gets the note attached to the specified occurrence. Consumer projects can
614
- # use this method to get a note that belongs to a provider project.
615
- #
616
- # @param name [String]
617
- # The name of the occurrence in the form of
618
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
619
- # @param options [Google::Gax::CallOptions]
620
- # Overrides the default settings for this call, e.g, timeout,
621
- # retries, etc.
622
- # @yield [result, operation] Access the result along with the RPC operation
623
- # @yieldparam result [Grafeas::V1::Note]
624
- # @yieldparam operation [GRPC::ActiveCall::Operation]
625
- # @return [Grafeas::V1::Note]
626
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
627
- # @example
628
- # require "grafeas"
629
- #
630
- # grafeas_client = Grafeas.new(version: :v1)
631
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
632
- # response = grafeas_client.get_occurrence_note(formatted_name)
633
-
634
- def get_occurrence_note \
635
- name,
636
- options: nil,
637
- &block
638
- req = {
639
- name: name
640
- }.delete_if { |_, v| v.nil? }
641
- req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceNoteRequest)
642
- @get_occurrence_note.call(req, options, &block)
643
- end
644
-
645
- # Gets the specified note.
646
- #
647
- # @param name [String]
648
- # The name of the note in the form of
649
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
650
- # @param options [Google::Gax::CallOptions]
651
- # Overrides the default settings for this call, e.g, timeout,
652
- # retries, etc.
653
- # @yield [result, operation] Access the result along with the RPC operation
654
- # @yieldparam result [Grafeas::V1::Note]
655
- # @yieldparam operation [GRPC::ActiveCall::Operation]
656
- # @return [Grafeas::V1::Note]
657
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
658
- # @example
659
- # require "grafeas"
660
- #
661
- # grafeas_client = Grafeas.new(version: :v1)
662
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
663
- # response = grafeas_client.get_note(formatted_name)
664
-
665
- def get_note \
666
- name,
667
- options: nil,
668
- &block
669
- req = {
670
- name: name
671
- }.delete_if { |_, v| v.nil? }
672
- req = Google::Gax::to_proto(req, Grafeas::V1::GetNoteRequest)
673
- @get_note.call(req, options, &block)
674
- end
675
-
676
- # Lists notes for the specified project.
677
- #
678
- # @param parent [String]
679
- # The name of the project to list notes for in the form of
680
- # `projects/[PROJECT_ID]`.
681
- # @param filter [String]
682
- # The filter expression.
683
- # @param page_size [Integer]
684
- # The maximum number of resources contained in the underlying API
685
- # response. If page streaming is performed per-resource, this
686
- # parameter does not affect the return value. If page streaming is
687
- # performed per-page, this determines the maximum number of
688
- # resources in a page.
689
- # @param options [Google::Gax::CallOptions]
690
- # Overrides the default settings for this call, e.g, timeout,
691
- # retries, etc.
692
- # @yield [result, operation] Access the result along with the RPC operation
693
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Note>]
694
- # @yieldparam operation [GRPC::ActiveCall::Operation]
695
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Note>]
696
- # An enumerable of Grafeas::V1::Note instances.
697
- # See Google::Gax::PagedEnumerable documentation for other
698
- # operations such as per-page iteration or access to the response
699
- # object.
700
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
701
- # @example
702
- # require "grafeas"
703
- #
704
- # grafeas_client = Grafeas.new(version: :v1)
705
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
706
- #
707
- # # Iterate over all results.
708
- # grafeas_client.list_notes(formatted_parent).each do |element|
709
- # # Process element.
710
- # end
711
- #
712
- # # Or iterate over results one page at a time.
713
- # grafeas_client.list_notes(formatted_parent).each_page do |page|
714
- # # Process each page at a time.
715
- # page.each do |element|
716
- # # Process element.
717
- # end
718
- # end
719
-
720
- def list_notes \
721
- parent,
722
- filter: nil,
723
- page_size: nil,
724
- options: nil,
725
- &block
726
- req = {
727
- parent: parent,
728
- filter: filter,
729
- page_size: page_size
730
- }.delete_if { |_, v| v.nil? }
731
- req = Google::Gax::to_proto(req, Grafeas::V1::ListNotesRequest)
732
- @list_notes.call(req, options, &block)
733
- end
734
-
735
- # Deletes the specified note.
736
- #
737
- # @param name [String]
738
- # The name of the note in the form of
739
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
740
- # @param options [Google::Gax::CallOptions]
741
- # Overrides the default settings for this call, e.g, timeout,
742
- # retries, etc.
743
- # @yield [result, operation] Access the result along with the RPC operation
744
- # @yieldparam result []
745
- # @yieldparam operation [GRPC::ActiveCall::Operation]
746
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
747
- # @example
748
- # require "grafeas"
749
- #
750
- # grafeas_client = Grafeas.new(version: :v1)
751
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
752
- # grafeas_client.delete_note(formatted_name)
753
-
754
- def delete_note \
755
- name,
756
- options: nil,
757
- &block
758
- req = {
759
- name: name
760
- }.delete_if { |_, v| v.nil? }
761
- req = Google::Gax::to_proto(req, Grafeas::V1::DeleteNoteRequest)
762
- @delete_note.call(req, options, &block)
763
- nil
764
- end
765
-
766
- # Creates a new note.
767
- #
768
- # @param parent [String]
769
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
770
- # the note is to be created.
771
- # @param note_id [String]
772
- # The ID to use for this note.
773
- # @param note [Grafeas::V1::Note | Hash]
774
- # The note to create.
775
- # A hash of the same form as `Grafeas::V1::Note`
776
- # can also be provided.
777
- # @param options [Google::Gax::CallOptions]
778
- # Overrides the default settings for this call, e.g, timeout,
779
- # retries, etc.
780
- # @yield [result, operation] Access the result along with the RPC operation
781
- # @yieldparam result [Grafeas::V1::Note]
782
- # @yieldparam operation [GRPC::ActiveCall::Operation]
783
- # @return [Grafeas::V1::Note]
784
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
785
- # @example
786
- # require "grafeas"
787
- #
788
- # grafeas_client = Grafeas.new(version: :v1)
789
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
790
- #
791
- # # TODO: Initialize `note_id`:
792
- # note_id = ''
793
- #
794
- # # TODO: Initialize `note`:
795
- # note = {}
796
- # response = grafeas_client.create_note(formatted_parent, note_id, note)
797
-
798
- def create_note \
799
- parent,
800
- note_id,
801
- note,
802
- options: nil,
803
- &block
804
- req = {
805
- parent: parent,
806
- note_id: note_id,
807
- note: note
808
- }.delete_if { |_, v| v.nil? }
809
- req = Google::Gax::to_proto(req, Grafeas::V1::CreateNoteRequest)
810
- @create_note.call(req, options, &block)
811
- end
812
-
813
- # Creates new notes in batch.
814
- #
815
- # @param parent [String]
816
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
817
- # the notes are to be created.
818
- # @param notes [Hash{String => Grafeas::V1::Note | Hash}]
819
- # The notes to create. Max allowed length is 1000.
820
- # A hash of the same form as `Grafeas::V1::Note`
821
- # can also be provided.
822
- # @param options [Google::Gax::CallOptions]
823
- # Overrides the default settings for this call, e.g, timeout,
824
- # retries, etc.
825
- # @yield [result, operation] Access the result along with the RPC operation
826
- # @yieldparam result [Grafeas::V1::BatchCreateNotesResponse]
827
- # @yieldparam operation [GRPC::ActiveCall::Operation]
828
- # @return [Grafeas::V1::BatchCreateNotesResponse]
829
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
830
- # @example
831
- # require "grafeas"
832
- #
833
- # grafeas_client = Grafeas.new(version: :v1)
834
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
835
- #
836
- # # TODO: Initialize `notes`:
837
- # notes = {}
838
- # response = grafeas_client.batch_create_notes(formatted_parent, notes)
839
-
840
- def batch_create_notes \
841
- parent,
842
- notes,
843
- options: nil,
844
- &block
845
- req = {
846
- parent: parent,
847
- notes: notes
848
- }.delete_if { |_, v| v.nil? }
849
- req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateNotesRequest)
850
- @batch_create_notes.call(req, options, &block)
851
- end
852
-
853
- # Updates the specified note.
854
- #
855
- # @param name [String]
856
- # The name of the note in the form of
857
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
858
- # @param note [Grafeas::V1::Note | Hash]
859
- # The updated note.
860
- # A hash of the same form as `Grafeas::V1::Note`
861
- # can also be provided.
862
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
863
- # The fields to update.
864
- # A hash of the same form as `Google::Protobuf::FieldMask`
865
- # can also be provided.
866
- # @param options [Google::Gax::CallOptions]
867
- # Overrides the default settings for this call, e.g, timeout,
868
- # retries, etc.
869
- # @yield [result, operation] Access the result along with the RPC operation
870
- # @yieldparam result [Grafeas::V1::Note]
871
- # @yieldparam operation [GRPC::ActiveCall::Operation]
872
- # @return [Grafeas::V1::Note]
873
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
874
- # @example
875
- # require "grafeas"
876
- #
877
- # grafeas_client = Grafeas.new(version: :v1)
878
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
879
- #
880
- # # TODO: Initialize `note`:
881
- # note = {}
882
- # response = grafeas_client.update_note(formatted_name, note)
883
-
884
- def update_note \
885
- name,
886
- note,
887
- update_mask: nil,
888
- options: nil,
889
- &block
890
- req = {
891
- name: name,
892
- note: note,
893
- update_mask: update_mask
894
- }.delete_if { |_, v| v.nil? }
895
- req = Google::Gax::to_proto(req, Grafeas::V1::UpdateNoteRequest)
896
- @update_note.call(req, options, &block)
897
- end
898
-
899
- # Lists occurrences referencing the specified note. Provider projects can use
900
- # this method to get all occurrences across consumer projects referencing the
901
- # specified note.
902
- #
903
- # @param name [String]
904
- # The name of the note to list occurrences for in the form of
905
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
906
- # @param filter [String]
907
- # The filter expression.
908
- # @param page_size [Integer]
909
- # The maximum number of resources contained in the underlying API
910
- # response. If page streaming is performed per-resource, this
911
- # parameter does not affect the return value. If page streaming is
912
- # performed per-page, this determines the maximum number of
913
- # resources in a page.
914
- # @param options [Google::Gax::CallOptions]
915
- # Overrides the default settings for this call, e.g, timeout,
916
- # retries, etc.
917
- # @yield [result, operation] Access the result along with the RPC operation
918
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
919
- # @yieldparam operation [GRPC::ActiveCall::Operation]
920
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
921
- # An enumerable of Grafeas::V1::Occurrence instances.
922
- # See Google::Gax::PagedEnumerable documentation for other
923
- # operations such as per-page iteration or access to the response
924
- # object.
925
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
926
- # @example
927
- # require "grafeas"
928
- #
929
- # grafeas_client = Grafeas.new(version: :v1)
930
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
931
- #
932
- # # Iterate over all results.
933
- # grafeas_client.list_note_occurrences(formatted_name).each do |element|
934
- # # Process element.
935
- # end
936
- #
937
- # # Or iterate over results one page at a time.
938
- # grafeas_client.list_note_occurrences(formatted_name).each_page do |page|
939
- # # Process each page at a time.
940
- # page.each do |element|
941
- # # Process element.
942
- # end
943
- # end
944
-
945
- def list_note_occurrences \
946
- name,
947
- filter: nil,
948
- page_size: nil,
949
- options: nil,
950
- &block
951
- req = {
952
- name: name,
953
- filter: filter,
954
- page_size: page_size
955
- }.delete_if { |_, v| v.nil? }
956
- req = Google::Gax::to_proto(req, Grafeas::V1::ListNoteOccurrencesRequest)
957
- @list_note_occurrences.call(req, options, &block)
958
- end
959
- end
960
- end
961
- end