google-cloud-logging 1.10.5 → 2.0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/TROUBLESHOOTING.md +2 -8
  5. data/lib/google-cloud-logging.rb +14 -15
  6. data/lib/google/cloud/logging.rb +12 -13
  7. data/lib/google/cloud/logging/credentials.rb +2 -2
  8. data/lib/google/cloud/logging/entry.rb +5 -5
  9. data/lib/google/cloud/logging/entry/http_request.rb +3 -3
  10. data/lib/google/cloud/logging/entry/list.rb +1 -1
  11. data/lib/google/cloud/logging/entry/operation.rb +3 -3
  12. data/lib/google/cloud/logging/entry/source_location.rb +3 -3
  13. data/lib/google/cloud/logging/log/list.rb +1 -1
  14. data/lib/google/cloud/logging/metric.rb +2 -2
  15. data/lib/google/cloud/logging/metric/list.rb +1 -1
  16. data/lib/google/cloud/logging/resource_descriptor/list.rb +1 -1
  17. data/lib/google/cloud/logging/service.rb +70 -173
  18. data/lib/google/cloud/logging/sink.rb +2 -2
  19. data/lib/google/cloud/logging/sink/list.rb +1 -1
  20. data/lib/google/cloud/logging/version.rb +1 -1
  21. metadata +11 -81
  22. data/lib/google/cloud/logging/v2.rb +0 -18
  23. data/lib/google/cloud/logging/v2/config_service_v2_client.rb +0 -1368
  24. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +0 -101
  25. data/lib/google/cloud/logging/v2/credentials.rb +0 -39
  26. data/lib/google/cloud/logging/v2/doc/google/api/distribution.rb +0 -164
  27. data/lib/google/cloud/logging/v2/doc/google/api/label.rb +0 -42
  28. data/lib/google/cloud/logging/v2/doc/google/api/metric.rb +0 -233
  29. data/lib/google/cloud/logging/v2/doc/google/api/monitored_resource.rb +0 -85
  30. data/lib/google/cloud/logging/v2/doc/google/logging/type/http_request.rb +0 -86
  31. data/lib/google/cloud/logging/v2/doc/google/logging/v2/log_entry.rb +0 -179
  32. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging.rb +0 -238
  33. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_config.rb +0 -660
  34. data/lib/google/cloud/logging/v2/doc/google/logging/v2/logging_metrics.rb +0 -220
  35. data/lib/google/cloud/logging/v2/doc/google/protobuf/any.rb +0 -131
  36. data/lib/google/cloud/logging/v2/doc/google/protobuf/duration.rb +0 -91
  37. data/lib/google/cloud/logging/v2/doc/google/protobuf/empty.rb +0 -29
  38. data/lib/google/cloud/logging/v2/doc/google/protobuf/field_mask.rb +0 -222
  39. data/lib/google/cloud/logging/v2/doc/google/protobuf/struct.rb +0 -74
  40. data/lib/google/cloud/logging/v2/doc/google/protobuf/timestamp.rb +0 -113
  41. data/lib/google/cloud/logging/v2/logging_service_v2_client.rb +0 -680
  42. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +0 -56
  43. data/lib/google/cloud/logging/v2/metrics_service_v2_client.rb +0 -475
  44. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +0 -51
  45. data/lib/google/logging/v2/log_entry_pb.rb +0 -59
  46. data/lib/google/logging/v2/logging_config_pb.rb +0 -173
  47. data/lib/google/logging/v2/logging_config_services_pb.rb +0 -112
  48. data/lib/google/logging/v2/logging_metrics_pb.rb +0 -72
  49. data/lib/google/logging/v2/logging_metrics_services_pb.rb +0 -52
  50. data/lib/google/logging/v2/logging_pb.rb +0 -80
  51. data/lib/google/logging/v2/logging_services_pb.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd1f41e64309828c0a4ade40f6f37f34f5c880d5bc076cef18c3d864aba75e1d
4
- data.tar.gz: 58f97d26011dbd5438f3644291096c37cf39fef9ab0394498148153d1a45ac50
3
+ metadata.gz: 7260d28a439e63fe96c5fa11487110226714c1f6faf62ed29ffeb48aba5c1914
4
+ data.tar.gz: c6eeefa5d3000417ca70eecbcc3a947268776947ad4922e08cb572579ae46257
5
5
  SHA512:
