google-cloud-logging 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/lib/google-cloud-logging.rb +13 -10
  3. data/lib/google/cloud/logging.rb +41 -17
  4. data/lib/google/cloud/logging/async_writer.rb +5 -2
  5. data/lib/google/cloud/logging/credentials.rb +31 -15
  6. data/lib/google/cloud/logging/entry.rb +13 -0
  7. data/lib/google/cloud/logging/entry/http_request.rb +35 -12
  8. data/lib/google/cloud/logging/logger.rb +14 -0
  9. data/lib/google/cloud/logging/middleware.rb +1 -1
  10. data/lib/google/cloud/logging/project.rb +55 -8
  11. data/lib/google/cloud/logging/rails.rb +1 -1
  12. data/lib/google/cloud/logging/service.rb +8 -27
  13. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +360 -93
  14. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +43 -8
  15. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +172 -0
  16. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +187 -0
  17. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +4 -4
  18. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +4 -1
  19. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +13 -6
  20. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +55 -21
  21. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +185 -23
  22. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +89 -5
  23. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +12 -2
  24. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +14 -1
  25. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +223 -0
  26. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +26 -1
  27. data/lib/google/cloud/logging/v2/doc/overview.rb +67 -0
  28. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +116 -91
  29. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +12 -11
  30. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +87 -76
  31. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +9 -8
  32. data/lib/google/cloud/logging/version.rb +1 -1
  33. metadata +11 -7
@@ -132,7 +132,7 @@ module Google
132
132
  ##
133
133
  # Fallback to default config values if config parameters not provided.
134
134
  def self.init_default_config
135
- Logging.configure.project_id ||= Logging::Project.default_project
135
+ Logging.configure.project_id ||= Logging::Project.default_project_id
136
136
  Logging.configure.log_name ||= Middleware::DEFAULT_LOG_NAME
137
137
  end
138
138
 
@@ -25,37 +25,22 @@ module Google
25
25
  # @private Represents the gRPC Logging service, including all the API
26
26
  # methods.
27
27
  class Service
28
- attr_accessor :project, :credentials, :host, :timeout, :client_config
28
+ attr_accessor :project, :credentials, :timeout, :client_config
29
29
 
30
30
  ##
31
31
  # Creates a new Service instance.
32
- def initialize project, credentials, host: nil, timeout: nil,
33
- client_config: nil
32
+ def initialize project, credentials, timeout: nil, client_config: nil
34
33
  @project = project
35
34
  @credentials = credentials
36
- @host = host || V2::LoggingServiceV2Client::SERVICE_ADDRESS
37
35
  @timeout = timeout
38
36
  @client_config = client_config || {}
39
37
  end
40
38
 
41
- def channel
42
- require "grpc"
43
- GRPC::Core::Channel.new host, nil, chan_creds
44
- end
45
-
46
- def chan_creds
47
- return credentials if insecure?
48
- require "grpc"
49
- GRPC::Core::ChannelCredentials.new.compose \
50
- GRPC::Core::CallCredentials.new credentials.client.updater_proc
51
- end
52
-
53
39
  def logging
54
40
  return mocked_logging if mocked_logging
55
41
  @logging ||= \
