grafeas 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/AUTHENTICATION.md +199 -0
- data/LICENSE +201 -0
- data/README.md +55 -25
- data/lib/grafeas.rb +151 -2
- data/lib/grafeas/v1.rb +155 -0
- data/lib/grafeas/v1/attestation_pb.rb +27 -0
- data/lib/grafeas/v1/build_pb.rb +23 -0
- data/lib/grafeas/v1/common_pb.rb +34 -0
- data/lib/grafeas/v1/credentials.rb +37 -0
- data/lib/grafeas/v1/cvss_pb.rb +67 -0
- data/lib/grafeas/v1/deployment_pb.rb +35 -0
- data/lib/grafeas/v1/discovery_pb.rb +40 -0
- data/lib/grafeas/v1/doc/google/protobuf/any.rb +131 -0
- data/lib/grafeas/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/grafeas/v1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/grafeas/v1/doc/google/protobuf/timestamp.rb +113 -0
- data/lib/grafeas/v1/doc/google/rpc/status.rb +87 -0
- data/lib/grafeas/v1/doc/grafeas/v1/attestation.rb +64 -0
- data/lib/grafeas/v1/doc/grafeas/v1/build.rb +44 -0
- data/lib/grafeas/v1/doc/grafeas/v1/common.rb +105 -0
- data/lib/grafeas/v1/doc/grafeas/v1/cvss.rb +104 -0
- data/lib/grafeas/v1/doc/grafeas/v1/deployment.rb +64 -0
- data/lib/grafeas/v1/doc/grafeas/v1/discovery.rb +76 -0
- data/lib/grafeas/v1/doc/grafeas/v1/grafeas.rb +322 -0
- data/lib/grafeas/v1/doc/grafeas/v1/image.rb +79 -0
- data/lib/grafeas/v1/doc/grafeas/v1/package.rb +125 -0
- data/lib/grafeas/v1/doc/grafeas/v1/provenance.rb +248 -0
- data/lib/grafeas/v1/doc/grafeas/v1/vulnerability.rb +214 -0
- data/lib/grafeas/v1/grafeas_client.rb +961 -0
- data/lib/grafeas/v1/grafeas_client_config.json +96 -0
- data/lib/grafeas/v1/grafeas_pb.rb +163 -0
- data/lib/grafeas/v1/grafeas_services_pb.rb +86 -0
- data/lib/grafeas/v1/image_pb.rb +36 -0
- data/lib/grafeas/v1/package_pb.rb +59 -0
- data/lib/grafeas/v1/provenance_pb.rb +116 -0
- data/lib/grafeas/v1/vulnerability_pb.rb +81 -0
- data/lib/grafeas/version.rb +16 -1
- metadata +111 -31
- data/.gitignore +0 -8
- data/.travis.yml +0 -5
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -22
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/grafeas.gemspec +0 -26
@@ -0,0 +1,214 @@
|
|
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
|
+
|
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
|
+
class VulnerabilityNote
|
39
|
+
# A detail for a distro and package affected by this vulnerability and its
|
40
|
+
# associated fix (if one is available).
|
41
|
+
# @!attribute [rw] severity_name
|
42
|
+
# @return [String]
|
43
|
+
# The distro assigned severity of this vulnerability.
|
44
|
+
# @!attribute [rw] description
|
45
|
+
# @return [String]
|
46
|
+
# A vendor-specific description of this vulnerability.
|
47
|
+
# @!attribute [rw] package_type
|
48
|
+
# @return [String]
|
49
|
+
# The type of package; whether native or non native (e.g., ruby gems,
|
50
|
+
# node.js packages, etc.).
|
51
|
+
# @!attribute [rw] affected_cpe_uri
|
52
|
+
# @return [String]
|
53
|
+
# Required. The [CPE URI](https://cpe.mitre.org/specification/) this
|
54
|
+
# vulnerability affects.
|
55
|
+
# @!attribute [rw] affected_package
|
56
|
+
# @return [String]
|
57
|
+
# Required. The package this vulnerability affects.
|
58
|
+
# @!attribute [rw] affected_version_start
|
59
|
+
# @return [Grafeas::V1::Version]
|
60
|
+
# The version number at the start of an interval in which this
|
61
|
+
# vulnerability exists. A vulnerability can affect a package between
|
62
|
+
# version numbers that are disjoint sets of intervals (example:
|
63
|
+
# [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be
|
64
|
+
# represented in its own Detail. If a specific affected version is provided
|
65
|
+
# by a vulnerability database, affected_version_start and
|
66
|
+
# affected_version_end will be the same in that Detail.
|
67
|
+
# @!attribute [rw] affected_version_end
|
68
|
+
# @return [Grafeas::V1::Version]
|
69
|
+
# The version number at the end of an interval in which this vulnerability
|
70
|
+
# exists. A vulnerability can affect a package between version numbers
|
71
|
+
# that are disjoint sets of intervals (example: [1.0.0-1.1.0],
|
72
|
+
# [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its
|
73
|
+
# own Detail. If a specific affected version is provided by a vulnerability
|
74
|
+
# database, affected_version_start and affected_version_end will be the
|
75
|
+
# same in that Detail.
|
76
|
+
# @!attribute [rw] fixed_cpe_uri
|
77
|
+
# @return [String]
|
78
|
+
# The distro recommended [CPE URI](https://cpe.mitre.org/specification/)
|
79
|
+
# to update to that contains a fix for this vulnerability. It is possible
|
80
|
+
# for this to be different from the affected_cpe_uri.
|
81
|
+
# @!attribute [rw] fixed_package
|
82
|
+
# @return [String]
|
83
|
+
# The distro recommended package to update to that contains a fix for this
|
84
|
+
# vulnerability. It is possible for this to be different from the
|
85
|
+
# affected_package.
|
86
|
+
# @!attribute [rw] fixed_version
|
87
|
+
# @return [Grafeas::V1::Version]
|
88
|
+
# The distro recommended version to update to that contains a
|
89
|
+
# fix for this vulnerability. Setting this to VersionKind.MAXIMUM means no
|
90
|
+
# such version is yet available.
|
91
|
+
# @!attribute [rw] is_obsolete
|
92
|
+
# @return [true, false]
|
93
|
+
# Whether this detail is obsolete. Occurrences are expected not to point to
|
94
|
+
# obsolete details.
|
95
|
+
class Detail; end
|
96
|
+
|
97
|
+
# @!attribute [rw] cpe_uri
|
98
|
+
# @return [String]
|
99
|
+
# Required. The [CPE URI](https://cpe.mitre.org/specification/) this
|
100
|
+
# vulnerability affects.
|
101
|
+
# @!attribute [rw] name
|
102
|
+
# @return [String]
|
103
|
+
# Required. The name of this vulnerability.
|
104
|
+
# @!attribute [rw] description
|
105
|
+
# @return [String]
|
106
|
+
# The description of this vulnerability.
|
107
|
+
# @!attribute [rw] fixing_kbs
|
108
|
+
# @return [Array<Grafeas::V1::VulnerabilityNote::WindowsDetail::KnowledgeBase>]
|
109
|
+
# Required. The names of the KBs which have hotfixes to mitigate this
|
110
|
+
# vulnerability. Note that there may be multiple hotfixes (and thus
|
111
|
+
# multiple KBs) that mitigate a given vulnerability. Currently any listed
|
112
|
+
# KBs presence is considered a fix.
|
113
|
+
class WindowsDetail
|
114
|
+
# @!attribute [rw] name
|
115
|
+
# @return [String]
|
116
|
+
# The KB name (generally of the form KB[0-9]+ (e.g., KB123456)).
|
117
|
+
# @!attribute [rw] url
|
118
|
+
# @return [String]
|
119
|
+
# A link to the KB in the [Windows update catalog]
|
120
|
+
# (https://www.catalog.update.microsoft.com/).
|
121
|
+
class KnowledgeBase; end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# An occurrence of a severity vulnerability on a resource.
|
126
|
+
# @!attribute [rw] type
|
127
|
+
# @return [String]
|
128
|
+
# The type of package; whether native or non native (e.g., ruby gems, node.js
|
129
|
+
# packages, etc.).
|
130
|
+
# @!attribute [rw] severity
|
131
|
+
# @return [Grafeas::V1::Severity]
|
132
|
+
# Output only. The note provider assigned severity of this vulnerability.
|
133
|
+
# @!attribute [rw] cvss_score
|
134
|
+
# @return [Float]
|
135
|
+
# Output only. The CVSS score of this vulnerability. CVSS score is on a
|
136
|
+
# scale of 0 - 10 where 0 indicates low severity and 10 indicates high
|
137
|
+
# severity.
|
138
|
+
# @!attribute [rw] package_issue
|
139
|
+
# @return [Array<Grafeas::V1::VulnerabilityOccurrence::PackageIssue>]
|
140
|
+
# Required. The set of affected locations and their fixes (if available)
|
141
|
+
# within the associated resource.
|
142
|
+
# @!attribute [rw] short_description
|
143
|
+
# @return [String]
|
144
|
+
# Output only. A one sentence description of this vulnerability.
|
145
|
+
# @!attribute [rw] long_description
|
146
|
+
# @return [String]
|
147
|
+
# Output only. A detailed description of this vulnerability.
|
148
|
+
# @!attribute [rw] related_urls
|
149
|
+
# @return [Array<Grafeas::V1::RelatedUrl>]
|
150
|
+
# Output only. URLs related to this vulnerability.
|
151
|
+
# @!attribute [rw] effective_severity
|
152
|
+
# @return [Grafeas::V1::Severity]
|
153
|
+
# The distro assigned severity for this vulnerability when it is available,
|
154
|
+
# and note provider assigned severity when distro has not yet assigned a
|
155
|
+
# severity for this vulnerability.
|
156
|
+
# @!attribute [rw] fix_available
|
157
|
+
# @return [true, false]
|
158
|
+
# Output only. Whether at least one of the affected packages has a fix
|
159
|
+
# available.
|
160
|
+
class VulnerabilityOccurrence
|
161
|
+
# A detail for a distro and package this vulnerability occurrence was found
|
162
|
+
# in and its associated fix (if one is available).
|
163
|
+
# @!attribute [rw] affected_cpe_uri
|
164
|
+
# @return [String]
|
165
|
+
# Required. The [CPE URI](https://cpe.mitre.org/specification/) this
|
166
|
+
# vulnerability was found in.
|
167
|
+
# @!attribute [rw] affected_package
|
168
|
+
# @return [String]
|
169
|
+
# Required. The package this vulnerability was found in.
|
170
|
+
# @!attribute [rw] affected_version
|
171
|
+
# @return [Grafeas::V1::Version]
|
172
|
+
# Required. The version of the package that is installed on the resource
|
173
|
+
# affected by this vulnerability.
|
174
|
+
# @!attribute [rw] fixed_cpe_uri
|
175
|
+
# @return [String]
|
176
|
+
# The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability
|
177
|
+
# was fixed in. It is possible for this to be different from the
|
178
|
+
# affected_cpe_uri.
|
179
|
+
# @!attribute [rw] fixed_package
|
180
|
+
# @return [String]
|
181
|
+
# The package this vulnerability was fixed in. It is possible for this to
|
182
|
+
# be different from the affected_package.
|
183
|
+
# @!attribute [rw] fixed_version
|
184
|
+
# @return [Grafeas::V1::Version]
|
185
|
+
# Required. The version of the package this vulnerability was fixed in.
|
186
|
+
# Setting this to VersionKind.MAXIMUM means no fix is yet available.
|
187
|
+
# @!attribute [rw] fix_available
|
188
|
+
# @return [true, false]
|
189
|
+
# Output only. Whether a fix is available for this package.
|
190
|
+
class PackageIssue; end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Note provider assigned severity/impact ranking.
|
194
|
+
module Severity
|
195
|
+
# Unknown.
|
196
|
+
SEVERITY_UNSPECIFIED = 0
|
197
|
+
|
198
|
+
# Minimal severity.
|
199
|
+
MINIMAL = 1
|
200
|
+
|
201
|
+
# Low severity.
|
202
|
+
LOW = 2
|
203
|
+
|
204
|
+
# Medium severity.
|
205
|
+
MEDIUM = 3
|
206
|
+
|
207
|
+
# High severity.
|
208
|
+
HIGH = 4
|
209
|
+
|
210
|
+
# Critical severity.
|
211
|
+
CRITICAL = 5
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,961 @@
|
|
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/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
|
+
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
|