google-cloud-logging 0.21.2 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,7 +62,7 @@ module Google
62
62
  #
63
63
  # logging = Google::Cloud::Logging.new
64
64
  #
65
- # sinks = dataset.sinks
65
+ # sinks = logging.sinks
66
66
  # if sinks.next?
67
67
  # next_sinks = sinks.next
68
68
  # end
@@ -12,6 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require "google/cloud/logging/v2/config_service_v2_api"
16
- require "google/cloud/logging/v2/logging_service_v2_api"
17
- require "google/cloud/logging/v2/metrics_service_v2_api"
15
+ require "google/cloud/logging/v2/config_service_v2_client"
16
+ require "google/cloud/logging/v2/logging_service_v2_client"
17
+ require "google/cloud/logging/v2/metrics_service_v2_client"
@@ -32,12 +32,12 @@ module Google
32
32
  module Cloud
33
33
  module Logging
34
34
  module V2
35
- # Service for configuring sinks used to export log entries outside Stackdriver
36
- # Logging.
35
+ # Service for configuring sinks used to export log entries outside of
36
+ # Stackdriver Logging.
37
37
  #
38
38
  # @!attribute [r] config_service_v2_stub
39
39
  # @return [Google::Logging::V2::ConfigServiceV2::Stub]
40
- class ConfigServiceV2Api
40
+ class ConfigServiceV2Client
41
41
  attr_reader :config_service_v2_stub
42
42
 
43
43
  # The default address of the service.
@@ -69,11 +69,11 @@ module Google
69
69
  "https://www.googleapis.com/auth/logging.write"
70
70
  ].freeze
71
71
 
72
- PARENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
72
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
73
73
  "projects/{project}"
74
74
  )
75
75
 
76
- private_constant :PARENT_PATH_TEMPLATE
76
+ private_constant :PROJECT_PATH_TEMPLATE
77
77
 
78
78
  SINK_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
79
79
  "projects/{project}/sinks/{sink}"
@@ -81,11 +81,11 @@ module Google
81
81
 
82
82
  private_constant :SINK_PATH_TEMPLATE
83
83
 
84
- # Returns a fully-qualified parent resource name string.
84
+ # Returns a fully-qualified project resource name string.
85
85
  # @param project [String]
86
86
  # @return [String]
87
- def self.parent_path project
88
- PARENT_PATH_TEMPLATE.render(
87
+ def self.project_path project
88
+ PROJECT_PATH_TEMPLATE.render(
89
89
  :"project" => project
90
90
  )
91
91
  end
@@ -101,11 +101,11 @@ module Google
101
101
  )
102
102
  end
103
103
 
104
- # Parses the project from a parent resource.
105
- # @param parent_name [String]
104
+ # Parses the project from a project resource.
105
+ # @param project_name [String]
106
106
  # @return [String]
107
- def self.match_project_from_parent_name parent_name
108
- PARENT_PATH_TEMPLATE.match(parent_name)["project"]
107
+ def self.match_project_from_project_name project_name
108
+ PROJECT_PATH_TEMPLATE.match(project_name)["project"]
109
109
  end
110
110
 
111
111
  # Parses the project from a sink resource.
@@ -157,6 +157,7 @@ module Google
157
157
  require "google/gax/grpc"
158
158
  require "google/logging/v2/logging_config_services_pb"
159
159
 
160
+
160
161
  google_api_client = "#{app_name}/#{app_version} " \
161
162
  "#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
162
163
  "ruby/#{RUBY_VERSION}".freeze
@@ -212,8 +213,10 @@ module Google
212
213
  # Lists sinks.
213
214
  #
214
215
  # @param parent [String]
215
- # Required. The cloud resource containing the sinks.
216
- # Example: +"projects/my-logging-project"+.
216
+ # Required. The resource name where this sink was created:
217
+ #
218
+ # "projects/[PROJECT_ID]"
219
+ # "organizations/[ORGANIZATION_ID]"
217
220
  # @param page_size [Integer]
218
221
  # The maximum number of resources contained in the underlying API
219
222
  # response. If page streaming is performed per-resource, this
@@ -230,20 +233,20 @@ module Google
230
233
  # object.
231
234
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
232
235
  # @example
233
- # require "google/cloud/logging/v2/config_service_v2_api"
236
+ # require "google/cloud/logging/v2/config_service_v2_client"
234
237
  #
235
- # ConfigServiceV2Api = Google::Cloud::Logging::V2::ConfigServiceV2Api
238
+ # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
236
239
  #
237
- # config_service_v2_api = ConfigServiceV2Api.new
238
- # formatted_parent = ConfigServiceV2Api.parent_path("[PROJECT]")
240
+ # config_service_v2_client = ConfigServiceV2Client.new
241
+ # formatted_parent = ConfigServiceV2Client.project_path("[PROJECT]")
239
242
  #
240
243
  # # Iterate over all results.
241
- # config_service_v2_api.list_sinks(formatted_parent).each do |element|
244
+ # config_service_v2_client.list_sinks(formatted_parent).each do |element|
242
245
  # # Process element.
243
246
  # end
244
247
  #
245
248
  # # Or iterate over results one page at a time.
246
- # config_service_v2_api.list_sinks(formatted_parent).each_page do |page|
249
+ # config_service_v2_client.list_sinks(formatted_parent).each_page do |page|
247
250
  # # Process each page at a time.
248
251
  # page.each do |element|
249
252
  # # Process element.
@@ -264,21 +267,23 @@ module Google
264
267
  # Gets a sink.
265
268
  #
266
269
  # @param sink_name [String]
267
- # Required. The resource name of the sink to return.
268
- # Example: +"projects/my-project-id/sinks/my-sink-id"+.
270
+ # Required. The resource name of the sink to return:
271
+ #
272
+ # "projects/[PROJECT_ID]/sinks/[SINK_ID]"
273
+ # "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
269
274
  # @param options [Google::Gax::CallOptions]
270
275
  # Overrides the default settings for this call, e.g, timeout,
271
276
  # retries, etc.
272
277
  # @return [Google::Logging::V2::LogSink]
273
278
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
274
279
  # @example
275
- # require "google/cloud/logging/v2/config_service_v2_api"
280
+ # require "google/cloud/logging/v2/config_service_v2_client"
276
281
  #
277
- # ConfigServiceV2Api = Google::Cloud::Logging::V2::ConfigServiceV2Api
282
+ # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
278
283
  #
279
- # config_service_v2_api = ConfigServiceV2Api.new
280
- # formatted_sink_name = ConfigServiceV2Api.sink_path("[PROJECT]", "[SINK]")
281
- # response = config_service_v2_api.get_sink(formatted_sink_name)
284
+ # config_service_v2_client = ConfigServiceV2Client.new
285
+ # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
286
+ # response = config_service_v2_client.get_sink(formatted_sink_name)
282
287
 
283
288
  def get_sink \
284
289
  sink_name,
@@ -292,35 +297,44 @@ module Google
292
297
  # Creates a sink.
293
298
  #
294
299
  # @param parent [String]
295
- # Required. The resource in which to create the sink.
296
- # Example: +"projects/my-project-id"+.
297
- # The new sink must be provided in the request.
300
+ # Required. The resource in which to create the sink:
301
+ #
302
+ # "projects/[PROJECT_ID]"
303
+ # "organizations/[ORGANIZATION_ID]"
298
304
  # @param sink [Google::Logging::V2::LogSink]
299
305
  # Required. The new sink, whose +name+ parameter is a sink identifier that
300
306
  # is not already in use.
307
+ # @param unique_writer_identity [true, false]
308
+ # Optional. Whether the sink will have a dedicated service account returned
309
+ # in the sink's writer_identity. Set this field to be true to export
310
+ # logs from one project to a different project. This field is ignored for
311
+ # non-project sinks (e.g. organization sinks) because those sinks are
312
+ # required to have dedicated service accounts.
301
313
  # @param options [Google::Gax::CallOptions]
302
314
  # Overrides the default settings for this call, e.g, timeout,
303
315
  # retries, etc.
304
316
  # @return [Google::Logging::V2::LogSink]
305
317
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
306
318
  # @example
307
- # require "google/cloud/logging/v2/config_service_v2_api"
319
+ # require "google/cloud/logging/v2/config_service_v2_client"
308
320
  #
309
- # ConfigServiceV2Api = Google::Cloud::Logging::V2::ConfigServiceV2Api
321
+ # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
310
322
  # LogSink = Google::Logging::V2::LogSink