56
42
  V2::LoggingServiceV2Client.new(
57
- service_path: host,
58
- channel: channel,
43
+ credentials: credentials,
59
44
  timeout: timeout,
60
45
  client_config: client_config,
61
46
  lib_name: "gccl",
@@ -67,8 +52,7 @@ module Google
67
52
  return mocked_sinks if mocked_sinks
68
53
  @sinks ||= \
69
54
  V2::ConfigServiceV2Client.new(
70
- service_path: host,
71
- channel: channel,
55
+ credentials: credentials,
72
56
  timeout: timeout,
73
57
  client_config: client_config,
74
58
  lib_name: "gccl",
@@ -80,8 +64,7 @@ module Google
80
64
  return mocked_metrics if mocked_metrics
81
65
  @metrics ||= \
82
66
  V2::MetricsServiceV2Client.new(
83
- service_path: host,
84
- channel: channel,
67
+ credentials: credentials,
85
68
  timeout: timeout,
86
69
  client_config: client_config,
87
70
  lib_name: "gccl",
@@ -89,10 +72,6 @@ module Google
89
72
  end
90
73
  attr_accessor :mocked_metrics
91
74
 
92
- def insecure?
93
- credentials == :this_channel_is_insecure
94
- end
95
-
96
75
  def list_entries resources: nil, filter: nil, order: nil, token: nil,
97
76
  max: nil, projects: nil
98
77
 
@@ -113,7 +92,8 @@ module Google
113
92
  end
114
93
  end
115
94
 
116
- def write_entries entries, log_name: nil, resource: nil, labels: nil
95
+ def write_entries entries, log_name: nil, resource: nil, labels: nil,
96
+ partial_success: nil
117
97
  # Fix log names so they are the full path
118
98
  entries = Array(entries).each do |entry|
119
99
  entry.log_name = log_path(entry.log_name)
@@ -125,6 +105,7 @@ module Google
125
105
  logging.write_log_entries entries,
126
106
  log_name: log_path(log_name),
127
107
  resource: resource, labels: labels,
108
+ partial_success: partial_success,
128
109
  options: default_options
129
110
  end
130
111
  end
@@ -28,6 +28,7 @@ require "pathname"
28
28
  require "google/gax"
29
29
 
30
30
  require "google/logging/v2/logging_config_pb"
31
+ require "google/cloud/logging/credentials"
31
32
 
32
33
  module Google
33
34
  module Cloud
@@ -53,7 +54,11 @@ module Google
53
54
  "list_sinks" => Google::Gax::PageDescriptor.new(
54
55
  "page_token",
55
56
  "next_page_token",
56
- "sinks")
57
+ "sinks"),
58
+ "list_exclusions" => Google::Gax::PageDescriptor.new(
59
+ "page_token",
60
+ "next_page_token",
61
+ "exclusions")
57
62
  }.freeze
58
63
 
59
64
  private_constant :PAGE_DESCRIPTORS
@@ -80,6 +85,12 @@ module Google
80
85
 
81
86
  private_constant :SINK_PATH_TEMPLATE
82
87
 
88
+ EXCLUSION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
89
+ "projects/{project}/exclusions/{exclusion}"
90
+ )
91
+
92
+ private_constant :EXCLUSION_PATH_TEMPLATE
93
+
83
94
  # Returns a fully-qualified project resource name string.
84
95
  # @param project [String]
85
96
  # @return [String]
@@ -100,36 +111,35 @@ module Google
100
111
  )
101
112
  end
102
113
 
103
- # Parses the project from a project resource.
104
- # @param project_name [String]
105
- # @return [String]
106
- def self.match_project_from_project_name project_name
107
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
108
- end
109
-
110
- # Parses the project from a sink resource.
111
- # @param sink_name [String]
112
- # @return [String]
113
- def self.match_project_from_sink_name sink_name
114
- SINK_PATH_TEMPLATE.match(sink_name)["project"]
115
- end
116
-
117
- # Parses the sink from a sink resource.
118
- # @param sink_name [String]
114
+ # Returns a fully-qualified exclusion resource name string.
115
+ # @param project [String]
116
+ # @param exclusion [String]
119
117
  # @return [String]
120
- def self.match_sink_from_sink_name sink_name
121
- SINK_PATH_TEMPLATE.match(sink_name)["sink"]
118
+ def self.exclusion_path project, exclusion
119
+ EXCLUSION_PATH_TEMPLATE.render(
120
+ :"project" => project,
121
+ :"exclusion" => exclusion
122
+ )
122
123
  end
123
124
 