6
- metadata.gz: f702d5baed7f22f965e294e4e81ec582aa04b0df72ffb9231d02a41791656acc486e8b0093b9c60c3f5119ceb195cf74208a5fdfa13373758f2d7a20e9326057
7
- data.tar.gz: cf3d386de873038b9db370e66b85078dc4ed15961e5ba4410f7ac5dc192131db84ced61a9312d215b2e4039587433507c0758b8f913d5101d6ad1ec781d3baaa
6
+ metadata.gz: fc5593e6afcb5076293746ed65d754ba32b65df69e6749198eef48e9c23e0277e558fb2abb6064917ee947376d6506349916c9ea003f1bc59bcb89e0e3a71a9e
7
+ data.tar.gz: c4cf55027963d1ab020e3cae9049087dbf602860c5eb81c623059d5d6f3c4d0495cd30abda2b621ac385ba77c0c68ace6a9bb5851b90ac57fe57f28ce510a631
@@ -76,7 +76,8 @@ The environment variables that google-cloud-logging checks for project ID are:
76
76
  1. `LOGGING_PROJECT`
77
77
  2. `GOOGLE_CLOUD_PROJECT`
78
78
 
79
- The environment variables that google-cloud-logging checks for credentials are configured on {Google::Cloud::Logging::V2::Credentials}:
79
+ The environment variables that google-cloud-logging checks for credentials are
80
+ configured on `Google::Cloud::Logging::V2::LoggingService::Credentials`:
80
81
 
81
82
  1. `LOGGING_CREDENTIALS` - Path to JSON file, or JSON contents
82
83
  2. `LOGGING_KEYFILE` - Path to JSON file, or JSON contents
@@ -1,5 +1,52 @@
1
1
  # Release History
2
2
 
3
+ ### 2.0.0 / 2020-07-21
4
+
5
+ This is a major update that removes the "low-level" client interface code, and
6
+ instead adds the new `google-cloud-logging-v2` gem as a dependency.
7
+ The new dependency is a rewritten low-level client, produced by a next-
8
+ generation client code generator, with improved performance and stability.
9
+
10
+ This change should have no effect on the high-level interface that most users
11
+ will use. The one exception is that the (mostly undocumented) `client_config`
12
+ argument, for adjusting low-level parameters such as RPC retry settings on
13
+ client objects, has been removed. If you need to adjust these parameters, use
14
+ the configuration interface in `google-cloud-logging-v2`.
15
+
16
+ Substantial changes have been made in the low-level interfaces, however. If you
17
+ are using the low-level classes under the `Google::Cloud::Logging::V2` module,
18
+ please review the docs for the new `google-cloud-logging-v2` gem. In
19
+ particular:
20
+
21
+ * Some classes have been renamed, notably the client class itself.
22
+ * The client constructor takes a configuration block instead of configuration
23
+ keyword arguments.
24
+ * All RPC method arguments are now keyword arguments.
25
+
26
+ ### 1.10.9 / 2020-06-17
27
+
28
+ #### Documentation
29
+
30
+ * Improved field descriptions in the low-level interface.
31
+
32
+ ### 1.10.8 / 2020-06-12
33
+
34
+ #### Documentation
35
+
36
+ * Provide more details on low-level monitored resource data types
37
+
38
+ ### 1.10.7 / 2020-05-28
39
+
40
+ #### Documentation
41
+
42
+ * Fix a few broken links
43
+
44
+ ### 1.10.6 / 2020-05-19
45
+
46
+ #### Bug Fixes
47
+
48
+ * Adjusted some default timeout and retry settings
49
+
3
50
  ### 1.10.5 / 2020-05-05
4
51
 
5
52
  #### Bug Fixes
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
24
24
 
25
25
  - [New issue][gh-ruby]
26
26
 
