google-cloud-logging 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/lib/google-cloud-logging.rb +119 -0
  3. data/lib/google/cloud/logging.rb +293 -0
  4. data/lib/google/cloud/logging/credentials.rb +31 -0
  5. data/lib/google/cloud/logging/entry.rb +469 -0
  6. data/lib/google/cloud/logging/entry/http_request.rb +145 -0
  7. data/lib/google/cloud/logging/entry/list.rb +180 -0
  8. data/lib/google/cloud/logging/entry/operation.rb +92 -0
  9. data/lib/google/cloud/logging/logger.rb +309 -0
  10. data/lib/google/cloud/logging/metric.rb +172 -0
  11. data/lib/google/cloud/logging/metric/list.rb +175 -0
  12. data/lib/google/cloud/logging/project.rb +650 -0
  13. data/lib/google/cloud/logging/resource.rb +86 -0
  14. data/lib/google/cloud/logging/resource_descriptor.rb +139 -0
  15. data/lib/google/cloud/logging/resource_descriptor/list.rb +179 -0
  16. data/lib/google/cloud/logging/service.rb +270 -0
  17. data/lib/google/cloud/logging/sink.rb +230 -0
  18. data/lib/google/cloud/logging/sink/list.rb +173 -0
  19. data/lib/google/cloud/logging/v2.rb +17 -0
  20. data/lib/google/cloud/logging/v2/config_service_v2_api.rb +331 -0
  21. data/lib/google/cloud/logging/v2/config_service_v2_client_config.json +53 -0
  22. data/lib/google/cloud/logging/v2/logging_service_v2_api.rb +351 -0
  23. data/lib/google/cloud/logging/v2/logging_service_v2_client_config.json +57 -0
  24. data/lib/google/cloud/logging/v2/metrics_service_v2_api.rb +330 -0
  25. data/lib/google/cloud/logging/v2/metrics_service_v2_client_config.json +53 -0
  26. data/lib/google/cloud/logging/version.rb +22 -0
  27. data/lib/google/logging/v2/log_entry_pb.rb +44 -0
  28. data/lib/google/logging/v2/logging_config_pb.rb +59 -0
  29. data/lib/google/logging/v2/logging_config_services_pb.rb +52 -0
  30. data/lib/google/logging/v2/logging_metrics_pb.rb +51 -0
  31. data/lib/google/logging/v2/logging_metrics_services_pb.rb +51 -0
  32. data/lib/google/logging/v2/logging_pb.rb +59 -0
  33. data/lib/google/logging/v2/logging_services_pb.rb +56 -0
  34. metadata +260 -0