124
- # @param service_path [String]
125
- # The domain name of the API remote host.
126
- # @param port [Integer]
127
- # The port on which to connect to the remote host.
128
- # @param channel [Channel]
129
- # A Channel object through which to make calls.
130
- # @param chan_creds [Grpc::ChannelCredentials]
131
- # A ChannelCredentials for the setting up the RPC client.
132
- # @param client_config[Hash]
125
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
126
+ # Provides the means for authenticating requests made by the client. This parameter can
127
+ # be many types.
128
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
129
+ # authenticating requests made by this client.
130
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
131
+ # credentials for this client.
132
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
133
+ # credentials for this client.
134
+ # A `GRPC::Core::Channel` will be used to make calls through.
135
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
136
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
137
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
138
+ # metadata for requests, generally, to give OAuth credentials.
139
+ # @param scopes [Array<String>]
140
+ # The OAuth scopes for this service. This parameter is ignored if
141
+ # an updater_proc is supplied.
142
+ # @param client_config [Hash]
133
143
  # A Hash for call options for each method. See
134
144
  # Google::Gax#construct_settings for the structure of
135
145
  # this data. Falls back to the default config if not specified
@@ -141,11 +151,11 @@ module Google
141
151
  port: DEFAULT_SERVICE_PORT,
142
152
  channel: nil,
143
153
  chan_creds: nil,
154
+ updater_proc: nil,
155
+ credentials: nil,
144
156
  scopes: ALL_SCOPES,
145
157
  client_config: {},
146
158
  timeout: DEFAULT_TIMEOUT,
147
- app_name: nil,
148
- app_version: nil,
149
159
  lib_name: nil,
150
160
  lib_version: ""
151
161
  # These require statements are intentionally placed here to initialize
@@ -154,14 +164,38 @@ module Google
154
164
  require "google/gax/grpc"
155
165
  require "google/logging/v2/logging_config_services_pb"
156
166
 
167
+ if channel || chan_creds || updater_proc
168
+ warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
169
+ "on 2017/09/08"
170
+ credentials ||= channel
171
+ credentials ||= chan_creds
172
+ credentials ||= updater_proc
173
+ end
174
+ if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
175
+ warn "`service_path` and `port` parameters are deprecated and will be removed"
176
+ end
177
+
178
+ credentials ||= Google::Cloud::Logging::Credentials.default
157
179
 
158
- if app_name || app_version
159
- warn "`app_name` and `app_version` are no longer being used in the request headers."
180
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
181
+ updater_proc = Google::Cloud::Logging::Credentials.new(credentials).updater_proc
182
+ end
183
+ if credentials.is_a?(GRPC::Core::Channel)
184
+ channel = credentials
185
+ end
186
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
187
+ chan_creds = credentials
188
+ end
189
+ if credentials.is_a?(Proc)
190
+ updater_proc = credentials
191
+ end
192
+ if credentials.is_a?(Google::Auth::Credentials)
193
+ updater_proc = credentials.updater_proc
160
194
  end
161
195
 
162
196
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
163
197
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
164
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
198
+ google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
165
199
  google_api_client << " grpc/#{GRPC::VERSION}"
166
200
  google_api_client.freeze
167
201
 
@@ -186,6 +220,7 @@ module Google
186
220
  port,
187
221
  chan_creds: chan_creds,
188
222
  channel: channel,
223
+ updater_proc: updater_proc,
189
224
  scopes: scopes,
190
225
  &Google::Logging::V2::ConfigServiceV2::Stub.method(:new)
191
226
  )
@@ -210,6 +245,26 @@ module Google
210
245
  @config_service_v2_stub.method(:delete_sink),
211
246
  defaults["delete_sink"]
212
247
  )
248
+ @list_exclusions = Google::Gax.create_api_call(
249
+ @config_service_v2_stub.method(:list_exclusions),
250
+ defaults["list_exclusions"]
251
+ )
252
+ @get_exclusion = Google::Gax.create_api_call(
253
+ @config_service_v2_stub.method(:get_exclusion),
254
+ defaults["get_exclusion"]
255
+ )
256
+ @create_exclusion = Google::Gax.create_api_call(
257
+ @config_service_v2_stub.method(:create_exclusion),
258
+ defaults["create_exclusion"]
259
+ )
260
+ @update_exclusion = Google::Gax.create_api_call(
261
+ @config_service_v2_stub.method(:update_exclusion),
262
+ defaults["update_exclusion"]
263
+ )
264
+ @delete_exclusion = Google::Gax.create_api_call(
265
+ @config_service_v2_stub.method(:delete_exclusion),
266
+ defaults["delete_exclusion"]
267
+ )
213
268
  end
214
269
 
215
270
  # Service calls
@@ -239,12 +294,10 @@ module Google
239
294
  # object.
240
295
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
241
296
  # @example
242
- # require "google/cloud/logging/v2/config_service_v2_client"
297
+ # require "google/cloud/logging/v2"
243
298
  #
244
- # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
245
- #
246
- # config_service_v2_client = ConfigServiceV2Client.new
247
- # formatted_parent = ConfigServiceV2Client.project_path("[PROJECT]")
299
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
300
+ # formatted_parent = Google::Cloud::Logging::V2::ConfigServiceV2Client.project_path("[PROJECT]")
248
301
  #
249
302
  # # Iterate over all results.
250
303
  # config_service_v2_client.list_sinks(formatted_parent).each do |element|
@@ -263,10 +316,11 @@ module Google
263
316
  parent,
264
317
  page_size: nil,
265
318
  options: nil
266
- req = Google::Logging::V2::ListSinksRequest.new({
319
+ req = {
267
320
  parent: parent,
268
321
  page_size: page_size
269
- }.delete_if { |_, v| v.nil? })
322
+ }.delete_if { |_, v| v.nil? }
323
+ req = Google::Gax::to_proto(req, Google::Logging::V2::ListSinksRequest)
270
324
  @list_sinks.call(req, options)
271
325
  end
272
326
 
@@ -280,27 +334,26 @@ module Google
280
334
  # "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
281
335
  # "folders/[FOLDER_ID]/sinks/[SINK_ID]"
282
336
  #
283
- # Example: +"projects/my-project-id/sinks/my-sink-id"+.
337
+ # Example: +"projects/my-project/sinks/my-sink-id"+.
284
338
  # @param options [Google::Gax::CallOptions]
285
339
  # Overrides the default settings for this call, e.g, timeout,
286
340
  # retries, etc.
287
341
  # @return [Google::Logging::V2::LogSink]
288
342
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
289
343
  # @example
290
- # require "google/cloud/logging/v2/config_service_v2_client"
291
- #
292
- # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
344
+ # require "google/cloud/logging/v2"
293
345
  #
294
- # config_service_v2_client = ConfigServiceV2Client.new
295
- # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
346
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
347
+ # formatted_sink_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
296
348
  # response = config_service_v2_client.get_sink(formatted_sink_name)
297
349
 
298
350
  def get_sink \
299
351
  sink_name,
300
352
  options: nil
301
- req = Google::Logging::V2::GetSinkRequest.new({
353
+ req = {
302
354
  sink_name: sink_name
303
- }.delete_if { |_, v| v.nil? })
355
+ }.delete_if { |_, v| v.nil? }
356
+ req = Google::Gax::to_proto(req, Google::Logging::V2::GetSinkRequest)
304
357
  @get_sink.call(req, options)
305
358
  end
306
359
 
@@ -319,9 +372,11 @@ module Google
319
372
  # "folders/[FOLDER_ID]"
320
373
  #
321
374
  # Examples: +"projects/my-logging-project"+, +"organizations/123456789"+.
322
- # @param sink [Google::Logging::V2::LogSink]
375
+ # @param sink [Google::Logging::V2::LogSink | Hash]
323
376
  # Required. The new sink, whose +name+ parameter is a sink identifier that
324
377
  # is not already in use.
378
+ # A hash of the same form as `Google::Logging::V2::LogSink`
379
+ # can also be provided.
325
380
  # @param unique_writer_identity [true, false]
326
381
  # Optional. Determines the kind of IAM identity returned as +writer_identity+
327
382
  # in the new sink. If this value is omitted or set to false, and if the
@@ -333,21 +388,18 @@ module Google
333
388
  # If this field is set to true, or if the sink is owned by a non-project
334
389
  # resource such as an organization, then the value of +writer_identity+ will
335
390
  # be a unique service account used only for exports from the new sink. For