311
323
  #
312
- # config_service_v2_api = ConfigServiceV2Api.new
313
- # formatted_parent = ConfigServiceV2Api.parent_path("[PROJECT]")
324
+ # config_service_v2_client = ConfigServiceV2Client.new
325
+ # formatted_parent = ConfigServiceV2Client.project_path("[PROJECT]")
314
326
  # sink = LogSink.new
315
- # response = config_service_v2_api.create_sink(formatted_parent, sink)
327
+ # response = config_service_v2_client.create_sink(formatted_parent, sink)
316
328
 
317
329
  def create_sink \
318
330
  parent,
319
331
  sink,
332
+ unique_writer_identity: nil,
320
333
  options: nil
321
334
  req = Google::Logging::V2::CreateSinkRequest.new({
322
335
  parent: parent,
323
- sink: sink
336
+ sink: sink,
337
+ unique_writer_identity: unique_writer_identity
324
338
  }.delete_if { |_, v| v.nil? })
325
339
  @create_sink.call(req, options)
326
340
  end
@@ -329,35 +343,47 @@ module Google
329
343
  #
330
344
  # @param sink_name [String]
331
345
  # Required. The resource name of the sink to update, including the parent
332
- # resource and the sink identifier. If the sink does not exist, this method
333
- # creates the sink. Example: +"projects/my-project-id/sinks/my-sink-id"+.
346
+ # resource and the sink identifier:
347
+ #
348
+ # "projects/[PROJECT_ID]/sinks/[SINK_ID]"
349
+ # "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
350
+ #
351
+ # Example: +"projects/my-project-id/sinks/my-sink-id"+.
334
352
  # @param sink [Google::Logging::V2::LogSink]
335
353
  # Required. The updated sink, whose name is the same identifier that appears
336
354
  # as part of +sinkName+. If +sinkName+ does not exist, then
337
355
  # this method creates a new sink.
356
+ # @param unique_writer_identity [true, false]
357
+ # Optional. Whether the sink will have a dedicated service account returned
358
+ # in the sink's writer_identity. Set this field to be true to export
359
+ # logs from one project to a different project. This field is ignored for
360
+ # non-project sinks (e.g. organization sinks) because those sinks are
361
+ # required to have dedicated service accounts.
338
362
  # @param options [Google::Gax::CallOptions]
339
363
  # Overrides the default settings for this call, e.g, timeout,
340
364
  # retries, etc.
341
365
  # @return [Google::Logging::V2::LogSink]
342
366
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
343
367
  # @example
344
- # require "google/cloud/logging/v2/config_service_v2_api"
368
+ # require "google/cloud/logging/v2/config_service_v2_client"
345
369
  #
346
- # ConfigServiceV2Api = Google::Cloud::Logging::V2::ConfigServiceV2Api
370
+ # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
347
371
  # LogSink = Google::Logging::V2::LogSink
348
372
  #
349
- # config_service_v2_api = ConfigServiceV2Api.new
350
- # formatted_sink_name = ConfigServiceV2Api.sink_path("[PROJECT]", "[SINK]")
373
+ # config_service_v2_client = ConfigServiceV2Client.new
374
+ # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
351
375
  # sink = LogSink.new
352
- # response = config_service_v2_api.update_sink(formatted_sink_name, sink)
376
+ # response = config_service_v2_client.update_sink(formatted_sink_name, sink)
353
377
 
354
378
  def update_sink \
355
379
  sink_name,
356
380
  sink,
381
+ unique_writer_identity: nil,
357
382
  options: nil
358
383
  req = Google::Logging::V2::UpdateSinkRequest.new({
359
384
  sink_name: sink_name,
360
- sink: sink
385
+ sink: sink,
386
+ unique_writer_identity: unique_writer_identity
361
387
  }.delete_if { |_, v| v.nil? })
362
388
  @update_sink.call(req, options)
363
389
  end
@@ -366,21 +392,24 @@ module Google
366
392
  #
367
393
  # @param sink_name [String]
368
394
  # Required. The resource name of the sink to delete, including the parent