@@ -0,0 +1,330 @@
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
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/logging/v2/logging_metrics.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+ #
22
+ # The only allowed edits are to method and file documentation. A 3-way
23
+ # merge preserves those additions if the generated source changes.
24
+
25
+ require "json"
26
+ require "pathname"
27
+
28
+ require "google/gax"
29
+ require "google/logging/v2/logging_metrics_services_pb"
30
+
31
+ module Google
32
+ module Cloud
33
+ module Logging
34
+ module V2
35
+ # Service for configuring logs-based metrics.
36
+ #
37
+ # @!attribute [r] stub
38
+ # @return [Google::Logging::V2::MetricsServiceV2::Stub]
39
+ class MetricsServiceV2Api
40
+ attr_reader :stub
41
+
42
+ # The default address of the service.
43
+ SERVICE_ADDRESS = "logging.googleapis.com".freeze
44
+
45
+ # The default port of the service.
46
+ DEFAULT_SERVICE_PORT = 443
47
+
48
+ CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
49
+
50
+ DEFAULT_TIMEOUT = 30
51
+
52
+ PAGE_DESCRIPTORS = {
53
+ "list_log_metrics" => Google::Gax::PageDescriptor.new(
54
+ "page_token",
55
+ "next_page_token",
56
+ "metrics")
57
+ }.freeze
58
+
59
+ private_constant :PAGE_DESCRIPTORS
60
+
61
+ # The scopes needed to make gRPC calls to all of the methods defined in
62
+ # this service.
63
+ ALL_SCOPES = [
64
+ "https://www.googleapis.com/auth/cloud-platform",
65
+ "https://www.googleapis.com/auth/cloud-platform.read-only",
66
+ "https://www.googleapis.com/auth/logging.admin",
67
+ "https://www.googleapis.com/auth/logging.read",
68
+ "https://www.googleapis.com/auth/logging.write"
69
+ ].freeze
70
+
71
+ PARENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
72
+ "projects/{project}"
73
+ )
74
+
75
+ private_constant :PARENT_PATH_TEMPLATE
76
+
77
+ METRIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
78
+ "projects/{project}/metrics/{metric}"
79
+ )
80
+
81
+ private_constant :METRIC_PATH_TEMPLATE
82
+
83
+ # Returns a fully-qualified parent resource name string.
84
+ # @param project [String]
85
+ # @return [String]
86
+ def self.parent_path project
87
+ PARENT_PATH_TEMPLATE.render(
88
+ :"project" => project
89
+ )
90
+ end
91
+
92
+ # Returns a fully-qualified metric resource name string.
93
+ # @param project [String]
94
+ # @param metric [String]
95
+ # @return [String]
96
+ def self.metric_path project, metric
97
+ METRIC_PATH_TEMPLATE.render(
98
+ :"project" => project,
99
+ :"metric" => metric
100
+ )
101
+ end
102
+
103
+ # Parses the project from a parent resource.
104
+ # @param parent_name [String]
105
+ # @return [String]
106
+ def self.match_project_from_parent_name parent_name
107
+ PARENT_PATH_TEMPLATE.match(parent_name)["project"]
108
+ end
109
+
110
+ # Parses the project from a metric resource.
111
+ # @param metric_name [String]
112
+ # @return [String]
113
+ def self.match_project_from_metric_name metric_name
114
+ METRIC_PATH_TEMPLATE.match(metric_name)["project"]
115
+ end
116
+
117
+ # Parses the metric from a metric resource.
118
+ # @param metric_name [String]
119
+ # @return [String]
120
+ def self.match_metric_from_metric_name metric_name
121
+ METRIC_PATH_TEMPLATE.match(metric_name)["metric"]
122
+ end
123
+
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]
133
+ # A Hash for call options for each method. See
134
+ # Google::Gax#construct_settings for the structure of
135
+ # this data. Falls back to the default config if not specified
136
+ # or the specified config is missing data points.
137
+ # @param timeout [Numeric]
138
+ # The default timeout, in seconds, for calls made through this client.
139
+ # @param app_name [String]
140
+ # The codename of the calling service.
141
+ # @param app_version [String]
142
+ # The version of the calling service.
143
+ def initialize \
144
+ service_path: SERVICE_ADDRESS,
145
+ port: DEFAULT_SERVICE_PORT,
146
+ channel: nil,
147
+ chan_creds: nil,
148
+ scopes: ALL_SCOPES,
149
+ client_config: {},
150
+ timeout: DEFAULT_TIMEOUT,
151
+ app_name: "gax",
152
+ app_version: Google::Gax::VERSION
153
+ google_api_client = "#{app_name}/#{app_version} " \
154
+ "#{CODE_GEN_NAME_VERSION} ruby/#{RUBY_VERSION}".freeze
155
+ headers = { :"x-goog-api-client" => google_api_client }
156
+ client_config_file = Pathname.new(__dir__).join(
157
+ "metrics_service_v2_client_config.json"
158
+ )
159
+ defaults = client_config_file.open do |f|
160
+ Google::Gax.construct_settings(
161
+ "google.logging.v2.MetricsServiceV2",
162
+ JSON.parse(f.read),
163
+ client_config,
164
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
165
+ timeout,
166
+ page_descriptors: PAGE_DESCRIPTORS,
167
+ errors: Google::Gax::Grpc::API_ERRORS,
168
+ kwargs: headers
169
+ )
170
+ end
171
+ @stub = Google::Gax::Grpc.create_stub(
172
+ service_path,
173
+ port,
174
+ chan_creds: chan_creds,
175
+ channel: channel,
176
+ scopes: scopes,
177
+ &Google::Logging::V2::MetricsServiceV2::Stub.method(:new)
178
+ )
179
+
180
+ @list_log_metrics = Google::Gax.create_api_call(
181
+ @stub.method(:list_log_metrics),
182
+ defaults["list_log_metrics"]
183
+ )
184
+ @get_log_metric = Google::Gax.create_api_call(
185
+ @stub.method(:get_log_metric),
186
+ defaults["get_log_metric"]
187
+ )
188
+ @create_log_metric = Google::Gax.create_api_call(
189
+ @stub.method(:create_log_metric),
190
+ defaults["create_log_metric"]
191
+ )
192
+ @update_log_metric = Google::Gax.create_api_call(
193
+ @stub.method(:update_log_metric),
194
+ defaults["update_log_metric"]
195
+ )
196
+ @delete_log_metric = Google::Gax.create_api_call(
197
+ @stub.method(:delete_log_metric),
198
+ defaults["delete_log_metric"]
199
+ )
200
+ end
201
+
202
+ # Service calls
203
+
204
+ # Lists logs-based metrics.
205
+ #
206
+ # @param parent [String]
207
+ # Required. The resource name containing the metrics.
208
+ # Example: +"projects/my-project-id"+.
209
+ # @param page_size [Integer]
210
+ # The maximum number of resources contained in the underlying API
211
+ # response. If page streaming is performed per-resource, this
212
+ # parameter does not affect the return value. If page streaming is
213
+ # performed per-page, this determines the maximum number of
214
+ # resources in a page.
215
+ # @param options [Google::Gax::CallOptions]
216
+ # Overrides the default settings for this call, e.g, timeout,
217
+ # retries, etc.
218
+ # @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogMetric>]
219
+ # An enumerable of Google::Logging::V2::LogMetric instances.
220
+ # See Google::Gax::PagedEnumerable documentation for other
221
+ # operations such as per-page iteration or access to the response
222
+ # object.
223
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
224
+ def list_log_metrics \
225
+ parent,
226
+ page_size: nil,
227
+ options: nil
228
+ req = Google::Logging::V2::ListLogMetricsRequest.new(
229
+ parent: parent
230
+ )
231
+ req.page_size = page_size unless page_size.nil?
232
+ @list_log_metrics.call(req, options)
233
+ end
234
+
235
+ # Gets a logs-based metric.
236
+ #
237
+ # @param metric_name [String]
238
+ # The resource name of the desired metric.
239
+ # Example: +"projects/my-project-id/metrics/my-metric-id"+.
240
+ # @param options [Google::Gax::CallOptions]
241
+ # Overrides the default settings for this call, e.g, timeout,
242
+ # retries, etc.
243
+ # @return [Google::Logging::V2::LogMetric]
244
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
245
+ def get_log_metric \
246
+ metric_name,
247
+ options: nil
248
+ req = Google::Logging::V2::GetLogMetricRequest.new(
249
+ metric_name: metric_name
250
+ )
251
+ @get_log_metric.call(req, options)
252
+ end
253
+
254
+ # Creates a logs-based metric.
255
+ #
256
+ # @param parent [String]
257
+ # The resource name of the project in which to create the metric.
258
+ # Example: +"projects/my-project-id"+.
259
+ #
260
+ # The new metric must be provided in the request.
261
+ # @param metric [Google::Logging::V2::LogMetric]
262
+ # The new logs-based metric, which must not have an identifier that
263
+ # already exists.
264
+ # @param options [Google::Gax::CallOptions]
265
+ # Overrides the default settings for this call, e.g, timeout,
266
+ # retries, etc.
267
+ # @return [Google::Logging::V2::LogMetric]
268
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
269
+ def create_log_metric \
270
+ parent,
271
+ metric,
272
+ options: nil
273
+ req = Google::Logging::V2::CreateLogMetricRequest.new(
274
+ parent: parent,
275
+ metric: metric
276
+ )
277
+ @create_log_metric.call(req, options)
278
+ end
279
+
280
+ # Creates or updates a logs-based metric.
281
+ #
282
+ # @param metric_name [String]
283
+ # The resource name of the metric to update.
284
+ # Example: +"projects/my-project-id/metrics/my-metric-id"+.
285
+ #
286
+ # The updated metric must be provided in the request and have the
287
+ # same identifier that is specified in +metricName+.
288
+ # If the metric does not exist, it is created.
289
+ # @param metric [Google::Logging::V2::LogMetric]
290
+ # The updated metric, whose name must be the same as the
291
+ # metric identifier in +metricName+. If +metricName+ does not
292
+ # exist, then a new metric is created.
293
+ # @param options [Google::Gax::CallOptions]
294
+ # Overrides the default settings for this call, e.g, timeout,
295
+ # retries, etc.
296
+ # @return [Google::Logging::V2::LogMetric]
297
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
298
+ def update_log_metric \
299
+ metric_name,
300
+ metric,
301
+ options: nil
302
+ req = Google::Logging::V2::UpdateLogMetricRequest.new(
303
+ metric_name: metric_name,
304
+ metric: metric
305
+ )
306
+ @update_log_metric.call(req, options)
307
+ end
308
+
309
+ # Deletes a logs-based metric.
310
+ #
311
+ # @param metric_name [String]
312
+ # The resource name of the metric to delete.
313
+ # Example: +"projects/my-project-id/metrics/my-metric-id"+.
314
+ # @param options [Google::Gax::CallOptions]
315
+ # Overrides the default settings for this call, e.g, timeout,
316
+ # retries, etc.
317
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
318
+ def delete_log_metric \
319
+ metric_name,
320
+ options: nil
321
+ req = Google::Logging::V2::DeleteLogMetricRequest.new(
322
+ metric_name: metric_name
323
+ )
324
+ @delete_log_metric.call(req, options)
325
+ end
326
+ end
327
+ end
328
+ end
329
+ end
330
+ end
@@ -0,0 +1,53 @@
1
+ {
2
+ "interfaces": {
3
+ "google.logging.v2.MetricsServiceV2": {
4
+ "retry_codes": {
5
+ "retry_codes_def": {
6
+ "idempotent": [
7
+ "DEADLINE_EXCEEDED",
8
+ "UNAVAILABLE"
9
+ ],
10
+ "non_idempotent": []
11
+ }
12
+ },
13
+ "retry_params": {
14
+ "default": {
15
+ "initial_retry_delay_millis": 100,
16
+ "retry_delay_multiplier": 1.2,
17
+ "max_retry_delay_millis": 1000,
18
+ "initial_rpc_timeout_millis": 2000,
19
+ "rpc_timeout_multiplier": 1.5,
20
+ "max_rpc_timeout_millis": 30000,
21
+ "total_timeout_millis": 45000
22
+ }
23
+ },
24
+ "methods": {
25
+ "ListLogMetrics": {
26
+ "timeout_millis": 30000,
27
+ "retry_codes_name": "idempotent",
28
+ "retry_params_name": "default"
29
+ },
30
+ "GetLogMetric": {
31
+ "timeout_millis": 30000,
32
+ "retry_codes_name": "idempotent",
33
+ "retry_params_name": "default"
34
+ },
35
+ "CreateLogMetric": {
36
+ "timeout_millis": 30000,
37
+ "retry_codes_name": "non_idempotent",
38
+ "retry_params_name": "default"
39
+ },
40
+ "UpdateLogMetric": {
41
+ "timeout_millis": 30000,
42
+ "retry_codes_name": "non_idempotent",
43
+ "retry_params_name": "default"
44
+ },
45
+ "DeleteLogMetric": {
46
+ "timeout_millis": 30000,
47
+ "retry_codes_name": "idempotent",
48
+ "retry_params_name": "default"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,22 @@
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
+
16
+ module Google
17
+ module Cloud
18
+ module Logging
19
+ VERSION = "0.20.0"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/logging/v2/log_entry.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/monitored_resource_pb'
8
+ require 'google/logging/type/http_request_pb'
9
+ require 'google/logging/type/log_severity_pb'
10
+ require 'google/protobuf/any_pb'
11
+ require 'google/protobuf/struct_pb'
12
+ require 'google/protobuf/timestamp_pb'
13
+ Google::Protobuf::DescriptorPool.generated_pool.build do
14
+ add_message "google.logging.v2.LogEntry" do
15
+ optional :log_name, :string, 12
16
+ optional :resource, :message, 8, "google.api.MonitoredResource"
17
+ optional :timestamp, :message, 9, "google.protobuf.Timestamp"
18
+ optional :severity, :enum, 10, "google.logging.type.LogSeverity"
19
+ optional :insert_id, :string, 4
20
+ optional :http_request, :message, 7, "google.logging.type.HttpRequest"
21
+ map :labels, :string, :string, 11
22
+ optional :operation, :message, 15, "google.logging.v2.LogEntryOperation"
23
+ oneof :payload do
24
+ optional :proto_payload, :message, 2, "google.protobuf.Any"
25
+ optional :text_payload, :string, 3
26
+ optional :json_payload, :message, 6, "google.protobuf.Struct"
27
+ end
28
+ end
29
+ add_message "google.logging.v2.LogEntryOperation" do
30
+ optional :id, :string, 1
31
+ optional :producer, :string, 2
32
+ optional :first, :bool, 3
33
+ optional :last, :bool, 4
34
+ end
35
+ end
36
+
37
+ module Google
38
+ module Logging
39
+ module V2
40
+ LogEntry = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.logging.v2.LogEntry").msgclass
41
+ LogEntryOperation = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.logging.v2.LogEntryOperation").msgclass
42
+ end
43
+ end
44
+ end