336
- # more information, see +writer_identity+ in LogSink.
391
+ # more information, see +writer_identity+ in {Google::Logging::V2::LogSink LogSink}.
337
392
  # @param options [Google::Gax::CallOptions]
338
393
  # Overrides the default settings for this call, e.g, timeout,
339
394
  # retries, etc.
340
395
  # @return [Google::Logging::V2::LogSink]
341
396
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
342
397
  # @example
343
- # require "google/cloud/logging/v2/config_service_v2_client"
398
+ # require "google/cloud/logging/v2"
344
399
  #
345
- # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
346
- # LogSink = Google::Logging::V2::LogSink
347
- #
348
- # config_service_v2_client = ConfigServiceV2Client.new
349
- # formatted_parent = ConfigServiceV2Client.project_path("[PROJECT]")
350
- # sink = LogSink.new
400
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
401
+ # formatted_parent = Google::Cloud::Logging::V2::ConfigServiceV2Client.project_path("[PROJECT]")
402
+ # sink = {}
351
403
  # response = config_service_v2_client.create_sink(formatted_parent, sink)
352
404
 
353
405
  def create_sink \
@@ -355,21 +407,19 @@ module Google
355
407
  sink,
356
408
  unique_writer_identity: nil,
357
409
  options: nil
358
- req = Google::Logging::V2::CreateSinkRequest.new({
410
+ req = {
359
411
  parent: parent,
360
412
  sink: sink,
361
413
  unique_writer_identity: unique_writer_identity
362
- }.delete_if { |_, v| v.nil? })
414
+ }.delete_if { |_, v| v.nil? }
415
+ req = Google::Gax::to_proto(req, Google::Logging::V2::CreateSinkRequest)
363
416
  @create_sink.call(req, options)
364
417
  end
365
418
 
366
- # Updates a sink. If the named sink doesn't exist, then this method is
367
- # identical to
368
- # {sinks.create}[https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks/create].
369
- # If the named sink does exist, then this method replaces the following
370
- # fields in the existing sink with values from the new sink: +destination+,
371
- # +filter+, +output_version_format+, +start_time+, and +end_time+.
372
- # The updated filter might also have a new +writer_identity+; see the
419
+ # Updates a sink. This method replaces the following fields in the existing
420
+ # sink with values from the new sink: +destination+, +filter+,
421
+ # +output_version_format+, +start_time+, and +end_time+.
422
+ # The updated sink might also have a new +writer_identity+; see the
373
423
  # +unique_writer_identity+ field.
374
424
  #
375
425
  # @param sink_name [String]
@@ -381,37 +431,36 @@ module Google
381
431
  # "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
382
432
  # "folders/[FOLDER_ID]/sinks/[SINK_ID]"
383
433
  #
384
- # Example: +"projects/my-project-id/sinks/my-sink-id"+.
385
- # @param sink [Google::Logging::V2::LogSink]
434
+ # Example: +"projects/my-project/sinks/my-sink-id"+.
435
+ # @param sink [Google::Logging::V2::LogSink | Hash]
386
436
  # Required. The updated sink, whose name is the same identifier that appears
387
- # as part of +sink_name+. If +sink_name+ does not exist, then
388
- # this method creates a new sink.
437
+ # as part of +sink_name+.
438
+ # A hash of the same form as `Google::Logging::V2::LogSink`
439
+ # can also be provided.
389
440
  # @param unique_writer_identity [true, false]
390
441
  # Optional. See
391
- # {sinks.create}[https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks/create]
442
+ # [sinks.create](https://cloud.google.com/logging/docs/api/reference/rest/v2/projects.sinks/create)
392
443
  # for a description of this field. When updating a sink, the effect of this
393
444
  # field on the value of +writer_identity+ in the updated sink depends on both
394
445
  # the old and new values of this field:
395
446
  #
396
- # + If the old and new values of this field are both false or both true,
397
- # then there is no change to the sink's +writer_identity+.
398
- # + If the old value is false and the new value is true, then
399
- # +writer_identity+ is changed to a unique service account.
400
- # + It is an error if the old value is true and the new value is false.
447
+ # * If the old and new values of this field are both false or both true,
448
+ # then there is no change to the sink's +writer_identity+.
449
+ # * If the old value is false and the new value is true, then
450
+ # +writer_identity+ is changed to a unique service account.
451
+ # * It is an error if the old value is true and the new value is
452
+ # set to false or defaulted to false.
401
453
  # @param options [Google::Gax::CallOptions]
