grafeas 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/LICENSE.md +203 -0
  4. data/MIGRATING.md +366 -0
  5. data/README.md +28 -25
  6. data/lib/grafeas.rb +36 -117
  7. data/lib/grafeas/version.rb +6 -2
  8. metadata +49 -80
  9. data/AUTHENTICATION.md +0 -172
  10. data/LICENSE +0 -201
  11. data/lib/grafeas/v1.rb +0 -155
  12. data/lib/grafeas/v1/attestation_pb.rb +0 -27
  13. data/lib/grafeas/v1/build_pb.rb +0 -23
  14. data/lib/grafeas/v1/common_pb.rb +0 -35
  15. data/lib/grafeas/v1/credentials.rb +0 -37
  16. data/lib/grafeas/v1/cvss_pb.rb +0 -67
  17. data/lib/grafeas/v1/deployment_pb.rb +0 -35
  18. data/lib/grafeas/v1/discovery_pb.rb +0 -43
  19. data/lib/grafeas/v1/doc/google/protobuf/any.rb +0 -131
  20. data/lib/grafeas/v1/doc/google/protobuf/empty.rb +0 -29
  21. data/lib/grafeas/v1/doc/google/protobuf/field_mask.rb +0 -222
  22. data/lib/grafeas/v1/doc/google/protobuf/timestamp.rb +0 -113
  23. data/lib/grafeas/v1/doc/google/rpc/status.rb +0 -39
  24. data/lib/grafeas/v1/doc/grafeas/v1/attestation.rb +0 -64
  25. data/lib/grafeas/v1/doc/grafeas/v1/build.rb +0 -44
  26. data/lib/grafeas/v1/doc/grafeas/v1/common.rb +0 -108
  27. data/lib/grafeas/v1/doc/grafeas/v1/cvss.rb +0 -104
  28. data/lib/grafeas/v1/doc/grafeas/v1/deployment.rb +0 -64
  29. data/lib/grafeas/v1/doc/grafeas/v1/discovery.rb +0 -82
  30. data/lib/grafeas/v1/doc/grafeas/v1/grafeas.rb +0 -328
  31. data/lib/grafeas/v1/doc/grafeas/v1/image.rb +0 -79
  32. data/lib/grafeas/v1/doc/grafeas/v1/package.rb +0 -125
  33. data/lib/grafeas/v1/doc/grafeas/v1/provenance.rb +0 -248
  34. data/lib/grafeas/v1/doc/grafeas/v1/upgrade.rb +0 -126
  35. data/lib/grafeas/v1/doc/grafeas/v1/vulnerability.rb +0 -223
  36. data/lib/grafeas/v1/grafeas_client.rb +0 -964
  37. data/lib/grafeas/v1/grafeas_client_config.json +0 -96
  38. data/lib/grafeas/v1/grafeas_pb.rb +0 -168
  39. data/lib/grafeas/v1/grafeas_services_pb.rb +0 -86
  40. data/lib/grafeas/v1/image_pb.rb +0 -36
  41. data/lib/grafeas/v1/package_pb.rb +0 -59
  42. data/lib/grafeas/v1/provenance_pb.rb +0 -116
  43. data/lib/grafeas/v1/upgrade_pb.rb +0 -56
  44. data/lib/grafeas/v1/vulnerability_pb.rb +0 -84
