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,53 @@
1
+ {
2
+ "interfaces": {
3
+ "google.logging.v2.ConfigServiceV2": {
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
+ "ListSinks": {
26
+ "timeout_millis": 30000,
27
+ "retry_codes_name": "idempotent",
28
+ "retry_params_name": "default"
29
+ },
30
+ "GetSink": {
31
+ "timeout_millis": 30000,
32
+ "retry_codes_name": "idempotent",
33
+ "retry_params_name": "default"
34
+ },
35
+ "CreateSink": {
36
+ "timeout_millis": 30000,
37
+ "retry_codes_name": "non_idempotent",
38
+ "retry_params_name": "default"
39
+ },
40
+ "UpdateSink": {
41
+ "timeout_millis": 30000,
42
+ "retry_codes_name": "non_idempotent",
43
+ "retry_params_name": "default"
44
+ },
45
+ "DeleteSink": {
46
+ "timeout_millis": 30000,
47
+ "retry_codes_name": "idempotent",
48
+ "retry_params_name": "default"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,351 @@
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.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_services_pb"
30
+
31
+ module Google
32
+ module Cloud
33
+ module Logging
34
+ module V2
35
+ # Service for ingesting and querying logs.
36
+ #
37
+ # @!attribute [r] stub
38
+ # @return [Google::Logging::V2::LoggingServiceV2::Stub]
39
+ class LoggingServiceV2Api
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_entries" => Google::Gax::PageDescriptor.new(
54
+ "page_token",
55
+ "next_page_token",
56
+ "entries"),
57
+ "list_monitored_resource_descriptors" => Google::Gax::PageDescriptor.new(
58
+ "page_token",
59
+ "next_page_token",
60
+ "resource_descriptors")
61
+ }.freeze
62
+
63
+ private_constant :PAGE_DESCRIPTORS
64
+
65
+ # The scopes needed to make gRPC calls to all of the methods defined in
66
+ # this service.
67
+ ALL_SCOPES = [
68
+ "https://www.googleapis.com/auth/cloud-platform",
69
+ "https://www.googleapis.com/auth/cloud-platform.read-only",
70
+ "https://www.googleapis.com/auth/logging.admin",
71
+ "https://www.googleapis.com/auth/logging.read",
72
+ "https://www.googleapis.com/auth/logging.write"
73
+ ].freeze
74
+
75
+ PARENT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
76
+ "projects/{project}"
77
+ )
78
+
79
+ private_constant :PARENT_PATH_TEMPLATE
80
+
81
+ LOG_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
+ "projects/{project}/logs/{log}"
83
+ )
84
+
85
+ private_constant :LOG_PATH_TEMPLATE
86
+
87
+ # Returns a fully-qualified parent resource name string.
88
+ # @param project [String]
89
+ # @return [String]
90
+ def self.parent_path project
91
+ PARENT_PATH_TEMPLATE.render(
92
+ :"project" => project
93
+ )
94
+ end
95
+
96
+ # Returns a fully-qualified log resource name string.
97
+ # @param project [String]
98
+ # @param log [String]
99
+ # @return [String]
100
+ def self.log_path project, log
101
+ LOG_PATH_TEMPLATE.render(
102
+ :"project" => project,
103
+ :"log" => log
104
+ )
105
+ end
106
+
107
+ # Parses the project from a parent resource.
108
+ # @param parent_name [String]
109
+ # @return [String]
110
+ def self.match_project_from_parent_name parent_name
111
+ PARENT_PATH_TEMPLATE.match(parent_name)["project"]
112
+ end
113
+
114
+ # Parses the project from a log resource.
115
+ # @param log_name [String]
116
+ # @return [String]
117
+ def self.match_project_from_log_name log_name
118
+ LOG_PATH_TEMPLATE.match(log_name)["project"]
119
+ end
120
+
121
+ # Parses the log from a log resource.
122
+ # @param log_name [String]
123
+ # @return [String]
124
+ def self.match_log_from_log_name log_name
125
+ LOG_PATH_TEMPLATE.match(log_name)["log"]
126
+ end
127
+
128
+ # @param service_path [String]
129
+ # The domain name of the API remote host.
130
+ # @param port [Integer]
131
+ # The port on which to connect to the remote host.
132
+ # @param channel [Channel]
133
+ # A Channel object through which to make calls.
134
+ # @param chan_creds [Grpc::ChannelCredentials]
135
+ # A ChannelCredentials for the setting up the RPC client.
136
+ # @param client_config[Hash]
137
+ # A Hash for call options for each method. See
138
+ # Google::Gax#construct_settings for the structure of
139
+ # this data. Falls back to the default config if not specified
140
+ # or the specified config is missing data points.
141
+ # @param timeout [Numeric]
142
+ # The default timeout, in seconds, for calls made through this client.
143
+ # @param app_name [String]
144
+ # The codename of the calling service.
145
+ # @param app_version [String]
146
+ # The version of the calling service.
147
+ def initialize \
148
+ service_path: SERVICE_ADDRESS,
149
+ port: DEFAULT_SERVICE_PORT,
150
+ channel: nil,
151
+ chan_creds: nil,
152
+ scopes: ALL_SCOPES,
153
+ client_config: {},
154
+ timeout: DEFAULT_TIMEOUT,
155
+ app_name: "gax",
156
+ app_version: Google::Gax::VERSION
157
+ google_api_client = "#{app_name}/#{app_version} " \
158
+ "#{CODE_GEN_NAME_VERSION} ruby/#{RUBY_VERSION}".freeze
159
+ headers = { :"x-goog-api-client" => google_api_client }
160
+ client_config_file = Pathname.new(__dir__).join(
161
+ "logging_service_v2_client_config.json"
162
+ )
163
+ defaults = client_config_file.open do |f|
164
+ Google::Gax.construct_settings(
165
+ "google.logging.v2.LoggingServiceV2",
166
+ JSON.parse(f.read),
167
+ client_config,
168
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
169
+ timeout,
170
+ page_descriptors: PAGE_DESCRIPTORS,
171
+ errors: Google::Gax::Grpc::API_ERRORS,
172
+ kwargs: headers
173
+ )
174
+ end
175
+ @stub = Google::Gax::Grpc.create_stub(
176
+ service_path,
177
+ port,
178
+ chan_creds: chan_creds,
179
+ channel: channel,
180
+ scopes: scopes,
181
+ &Google::Logging::V2::LoggingServiceV2::Stub.method(:new)
182
+ )
183
+
184
+ @delete_log = Google::Gax.create_api_call(
185
+ @stub.method(:delete_log),
186
+ defaults["delete_log"]
187
+ )
188
+ @write_log_entries = Google::Gax.create_api_call(
189
+ @stub.method(:write_log_entries),
190
+ defaults["write_log_entries"]
191
+ )
192
+ @list_log_entries = Google::Gax.create_api_call(
193
+ @stub.method(:list_log_entries),
194
+ defaults["list_log_entries"]
195
+ )
196
+ @list_monitored_resource_descriptors = Google::Gax.create_api_call(
197
+ @stub.method(:list_monitored_resource_descriptors),
198
+ defaults["list_monitored_resource_descriptors"]
199
+ )
200
+ end
201
+
202
+ # Service calls
203
+
204
+ # Deletes a log and all its log entries.
205
+ # The log will reappear if it receives new entries.
206
+ #
207
+ # @param log_name [String]
208
+ # Required. The resource name of the log to delete. Example:
209
+ # +"projects/my-project/logs/syslog"+.
210
+ # @param options [Google::Gax::CallOptions]
211
+ # Overrides the default settings for this call, e.g, timeout,
212
+ # retries, etc.
213
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
214
+ def delete_log \
215
+ log_name,
216
+ options: nil
217
+ req = Google::Logging::V2::DeleteLogRequest.new(
218
+ log_name: log_name
219
+ )
220
+ @delete_log.call(req, options)
221
+ end
222
+
223
+ # Writes log entries to Stackdriver Logging. All log entries are
224
+ # written by this method.
225
+ #
226
+ # @param log_name [String]
227
+ # Optional. A default log resource name for those log entries in +entries+
228
+ # that do not specify their own +logName+. Example:
229
+ # +"projects/my-project/logs/syslog"+. See
230
+ # LogEntry.
231
+ # @param resource [Google::Api::MonitoredResource]
232
+ # Optional. A default monitored resource for those log entries in +entries+
233
+ # that do not specify their own +resource+.
234
+ # @param labels [Hash{String => String}]
235
+ # Optional. User-defined +key:value+ items that are added to
236
+ # the +labels+ field of each log entry in +entries+, except when a log
237
+ # entry specifies its own +key:value+ item with the same key.
238
+ # Example: +{ "size": "large", "color":"red" }+
239
+ # @param entries [Array<Google::Logging::V2::LogEntry>]
240
+ # Required. The log entries to write. The log entries must have values for
241
+ # all required fields.
242
+ #
243
+ # To improve throughput and to avoid exceeding the quota limit for calls
244
+ # to +entries.write+, use this field to write multiple log entries at once
245
+ # rather than // calling this method for each log entry.
246
+ # @param partial_success [true, false]
247
+ # Optional. Whether valid entries should be written even if some other
248
+ # entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any
249
+ # entry is not written, the response status will be the error associated
250
+ # with one of the failed entries and include error details in the form of
251
+ # WriteLogEntriesPartialErrors.
252
+ # @param options [Google::Gax::CallOptions]
253
+ # Overrides the default settings for this call, e.g, timeout,
254
+ # retries, etc.
255
+ # @return [Google::Logging::V2::WriteLogEntriesResponse]
256
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
257
+ def write_log_entries \
258
+ entries,
259
+ log_name: nil,
260
+ resource: nil,
261
+ labels: nil,
262
+ partial_success: nil,
263
+ options: nil
264
+ req = Google::Logging::V2::WriteLogEntriesRequest.new(
265
+ entries: entries
266
+ )
267
+ req.log_name = log_name unless log_name.nil?
268
+ req.resource = resource unless resource.nil?
269
+ req.labels = labels unless labels.nil?
270
+ req.partial_success = partial_success unless partial_success.nil?
271
+ @write_log_entries.call(req, options)
272
+ end
273
+
274
+ # Lists log entries. Use this method to retrieve log entries from Cloud
275
+ # Logging. For ways to export log entries, see
276
+ # {Exporting Logs}[https://cloud.google.com/logging/docs/export].
277
+ #
278
+ # @param project_ids [Array<String>]
279
+ # Required. One or more project IDs or project numbers from which to retrieve
280
+ # log entries. Examples of a project ID: +"my-project-1A"+, +"1234567890"+.
281
+ # @param filter [String]
282
+ # Optional. An {advanced logs filter}[https://cloud.google.com/logging/docs/view/advanced_filters].
283
+ # The filter is compared against all log entries in the projects specified by
284
+ # +projectIds+. Only entries that match the filter are retrieved. An empty
285
+ # filter matches all log entries.
286
+ # @param order_by [String]
287
+ # Optional. How the results should be sorted. Presently, the only permitted
288
+ # values are +"timestamp asc"+ (default) and +"timestamp desc"+. The first
289
+ # option returns entries in order of increasing values of
290
+ # +LogEntry.timestamp+ (oldest first), and the second option returns entries
291
+ # in order of decreasing timestamps (newest first). Entries with equal
292
+ # timestamps are returned in order of +LogEntry.insertId+.
293
+ # @param page_size [Integer]
294
+ # The maximum number of resources contained in the underlying API
295
+ # response. If page streaming is performed per-resource, this
296
+ # parameter does not affect the return value. If page streaming is
297
+ # performed per-page, this determines the maximum number of
298
+ # resources in a page.
299
+ # @param options [Google::Gax::CallOptions]
300
+ # Overrides the default settings for this call, e.g, timeout,
301
+ # retries, etc.
302
+ # @return [Google::Gax::PagedEnumerable<Google::Logging::V2::LogEntry>]
303
+ # An enumerable of Google::Logging::V2::LogEntry instances.
304
+ # See Google::Gax::PagedEnumerable documentation for other
305
+ # operations such as per-page iteration or access to the response
306
+ # object.
307
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
308
+ def list_log_entries \
309
+ project_ids,
310
+ filter: nil,
311
+ order_by: nil,
312
+ page_size: nil,
313
+ options: nil
314
+ req = Google::Logging::V2::ListLogEntriesRequest.new(
315
+ project_ids: project_ids
316
+ )
317
+ req.filter = filter unless filter.nil?
318
+ req.order_by = order_by unless order_by.nil?
319
+ req.page_size = page_size unless page_size.nil?
320
+ @list_log_entries.call(req, options)
321
+ end
322
+
323
+ # Lists the monitored resource descriptors used by Stackdriver Logging.
324
+ #
325
+ # @param page_size [Integer]
326
+ # The maximum number of resources contained in the underlying API
327
+ # response. If page streaming is performed per-resource, this
328
+ # parameter does not affect the return value. If page streaming is
329
+ # performed per-page, this determines the maximum number of
330
+ # resources in a page.
331
+ # @param options [Google::Gax::CallOptions]
332
+ # Overrides the default settings for this call, e.g, timeout,
333
+ # retries, etc.
334
+ # @return [Google::Gax::PagedEnumerable<Google::Api::MonitoredResourceDescriptor>]
335
+ # An enumerable of Google::Api::MonitoredResourceDescriptor instances.
336
+ # See Google::Gax::PagedEnumerable documentation for other
337
+ # operations such as per-page iteration or access to the response
338
+ # object.
339
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
340
+ def list_monitored_resource_descriptors \
341
+ page_size: nil,
342
+ options: nil
343
+ req = Google::Logging::V2::ListMonitoredResourceDescriptorsRequest.new
344
+ req.page_size = page_size unless page_size.nil?
345
+ @list_monitored_resource_descriptors.call(req, options)
346
+ end
347
+ end
348
+ end
349
+ end
350
+ end
351
+ end
@@ -0,0 +1,57 @@
1
+ {
2
+ "interfaces": {
3
+ "google.logging.v2.LoggingServiceV2": {
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
+ "list": {
24
+ "initial_retry_delay_millis": 100,
25
+ "retry_delay_multiplier": 1.2,
26
+ "max_retry_delay_millis": 1000,
27
+ "initial_rpc_timeout_millis": 7000,
28
+ "rpc_timeout_multiplier": 1.5,
29
+ "max_rpc_timeout_millis": 30000,
30
+ "total_timeout_millis": 45000
31
+ }
32
+ },
33
+ "methods": {
34
+ "DeleteLog": {
35
+ "timeout_millis": 30000,
36
+ "retry_codes_name": "idempotent",
37
+ "retry_params_name": "default"
38
+ },
39
+ "WriteLogEntries": {
40
+ "timeout_millis": 30000,
41
+ "retry_codes_name": "non_idempotent",
42
+ "retry_params_name": "default"
43
+ },
44
+ "ListLogEntries": {
45
+ "timeout_millis": 30000,
46
+ "retry_codes_name": "idempotent",
47
+ "retry_params_name": "list"
48
+ },
49
+ "ListMonitoredResourceDescriptors": {
50
+ "timeout_millis": 30000,
51
+ "retry_codes_name": "idempotent",
52
+ "retry_params_name": "default"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }