google-cloud-advisory_notifications-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +149 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +144 -0
  6. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/client.rb +521 -0
  7. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/credentials.rb +47 -0
  8. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/paths.rb +69 -0
  9. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/rest/client.rb +451 -0
  10. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/rest/service_stub.rb +166 -0
  11. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service/rest.rb +52 -0
  12. data/lib/google/cloud/advisory_notifications/v1/advisory_notifications_service.rb +55 -0
  13. data/lib/google/cloud/advisory_notifications/v1/rest.rb +37 -0
  14. data/lib/google/cloud/advisory_notifications/v1/version.rb +28 -0
  15. data/lib/google/cloud/advisory_notifications/v1.rb +45 -0
  16. data/lib/google/cloud/advisorynotifications/v1/service_pb.rb +100 -0
  17. data/lib/google/cloud/advisorynotifications/v1/service_services_pb.rb +47 -0
  18. data/lib/google-cloud-advisory_notifications-v1.rb +21 -0
  19. data/proto_docs/README.md +4 -0
  20. data/proto_docs/google/api/client.rb +318 -0
  21. data/proto_docs/google/api/field_behavior.rb +71 -0
  22. data/proto_docs/google/api/launch_stage.rb +71 -0
  23. data/proto_docs/google/api/resource.rb +222 -0
  24. data/proto_docs/google/cloud/advisorynotifications/v1/service.rb +234 -0
  25. data/proto_docs/google/protobuf/duration.rb +98 -0
  26. data/proto_docs/google/protobuf/timestamp.rb +129 -0
  27. metadata +216 -0