@@ -1,126 +0,0 @@
1
- # Copyright 2020 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
-
16
- module Grafeas
17
- module V1
18
- # An Upgrade Note represents a potential upgrade of a package to a given
19
- # version. For each package version combination (i.e. bash 4.0, bash 4.1,
20
- # bash 4.1.2), there will be an Upgrade Note. For Windows, windows_update field
21
- # represents the information related to the update.
22
- # @!attribute [rw] package
23
- # @return [String]
24
- # Required for non-Windows OS. The package this Upgrade is for.
25
- # @!attribute [rw] version
26
- # @return [Grafeas::V1::Version]
27
- # Required for non-Windows OS. The version of the package in machine + human
28
- # readable form.
29
- # @!attribute [rw] distributions
30
- # @return [Array<Grafeas::V1::UpgradeDistribution>]
31
- # Metadata about the upgrade for each specific operating system.
32
- # @!attribute [rw] windows_update
33
- # @return [Grafeas::V1::WindowsUpdate]
34
- # Required for Windows OS. Represents the metadata about the Windows update.
35
- class UpgradeNote; end
36
-
37
- # The Upgrade Distribution represents metadata about the Upgrade for each
38
- # operating system (CPE). Some distributions have additional metadata around
39
- # updates, classifying them into various categories and severities.
40
- # @!attribute [rw] cpe_uri
41
- # @return [String]
42
- # Required - The specific operating system this metadata applies to. See
43
- # https://cpe.mitre.org/specification/.
44
- # @!attribute [rw] classification
45
- # @return [String]
46
- # The operating system classification of this Upgrade, as specified by the
47
- # upstream operating system upgrade feed. For Windows the classification is
48
- # one of the category_ids listed at
49
- # https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ff357803(v=vs.85)
50
- # @!attribute [rw] severity
51
- # @return [String]
52
- # The severity as specified by the upstream operating system.
53
- # @!attribute [rw] cve
54
- # @return [Array<String>]
55
- # The cve tied to this Upgrade.
56
- class UpgradeDistribution; end
57
-
58
- # Windows Update represents the metadata about the update for the Windows
59
- # operating system. The fields in this message come from the Windows Update API
60
- # documented at
61
- # https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdate.
62
- # @!attribute [rw] identity
63
- # @return [Grafeas::V1::WindowsUpdate::Identity]
64
- # Required - The unique identifier for the update.
65
- # @!attribute [rw] title
66
- # @return [String]
67
- # The localized title of the update.
68
- # @!attribute [rw] description
69
- # @return [String]
70
- # The localized description of the update.
71
- # @!attribute [rw] categories
72
- # @return [Array<Grafeas::V1::WindowsUpdate::Category>]
73
- # The list of categories to which the update belongs.
74
- # @!attribute [rw] kb_article_ids
75
- # @return [Array<String>]
76
- # The Microsoft Knowledge Base article IDs that are associated with the
77
- # update.
78
- # @!attribute [rw] support_url
79
- # @return [String]
80
- # The hyperlink to the support information for the update.
81
- # @!attribute [rw] last_published_timestamp
82
- # @return [Google::Protobuf::Timestamp]
83
- # The last published timestamp of the update.
84
- class WindowsUpdate
85
- # The unique identifier of the update.
86
- # @!attribute [rw] update_id
87
- # @return [String]
88
- # The revision independent identifier of the update.
89
- # @!attribute [rw] revision
90
- # @return [Integer]
91
- # The revision number of the update.
92
- class Identity; end
93
-
94
- # The category to which the update belongs.
95
- # @!attribute [rw] category_id
96
- # @return [String]
97
- # The identifier of the category.
98
- # @!attribute [rw] name
99
- # @return [String]
100
- # The localized name of the category.
101
- class Category; end
102
- end
103
-
104
- # An Upgrade Occurrence represents that a specific resource_url could install a
105
- # specific upgrade. This presence is supplied via local sources (i.e. it is
106
- # present in the mirror and the running system has noticed its availability).
107
- # For Windows, both distribution and windows_update contain information for the
108
- # Windows update.
109
- # @!attribute [rw] package
110
- # @return [String]
111
- # Required for non-Windows OS. The package this Upgrade is for.
112
- # @!attribute [rw] parsed_version
113
- # @return [Grafeas::V1::Version]
114
- # Required for non-Windows OS. The version of the package in a machine +
115
- # human readable form.
116
- # @!attribute [rw] distribution
117
- # @return [Grafeas::V1::UpgradeDistribution]
118
- # Metadata about the upgrade for available for the specific operating system
119
- # for the resource_url. This allows efficient filtering, as well as
120
- # making it easier to use the occurrence.
121
- # @!attribute [rw] windows_update
122
- # @return [Grafeas::V1::WindowsUpdate]
123
- # Required for Windows OS. Represents the metadata about the Windows update.
124
- class UpgradeOccurrence; end
125
- end
126
- end
@@ -1,223 +0,0 @@
1
- # Copyright 2020 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
-
16
- module Grafeas
17
- module V1
18
- # A security vulnerability that can be found in resources.
19
- # @!attribute [rw] cvss_score
20
- # @return [Float]
21
- # The CVSS score of this vulnerability. CVSS score is on a scale of 0 - 10
22
- # where 0 indicates low severity and 10 indicates high severity.
23
- # @!attribute [rw] severity
24
- # @return [Grafeas::V1::Severity]
25
- # The note provider assigned severity of this vulnerability.
26
- # @!attribute [rw] details
27
- # @return [Array<Grafeas::V1::VulnerabilityNote::Detail>]
28
- # Details of all known distros and packages affected by this vulnerability.
29
- # @!attribute [rw] cvss_v3
30
- # @return [Grafeas::V1::CVSSv3]
31
- # The full description of the CVSSv3 for this vulnerability.
32
- # @!attribute [rw] windows_details
33
- # @return [Array<Grafeas::V1::VulnerabilityNote::WindowsDetail>]
34
- # Windows details get their own format because the information format and
35
- # model don't match a normal detail. Specifically Windows updates are done as
36
- # patches, thus Windows vulnerabilities really are a missing package, rather
37
- # than a package being at an incorrect version.
38
- # @!attribute [rw] source_update_time
39
- # @return [Google::Protobuf::Timestamp]
40
- # The time this information was last changed at the source. This is an
41
- # upstream timestamp from the underlying information source - e.g. Ubuntu
42
- # security tracker.
43
- class VulnerabilityNote
44
- # A detail for a distro and package affected by this vulnerability and its
45
- # associated fix (if one is available).
46
- # @!attribute [rw] severity_name
47
- # @return [String]
48
- # The distro assigned severity of this vulnerability.
49
- # @!attribute [rw] description
50
- # @return [String]
51
- # A vendor-specific description of this vulnerability.
52
- # @!attribute [rw] package_type
53
- # @return [String]
54
- # The type of package; whether native or non native (e.g., ruby gems,
55
- # node.js packages, etc.).
56
- # @!attribute [rw] affected_cpe_uri
57
- # @return [String]
58
- # Required. The [CPE URI](https://cpe.mitre.org/specification/) this
59
- # vulnerability affects.
60
- # @!attribute [rw] affected_package
61
- # @return [String]
62
- # Required. The package this vulnerability affects.
63
- # @!attribute [rw] affected_version_start
64
- # @return [Grafeas::V1::Version]
65
- # The version number at the start of an interval in which this
66
- # vulnerability exists. A vulnerability can affect a package between
67
- # version numbers that are disjoint sets of intervals (example:
68
- # [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be
69
- # represented in its own Detail. If a specific affected version is provided
70
- # by a vulnerability database, affected_version_start and
71
- # affected_version_end will be the same in that Detail.
72
- # @!attribute [rw] affected_version_end
73
- # @return [Grafeas::V1::Version]
74
- # The version number at the end of an interval in which this vulnerability
75
- # exists. A vulnerability can affect a package between version numbers
76
- # that are disjoint sets of intervals (example: [1.0.0-1.1.0],
77
- # [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its
78
- # own Detail. If a specific affected version is provided by a vulnerability
79
- # database, affected_version_start and affected_version_end will be the
80
- # same in that Detail.
81
- # @!attribute [rw] fixed_cpe_uri
82
- # @return [String]
83
- # The distro recommended [CPE URI](https://cpe.mitre.org/specification/)
84
- # to update to that contains a fix for this vulnerability. It is possible
85
- # for this to be different from the affected_cpe_uri.
86
- # @!attribute [rw] fixed_package
87
- # @return [String]
88
- # The distro recommended package to update to that contains a fix for this
89
- # vulnerability. It is possible for this to be different from the
90
- # affected_package.
91
- # @!attribute [rw] fixed_version
92
- # @return [Grafeas::V1::Version]
93
- # The distro recommended version to update to that contains a
94
- # fix for this vulnerability. Setting this to VersionKind.MAXIMUM means no
95
- # such version is yet available.
96
- # @!attribute [rw] is_obsolete
97
- # @return [true, false]
98
- # Whether this detail is obsolete. Occurrences are expected not to point to
99
- # obsolete details.
100
- # @!attribute [rw] source_update_time
101
- # @return [Google::Protobuf::Timestamp]
102
- # The time this information was last changed at the source. This is an
103
- # upstream timestamp from the underlying information source - e.g. Ubuntu
104
- # security tracker.
105
- class Detail; end
106
-
107
- # @!attribute [rw] cpe_uri
108
- # @return [String]
109
- # Required. The [CPE URI](https://cpe.mitre.org/specification/) this
110
- # vulnerability affects.
111
- # @!attribute [rw] name
112
- # @return [String]
113
- # Required. The name of this vulnerability.
114
- # @!attribute [rw] description
115
- # @return [String]
116
- # The description of this vulnerability.
117
- # @!attribute [rw] fixing_kbs
118
- # @return [Array<Grafeas::V1::VulnerabilityNote::WindowsDetail::KnowledgeBase>]
119
- # Required. The names of the KBs which have hotfixes to mitigate this
120
- # vulnerability. Note that there may be multiple hotfixes (and thus
121
- # multiple KBs) that mitigate a given vulnerability. Currently any listed
122
- # KBs presence is considered a fix.
123
- class WindowsDetail
124
- # @!attribute [rw] name
125
- # @return [String]
126
- # The KB name (generally of the form KB[0-9]+ (e.g., KB123456)).
127
- # @!attribute [rw] url
128
- # @return [String]
129
- # A link to the KB in the [Windows update catalog]
130
- # (https://www.catalog.update.microsoft.com/).
131
- class KnowledgeBase; end
132
- end
133
- end
134
-
135
- # An occurrence of a severity vulnerability on a resource.
136
- # @!attribute [rw] type
137
- # @return [String]
138
- # The type of package; whether native or non native (e.g., ruby gems, node.js
139
- # packages, etc.).
140
- # @!attribute [rw] severity
141
- # @return [Grafeas::V1::Severity]
142
- # Output only. The note provider assigned severity of this vulnerability.
143
- # @!attribute [rw] cvss_score
144
- # @return [Float]
145
- # Output only. The CVSS score of this vulnerability. CVSS score is on a
146
- # scale of 0 - 10 where 0 indicates low severity and 10 indicates high
147
- # severity.
148
- # @!attribute [rw] package_issue
149
- # @return [Array<Grafeas::V1::VulnerabilityOccurrence::PackageIssue>]
150
- # Required. The set of affected locations and their fixes (if available)
151
- # within the associated resource.
152
- # @!attribute [rw] short_description
153
- # @return [String]
154
- # Output only. A one sentence description of this vulnerability.
155
- # @!attribute [rw] long_description
156
- # @return [String]
157
- # Output only. A detailed description of this vulnerability.
158
- # @!attribute [rw] related_urls
159
- # @return [Array<Grafeas::V1::RelatedUrl>]
160
- # Output only. URLs related to this vulnerability.
161
- # @!attribute [rw] effective_severity
162
- # @return [Grafeas::V1::Severity]
163
- # The distro assigned severity for this vulnerability when it is available,
164
- # otherwise this is the note provider assigned severity.
165
- # @!attribute [rw] fix_available
166
- # @return [true, false]
167
- # Output only. Whether at least one of the affected packages has a fix
168
- # available.
169
- class VulnerabilityOccurrence
170
- # A detail for a distro and package this vulnerability occurrence was found
171
- # in and its associated fix (if one is available).
172
- # @!attribute [rw] affected_cpe_uri
173
- # @return [String]
174
- # Required. The [CPE URI](https://cpe.mitre.org/specification/) this
175
- # vulnerability was found in.
176
- # @!attribute [rw] affected_package
177
- # @return [String]
178
- # Required. The package this vulnerability was found in.
179
- # @!attribute [rw] affected_version
180
- # @return [Grafeas::V1::Version]
181
- # Required. The version of the package that is installed on the resource
182
- # affected by this vulnerability.
183
- # @!attribute [rw] fixed_cpe_uri
184
- # @return [String]
185
- # The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability
186
- # was fixed in. It is possible for this to be different from the
187
- # affected_cpe_uri.
188
- # @!attribute [rw] fixed_package
189
- # @return [String]
190
- # The package this vulnerability was fixed in. It is possible for this to
191
- # be different from the affected_package.
192
- # @!attribute [rw] fixed_version
193
- # @return [Grafeas::V1::Version]
194
- # Required. The version of the package this vulnerability was fixed in.
195
- # Setting this to VersionKind.MAXIMUM means no fix is yet available.
196
- # @!attribute [rw] fix_available
197
- # @return [true, false]
198
- # Output only. Whether a fix is available for this package.
199
- class PackageIssue; end
200
- end
201
-
202
- # Note provider assigned severity/impact ranking.
203
- module Severity
204
- # Unknown.
205
- SEVERITY_UNSPECIFIED = 0
206
-
207
- # Minimal severity.
208
- MINIMAL = 1
209
-
210
- # Low severity.
211
- LOW = 2
212
-
213
- # Medium severity.
214
- MEDIUM = 3
215
-
216
- # High severity.
217
- HIGH = 4
218
-
219
- # Critical severity.
220
- CRITICAL = 5
221
- end
222
- end
223
- end
@@ -1,964 +0,0 @@
1
- # Copyright 2020 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/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::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
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
217
- headers[:"x-goog-user-project"] = credentials.quota_project_id
218
- end
219
- headers.merge!(metadata) unless metadata.nil?
220
- client_config_file = Pathname.new(__dir__).join(
221
- "grafeas_client_config.json"
222
- )
223
- defaults = client_config_file.open do |f|
224
- Google::Gax.construct_settings(
225
- "grafeas.v1.Grafeas",
226
- JSON.parse(f.read),
227
- client_config,
228
- Google::Gax::Grpc::STATUS_CODE_NAMES,
229
- timeout,
230
- page_descriptors: PAGE_DESCRIPTORS,
231
- errors: Google::Gax::Grpc::API_ERRORS,
232
- metadata: headers
233
- )
234
- end
235
-
236
- # Allow overriding the service path/port in subclasses.
237
- service_path = service_address || self.class::SERVICE_ADDRESS
238
- port = service_port || self.class::DEFAULT_SERVICE_PORT
239
- interceptors = self.class::GRPC_INTERCEPTORS
240
- @grafeas_stub = Google::Gax::Grpc.create_stub(
241
- service_path,
242
- port,
243
- chan_creds: chan_creds,
244
- channel: channel,
245
- updater_proc: updater_proc,
246
- scopes: scopes,
247
- interceptors: interceptors,
248
- &Grafeas::V1::GrafeasService::Stub.method(:new)
249
- )
250
-
251
- @get_occurrence = Google::Gax.create_api_call(
252
- @grafeas_stub.method(:get_occurrence),
253
- defaults["get_occurrence"],
254
- exception_transformer: exception_transformer,
255
- params_extractor: proc do |request|
256
- {'name' => request.name}
257
- end
258
- )
259
- @list_occurrences = Google::Gax.create_api_call(
260
- @grafeas_stub.method(:list_occurrences),
261
- defaults["list_occurrences"],
262
- exception_transformer: exception_transformer,
263
- params_extractor: proc do |request|
264
- {'parent' => request.parent}
265
- end
266
- )
267
- @delete_occurrence = Google::Gax.create_api_call(
268
- @grafeas_stub.method(:delete_occurrence),
269
- defaults["delete_occurrence"],
270
- exception_transformer: exception_transformer,
271
- params_extractor: proc do |request|
272
- {'name' => request.name}
273
- end
274
- )
275
- @create_occurrence = Google::Gax.create_api_call(
276
- @grafeas_stub.method(:create_occurrence),
277
- defaults["create_occurrence"],
278
- exception_transformer: exception_transformer,
279
- params_extractor: proc do |request|
280
- {'parent' => request.parent}
281
- end
282
- )
283
- @batch_create_occurrences = Google::Gax.create_api_call(
284
- @grafeas_stub.method(:batch_create_occurrences),
285
- defaults["batch_create_occurrences"],
286
- exception_transformer: exception_transformer,
287
- params_extractor: proc do |request|
288
- {'parent' => request.parent}
289
- end
290
- )
291
- @update_occurrence = Google::Gax.create_api_call(
292
- @grafeas_stub.method(:update_occurrence),
293
- defaults["update_occurrence"],
294
- exception_transformer: exception_transformer,
295
- params_extractor: proc do |request|
296
- {'name' => request.name}
297
- end
298
- )
299
- @get_occurrence_note = Google::Gax.create_api_call(
300
- @grafeas_stub.method(:get_occurrence_note),
301
- defaults["get_occurrence_note"],
302
- exception_transformer: exception_transformer,
303
- params_extractor: proc do |request|
304
- {'name' => request.name}
305
- end
306
- )
307
- @get_note = Google::Gax.create_api_call(
308
- @grafeas_stub.method(:get_note),
309
- defaults["get_note"],
310
- exception_transformer: exception_transformer,
311
- params_extractor: proc do |request|
312
- {'name' => request.name}
313
- end
314
- )
315
- @list_notes = Google::Gax.create_api_call(
316
- @grafeas_stub.method(:list_notes),
317
- defaults["list_notes"],
318
- exception_transformer: exception_transformer,
319
- params_extractor: proc do |request|
320
- {'parent' => request.parent}
321
- end
322
- )
323
- @delete_note = Google::Gax.create_api_call(
324
- @grafeas_stub.method(:delete_note),
325
- defaults["delete_note"],
326
- exception_transformer: exception_transformer,
327
- params_extractor: proc do |request|
328
- {'name' => request.name}
329
- end
330
- )
331
- @create_note = Google::Gax.create_api_call(
332
- @grafeas_stub.method(:create_note),
333
- defaults["create_note"],
334
- exception_transformer: exception_transformer,
335
- params_extractor: proc do |request|
336
- {'parent' => request.parent}
337
- end
338
- )
339
- @batch_create_notes = Google::Gax.create_api_call(
340
- @grafeas_stub.method(:batch_create_notes),
341
- defaults["batch_create_notes"],
342
- exception_transformer: exception_transformer,
343
- params_extractor: proc do |request|
344
- {'parent' => request.parent}
345
- end
346
- )
347
- @update_note = Google::Gax.create_api_call(
348
- @grafeas_stub.method(:update_note),
349
- defaults["update_note"],
350
- exception_transformer: exception_transformer,
351
- params_extractor: proc do |request|
352
- {'name' => request.name}
353
- end
354
- )
355
- @list_note_occurrences = Google::Gax.create_api_call(
356
- @grafeas_stub.method(:list_note_occurrences),
357
- defaults["list_note_occurrences"],
358
- exception_transformer: exception_transformer,
359
- params_extractor: proc do |request|
360
- {'name' => request.name}
361
- end
362
- )
363
- end
364
-
365
- # Service calls
366
-
367
- # Gets the specified occurrence.
368
- #
369
- # @param name [String]
370
- # The name of the occurrence in the form of
371
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
372
- # @param options [Google::Gax::CallOptions]
373
- # Overrides the default settings for this call, e.g, timeout,
374
- # retries, etc.
375
- # @yield [result, operation] Access the result along with the RPC operation
376
- # @yieldparam result [Grafeas::V1::Occurrence]
377
- # @yieldparam operation [GRPC::ActiveCall::Operation]
378
- # @return [Grafeas::V1::Occurrence]
379
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
380
- # @example
381
- # require "grafeas"
382
- #
383
- # grafeas_client = Grafeas.new(version: :v1)
384
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
385
- # response = grafeas_client.get_occurrence(formatted_name)
386
-
387
- def get_occurrence \
388
- name,
389
- options: nil,
390
- &block
391
- req = {
392
- name: name
393
- }.delete_if { |_, v| v.nil? }
394
- req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceRequest)
395
- @get_occurrence.call(req, options, &block)
396
- end
397
-
398
- # Lists occurrences for the specified project.
399
- #
400
- # @param parent [String]
401
- # The name of the project to list occurrences for in the form of
402
- # `projects/[PROJECT_ID]`.
403
- # @param filter [String]
404
- # The filter expression.
405
- # @param page_size [Integer]
406
- # The maximum number of resources contained in the underlying API
407
- # response. If page streaming is performed per-resource, this
408
- # parameter does not affect the return value. If page streaming is
409
- # performed per-page, this determines the maximum number of
410
- # resources in a page.
411
- # @param options [Google::Gax::CallOptions]
412
- # Overrides the default settings for this call, e.g, timeout,
413
- # retries, etc.
414
- # @yield [result, operation] Access the result along with the RPC operation
415
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
416
- # @yieldparam operation [GRPC::ActiveCall::Operation]
417
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
418
- # An enumerable of Grafeas::V1::Occurrence instances.
419
- # See Google::Gax::PagedEnumerable documentation for other
420
- # operations such as per-page iteration or access to the response
421
- # object.
422
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
423
- # @example
424
- # require "grafeas"
425
- #
426
- # grafeas_client = Grafeas.new(version: :v1)
427
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
428
- #
429
- # # Iterate over all results.
430
- # grafeas_client.list_occurrences(formatted_parent).each do |element|
431
- # # Process element.
432
- # end
433
- #
434
- # # Or iterate over results one page at a time.
435
- # grafeas_client.list_occurrences(formatted_parent).each_page do |page|
436
- # # Process each page at a time.
437
- # page.each do |element|
438
- # # Process element.
439
- # end
440
- # end
441
-
442
- def list_occurrences \
443
- parent,
444
- filter: nil,
445
- page_size: nil,
446
- options: nil,
447
- &block
448
- req = {
449
- parent: parent,
450
- filter: filter,
451
- page_size: page_size
452
- }.delete_if { |_, v| v.nil? }
453
- req = Google::Gax::to_proto(req, Grafeas::V1::ListOccurrencesRequest)
454
- @list_occurrences.call(req, options, &block)
455
- end
456
-
457
- # Deletes the specified occurrence. For example, use this method to delete an
458
- # occurrence when the occurrence is no longer applicable for the given
459
- # resource.
460
- #
461
- # @param name [String]
462
- # The name of the occurrence in the form of
463
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
464
- # @param options [Google::Gax::CallOptions]
465
- # Overrides the default settings for this call, e.g, timeout,
466
- # retries, etc.
467
- # @yield [result, operation] Access the result along with the RPC operation
468
- # @yieldparam result []
469
- # @yieldparam operation [GRPC::ActiveCall::Operation]
470
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
471
- # @example
472
- # require "grafeas"
473
- #
474
- # grafeas_client = Grafeas.new(version: :v1)
475
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
476
- # grafeas_client.delete_occurrence(formatted_name)
477
-
478
- def delete_occurrence \
479
- name,
480
- options: nil,
481
- &block
482
- req = {
483
- name: name
484
- }.delete_if { |_, v| v.nil? }
485
- req = Google::Gax::to_proto(req, Grafeas::V1::DeleteOccurrenceRequest)
486
- @delete_occurrence.call(req, options, &block)
487
- nil
488
- end
489
-
490
- # Creates a new occurrence.
491
- #
492
- # @param parent [String]
493
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
494
- # the occurrence is to be created.
495
- # @param occurrence [Grafeas::V1::Occurrence | Hash]
496
- # The occurrence to create.
497
- # A hash of the same form as `Grafeas::V1::Occurrence`
498
- # can also be provided.
499
- # @param options [Google::Gax::CallOptions]
500
- # Overrides the default settings for this call, e.g, timeout,
501
- # retries, etc.
502
- # @yield [result, operation] Access the result along with the RPC operation
503
- # @yieldparam result [Grafeas::V1::Occurrence]
504
- # @yieldparam operation [GRPC::ActiveCall::Operation]
505
- # @return [Grafeas::V1::Occurrence]
506
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
507
- # @example
508
- # require "grafeas"
509
- #
510
- # grafeas_client = Grafeas.new(version: :v1)
511
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
512
- #
513
- # # TODO: Initialize `occurrence`:
514
- # occurrence = {}
515
- # response = grafeas_client.create_occurrence(formatted_parent, occurrence)
516
-
517
- def create_occurrence \
518
- parent,
519
- occurrence,
520
- options: nil,
521
- &block
522
- req = {
523
- parent: parent,
524
- occurrence: occurrence
525
- }.delete_if { |_, v| v.nil? }
526
- req = Google::Gax::to_proto(req, Grafeas::V1::CreateOccurrenceRequest)
527
- @create_occurrence.call(req, options, &block)
528
- end
529
-
530
- # Creates new occurrences in batch.
531
- #
532
- # @param parent [String]
533
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
534
- # the occurrences are to be created.
535
- # @param occurrences [Array<Grafeas::V1::Occurrence | Hash>]
536
- # The occurrences to create. Max allowed length is 1000.
537
- # A hash of the same form as `Grafeas::V1::Occurrence`
538
- # can also be provided.
539
- # @param options [Google::Gax::CallOptions]
540
- # Overrides the default settings for this call, e.g, timeout,
541
- # retries, etc.
542
- # @yield [result, operation] Access the result along with the RPC operation
543
- # @yieldparam result [Grafeas::V1::BatchCreateOccurrencesResponse]
544
- # @yieldparam operation [GRPC::ActiveCall::Operation]
545
- # @return [Grafeas::V1::BatchCreateOccurrencesResponse]
546
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
547
- # @example
548
- # require "grafeas"
549
- #
550
- # grafeas_client = Grafeas.new(version: :v1)
551
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
552
- #
553
- # # TODO: Initialize `occurrences`:
554
- # occurrences = []
555
- # response = grafeas_client.batch_create_occurrences(formatted_parent, occurrences)
556
-
557
- def batch_create_occurrences \
558
- parent,
559
- occurrences,
560
- options: nil,
561
- &block
562
- req = {
563
- parent: parent,
564
- occurrences: occurrences
565
- }.delete_if { |_, v| v.nil? }
566
- req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateOccurrencesRequest)
567
- @batch_create_occurrences.call(req, options, &block)
568
- end
569
-
570
- # Updates the specified occurrence.
571
- #
572
- # @param name [String]
573
- # The name of the occurrence in the form of
574
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
575
- # @param occurrence [Grafeas::V1::Occurrence | Hash]
576
- # The updated occurrence.
577
- # A hash of the same form as `Grafeas::V1::Occurrence`
578
- # can also be provided.
579
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
580
- # The fields to update.
581
- # A hash of the same form as `Google::Protobuf::FieldMask`
582
- # can also be provided.
583
- # @param options [Google::Gax::CallOptions]
584
- # Overrides the default settings for this call, e.g, timeout,
585
- # retries, etc.
586
- # @yield [result, operation] Access the result along with the RPC operation
587
- # @yieldparam result [Grafeas::V1::Occurrence]
588
- # @yieldparam operation [GRPC::ActiveCall::Operation]
589
- # @return [Grafeas::V1::Occurrence]
590
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
591
- # @example
592
- # require "grafeas"
593
- #
594
- # grafeas_client = Grafeas.new(version: :v1)
595
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
596
- #
597
- # # TODO: Initialize `occurrence`:
598
- # occurrence = {}
599
- # response = grafeas_client.update_occurrence(formatted_name, occurrence)
600
-
601
- def update_occurrence \
602
- name,
603
- occurrence,
604
- update_mask: nil,
605
- options: nil,
606
- &block
607
- req = {
608
- name: name,
609
- occurrence: occurrence,
610
- update_mask: update_mask
611
- }.delete_if { |_, v| v.nil? }
612
- req = Google::Gax::to_proto(req, Grafeas::V1::UpdateOccurrenceRequest)
613
- @update_occurrence.call(req, options, &block)
614
- end
615
-
616
- # Gets the note attached to the specified occurrence. Consumer projects can
617
- # use this method to get a note that belongs to a provider project.
618
- #
619
- # @param name [String]
620
- # The name of the occurrence in the form of
621
- # `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
622
- # @param options [Google::Gax::CallOptions]
623
- # Overrides the default settings for this call, e.g, timeout,
624
- # retries, etc.
625
- # @yield [result, operation] Access the result along with the RPC operation
626
- # @yieldparam result [Grafeas::V1::Note]
627
- # @yieldparam operation [GRPC::ActiveCall::Operation]
628
- # @return [Grafeas::V1::Note]
629
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
630
- # @example
631
- # require "grafeas"
632
- #
633
- # grafeas_client = Grafeas.new(version: :v1)
634
- # formatted_name = Grafeas::V1::GrafeasClient.occurrence_path("[PROJECT]", "[OCCURRENCE]")
635
- # response = grafeas_client.get_occurrence_note(formatted_name)
636
-
637
- def get_occurrence_note \
638
- name,
639
- options: nil,
640
- &block
641
- req = {
642
- name: name
643
- }.delete_if { |_, v| v.nil? }
644
- req = Google::Gax::to_proto(req, Grafeas::V1::GetOccurrenceNoteRequest)
645
- @get_occurrence_note.call(req, options, &block)
646
- end
647
-
648
- # Gets the specified note.
649
- #
650
- # @param name [String]
651
- # The name of the note in the form of
652
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
653
- # @param options [Google::Gax::CallOptions]
654
- # Overrides the default settings for this call, e.g, timeout,
655
- # retries, etc.
656
- # @yield [result, operation] Access the result along with the RPC operation
657
- # @yieldparam result [Grafeas::V1::Note]
658
- # @yieldparam operation [GRPC::ActiveCall::Operation]
659
- # @return [Grafeas::V1::Note]
660
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
661
- # @example
662
- # require "grafeas"
663
- #
664
- # grafeas_client = Grafeas.new(version: :v1)
665
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
666
- # response = grafeas_client.get_note(formatted_name)
667
-
668
- def get_note \
669
- name,
670
- options: nil,
671
- &block
672
- req = {
673
- name: name
674
- }.delete_if { |_, v| v.nil? }
675
- req = Google::Gax::to_proto(req, Grafeas::V1::GetNoteRequest)
676
- @get_note.call(req, options, &block)
677
- end
678
-
679
- # Lists notes for the specified project.
680
- #
681
- # @param parent [String]
682
- # The name of the project to list notes for in the form of
683
- # `projects/[PROJECT_ID]`.
684
- # @param filter [String]
685
- # The filter expression.
686
- # @param page_size [Integer]
687
- # The maximum number of resources contained in the underlying API
688
- # response. If page streaming is performed per-resource, this
689
- # parameter does not affect the return value. If page streaming is
690
- # performed per-page, this determines the maximum number of
691
- # resources in a page.
692
- # @param options [Google::Gax::CallOptions]
693
- # Overrides the default settings for this call, e.g, timeout,
694
- # retries, etc.
695
- # @yield [result, operation] Access the result along with the RPC operation
696
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Note>]
697
- # @yieldparam operation [GRPC::ActiveCall::Operation]
698
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Note>]
699
- # An enumerable of Grafeas::V1::Note instances.
700
- # See Google::Gax::PagedEnumerable documentation for other
701
- # operations such as per-page iteration or access to the response
702
- # object.
703
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
704
- # @example
705
- # require "grafeas"
706
- #
707
- # grafeas_client = Grafeas.new(version: :v1)
708
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
709
- #
710
- # # Iterate over all results.
711
- # grafeas_client.list_notes(formatted_parent).each do |element|
712
- # # Process element.
713
- # end
714
- #
715
- # # Or iterate over results one page at a time.
716
- # grafeas_client.list_notes(formatted_parent).each_page do |page|
717
- # # Process each page at a time.
718
- # page.each do |element|
719
- # # Process element.
720
- # end
721
- # end
722
-
723
- def list_notes \
724
- parent,
725
- filter: nil,
726
- page_size: nil,
727
- options: nil,
728
- &block
729
- req = {
730
- parent: parent,
731
- filter: filter,
732
- page_size: page_size
733
- }.delete_if { |_, v| v.nil? }
734
- req = Google::Gax::to_proto(req, Grafeas::V1::ListNotesRequest)
735
- @list_notes.call(req, options, &block)
736
- end
737
-
738
- # Deletes the specified note.
739
- #
740
- # @param name [String]
741
- # The name of the note in the form of
742
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
743
- # @param options [Google::Gax::CallOptions]
744
- # Overrides the default settings for this call, e.g, timeout,
745
- # retries, etc.
746
- # @yield [result, operation] Access the result along with the RPC operation
747
- # @yieldparam result []
748
- # @yieldparam operation [GRPC::ActiveCall::Operation]
749
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
750
- # @example
751
- # require "grafeas"
752
- #
753
- # grafeas_client = Grafeas.new(version: :v1)
754
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
755
- # grafeas_client.delete_note(formatted_name)
756
-
757
- def delete_note \
758
- name,
759
- options: nil,
760
- &block
761
- req = {
762
- name: name
763
- }.delete_if { |_, v| v.nil? }
764
- req = Google::Gax::to_proto(req, Grafeas::V1::DeleteNoteRequest)
765
- @delete_note.call(req, options, &block)
766
- nil
767
- end
768
-
769
- # Creates a new note.
770
- #
771
- # @param parent [String]
772
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
773
- # the note is to be created.
774
- # @param note_id [String]
775
- # The ID to use for this note.
776
- # @param note [Grafeas::V1::Note | Hash]
777
- # The note to create.
778
- # A hash of the same form as `Grafeas::V1::Note`
779
- # can also be provided.
780
- # @param options [Google::Gax::CallOptions]
781
- # Overrides the default settings for this call, e.g, timeout,
782
- # retries, etc.
783
- # @yield [result, operation] Access the result along with the RPC operation
784
- # @yieldparam result [Grafeas::V1::Note]
785
- # @yieldparam operation [GRPC::ActiveCall::Operation]
786
- # @return [Grafeas::V1::Note]
787
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
788
- # @example
789
- # require "grafeas"
790
- #
791
- # grafeas_client = Grafeas.new(version: :v1)
792
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
793
- #
794
- # # TODO: Initialize `note_id`:
795
- # note_id = ''
796
- #
797
- # # TODO: Initialize `note`:
798
- # note = {}
799
- # response = grafeas_client.create_note(formatted_parent, note_id, note)
800
-
801
- def create_note \
802
- parent,
803
- note_id,
804
- note,
805
- options: nil,
806
- &block
807
- req = {
808
- parent: parent,
809
- note_id: note_id,
810
- note: note
811
- }.delete_if { |_, v| v.nil? }
812
- req = Google::Gax::to_proto(req, Grafeas::V1::CreateNoteRequest)
813
- @create_note.call(req, options, &block)
814
- end
815
-
816
- # Creates new notes in batch.
817
- #
818
- # @param parent [String]
819
- # The name of the project in the form of `projects/[PROJECT_ID]`, under which
820
- # the notes are to be created.
821
- # @param notes [Hash{String => Grafeas::V1::Note | Hash}]
822
- # The notes to create. Max allowed length is 1000.
823
- # A hash of the same form as `Grafeas::V1::Note`
824
- # can also be provided.
825
- # @param options [Google::Gax::CallOptions]
826
- # Overrides the default settings for this call, e.g, timeout,
827
- # retries, etc.
828
- # @yield [result, operation] Access the result along with the RPC operation
829
- # @yieldparam result [Grafeas::V1::BatchCreateNotesResponse]
830
- # @yieldparam operation [GRPC::ActiveCall::Operation]
831
- # @return [Grafeas::V1::BatchCreateNotesResponse]
832
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
833
- # @example
834
- # require "grafeas"
835
- #
836
- # grafeas_client = Grafeas.new(version: :v1)
837
- # formatted_parent = Grafeas::V1::GrafeasClient.project_path("[PROJECT]")
838
- #
839
- # # TODO: Initialize `notes`:
840
- # notes = {}
841
- # response = grafeas_client.batch_create_notes(formatted_parent, notes)
842
-
843
- def batch_create_notes \
844
- parent,
845
- notes,
846
- options: nil,
847
- &block
848
- req = {
849
- parent: parent,
850
- notes: notes
851
- }.delete_if { |_, v| v.nil? }
852
- req = Google::Gax::to_proto(req, Grafeas::V1::BatchCreateNotesRequest)
853
- @batch_create_notes.call(req, options, &block)
854
- end
855
-
856
- # Updates the specified note.
857
- #
858
- # @param name [String]
859
- # The name of the note in the form of
860
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
861
- # @param note [Grafeas::V1::Note | Hash]
862
- # The updated note.
863
- # A hash of the same form as `Grafeas::V1::Note`
864
- # can also be provided.
865
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
866
- # The fields to update.
867
- # A hash of the same form as `Google::Protobuf::FieldMask`
868
- # can also be provided.
869
- # @param options [Google::Gax::CallOptions]
870
- # Overrides the default settings for this call, e.g, timeout,
871
- # retries, etc.
872
- # @yield [result, operation] Access the result along with the RPC operation
873
- # @yieldparam result [Grafeas::V1::Note]
874
- # @yieldparam operation [GRPC::ActiveCall::Operation]
875
- # @return [Grafeas::V1::Note]
876
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
877
- # @example
878
- # require "grafeas"
879
- #
880
- # grafeas_client = Grafeas.new(version: :v1)
881
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
882
- #
883
- # # TODO: Initialize `note`:
884
- # note = {}
885
- # response = grafeas_client.update_note(formatted_name, note)
886
-
887
- def update_note \
888
- name,
889
- note,
890
- update_mask: nil,
891
- options: nil,
892
- &block
893
- req = {
894
- name: name,
895
- note: note,
896
- update_mask: update_mask
897
- }.delete_if { |_, v| v.nil? }
898
- req = Google::Gax::to_proto(req, Grafeas::V1::UpdateNoteRequest)
899
- @update_note.call(req, options, &block)
900
- end
901
-
902
- # Lists occurrences referencing the specified note. Provider projects can use
903
- # this method to get all occurrences across consumer projects referencing the
904
- # specified note.
905
- #
906
- # @param name [String]
907
- # The name of the note to list occurrences for in the form of
908
- # `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
909
- # @param filter [String]
910
- # The filter expression.
911
- # @param page_size [Integer]
912
- # The maximum number of resources contained in the underlying API
913
- # response. If page streaming is performed per-resource, this
914
- # parameter does not affect the return value. If page streaming is
915
- # performed per-page, this determines the maximum number of
916
- # resources in a page.
917
- # @param options [Google::Gax::CallOptions]
918
- # Overrides the default settings for this call, e.g, timeout,
919
- # retries, etc.
920
- # @yield [result, operation] Access the result along with the RPC operation
921
- # @yieldparam result [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
922
- # @yieldparam operation [GRPC::ActiveCall::Operation]
923
- # @return [Google::Gax::PagedEnumerable<Grafeas::V1::Occurrence>]
924
- # An enumerable of Grafeas::V1::Occurrence instances.
925
- # See Google::Gax::PagedEnumerable documentation for other
926
- # operations such as per-page iteration or access to the response
927
- # object.
928
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
929
- # @example
930
- # require "grafeas"
931
- #
932
- # grafeas_client = Grafeas.new(version: :v1)
933
- # formatted_name = Grafeas::V1::GrafeasClient.note_path("[PROJECT]", "[NOTE]")
934
- #
935
- # # Iterate over all results.
936
- # grafeas_client.list_note_occurrences(formatted_name).each do |element|
937
- # # Process element.
938
- # end
939
- #
940
- # # Or iterate over results one page at a time.
941
- # grafeas_client.list_note_occurrences(formatted_name).each_page do |page|
942
- # # Process each page at a time.
943
- # page.each do |element|
944
- # # Process element.
945
- # end
946
- # end
947
-
948
- def list_note_occurrences \
949
- name,
950
- filter: nil,
951
- page_size: nil,
952
- options: nil,
953
- &block
954
- req = {
955
- name: name,
956
- filter: filter,
957
- page_size: page_size
958
- }.delete_if { |_, v| v.nil? }
959
- req = Google::Gax::to_proto(req, Grafeas::V1::ListNoteOccurrencesRequest)
960
- @list_note_occurrences.call(req, options, &block)
961
- end
962
- end
963
- end
964
- end