google-cloud-container_analysis 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
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
+ require "google/cloud/container_analysis"
@@ -0,0 +1,153 @@
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
+ require "grafeas"
16
+ require "google/gax"
17
+ require "pathname"
18
+
19
+ module Google
20
+ module Cloud
21
+ # rubocop:disable LineLength
22
+
23
+ ##
24
+ # # Ruby Client for Container Analysis API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
25
+ #
26
+ # [Container Analysis API][Product Documentation]:
27
+ # An implementation of the Grafeas API, which stores, and enables querying
28
+ # and retrieval of critical metadata about all of your software artifacts.
29
+ # - [Product Documentation][]
30
+ #
31
+ # ## Quick Start
32
+ # In order to use this library, you first need to go through the following
33
+ # steps:
34
+ #
35
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
+ # 3. [Enable the Container Analysis API.](https://console.cloud.google.com/apis/library/containeranalysis.googleapis.com)
38
+ # 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
39
+ #
40
+ # ### Installation
41
+ # ```
42
+ # $ gem install google-cloud-container_analysis
43
+ # ```
44
+ #
45
+ # ### Next Steps
46
+ # - Read the [Container Analysis API Product documentation][Product Documentation]
47
+ # to learn more about the product and see How-to Guides.
48
+ # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
49
+ # to see the full list of Cloud APIs that we cover.
50
+ #
51
+ # [Product Documentation]: https://cloud.google.com/container-registry/docs/container-analysis
52
+ #
53
+ # ## Enabling Logging
54
+ #
55
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
56
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
57
+ # or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
58
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
59
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
60
+ #
61
+ # Configuring a Ruby stdlib logger:
62
+ #
63
+ # ```ruby
64
+ # require "logger"
65
+ #
66
+ # module MyLogger
67
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
68
+ # def logger
69
+ # LOGGER
70
+ # end
71
+ # end
72
+ #
73
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
74
+ # module GRPC
75
+ # extend MyLogger
76
+ # end
77
+ # ```
78
+ #
79
+ module ContainerAnalysis
80
+ # rubocop:enable LineLength
81
+
82
+ FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("container_analysis"))
83
+
84
+ AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
85
+ .select { |file| File.directory?(file) }
86
+ .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
87
+ .select { |dir| File.exist?(dir + ".rb") }
88
+ .map { |dir| File.basename(dir) }
89
+
90
+ ##
91
+ # Retrieves analysis results of Cloud components such as Docker container
92
+ # images. The Container Analysis API is an implementation of the
93
+ # [Grafeas](https://grafeas.io) API.
94
+ #
95
+ # Analysis results are stored as a series of occurrences. An `Occurrence`
96
+ # contains information about a specific analysis instance on a resource. An
97
+ # occurrence refers to a `Note`. A note contains details describing the
98
+ # analysis and is generally stored in a separate project, called a `Provider`.
99
+ # Multiple occurrences can refer to the same note.
100
+ #
101
+ # For example, an SSL vulnerability could affect multiple images. In this case,
102
+ # there would be one note for the vulnerability and an occurrence for each
103
+ # image with the vulnerability referring to that note.
104
+ #
105
+ # @param version [Symbol, String]
106
+ # The major version of the service to be used. By default :v1
107
+ # is used.
108
+ # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
109
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
110
+ # Provides the means for authenticating requests made by the client. This parameter can
111
+ # be many types.
112
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
113
+ # authenticating requests made by this client.
114
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
115
+ # credentials for this client.
116
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
117
+ # credentials for this client.
118
+ # A `GRPC::Core::Channel` will be used to make calls through.
119
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
120
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
121
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
122
+ # metadata for requests, generally, to give OAuth credentials.
123
+ # @param scopes [Array<String>]
124
+ # The OAuth scopes for this service. This parameter is ignored if
125
+ # an updater_proc is supplied.
126
+ # @param client_config [Hash]
127
+ # A Hash for call options for each method. See
128
+ # Google::Gax#construct_settings for the structure of
129
+ # this data. Falls back to the default config if not specified
130
+ # or the specified config is missing data points.
131
+ # @param timeout [Numeric]
132
+ # The default timeout, in seconds, for calls made through this client.
133
+ # @param metadata [Hash]
134
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
135
+ # @param exception_transformer [Proc]
136
+ # An optional proc that intercepts any exceptions raised during an API call to inject
137
+ # custom error handling.
138
+ def self.new(*args, version: :v1, **kwargs)
139
+ unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
140
+ raise "The version: #{version} is not available. The available versions " \
141
+ "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
142
+ end
143
+
144
+ require "#{FILE_DIR}/#{version.to_s.downcase}"
145
+ version_module = Google::Cloud::ContainerAnalysis
146
+ .constants
147
+ .select {|sym| sym.to_s.downcase == version.to_s.downcase}
148
+ .first
149
+ Google::Cloud::ContainerAnalysis.const_get(version_module).new(*args, **kwargs)
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,149 @@
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
+ require "google/cloud/container_analysis/v1/container_analysis_client"
16
+
17
+ module Google
18
+ module Cloud
19
+ module ContainerAnalysis
20
+ # rubocop:disable LineLength
21
+
22
+ ##
23
+ # # Ruby Client for Container Analysis API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
24
+ #
25
+ # [Container Analysis API][Product Documentation]:
26
+ # An implementation of the Grafeas API, which stores, and enables querying
27
+ # and retrieval of critical metadata about all of your software artifacts.
28
+ # - [Product Documentation][]
29
+ #
30
+ # ## Quick Start
31
+ # In order to use this library, you first need to go through the following
32
+ # steps:
33
+ #
34
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
36
+ # 3. [Enable the Container Analysis API.](https://console.cloud.google.com/apis/library/containeranalysis.googleapis.com)
37
+ # 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
38
+ #
39
+ # ### Installation
40
+ # ```
41
+ # $ gem install google-cloud-container_analysis
42
+ # ```
43
+ #
44
+ # ### Next Steps
45
+ # - Read the [Container Analysis API Product documentation][Product Documentation]
46
+ # to learn more about the product and see How-to Guides.
47
+ # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
48
+ # to see the full list of Cloud APIs that we cover.
49
+ #
50
+ # [Product Documentation]: https://cloud.google.com/container-registry/docs/container-analysis
51
+ #
52
+ # ## Enabling Logging
53
+ #
54
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
55
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
56
+ # or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
57
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
58
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
59
+ #
60
+ # Configuring a Ruby stdlib logger:
61
+ #
62
+ # ```ruby
63
+ # require "logger"
64
+ #
65
+ # module MyLogger
66
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
67
+ # def logger
68
+ # LOGGER
69
+ # end
70
+ # end
71
+ #
72
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
73
+ # module GRPC
74
+ # extend MyLogger
75
+ # end
76
+ # ```
77
+ #
78
+ module V1
79
+ # rubocop:enable LineLength
80
+
81
+ ##
82
+ # Retrieves analysis results of Cloud components such as Docker container
83
+ # images. The Container Analysis API is an implementation of the
84
+ # [Grafeas](https://grafeas.io) API.
85
+ #
86
+ # Analysis results are stored as a series of occurrences. An `Occurrence`
87
+ # contains information about a specific analysis instance on a resource. An
88
+ # occurrence refers to a `Note`. A note contains details describing the
89
+ # analysis and is generally stored in a separate project, called a `Provider`.
90
+ # Multiple occurrences can refer to the same note.
91
+ #
92
+ # For example, an SSL vulnerability could affect multiple images. In this case,
93
+ # there would be one note for the vulnerability and an occurrence for each
94
+ # image with the vulnerability referring to that note.
95
+ #
96
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
97
+ # Provides the means for authenticating requests made by the client. This parameter can
98
+ # be many types.
99
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
100
+ # authenticating requests made by this client.
101
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
102
+ # credentials for this client.
103
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
104
+ # credentials for this client.
105
+ # A `GRPC::Core::Channel` will be used to make calls through.
106
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
107
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
108
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
109
+ # metadata for requests, generally, to give OAuth credentials.
110
+ # @param scopes [Array<String>]
111
+ # The OAuth scopes for this service. This parameter is ignored if
112
+ # an updater_proc is supplied.
113
+ # @param client_config [Hash]
114
+ # A Hash for call options for each method. See
115
+ # Google::Gax#construct_settings for the structure of
116
+ # this data. Falls back to the default config if not specified
117
+ # or the specified config is missing data points.
118
+ # @param timeout [Numeric]
119
+ # The default timeout, in seconds, for calls made through this client.
120
+ # @param metadata [Hash]
121
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
122
+ # @param exception_transformer [Proc]
123
+ # An optional proc that intercepts any exceptions raised during an API call to inject
124
+ # custom error handling.
125
+ def self.new \
126
+ credentials: nil,
127
+ scopes: nil,
128
+ client_config: nil,
129
+ timeout: nil,
130
+ metadata: nil,
131
+ exception_transformer: nil,
132
+ lib_name: nil,
133
+ lib_version: nil
134
+ kwargs = {
135
+ credentials: credentials,
136
+ scopes: scopes,
137
+ client_config: client_config,
138
+ timeout: timeout,
139
+ metadata: metadata,
140
+ exception_transformer: exception_transformer,
141
+ lib_name: lib_name,
142
+ lib_version: lib_version
143
+ }.select { |_, v| v != nil }
144
+ Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisClient.new(**kwargs)
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,358 @@
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/google/devtools/containeranalysis/v1/containeranalysis.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
+ require "json"
23
+ require "pathname"
24
+
25
+ require "google/gax"
26
+
27
+ require "google/devtools/containeranalysis/v1/containeranalysis_pb"
28
+ require "google/cloud/container_analysis/v1/credentials"
29
+ require "google/cloud/container_analysis/version"
30
+
31
+ module Google
32
+ module Cloud
33
+ module ContainerAnalysis
34
+ module V1
35
+ # Retrieves analysis results of Cloud components such as Docker container
36
+ # images. The Container Analysis API is an implementation of the
37
+ # [Grafeas](https://grafeas.io) API.
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] container_analysis_stub
50
+ # @return [Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisService::Stub]
51
+ class ContainerAnalysisClient
52
+ # @private
53
+ attr_reader :container_analysis_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
+ # The scopes needed to make gRPC calls to all of the methods defined in
67
+ # this service.
68
+ ALL_SCOPES = [
69
+ "https://www.googleapis.com/auth/cloud-platform"
70
+ ].freeze
71
+
72
+
73
+ NOTE_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
74
+ "projects/{project}/notes/{note}"
75
+ )
76
+
77
+ private_constant :NOTE_PATH_TEMPLATE
78
+
79
+ # Returns a fully-qualified note resource name string.
80
+ # @param project [String]
81
+ # @param note [String]
82
+ # @return [String]
83
+ def self.note_path project, note
84
+ NOTE_PATH_TEMPLATE.render(
85
+ :"project" => project,
86
+ :"note" => note
87
+ )
88
+ end
89
+
90
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
91
+ # Provides the means for authenticating requests made by the client. This parameter can
92
+ # be many types.
93
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
94
+ # authenticating requests made by this client.
95
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
96
+ # credentials for this client.
97
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
98
+ # credentials for this client.
99
+ # A `GRPC::Core::Channel` will be used to make calls through.
100
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
101
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
102
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
103
+ # metadata for requests, generally, to give OAuth credentials.
104
+ # @param scopes [Array<String>]
105
+ # The OAuth scopes for this service. This parameter is ignored if
106
+ # an updater_proc is supplied.
107
+ # @param client_config [Hash]
108
+ # A Hash for call options for each method. See
109
+ # Google::Gax#construct_settings for the structure of
110
+ # this data. Falls back to the default config if not specified
111
+ # or the specified config is missing data points.
112
+ # @param timeout [Numeric]
113
+ # The default timeout, in seconds, for calls made through this client.
114
+ # @param metadata [Hash]
115
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
116
+ # @param exception_transformer [Proc]
117
+ # An optional proc that intercepts any exceptions raised during an API call to inject
118
+ # custom error handling.
119
+ def initialize \
120
+ credentials: nil,
121
+ scopes: ALL_SCOPES,
122
+ client_config: {},
123
+ timeout: DEFAULT_TIMEOUT,
124
+ metadata: nil,
125
+ exception_transformer: nil,
126
+ lib_name: nil,
127
+ lib_version: ""
128
+ # These require statements are intentionally placed here to initialize
129
+ # the gRPC module only when it's required.
130
+ # See https://github.com/googleapis/toolkit/issues/446
131
+ require "google/gax/grpc"
132
+ require "google/devtools/containeranalysis/v1/containeranalysis_services_pb"
133
+
134
+ credentials ||= Google::Cloud::ContainerAnalysis::V1::Credentials.default
135
+
136
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
137
+ updater_proc = Google::Cloud::ContainerAnalysis::V1::Credentials.new(credentials).updater_proc
138
+ end
139
+ if credentials.is_a?(GRPC::Core::Channel)
140
+ channel = credentials
141
+ end
142
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
143
+ chan_creds = credentials
144
+ end
145
+ if credentials.is_a?(Proc)
146
+ updater_proc = credentials
147
+ end
148
+ if credentials.is_a?(Google::Auth::Credentials)
149
+ updater_proc = credentials.updater_proc
150
+ end
151
+
152
+ package_version = Google::Cloud::ContainerAnalysis::VERSION
153
+
154
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
155
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
156
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
157
+ google_api_client << " grpc/#{GRPC::VERSION}"
158
+ google_api_client.freeze
159
+
160
+ headers = { :"x-goog-api-client" => google_api_client }
161
+ headers.merge!(metadata) unless metadata.nil?
162
+ client_config_file = Pathname.new(__dir__).join(
163
+ "container_analysis_client_config.json"
164
+ )
165
+ defaults = client_config_file.open do |f|
166
+ Google::Gax.construct_settings(
167
+ "google.devtools.containeranalysis.v1.ContainerAnalysis",
168
+ JSON.parse(f.read),
169
+ client_config,
170
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
171
+ timeout,
172
+ errors: Google::Gax::Grpc::API_ERRORS,
173
+ metadata: headers
174
+ )
175
+ end
176
+
177
+ # Allow overriding the service path/port in subclasses.
178
+ service_path = self.class::SERVICE_ADDRESS
179
+ port = self.class::DEFAULT_SERVICE_PORT
180
+ interceptors = self.class::GRPC_INTERCEPTORS
181
+ @container_analysis_stub = Google::Gax::Grpc.create_stub(
182
+ service_path,
183
+ port,
184
+ chan_creds: chan_creds,
185
+ channel: channel,
186
+ updater_proc: updater_proc,
187
+ scopes: scopes,
188
+ interceptors: interceptors,
189
+ &Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisService::Stub.method(:new)
190
+ )
191
+
192
+ @set_iam_policy = Google::Gax.create_api_call(
193
+ @container_analysis_stub.method(:set_iam_policy),
194
+ defaults["set_iam_policy"],
195
+ exception_transformer: exception_transformer,
196
+ params_extractor: proc do |request|
197
+ {'resource' => request.resource}
198
+ end
199
+ )
200
+ @get_iam_policy = Google::Gax.create_api_call(
201
+ @container_analysis_stub.method(:get_iam_policy),
202
+ defaults["get_iam_policy"],
203
+ exception_transformer: exception_transformer,
204
+ params_extractor: proc do |request|
205
+ {'resource' => request.resource}
206
+ end
207
+ )
208
+ @test_iam_permissions = Google::Gax.create_api_call(
209
+ @container_analysis_stub.method(:test_iam_permissions),
210
+ defaults["test_iam_permissions"],
211
+ exception_transformer: exception_transformer,
212
+ params_extractor: proc do |request|
213
+ {'resource' => request.resource}
214
+ end
215
+ )
216
+ end
217
+
218
+ # Service calls
219
+
220
+ # Sets the access control policy on the specified note or occurrence.
221
+ # Requires `containeranalysis.notes.setIamPolicy` or
222
+ # `containeranalysis.occurrences.setIamPolicy` permission if the resource is
223
+ # a note or an occurrence, respectively.
224
+ #
225
+ # The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
226
+ # notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
227
+ # occurrences.
228
+ #
229
+ # @param resource [String]
230
+ # REQUIRED: The resource for which the policy is being specified.
231
+ # See the operation documentation for the appropriate value for this field.
232
+ # @param policy [Google::Iam::V1::Policy | Hash]
233
+ # REQUIRED: The complete policy to be applied to the `resource`. The size of
234
+ # the policy is limited to a few 10s of KB. An empty policy is a
235
+ # valid policy but certain Cloud Platform services (such as Projects)
236
+ # might reject them.
237
+ # A hash of the same form as `Google::Iam::V1::Policy`
238
+ # can also be provided.
239
+ # @param options [Google::Gax::CallOptions]
240
+ # Overrides the default settings for this call, e.g, timeout,
241
+ # retries, etc.
242
+ # @yield [result, operation] Access the result along with the RPC operation
243
+ # @yieldparam result [Google::Iam::V1::Policy]
244
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
245
+ # @return [Google::Iam::V1::Policy]
246
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
247
+ # @example
248
+ # require "google/cloud/container_analysis"
249
+ #
250
+ # container_analysis_client = Google::Cloud::ContainerAnalysis.new(version: :v1)
251
+ # formatted_resource = Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisClient.note_path("[PROJECT]", "[NOTE]")
252
+ #
253
+ # # TODO: Initialize `policy`:
254
+ # policy = {}
255
+ # response = container_analysis_client.set_iam_policy(formatted_resource, policy)
256
+
257
+ def set_iam_policy \
258
+ resource,
259
+ policy,
260
+ options: nil,
261
+ &block
262
+ req = {
263
+ resource: resource,
264
+ policy: policy
265
+ }.delete_if { |_, v| v.nil? }
266
+ req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
267
+ @set_iam_policy.call(req, options, &block)
268
+ end
269
+
270
+ # Gets the access control policy for a note or an occurrence resource.
271
+ # Requires `containeranalysis.notes.setIamPolicy` or
272
+ # `containeranalysis.occurrences.setIamPolicy` permission if the resource is
273
+ # a note or occurrence, respectively.
274
+ #
275
+ # The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
276
+ # notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
277
+ # occurrences.
278
+ #
279
+ # @param resource [String]
280
+ # REQUIRED: The resource for which the policy is being requested.
281
+ # See the operation documentation for the appropriate value for this field.
282
+ # @param options [Google::Gax::CallOptions]
283
+ # Overrides the default settings for this call, e.g, timeout,
284
+ # retries, etc.
285
+ # @yield [result, operation] Access the result along with the RPC operation
286
+ # @yieldparam result [Google::Iam::V1::Policy]
287
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
288
+ # @return [Google::Iam::V1::Policy]
289
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
290
+ # @example
291
+ # require "google/cloud/container_analysis"
292
+ #
293
+ # container_analysis_client = Google::Cloud::ContainerAnalysis.new(version: :v1)
294
+ # formatted_resource = Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisClient.note_path("[PROJECT]", "[NOTE]")
295
+ # response = container_analysis_client.get_iam_policy(formatted_resource)
296
+
297
+ def get_iam_policy \
298
+ resource,
299
+ options: nil,
300
+ &block
301
+ req = {
302
+ resource: resource
303
+ }.delete_if { |_, v| v.nil? }
304
+ req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
305
+ @get_iam_policy.call(req, options, &block)
306
+ end
307
+
308
+ # Returns the permissions that a caller has on the specified note or
309
+ # occurrence. Requires list permission on the project (for example,
310
+ # `containeranalysis.notes.list`).
311
+ #
312
+ # The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
313
+ # notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
314
+ # occurrences.
315
+ #
316
+ # @param resource [String]
317
+ # REQUIRED: The resource for which the policy detail is being requested.
318
+ # See the operation documentation for the appropriate value for this field.
319
+ # @param permissions [Array<String>]
320
+ # The set of permissions to check for the `resource`. Permissions with
321
+ # wildcards (such as '*' or 'storage.*') are not allowed. For more
322
+ # information see
323
+ # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
324
+ # @param options [Google::Gax::CallOptions]
325
+ # Overrides the default settings for this call, e.g, timeout,
326
+ # retries, etc.
327
+ # @yield [result, operation] Access the result along with the RPC operation
328
+ # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
329
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
330
+ # @return [Google::Iam::V1::TestIamPermissionsResponse]
331
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
332
+ # @example
333
+ # require "google/cloud/container_analysis"
334
+ #
335
+ # container_analysis_client = Google::Cloud::ContainerAnalysis.new(version: :v1)
336
+ # formatted_resource = Google::Cloud::ContainerAnalysis::V1::ContainerAnalysisClient.note_path("[PROJECT]", "[NOTE]")
337
+ #
338
+ # # TODO: Initialize `permissions`:
339
+ # permissions = []
340
+ # response = container_analysis_client.test_iam_permissions(formatted_resource, permissions)
341
+
342
+ def test_iam_permissions \
343
+ resource,
344
+ permissions,
345
+ options: nil,
346
+ &block
347
+ req = {
348
+ resource: resource,
349
+ permissions: permissions
350
+ }.delete_if { |_, v| v.nil? }
351
+ req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
352
+ @test_iam_permissions.call(req, options, &block)
353
+ end
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end