369
- # resource and the sink identifier. Example:
370
- # +"projects/my-project-id/sinks/my-sink-id"+. It is an error if the sink
371
- # does not exist.
395
+ # resource and the sink identifier:
396
+ #
397
+ # "projects/[PROJECT_ID]/sinks/[SINK_ID]"
398
+ # "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]"
399
+ #
400
+ # It is an error if the sink does not exist.
372
401
  # @param options [Google::Gax::CallOptions]
373
402
  # Overrides the default settings for this call, e.g, timeout,
374
403
  # retries, etc.
375
404
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
376
405
  # @example
377
- # require "google/cloud/logging/v2/config_service_v2_api"
406
+ # require "google/cloud/logging/v2/config_service_v2_client"
378
407
  #
379
- # ConfigServiceV2Api = Google::Cloud::Logging::V2::ConfigServiceV2Api
408
+ # ConfigServiceV2Client = Google::Cloud::Logging::V2::ConfigServiceV2Client
380
409
  #
381
- # config_service_v2_api = ConfigServiceV2Api.new
382
- # formatted_sink_name = ConfigServiceV2Api.sink_path("[PROJECT]", "[SINK]")
383
- # config_service_v2_api.delete_sink(formatted_sink_name)
410
+ # config_service_v2_client = ConfigServiceV2Client.new
411
+ # formatted_sink_name = ConfigServiceV2Client.sink_path("[PROJECT]", "[SINK]")
412
+ # config_service_v2_client.delete_sink(formatted_sink_name)
384
413
 
385
414
  def delete_sink \
386
415
  sink_name,
@@ -389,6 +418,7 @@ module Google
389
418
  sink_name: sink_name
390
419
  }.delete_if { |_, v| v.nil? })
391
420
  @delete_sink.call(req, options)
421
+ nil
392
422
  end
393
423
  end
394
424
  end
@@ -0,0 +1,41 @@
1
+ # Copyright 2016 Google Inc. All rights reserved.
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
+ # http://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
+ module Google
16
+ module Api
17
+ # A description of a label.
18
+ # @!attribute [rw] key
19
+ # @return [String]
20
+ # The label key.
21
+ # @!attribute [rw] value_type
22
+ # @return [Google::Api::LabelDescriptor::ValueType]
23
+ # The type of data that can be assigned to the label.
24
+ # @!attribute [rw] description
25
+ # @return [String]
26
+ # A human-readable description for the label.
27
+ class LabelDescriptor
28
+ # Value types that can be used as label values.
29
+ module ValueType
30
+ # A variable-length string. This is the default.
31
+ STRING = 0
32
+
33
+ # Boolean; true or false.
34
+ BOOL = 1
35
+
36
+ # A 64-bit signed integer.
37
+ INT64 = 2
38
+ end
39
+ end
40
+ end
41
+ end
@@ -18,17 +18,22 @@ module Google
18
18
  # An individual entry in a log.
19
19
  # @!attribute [rw] log_name
20
20
  # @return [String]
21
- # Required. The resource name of the log to which this log entry
22
- # belongs. The format of the name is
23
- # +"projects/<project-id>/logs/<log-id>"+. Examples:
24
- # +"projects/my-projectid/logs/syslog"+,
25
- # +"projects/my-projectid/logs/library.googleapis.com%2Fbook_log"+.
21
+ # Required. The resource name of the log to which this log entry belongs:
26
22
  #
27
- # The log ID part of resource name must be less than 512 characters
28
- # long and can only include the following characters: upper and
29
- # lower case alphanumeric characters: [A-Za-z0-9]; and punctuation
30
- # characters: forward-slash, underscore, hyphen, and period.
31
- # Forward-slash (+/+) characters in the log ID must be URL-encoded.
23
+ # "projects/[PROJECT_ID]/logs/[LOG_ID]"
24
+ # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
25
+ #
26
+ # +[LOG_ID]+ must be URL-encoded within +log_name+. Example:
27
+ # +"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"+.
28
+ # +[LOG_ID]+ must be less than 512 characters long and can only include the
29
+ # following characters: upper and lower case alphanumeric characters,
30
+ # forward-slash, underscore, hyphen, and period.
31
+ #
32
+ # For backward compatibility, if +log_name+ begins with a forward-slash, such
33
+ # as +/projects/...+, then the log entry is ingested as usual but the
34
+ # forward-slash is removed. Listing the log entry will not show the leading
35
+ # slash and filtering for a log name with a leading slash will never return
36
+ # any results.
32
37
  # @!attribute [rw] resource