402
454
  # Overrides the default settings for this call, e.g, timeout,
403
455
  # retries, etc.
404
456
  # @return [Google::Logging::V2::LogSink]
405
457
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
406
458
  # @example
407
- # require "google/cloud/logging/v2/config_service_v2_client"
408
- #
409
- # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
410
- # LogSink = Google::Logging::V2::LogSink
459
+ # require "google/cloud/logging/v2"
411
460
  #
412
- # config_service_v2_client = ConfigServiceV2Client.new
413
- # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
414
- # sink = LogSink.new
461
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
462
+ # formatted_sink_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
463
+ # sink = {}
415
464
  # response = config_service_v2_client.update_sink(formatted_sink_name, sink)
416
465
 
417
466
  def update_sink \
@@ -419,11 +468,12 @@ module Google
419
468
  sink,
420
469
  unique_writer_identity: nil,
421
470
  options: nil
422
- req = Google::Logging::V2::UpdateSinkRequest.new({
471
+ req = {
423
472
  sink_name: sink_name,
424
473
  sink: sink,
425
474
  unique_writer_identity: unique_writer_identity
426
- }.delete_if { |_, v| v.nil? })
475
+ }.delete_if { |_, v| v.nil? }
476
+ req = Google::Gax::to_proto(req, Google::Logging::V2::UpdateSinkRequest)
427
477
  @update_sink.call(req, options)
428
478
  end
429
479
 
@@ -439,29 +489,246 @@ module Google
439
489
  # "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]"
440
490
  # "folders/[FOLDER_ID]/sinks/[SINK_ID]"
441
491
  #
442
- # Example: +"projects/my-project-id/sinks/my-sink-id"+.
492
+ # Example: +"projects/my-project/sinks/my-sink-id"+.
443
493
  # @param options [Google::Gax::CallOptions]
444
494
  # Overrides the default settings for this call, e.g, timeout,
445
495
  # retries, etc.
446
496
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
447
497
  # @example
448
- # require "google/cloud/logging/v2/config_service_v2_client"
498
+ # require "google/cloud/logging/v2"
449
499
  #
450
- # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
451
- #
452
- # config_service_v2_client = ConfigServiceV2Client.new
453
- # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
500
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
501
+ # formatted_sink_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
454
502
  # config_service_v2_client.delete_sink(formatted_sink_name)
455
503
 
456
504
  def delete_sink \
457
505
  sink_name,
458
506
  options: nil
459
- req = Google::Logging::V2::DeleteSinkRequest.new({
507
+ req = {
460
508
  sink_name: sink_name
461
- }.delete_if { |_, v| v.nil? })
509
+ }.delete_if { |_, v| v.nil? }
510
+ req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteSinkRequest)
462
511
  @delete_sink.call(req, options)
463
512
  nil
464
513
  end