27
- Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
- can use the "ruby" channel for general Ruby questions, or use the
29
- "google-cloud-ruby" channel if you have questions about this gem in particular.
30
-
31
27
  [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+logging
32
28
 
33
- [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+logging%22
34
-
35
- [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
29
+ [gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+logging%22
36
30
 
37
- [slack-ruby]: https://gcp-slack.appspot.com/
31
+ [gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
@@ -43,8 +43,6 @@ module Google
43
43
  # * `https://www.googleapis.com/auth/logging.admin`
44
44
  #
45
45
  # @param [Integer] timeout Default timeout to use in requests. Optional.
46
- # @param [Hash] client_config A hash of values to override the default
47
- # behavior of the API client. Optional.
48
46
  #
49
47
  # @return [Google::Cloud::Logging::Project]
50
48
  #
@@ -66,11 +64,10 @@ module Google
66
64
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
67
65
  # logging = gcloud.logging scope: platform_scope
68
66
  #
69
- def logging scope: nil, timeout: nil, client_config: nil
67
+ def logging scope: nil, timeout: nil
70
68
  timeout ||= @timeout
71
- Google::Cloud.logging @project, @keyfile, scope: scope,
72
- timeout: timeout,
73
- client_config: client_config
69
+ Google::Cloud.logging @project, @keyfile, scope: scope,
70
+ timeout: timeout
74
71
  end
75
72
 
76
73
  ##
@@ -96,8 +93,6 @@ module Google
96
93
  # * `https://www.googleapis.com/auth/logging.admin`
97
94
  #
98
95
  # @param [Integer] timeout Default timeout to use in requests. Optional.
99
- # @param [Hash] client_config A hash of values to override the default
100
- # behavior of the API client. Optional.
101
96
  #
102
97
  # @return [Google::Cloud::Logging::Project]
103
98
  #
@@ -111,13 +106,11 @@ module Google
111
106
  # puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
112
107
  # end
113
108
  #
114
- def self.logging project_id = nil, credentials = nil, scope: nil,
115
- timeout: nil, client_config: nil
109
+ def self.logging project_id = nil, credentials = nil, scope: nil, timeout: nil
116
110
  require "google/cloud/logging"
117
111
  Google::Cloud::Logging.new project_id: project_id,
118
112
  credentials: credentials,
119
- scope: scope, timeout: timeout,
120
- client_config: client_config
113
+ scope: scope, timeout: timeout
121
114
  end
122
115
  end
123
116
  end
@@ -139,6 +132,13 @@ Google::Cloud.configure.add_config! :logging do |config|
139
132
  "LOGGING_CREDENTIALS", "LOGGING_CREDENTIALS_JSON",
140
133
  "LOGGING_KEYFILE", "LOGGING_KEYFILE_JSON"
141
134
  end
135
+ default_scopes = [
136
+ "https://www.googleapis.com/auth/cloud-platform",
137
+ "https://www.googleapis.com/auth/cloud-platform.read-only",
138
+ "https://www.googleapis.com/auth/logging.admin",
139
+ "https://www.googleapis.com/auth/logging.read",
140
+ "https://www.googleapis.com/auth/logging.write"
141
+ ]
142
142
 
143
143
  config.add_field! :project_id, default_project, match: String, allow_nil: true
144
144
  config.add_alias! :project, :project_id
@@ -146,10 +146,9 @@ Google::Cloud.configure.add_config! :logging do |config|
146
146
  match: [String, Hash, Google::Auth::Credentials],
147
147
  allow_nil: true
148
148
  config.add_alias! :keyfile, :credentials
149
- config.add_field! :scope, nil, match: [String, Array]
149
+ config.add_field! :scope, default_scopes, match: [String, Array]
150
150
  config.add_field! :timeout, nil, match: Integer
151
- config.add_field! :client_config, nil, match: Hash
152
- config.add_field! :endpoint, nil, match: String
151
+ config.add_field! :endpoint, "logging.googleapis.com", match: String
153
152
  config.add_field! :log_name, nil, match: String
154
153
  config.add_field! :log_name_map, nil, match: Hash
155
154
  config.add_field! :labels, nil, match: Hash
@@ -63,8 +63,6 @@ module Google
63
63
  # * `https://www.googleapis.com/auth/logging.admin`
64
64
  #
65
65
  # @param [Integer] timeout Default timeout to use in requests. Optional.
66
- # @param [Hash] client_config A hash of values to override the default
67
- # behavior of the API client. Optional.
68
66
  # @param [String] endpoint Override of the endpoint host name. Optional.
69
67
  # If the param is nil, uses the default endpoint.
70
68
  # @param [String] project Alias for the `project_id` argument. Deprecated.
@@ -83,12 +81,16 @@ module Google
83
81
  # puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
84
82
  # end
85
83
  #
86
- def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
87
- client_config: nil, endpoint: nil, project: nil, keyfile: nil
84
+ def self.new project_id: nil,
85
+ credentials: nil,
86
+ scope: nil,
87
+ timeout: nil,
88
+ endpoint: nil,
89
+ project: nil,
90
+ keyfile: nil
88
91
  project_id ||= (project || default_project_id)
89
92
  scope ||= configure.scope
90
93
  timeout ||= configure.timeout
91
- client_config ||= configure.client_config
92
94
  endpoint ||= configure.endpoint
93
95
  credentials ||= (keyfile || default_credentials(scope: scope))
94
96
 
@@ -102,12 +104,8 @@ module Google
102
104
  project_id = project_id.to_s # Always cast to a string
103
105
  raise ArgumentError, "project_id is missing" if project_id.empty?
104
106
 
105
- Logging::Project.new(
106
- Logging::Service.new(
107
- project_id, credentials,
108
- host: endpoint, timeout: timeout, client_config: client_config
109
- )
110
- )
107
+ service = Logging::Service.new project_id, credentials, host: endpoint, timeout: timeout
108
+ Logging::Project.new service
111
109
  end
112
110
 
113
111
  ##
@@ -127,8 +125,6 @@ module Google
127
125
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
128
126
  # the set of resources and operations that the connection can access.
129
127
  # * `timeout` - (Integer) Default timeout to use in requests.
130
- # * `client_config` - (Hash) A hash of values to override the default
131
- # behavior of the API client.
132
128
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
133
129
  # to use the default endpoint.
134
130
  # * `log_name` - (String) Name of the application log file. Default:
@@ -186,4 +182,7 @@ module Google
186
182
  end
187
183
  end
188
184
  end
185
+
186
+ # @private
187
+ Logging = Cloud::Logging unless const_defined? :Logging
189
188
  end
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/logging/v2/credentials"
16
+ require "google/cloud/logging/v2/logging_service/credentials"
17
17
 
18
18
  module Google
19
19
  module Cloud
@@ -37,7 +37,7 @@ module Google
37
37
  #
38
38
  # logging.project_id #=> "my-project"
39
39
  #
40
- class Credentials < Google::Cloud::Logging::V2::Credentials
40
+ class Credentials < Google::Cloud::Logging::V2::LoggingService::Credentials
41
41
  end
42
42
  end
43
43
  end
@@ -422,9 +422,9 @@ module Google
422
422
  end
423
423
 
424
424
  ##
425
- # @private Exports the Entry to a Google::Logging::V2::LogEntry object.
425
+ # @private Exports the Entry to a Google::Cloud::Logging::V2::LogEntry object.
426
426
  def to_grpc
427
- grpc = Google::Logging::V2::LogEntry.new(
427
+ grpc = Google::Cloud::Logging::V2::LogEntry.new(
428
428
  log_name: log_name.to_s,
429
429
  timestamp: timestamp_grpc,
430
430
  # TODO: verify severity is the correct type?
@@ -444,7 +444,7 @@ module Google
444
444
  end
445
445
 
446
446
  ##
447
- # @private New Entry from a Google::Logging::V2::LogEntry object.
447
+ # @private New Entry from a Google::Cloud::Logging::V2::LogEntry object.
448
448
  def self.from_grpc grpc
449
449
  return new if grpc.nil?
450
450
  new.tap do |e|
@@ -483,7 +483,7 @@ module Google
483
483
 
484
484
  ##
485
485
  # @private Formats the labels so they can be saved to a
486
- # Google::Logging::V2::LogEntry object.
486
+ # Google::Cloud::Logging::V2::LogEntry object.
487
487
  def labels_grpc
488
488
  return {} if labels.nil?
489
489
  # Coerce symbols to strings
@@ -494,7 +494,7 @@ module Google
494
494
  end
495
495
 
496
496
  ##
497
- # @private Adds the payload data to a Google::Logging::V2::LogEntry
497
+ # @private Adds the payload data to a Google::Cloud::Logging::V2::LogEntry
498
498
  # object.
499
499
  def append_payload grpc
500
500
  grpc.proto_payload = nil
@@ -125,10 +125,10 @@ module Google
125
125
 
126
126
  ##
127
127
  # @private Exports the HttpRequest to a
128
- # Google::Logging::Type::HttpRequest object.
128
+ # Google::Cloud::Logging::Type::HttpRequest object.
129
129
  def to_grpc
130
130
  return nil if empty?
131
- Google::Logging::Type::HttpRequest.new(
131
+ Google::Cloud::Logging::Type::HttpRequest.new(
132
132
  request_method: request_method.to_s,
133
133
  request_url: url.to_s,
134
134
  request_size: size.to_i,
@@ -143,7 +143,7 @@ module Google
143
143
  end
144
144
 
145
145
  ##
146
- # @private New HttpRequest from a Google::Logging::Type::HttpRequest
146
+ # @private New HttpRequest from a Google::Cloud::Logging::Type::HttpRequest
147
147
  # object.
148
148
  def self.from_grpc grpc
149
149
  return new if grpc.nil?
@@ -145,7 +145,7 @@ module Google
145
145
 
146
146
  ##
147
147
  # @private New Entry::List from a
148
- # Google::Logging::V2::ListLogEntryResponse object.
148
+ # Google::Cloud::Logging::V2::ListLogEntryResponse object.
149
149
  def self.from_grpc grpc_list, service, resources: nil, filter: nil,
150
150
  order: nil, max: nil, projects: nil
151
151
  entries = new(Array(grpc_list.entries).map do |grpc_entry|
@@ -61,10 +61,10 @@ module Google
61
61
 
62
62
  ##
63
63
  # @private Exports the Operation to a
64
- # Google::Logging::V2::LogEntryOperation object.
64
+ # Google::Cloud::Logging::V2::LogEntryOperation object.
65
65
  def to_grpc
66
66
  return nil if empty?
67
- Google::Logging::V2::LogEntryOperation.new(
67
+ Google::Cloud::Logging::V2::LogEntryOperation.new(
68
68
  id: id.to_s,
69
69
  producer: producer.to_s,
70
70
  first: !(!first),
@@ -74,7 +74,7 @@ module Google
74
74
 
75
75
  ##
76
76
  # @private New Google::Cloud::Logging::Entry::Operation from a
77
- # Google::Logging::V2::LogEntryOperation object.
77
+ # Google::Cloud::Logging::V2::LogEntryOperation object.
78
78
  def self.from_grpc grpc
79
79
  return new if grpc.nil?
80
80
  new.tap do |o|
@@ -57,10 +57,10 @@ module Google
57
57
 
58
58
  ##
59
59
  # @private Exports the SourceLocation to a
60
- # Google::Logging::V2::LogEntrySourceLocation object.
60
+ # Google::Cloud::Logging::V2::LogEntrySourceLocation object.
61
61
  def to_grpc
62
62
  return nil if empty?
63
- Google::Logging::V2::LogEntrySourceLocation.new(
63
+ Google::Cloud::Logging::V2::LogEntrySourceLocation.new(
64
64
  file: file.to_s,
65
65
  line: line,
66
66
  function: function.to_s
@@ -69,7 +69,7 @@ module Google
69
69
 
70
70
  ##
71
71
  # @private New Google::Cloud::Logging::Entry::SourceLocation from a
72
- # Google::Logging::V2::LogEntrySourceLocation object.
72
+ # Google::Cloud::Logging::V2::LogEntrySourceLocation object.
73
73
  def self.from_grpc grpc
74
74
  return new if grpc.nil?
75
75
  new.tap do |o|
@@ -129,7 +129,7 @@ module Google
129
129
 
130
130
  ##
131
131
  # @private New Log::List from a
132
- # Google::Logging::V2::ListLogsResponse object.
132
+ # Google::Cloud::Logging::V2::ListLogsResponse object.
133
133
  def self.from_grpc grpc_list, service, resource: nil, max: nil
134
134
  logs = new Array(grpc_list.log_names)
135
135
  token = grpc_list.next_page_token
@@ -43,14 +43,14 @@ module Google
43
43
  attr_accessor :service
44
44
 
45
45
  ##
46
- # @private The gRPC Google::Logging::V2::LogMetric object.
46
+ # @private The gRPC Google::Cloud::Logging::V2::LogMetric object.
47
47
  attr_accessor :grpc
48
48
 
49
49
  ##
50
50
  # @private Create an empty Metric object.
51
51
  def initialize
52
52
  @service = nil
53
- @grpc = Google::Logging::V2::LogMetric.new
53
+ @grpc = Google::Cloud::Logging::V2::LogMetric.new
54
54
  end
55
55
 
56
56
  ##
@@ -142,7 +142,7 @@ module Google
142
142
 
143
143
  ##
144
144
  # @private New Metric::List from a
145
- # Google::Logging::V2::ListLogMetricsResponse object.
145
+ # Google::Cloud::Logging::V2::ListLogMetricsResponse object.
146
146
  def self.from_grpc grpc_list, service, max = nil
147
147
  metrics = new(Array(grpc_list.metrics).map do |grpc_metric|
148
148
  Metric.from_grpc grpc_metric, service
@@ -147,7 +147,7 @@ module Google
147
147
 
148
148
  ##
149
149
  # @private New ResourceDescriptor::List from a
150
- # Google::Logging::V2::ListMonitoredResourceDescriptorsResponse
150
+ # Google::Cloud::Logging::V2::ListMonitoredResourceDescriptorsResponse
151
151
  # object.
152
152
  def self.from_grpc grpc_list, service, max = nil
153
153
  rds = new(Array(grpc_list.resource_descriptors).map do |grpc|
@@ -16,7 +16,6 @@
16
16
  require "google/cloud/errors"
17
17
  require "google/cloud/logging/version"
18
18
  require "google/cloud/logging/v2"
19
- require "google/gax/errors"
20
19
  require "uri"
21
20
 
22
21
  module Google
@@ -26,61 +25,56 @@ module Google
26
25
  # @private Represents the gRPC Logging service, including all the API
27
26
  # methods.
28
27
  class Service
29
- attr_accessor :project, :credentials, :timeout, :client_config, :host
28
+ attr_accessor :project, :credentials, :timeout, :host
30
29
 
31
30
  ##
32
31
  # Creates a new Service instance.
33
- def initialize project, credentials, timeout: nil, client_config: nil,
34
- host: nil
32
+ def initialize project, credentials, timeout: nil, host: nil
35
33
  @project = project
36
34
  @credentials = credentials
37
35
  @timeout = timeout
38
- @client_config = client_config || {}
39
- @host = host || V2::LoggingServiceV2Client::SERVICE_ADDRESS
36
+ @host = host
40
37
  end
41
38
 
42
39
  def logging
43
40
  return mocked_logging if mocked_logging
44
41
  @logging ||= \
45
- V2::LoggingServiceV2Client.new(
46
- credentials: credentials,
47
- timeout: timeout,
48
- client_config: client_config,
49
- service_address: service_address,
50
- service_port: service_port,
51
- lib_name: "gccl",
52
- lib_version: Google::Cloud::Logging::VERSION
53
- )
42
+ V2::LoggingService::Client.new do |config|
43
+ config.credentials = credentials if credentials
44
+ config.timeout = timeout if timeout
45
+ config.endpoint = host if host
46
+ config.lib_name = "gccl"
47
+ config.lib_version = Google::Cloud::Logging::VERSION
48
+ config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
49
+ end
54
50
  end
55
51
  attr_accessor :mocked_logging
56
52
 
57
53
  def sinks
58
54
  return mocked_sinks if mocked_sinks
59
55
  @sinks ||= \
60
- V2::ConfigServiceV2Client.new(
61
- credentials: credentials,
62
- timeout: timeout,
63
- client_config: client_config,
64
- service_address: service_address,
65
- service_port: service_port,
66
- lib_name: "gccl",
67
- lib_version: Google::Cloud::Logging::VERSION
68
- )
56
+ V2::ConfigService::Client.new do |config|
57
+ config.credentials = credentials if credentials
58
+ config.timeout = timeout if timeout
59
+ config.endpoint = host if host
60
+ config.lib_name = "gccl"
61
+ config.lib_version = Google::Cloud::Logging::VERSION
62
+ config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
63
+ end
69
64
  end
70
65
  attr_accessor :mocked_sinks
71
66
 
72
67
  def metrics
73
68
  return mocked_metrics if mocked_metrics
74
69
  @metrics ||= \
75
- V2::MetricsServiceV2Client.new(
76
- credentials: credentials,
77
- timeout: timeout,
78
- client_config: client_config,
79
- service_address: service_address,
80
- service_port: service_port,
81
- lib_name: "gccl",
82
- lib_version: Google::Cloud::Logging::VERSION
83
- )
70
+ V2::MetricsService::Client.new do |config|
71
+ config.credentials = credentials if credentials
72
+ config.timeout = timeout if timeout
73
+ config.endpoint = host if host
74
+ config.lib_name = "gccl"
75
+ config.lib_version = Google::Cloud::Logging::VERSION
76
+ config.metadata = { "google-cloud-resource-prefix" => "projects/#{@project}" }
77
+ end
84
78
  end
85
79
  attr_accessor :mocked_metrics
86
80
 
@@ -90,20 +84,12 @@ module Google
90
84
  project_ids = Array(projects).map { |p| "projects/#{p}" }
91
85
  resource_names = Array(resources) + project_ids
92
86
  resource_names = ["projects/#{@project}"] if resource_names.empty?
93
- call_opts = default_options
94
- if token
95
- call_opts = Google::Gax::CallOptions.new(
96
- kwargs: default_headers,
97
- page_token: token
98
- )
99
- end
100
-
101
- execute do
102
- paged_enum = logging.list_log_entries \
103
- resource_names, filter: filter, order_by: order, page_size: max,
104
- options: call_opts
105
- paged_enum.page.response
106
- end
87
+ paged_enum = logging.list_log_entries resource_names: resource_names,
88
+ filter: filter,
89
+ order_by: order,
90
+ page_size: max,
91
+ page_token: token
92
+ paged_enum.response
107
93
  end
108
94
 
109
95
  def write_entries entries, log_name: nil, resource: nil, labels: nil,
@@ -114,157 +100,93 @@ module Google
114
100
  end
115
101
  resource = resource.to_grpc if resource
116
102
  labels = Hash[labels.map { |k, v| [String(k), String(v)] }] if labels
117
-
118
- execute do
119
- logging.write_log_entries entries,
120
- log_name: log_path(log_name),
121
- resource: resource, labels: labels,
122
- partial_success: partial_success,
123
- options: default_options
124
- end
103
+ logging.write_log_entries entries: entries,
104
+ log_name: log_path(log_name),
105
+ resource: resource,
106
+ labels: labels,
107
+ partial_success: partial_success
125
108
  end
126
109
 
127
110
  def list_logs resource: nil, token: nil, max: nil
128
111
  parent = resource || "projects/#{@project}"
129
- call_opts = default_options
130
- if token
131
- call_opts = Google::Gax::CallOptions.new(
132
- kwargs: default_headers,
133
- page_token: token
134
- )
135
- end
136
-
137
- execute do
138
- paged_enum = logging.list_logs parent, page_size: max,
139
- options: call_opts
140
- paged_enum.page.response
141
- end
112
+ paged_enum = logging.list_logs parent: parent,
113
+ page_size: max,
114
+ page_token: token
115
+ paged_enum.response
142
116
  end
143
117
 
144
118
  def delete_log name
145
- execute do
146
- logging.delete_log log_path(name), options: default_options
147
- end
119
+ logging.delete_log log_name: log_path(name)
148
120
  end
149
121
 
150
122
  def list_resource_descriptors token: nil, max: nil
151
- call_opts = default_options
152
- if token
153
- call_opts = Google::Gax::CallOptions.new(
154
- kwargs: default_headers,
155
- page_token: token
156
- )
157
- end
158
-
159
- execute do
160
- logging.list_monitored_resource_descriptors \
161
- page_size: max, options: call_opts
162
- end
123
+ logging.list_monitored_resource_descriptors page_size: max, page_token: token
163
124
  end
164
125
 
165
126
  def list_sinks token: nil, max: nil
166
- call_opts = default_options
167
- if token
168
- call_opts = Google::Gax::CallOptions.new(
169
- kwargs: default_headers,
170
- page_token: token
171
- )
172
- end
173
-
174
- execute do
175
- paged_enum = sinks.list_sinks \
176
- project_path, page_size: max, options: call_opts
177
- paged_enum.page.response
178
- end
127
+ paged_enum = sinks.list_sinks parent: project_path, page_size: max, page_token: token
128
+ paged_enum.response
179
129
  end
180
130
 
181
131
  def create_sink name, destination, filter, unique_writer_identity: nil
182
- sink = Google::Logging::V2::LogSink.new({
183
- name: name, destination: destination, filter: filter
184
- }.delete_if { |_, v| v.nil? })
185
-
186
- execute do
187
- sinks.create_sink project_path, sink,
188
- unique_writer_identity: unique_writer_identity,
189
- options: default_options
190
- end
132
+ sink = Google::Cloud::Logging::V2::LogSink.new(
133
+ {
134
+ name: name, destination: destination, filter: filter
135
+ }.delete_if { |_, v| v.nil? }
136
+ )
137
+ sinks.create_sink parent: project_path,
138
+ sink: sink,
139
+ unique_writer_identity: unique_writer_identity
191
140
  end
192
141
 
193
142
  def get_sink name
194
- execute { sinks.get_sink sink_path(name), options: default_options }
143
+ sinks.get_sink sink_name: sink_path(name)
195
144
  end
196
145
 
197
146
  def update_sink name, destination, filter, unique_writer_identity: nil
198
- sink = Google::Logging::V2::LogSink.new(
147
+ sink = Google::Cloud::Logging::V2::LogSink.new(
199
148
  {
200
149
  name: name, destination: destination, filter: filter
201
150
  }.delete_if { |_, v| v.nil? }
202
151
  )
203
-
204
- execute do
205
- sinks.update_sink sink_path(name), sink,
206
- unique_writer_identity: unique_writer_identity,
207
- options: default_options
208
- end
152
+ sinks.update_sink sink_name: sink_path(name),
153
+ sink: sink,
154
+ unique_writer_identity: unique_writer_identity
209
155
  end
210
156
 
211
157
  def delete_sink name
212
- execute do
213
- sinks.delete_sink sink_path(name), options: default_options
214
- end
158
+ sinks.delete_sink sink_name: sink_path(name)
215
159
  end
216
160
 
217
161
  def list_metrics token: nil, max: nil
218
- call_opts = default_options
219
- if token
220
- call_opts = Google::Gax::CallOptions.new(
221
- kwargs: default_headers,
222
- page_token: token
223
- )
224
- end
225
-
226
- execute do
227
- paged_enum = metrics.list_log_metrics \
228
- project_path, page_size: max, options: call_opts
229
- paged_enum.page.response
230
- end
162
+ paged_enum = metrics.list_log_metrics parent: project_path,
163
+ page_size: max,
164
+ page_token: token
165
+ paged_enum.response
231
166
  end
232
167
 
233
168
  def create_metric name, filter, description
234
- metric = Google::Logging::V2::LogMetric.new(
169
+ metric = Google::Cloud::Logging::V2::LogMetric.new(
235
170
  { name: name, description: description,
236
171
  filter: filter }.delete_if { |_, v| v.nil? }
237
172
  )
238
-
239
- execute do
240
- metrics.create_log_metric project_path, metric,
241
- options: default_options
242
- end
173
+ metrics.create_log_metric parent: project_path, metric: metric
243
174
  end
244
175
 
245
176
  def get_metric name
246
- execute do
247
- metrics.get_log_metric metric_path(name), options: default_options
248
- end
177
+ metrics.get_log_metric metric_name: metric_path(name)
249
178
  end
250
179
 
251
180
  def update_metric name, description, filter
252
- metric = Google::Logging::V2::LogMetric.new(
181
+ metric = Google::Cloud::Logging::V2::LogMetric.new(
253
182
  { name: name, description: description,
254
183
  filter: filter }.delete_if { |_, v| v.nil? }
255
184
  )
256
-
257
- execute do
258
- metrics.update_log_metric metric_path(name), metric,
259
- options: default_options
260
- end
185
+ metrics.update_log_metric metric_name: metric_path(name), metric: metric
261
186
  end
262
187
 
263
188
  def delete_metric name
264
- execute do
265
- metrics.delete_log_metric metric_path(name),
266
- options: default_options
267
- end
189
+ metrics.delete_log_metric metric_name: metric_path(name)
268
190
  end
269
191
 
270
192
  def log_path log_name
@@ -280,16 +202,6 @@ module Google
280
202
 
281
203
  protected
282
204
 
283
- def service_address
284
- return nil if host.nil?
285
- URI.parse("//#{host}").host
286
- end
287
-
288
- def service_port
289
- return nil if host.nil?
290
- URI.parse("//#{host}").port
291
- end
292
-
293
205
  def project_path
294
206
  "projects/#{@project}"
295
207
  end
@@ -304,14 +216,6 @@ module Google
304
216
  "#{project_path}/metrics/#{metric_name}"
305
217
  end
306
218
 
307
- def default_headers
308
- { "google-cloud-resource-prefix" => "projects/#{@project}" }
309
- end
310
-
311
- def default_options
312
- Google::Gax::CallOptions.new kwargs: default_headers
313
- end
314
-
315
219
  ##
316
220
  # @private Get a Google::Protobuf::Timestamp object from a Time object.
317
221
  def time_to_timestamp time
@@ -329,13 +233,6 @@ module Google
329
233
  # Time.at takes microseconds, so convert nano seconds to microseconds
330
234
  Time.at timestamp.seconds, Rational(timestamp.nanos, 1000)
331
235
  end
332
-
333
- def execute
334
- yield
335
- rescue Google::Gax::GaxError => e
336
- # GaxError wraps BadStatus, but exposes it as #cause
337
- raise Google::Cloud::Error.from_error(e.cause)
338
- end
339
236
  end
340
237
  end
341
238
  end