33
38
  # @return [Google::Api::MonitoredResource]
34
39
  # Required. The monitored resource associated with this log entry.
@@ -45,8 +50,8 @@ module Google
45
50
  # The log entry payload, represented as a Unicode string (UTF-8).
46
51
  # @!attribute [rw] json_payload
47
52
  # @return [Google::Protobuf::Struct]
48
- # The log entry payload, represented as a structure that
49
- # is expressed as a JSON object.
53
+ # The log entry payload, represented as a structure that is
54
+ # expressed as a JSON object.
50
55
  # @!attribute [rw] timestamp
51
56
  # @return [Google::Protobuf::Timestamp]
52
57
  # Optional. The time the event described by the log entry occurred. If
@@ -18,16 +18,31 @@ module Google
18
18
  # The parameters to DeleteLog.
19
19
  # @!attribute [rw] log_name
20
20
  # @return [String]
21
- # Required. The resource name of the log to delete. Example:
22
- # +"projects/my-project/logs/syslog"+.
21
+ # Required. The resource name of the log to delete:
22
+ #
23
+ # "projects/[PROJECT_ID]/logs/[LOG_ID]"
24
+ # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
25
+ #
26
+ # +[LOG_ID]+ must be URL-encoded. For example,
27
+ # +"projects/my-project-id/logs/syslog"+,
28
+ # +"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"+.
29
+ # For more information about log names, see
30
+ # LogEntry.
23
31
  class DeleteLogRequest; end
24
32
 
25
33
  # The parameters to WriteLogEntries.
26
34
  # @!attribute [rw] log_name
27
35
  # @return [String]
28
36
  # Optional. A default log resource name that is assigned to all log entries
29
- # in +entries+ that do not specify a value for +log_name+. Example:
30
- # +"projects/my-project/logs/syslog"+. See
37
+ # in +entries+ that do not specify a value for +log_name+:
38
+ #
39
+ # "projects/[PROJECT_ID]/logs/[LOG_ID]"
40
+ # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
41
+ #
42
+ # +[LOG_ID]+ must be URL-encoded. For example,
43
+ # +"projects/my-project-id/logs/syslog"+ or
44
+ # +"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"+.
45
+ # For more information about log names, see
31
46
  # LogEntry.
32
47
  # @!attribute [rw] resource
33
48
  # @return [Google::Api::MonitoredResource]
@@ -73,20 +88,25 @@ module Google
73
88
  # @!attribute [rw] project_ids
74
89
  # @return [Array<String>]
75
90
  # Deprecated. One or more project identifiers or project numbers from which
76
- # to retrieve log entries. Examples: +"my-project-1A"+, +"1234567890"+. If
91
+ # to retrieve log entries. Example: +"my-project-1A"+. If
77
92
  # present, these project identifiers are converted to resource format and
78
93
  # added to the list of resources in +resourceNames+. Callers should use
79
94
  # +resourceNames+ rather than this parameter.
80
95
  # @!attribute [rw] resource_names
81
96
  # @return [Array<String>]
82
- # Optional. One or more cloud resources from which to retrieve log entries.
83
- # Example: +"projects/my-project-1A"+, +"projects/1234567890"+. Projects
84
- # listed in +projectIds+ are added to this list.
97
+ # Required. One or more cloud resources from which to retrieve log
98
+ # entries:
99
+ #
100
+ # "projects/[PROJECT_ID]"
101
+ # "organizations/[ORGANIZATION_ID]"
102
+ #
103
+ # Projects listed in the +project_ids+ field are added to this list.
85
104
  # @!attribute [rw] filter
86
105
  # @return [String]
87
106
  # Optional. A filter that chooses which log entries to return. See {Advanced
88
107
  # Logs Filters}[https://cloud.google.com/logging/docs/view/advanced_filters]. Only log entries that
89
108
  # match the filter are returned. An empty filter matches all log entries.
109
+ # The maximum length of the filter is 20000 characters.
90
110
  # @!attribute [rw] order_by
91
111
  # @return [String]
92
112
  # Optional. How the results should be sorted. Presently, the only permitted