@@ -0,0 +1,451 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/advisorynotifications/v1/service_pb"
21
+ require "google/cloud/advisory_notifications/v1/advisory_notifications_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module AdvisoryNotifications
26
+ module V1
27
+ module AdvisoryNotificationsService
28
+ module Rest
29
+ ##
30
+ # REST client for the AdvisoryNotificationsService service.
31
+ #
32
+ # Service to manage Security and Privacy Notifications.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :advisory_notifications_service_stub
39
+
40
+ ##
41
+ # Configure the AdvisoryNotificationsService Client class.
42
+ #
43
+ # See {::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all AdvisoryNotificationsService clients
49
+ # ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "AdvisoryNotifications", "V1"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.rpcs.list_notifications.timeout = 60.0
70
+ default_config.rpcs.list_notifications.retry_policy = {
71
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
72
+ }
73
+
74
+ default_config.rpcs.get_notification.timeout = 60.0
75
+ default_config.rpcs.get_notification.retry_policy = {
76
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
77
+ }
78
+
79
+ default_config
80
+ end
81
+ yield @configure if block_given?
82
+ @configure
83
+ end
84
+
85
+ ##
86
+ # Configure the AdvisoryNotificationsService Client instance.
87
+ #
88
+ # The configuration is set to the derived mode, meaning that values can be changed,
89
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
90
+ # should be made on {Client.configure}.
91
+ #
92
+ # See {::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client::Configuration}
93
+ # for a description of the configuration fields.
94
+ #
95
+ # @yield [config] Configure the Client client.
96
+ # @yieldparam config [Client::Configuration]
97
+ #
98
+ # @return [Client::Configuration]
99
+ #
100
+ def configure
101
+ yield @config if block_given?
102
+ @config
103
+ end
104
+
105
+ ##
106
+ # Create a new AdvisoryNotificationsService REST client object.
107
+ #
108
+ # @example
109
+ #
110
+ # # Create a client using the default configuration
111
+ # client = ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.new
112
+ #
113
+ # # Create a client using a custom configuration
114
+ # client = ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.new do |config|
115
+ # config.timeout = 10.0
116
+ # end
117
+ #
118
+ # @yield [config] Configure the AdvisoryNotificationsService client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ def initialize
122
+ # Create the configuration object
123
+ @config = Configuration.new Client.configure
124
+
125
+ # Yield the configuration if needed
126
+ yield @config if block_given?
127
+
128
+ # Create credentials
129
+ credentials = @config.credentials
130
+ # Use self-signed JWT if the endpoint is unchanged from default,
131
+ # but only if the default endpoint does not have a region prefix.
132
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
133
+ !@config.endpoint.split(".").first.include?("-")
134
+ credentials ||= Credentials.default scope: @config.scope,
135
+ enable_self_signed_jwt: enable_self_signed_jwt
136
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
137
+ credentials = Credentials.new credentials, scope: @config.scope
138
+ end
139
+
140
+ @quota_project_id = @config.quota_project
141
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
142
+
143
+ @advisory_notifications_service_stub = ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
144
+ end
145
+
146
+ # Service calls
147
+
148
+ ##
149
+ # Lists notifications under a given parent.
150
+ #
151
+ # @overload list_notifications(request, options = nil)
152
+ # Pass arguments to `list_notifications` via a request object, either of type
153
+ # {::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsRequest} or an equivalent Hash.
154
+ #
155
+ # @param request [::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsRequest, ::Hash]
156
+ # A request object representing the call parameters. Required. To specify no
157
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
158
+ # @param options [::Gapic::CallOptions, ::Hash]
159
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
160
+ #
161
+ # @overload list_notifications(parent: nil, page_size: nil, page_token: nil, view: nil, language_code: nil)
162
+ # Pass arguments to `list_notifications` via keyword arguments. Note that at
163
+ # least one keyword argument is required. To specify no parameters, or to keep all
164
+ # the default parameter values, pass an empty Hash as a request object (see above).
165
+ #
166
+ # @param parent [::String]
167
+ # Required. The parent, which owns this collection of notifications.
168
+ # Must be of the form "organizations/\\{organization}/locations/\\{location}".
169
+ # @param page_size [::Integer]
170
+ # The maximum number of notifications to return. The service may return
171
+ # fewer than this value. If unspecified or equal to 0, at most 50
172
+ # notifications will be returned. The maximum value is 50; values above 50
173
+ # will be coerced to 50.
174
+ # @param page_token [::String]
175
+ # A page token returned from a previous request.
176
+ # When paginating, all other parameters provided in the request
177
+ # must match the call that returned the page token.
178
+ # @param view [::Google::Cloud::AdvisoryNotifications::V1::NotificationView]
179
+ # Specifies which parts of the notification resource should be returned
180
+ # in the response.
181
+ # @param language_code [::String]
182
+ # ISO code for requested localization language. If unset, will be
183
+ # interpereted as "en". If the requested language is valid, but not supported
184
+ # for this notification, English will be returned with an "Not applicable"
185
+ # LocalizationState. If the ISO code is invalid (i.e. not a real language),
186
+ # this RPC will throw an error.
187
+ # @yield [result, operation] Access the result along with the TransportOperation object
188
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::AdvisoryNotifications::V1::Notification>]
189
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
190
+ #
191
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::AdvisoryNotifications::V1::Notification>]
192
+ #
193
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
194
+ def list_notifications request, options = nil
195
+ raise ::ArgumentError, "request must be provided" if request.nil?
196
+
197
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsRequest
198
+
199
+ # Converts hash and nil to an options object
200
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
201
+
202
+ # Customize the options with defaults
203
+ call_metadata = @config.rpcs.list_notifications.metadata.to_h
204
+
205
+ # Set x-goog-api-client and x-goog-user-project headers
206
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
207
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
208
+ gapic_version: ::Google::Cloud::AdvisoryNotifications::V1::VERSION,
209
+ transports_version_send: [:rest]
210
+
211
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
212
+
213
+ options.apply_defaults timeout: @config.rpcs.list_notifications.timeout,
214
+ metadata: call_metadata,
215
+ retry_policy: @config.rpcs.list_notifications.retry_policy
216
+
217
+ options.apply_defaults timeout: @config.timeout,
218
+ metadata: @config.metadata,
219
+ retry_policy: @config.retry_policy
220
+
221
+ @advisory_notifications_service_stub.list_notifications request, options do |result, operation|
222
+ result = ::Gapic::Rest::PagedEnumerable.new @advisory_notifications_service_stub, :list_notifications, "notifications", request, result, options
223
+ yield result, operation if block_given?
224
+ return result
225
+ end
226
+ rescue ::Gapic::Rest::Error => e
227
+ raise ::Google::Cloud::Error.from_error(e)
228
+ end
229
+
230
+ ##
231
+ # Gets a notification.
232
+ #
233
+ # @overload get_notification(request, options = nil)
234
+ # Pass arguments to `get_notification` via a request object, either of type
235
+ # {::Google::Cloud::AdvisoryNotifications::V1::GetNotificationRequest} or an equivalent Hash.
236
+ #
237
+ # @param request [::Google::Cloud::AdvisoryNotifications::V1::GetNotificationRequest, ::Hash]
238
+ # A request object representing the call parameters. Required. To specify no
239
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
240
+ # @param options [::Gapic::CallOptions, ::Hash]
241
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
242
+ #
243
+ # @overload get_notification(name: nil, language_code: nil)
244
+ # Pass arguments to `get_notification` via keyword arguments. Note that at
245
+ # least one keyword argument is required. To specify no parameters, or to keep all
246
+ # the default parameter values, pass an empty Hash as a request object (see above).
247
+ #
248
+ # @param name [::String]
249
+ # Required. A name of the notification to retrieve.
250
+ # Format:
251
+ # organizations/\\{organization}/locations/\\{location}/notifications/\\{notification}.
252
+ # @param language_code [::String]
253
+ # ISO code for requested localization language. If unset, will be
254
+ # interpereted as "en". If the requested language is valid, but not supported
255
+ # for this notification, English will be returned with an "Not applicable"
256
+ # LocalizationState. If the ISO code is invalid (i.e. not a real language),
257
+ # this RPC will throw an error.
258
+ # @yield [result, operation] Access the result along with the TransportOperation object
259
+ # @yieldparam result [::Google::Cloud::AdvisoryNotifications::V1::Notification]
260
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
261
+ #
262
+ # @return [::Google::Cloud::AdvisoryNotifications::V1::Notification]
263
+ #
264
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
265
+ def get_notification request, options = nil
266
+ raise ::ArgumentError, "request must be provided" if request.nil?
267
+
268
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AdvisoryNotifications::V1::GetNotificationRequest
269
+
270
+ # Converts hash and nil to an options object
271
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
272
+
273
+ # Customize the options with defaults
274
+ call_metadata = @config.rpcs.get_notification.metadata.to_h
275
+
276
+ # Set x-goog-api-client and x-goog-user-project headers
277
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
278
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
279
+ gapic_version: ::Google::Cloud::AdvisoryNotifications::V1::VERSION,
280
+ transports_version_send: [:rest]
281
+
282
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
283
+
284
+ options.apply_defaults timeout: @config.rpcs.get_notification.timeout,
285
+ metadata: call_metadata,
286
+ retry_policy: @config.rpcs.get_notification.retry_policy
287
+
288
+ options.apply_defaults timeout: @config.timeout,
289
+ metadata: @config.metadata,
290
+ retry_policy: @config.retry_policy
291
+
292
+ @advisory_notifications_service_stub.get_notification request, options do |result, operation|
293
+ yield result, operation if block_given?
294
+ return result
295
+ end
296
+ rescue ::Gapic::Rest::Error => e
297
+ raise ::Google::Cloud::Error.from_error(e)
298
+ end
299
+
300
+ ##
301
+ # Configuration class for the AdvisoryNotificationsService REST API.
302
+ #
303
+ # This class represents the configuration for AdvisoryNotificationsService REST,
304
+ # providing control over timeouts, retry behavior, logging, transport
305
+ # parameters, and other low-level controls. Certain parameters can also be
306
+ # applied individually to specific RPCs. See
307
+ # {::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client::Configuration::Rpcs}
308
+ # for a list of RPCs that can be configured independently.
309
+ #
310
+ # Configuration can be applied globally to all clients, or to a single client
311
+ # on construction.
312
+ #
313
+ # @example
314
+ #
315
+ # # Modify the global config, setting the timeout for
316
+ # # list_notifications to 20 seconds,
317
+ # # and all remaining timeouts to 10 seconds.
318
+ # ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.configure do |config|
319
+ # config.timeout = 10.0
320
+ # config.rpcs.list_notifications.timeout = 20.0
321
+ # end
322
+ #
323
+ # # Apply the above configuration only to a new client.
324
+ # client = ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.new do |config|
325
+ # config.timeout = 10.0
326
+ # config.rpcs.list_notifications.timeout = 20.0
327
+ # end
328
+ #
329
+ # @!attribute [rw] endpoint
330
+ # The hostname or hostname:port of the service endpoint.
331
+ # Defaults to `"advisorynotifications.googleapis.com"`.
332
+ # @return [::String]
333
+ # @!attribute [rw] credentials
334
+ # Credentials to send with calls. You may provide any of the following types:
335
+ # * (`String`) The path to a service account key file in JSON format
336
+ # * (`Hash`) A service account key as a Hash
337
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
338
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
339
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
340
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
341
+ # * (`nil`) indicating no credentials
342
+ # @return [::Object]
343
+ # @!attribute [rw] scope
344
+ # The OAuth scopes
345
+ # @return [::Array<::String>]
346
+ # @!attribute [rw] lib_name
347
+ # The library name as recorded in instrumentation and logging
348
+ # @return [::String]
349
+ # @!attribute [rw] lib_version
350
+ # The library version as recorded in instrumentation and logging
351
+ # @return [::String]
352
+ # @!attribute [rw] timeout
353
+ # The call timeout in seconds.
354
+ # @return [::Numeric]
355
+ # @!attribute [rw] metadata
356
+ # Additional headers to be sent with the call.
357
+ # @return [::Hash{::Symbol=>::String}]
358
+ # @!attribute [rw] retry_policy
359
+ # The retry policy. The value is a hash with the following keys:
360
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
361
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
362
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
363
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
364
+ # trigger a retry.
365
+ # @return [::Hash]
366
+ # @!attribute [rw] quota_project
367
+ # A separate project against which to charge quota.
368
+ # @return [::String]
369
+ #
370
+ class Configuration
371
+ extend ::Gapic::Config
372
+
373
+ config_attr :endpoint, "advisorynotifications.googleapis.com", ::String
374
+ config_attr :credentials, nil do |value|
375
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
376
+ allowed.any? { |klass| klass === value }
377
+ end
378
+ config_attr :scope, nil, ::String, ::Array, nil
379
+ config_attr :lib_name, nil, ::String, nil
380
+ config_attr :lib_version, nil, ::String, nil
381
+ config_attr :timeout, nil, ::Numeric, nil
382
+ config_attr :metadata, nil, ::Hash, nil
383
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
384
+ config_attr :quota_project, nil, ::String, nil
385
+
386
+ # @private
387
+ def initialize parent_config = nil
388
+ @parent_config = parent_config unless parent_config.nil?
389
+
390
+ yield self if block_given?
391
+ end
392
+
393
+ ##
394
+ # Configurations for individual RPCs
395
+ # @return [Rpcs]
396
+ #
397
+ def rpcs
398
+ @rpcs ||= begin
399
+ parent_rpcs = nil
400
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
401
+ Rpcs.new parent_rpcs
402
+ end
403
+ end
404
+
405
+ ##
406
+ # Configuration RPC class for the AdvisoryNotificationsService API.
407
+ #
408
+ # Includes fields providing the configuration for each RPC in this service.
409
+ # Each configuration object is of type `Gapic::Config::Method` and includes
410
+ # the following configuration fields:
411
+ #
412
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
413
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
414
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
415
+ # include the following keys:
416
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
417
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
418
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
419
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
420
+ # trigger a retry.
421
+ #
422
+ class Rpcs
423
+ ##
424
+ # RPC-specific configuration for `list_notifications`
425
+ # @return [::Gapic::Config::Method]
426
+ #
427
+ attr_reader :list_notifications
428
+ ##
429
+ # RPC-specific configuration for `get_notification`
430
+ # @return [::Gapic::Config::Method]
431
+ #
432
+ attr_reader :get_notification
433
+
434
+ # @private
435
+ def initialize parent_rpcs = nil
436
+ list_notifications_config = parent_rpcs.list_notifications if parent_rpcs.respond_to? :list_notifications
437
+ @list_notifications = ::Gapic::Config::Method.new list_notifications_config
438
+ get_notification_config = parent_rpcs.get_notification if parent_rpcs.respond_to? :get_notification
439
+ @get_notification = ::Gapic::Config::Method.new get_notification_config
440
+
441
+ yield self if block_given?
442
+ end
443
+ end
444
+ end
445
+ end
446
+ end
447
+ end
448
+ end
449
+ end
450
+ end
451
+ end
@@ -0,0 +1,166 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/advisorynotifications/v1/service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module AdvisoryNotifications
24
+ module V1
25
+ module AdvisoryNotificationsService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the AdvisoryNotificationsService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the list_notifications REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsResponse]
56
+ # A result object deserialized from the server's reply
57
+ def list_notifications request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_notifications_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the get_notification REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::AdvisoryNotifications::V1::GetNotificationRequest]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::AdvisoryNotifications::V1::Notification]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::AdvisoryNotifications::V1::Notification]
94
+ # A result object deserialized from the server's reply
95
+ def get_notification request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_get_notification_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::AdvisoryNotifications::V1::Notification.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the list_notifications REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::AdvisoryNotifications::V1::ListNotificationsRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_list_notifications_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :get,
132
+ uri_template: "/v1/{parent}/notifications",
133
+ matches: [
134
+ ["parent", %r{^organizations/[^/]+/locations/[^/]+/?$}, false]
135
+ ]
136
+ )
137
+ transcoder.transcode request_pb
138
+ end
139
+
140
+ ##
141
+ # @private
142
+ #
143
+ # GRPC transcoding helper method for the get_notification REST call
144
+ #
145
+ # @param request_pb [::Google::Cloud::AdvisoryNotifications::V1::GetNotificationRequest]
146
+ # A request object representing the call parameters. Required.
147
+ # @return [Array(String, [String, nil], Hash{String => String})]
148
+ # Uri, Body, Query string parameters
149
+ def self.transcode_get_notification_request request_pb
150
+ transcoder = Gapic::Rest::GrpcTranscoder.new
151
+ .with_bindings(
152
+ uri_method: :get,
153
+ uri_template: "/v1/{name}",
154
+ matches: [
155
+ ["name", %r{^organizations/[^/]+/locations/[^/]+/notifications/[^/]+/?$}, false]
156
+ ]
157
+ )
158
+ transcoder.transcode request_pb
159
+ end
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/advisory_notifications/v1/version"
24
+
25
+ require "google/cloud/advisory_notifications/v1/advisory_notifications_service/credentials"
26
+ require "google/cloud/advisory_notifications/v1/advisory_notifications_service/paths"
27
+ require "google/cloud/advisory_notifications/v1/advisory_notifications_service/rest/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module AdvisoryNotifications
32
+ module V1
33
+ ##
34
+ # Service to manage Security and Privacy Notifications.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/advisory_notifications/v1/advisory_notifications_service/rest"
39
+ # client = ::Google::Cloud::AdvisoryNotifications::V1::AdvisoryNotificationsService::Rest::Client.new
40
+ #
41
+ module AdvisoryNotificationsService
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
52
+ require "google/cloud/advisory_notifications/v1/advisory_notifications_service/rest/helpers" if ::File.file? helper_path