514
+
515
+ # Lists all the exclusions in a parent resource.
516
+ #
517
+ # @param parent [String]
518
+ # Required. The parent resource whose exclusions are to be listed.
519
+ #
520
+ # "projects/[PROJECT_ID]"
521
+ # "organizations/[ORGANIZATION_ID]"
522
+ # "billingAccounts/[BILLING_ACCOUNT_ID]"
523
+ # "folders/[FOLDER_ID]"
524
+ # @param page_size [Integer]
525
+ # The maximum number of resources contained in the underlying API
526
+ # response. If page streaming is performed per-resource, this
527
+ # parameter does not affect the return value. If page streaming is
528
+ # performed per-page, this determines the maximum number of
529
+ # resources in a page.
530
+ # @param options [Google::Gax::CallOptions]
531
+ # Overrides the default settings for this call, e.g, timeout,
532
+ # retries, etc.
533
+ # @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogExclusion>]
534
+ # An enumerable of Google::Logging::V2::LogExclusion instances.
535
+ # See Google::Gax::PagedEnumerable documentation for other
536
+ # operations such as per-page iteration or access to the response
537
+ # object.
538
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
539
+ # @example
540
+ # require "google/cloud/logging/v2"
541
+ #
542
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
543
+ # formatted_parent = Google::Cloud::Logging::V2::ConfigServiceV2Client.project_path("[PROJECT]")
544
+ #
545
+ # # Iterate over all results.
546
+ # config_service_v2_client.list_exclusions(formatted_parent).each do |element|
547
+ # # Process element.
548
+ # end
549
+ #
550
+ # # Or iterate over results one page at a time.
551
+ # config_service_v2_client.list_exclusions(formatted_parent).each_page do |page|
552
+ # # Process each page at a time.
553
+ # page.each do |element|
554
+ # # Process element.
555
+ # end
556
+ # end
557
+
558
+ def list_exclusions \
559
+ parent,
560
+ page_size: nil,
561
+ options: nil
562
+ req = {
563
+ parent: parent,
564
+ page_size: page_size
565
+ }.delete_if { |_, v| v.nil? }
566
+ req = Google::Gax::to_proto(req, Google::Logging::V2::ListExclusionsRequest)
567
+ @list_exclusions.call(req, options)
568
+ end
569
+
570
+ # Gets the description of an exclusion.
571
+ #
572
+ # @param name [String]
573
+ # Required. The resource name of an existing exclusion:
574
+ #
575
+ # "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
576
+ # "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
577
+ # "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
578
+ # "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
579
+ #
580
+ # Example: +"projects/my-project/exclusions/my-exclusion-id"+.
581
+ # @param options [Google::Gax::CallOptions]
582
+ # Overrides the default settings for this call, e.g, timeout,
583
+ # retries, etc.
584
+ # @return [Google::Logging::V2::LogExclusion]
585
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
586
+ # @example
587
+ # require "google/cloud/logging/v2"
588
+ #
589
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
590
+ # formatted_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.exclusion_path("[PROJECT]", "[EXCLUSION]")
591
+ # response = config_service_v2_client.get_exclusion(formatted_name)
592
+
593
+ def get_exclusion \
594
+ name,
595
+ options: nil
596
+ req = {
597
+ name: name
598
+ }.delete_if { |_, v| v.nil? }
599
+ req = Google::Gax::to_proto(req, Google::Logging::V2::GetExclusionRequest)
600
+ @get_exclusion.call(req, options)
601
+ end
602
+
603
+ # Creates a new exclusion in a specified parent resource.
604
+ # Only log entries belonging to that resource can be excluded.
605
+ # You can have up to 10 exclusions in a resource.
606
+ #
607
+ # @param parent [String]
608
+ # Required. The parent resource in which to create the exclusion:
609
+ #
610
+ # "projects/[PROJECT_ID]"
611
+ # "organizations/[ORGANIZATION_ID]"
612
+ # "billingAccounts/[BILLING_ACCOUNT_ID]"
613
+ # "folders/[FOLDER_ID]"
614
+ #
615
+ # Examples: +"projects/my-logging-project"+, +"organizations/123456789"+.
616
+ # @param exclusion [Google::Logging::V2::LogExclusion | Hash]
617
+ # Required. The new exclusion, whose +name+ parameter is an exclusion name
618
+ # that is not already used in the parent resource.
619
+ # A hash of the same form as `Google::Logging::V2::LogExclusion`
620
+ # can also be provided.
621
+ # @param options [Google::Gax::CallOptions]
622
+ # Overrides the default settings for this call, e.g, timeout,
623
+ # retries, etc.
624
+ # @return [Google::Logging::V2::LogExclusion]
625
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
626
+ # @example
627
+ # require "google/cloud/logging/v2"
628
+ #
629
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
630
+ # formatted_parent = Google::Cloud::Logging::V2::ConfigServiceV2Client.project_path("[PROJECT]")
631
+ # exclusion = {}
632
+ # response = config_service_v2_client.create_exclusion(formatted_parent, exclusion)
633
+
634
+ def create_exclusion \
635
+ parent,
636
+ exclusion,
637
+ options: nil
638
+ req = {
639
+ parent: parent,
640
+ exclusion: exclusion
641
+ }.delete_if { |_, v| v.nil? }
642
+ req = Google::Gax::to_proto(req, Google::Logging::V2::CreateExclusionRequest)
643
+ @create_exclusion.call(req, options)
644
+ end
645
+
646
+ # Changes one or more properties of an existing exclusion.
647
+ #
648
+ # @param name [String]
649
+ # Required. The resource name of the exclusion to update:
650
+ #
651
+ # "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
652
+ # "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
653
+ # "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
654
+ # "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
655
+ #
656
+ # Example: +"projects/my-project/exclusions/my-exclusion-id"+.
657
+ # @param exclusion [Google::Logging::V2::LogExclusion | Hash]
658
+ # Required. New values for the existing exclusion. Only the fields specified
659
+ # in +update_mask+ are relevant.
660
+ # A hash of the same form as `Google::Logging::V2::LogExclusion`
661
+ # can also be provided.
662
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
663
+ # Required. A nonempty list of fields to change in the existing exclusion.
664
+ # New values for the fields are taken from the corresponding fields in the
665
+ # {Google::Logging::V2::LogExclusion LogExclusion} included in this request. Fields not mentioned in
666
+ # +update_mask+ are not changed and are ignored in the request.
667
+ #
668
+ # For example, to change the filter and description of an exclusion,
669
+ # specify an +update_mask+ of +"filter,description"+.
670
+ # A hash of the same form as `Google::Protobuf::FieldMask`
671
+ # can also be provided.
672
+ # @param options [Google::Gax::CallOptions]
673
+ # Overrides the default settings for this call, e.g, timeout,
674
+ # retries, etc.
675
+ # @return [Google::Logging::V2::LogExclusion]
676
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
677
+ # @example
678
+ # require "google/cloud/logging/v2"
679
+ #
680
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
681
+ # formatted_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.exclusion_path("[PROJECT]", "[EXCLUSION]")
682
+ # exclusion = {}
683
+ # update_mask = {}
684
+ # response = config_service_v2_client.update_exclusion(formatted_name, exclusion, update_mask)
685
+
686
+ def update_exclusion \
687
+ name,
688
+ exclusion,
689
+ update_mask,
690
+ options: nil
691
+ req = {
692
+ name: name,
693
+ exclusion: exclusion,
694
+ update_mask: update_mask
695
+ }.delete_if { |_, v| v.nil? }
696
+ req = Google::Gax::to_proto(req, Google::Logging::V2::UpdateExclusionRequest)
697
+ @update_exclusion.call(req, options)
698
+ end
699
+
700
+ # Deletes an exclusion.
701
+ #
702
+ # @param name [String]
703
+ # Required. The resource name of an existing exclusion to delete:
704
+ #
705
+ # "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]"
706
+ # "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]"
707
+ # "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]"
708
+ # "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]"
709
+ #
710
+ # Example: +"projects/my-project/exclusions/my-exclusion-id"+.
711
+ # @param options [Google::Gax::CallOptions]
712
+ # Overrides the default settings for this call, e.g, timeout,
713
+ # retries, etc.
714
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
715
+ # @example
716
+ # require "google/cloud/logging/v2"
717
+ #
718
+ # config_service_v2_client = Google::Cloud::Logging::V2::Config.new
719
+ # formatted_name = Google::Cloud::Logging::V2::ConfigServiceV2Client.exclusion_path("[PROJECT]", "[EXCLUSION]")
720
+ # config_service_v2_client.delete_exclusion(formatted_name)
721
+
722
+ def delete_exclusion \
723
+ name,
724
+ options: nil
725
+ req = {
726
+ name: name
727
+ }.delete_if { |_, v| v.nil? }
728
+ req = Google::Gax::to_proto(req, Google::Logging::V2::DeleteExclusionRequest)
729
+ @delete_exclusion.call(req, options)
730
+ nil
731
+ end
465
732
  end
466
733
  end
467
734
  end