google-cloud-logging-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-logging-v2.rb +21 -0
  7. data/lib/google/cloud/logging/v2.rb +37 -0
  8. data/lib/google/cloud/logging/v2/config_service.rb +49 -0
  9. data/lib/google/cloud/logging/v2/config_service/client.rb +1723 -0
  10. data/lib/google/cloud/logging/v2/config_service/credentials.rb +54 -0
  11. data/lib/google/cloud/logging/v2/config_service/paths.rb +413 -0
  12. data/lib/google/cloud/logging/v2/logging_service.rb +49 -0
  13. data/lib/google/cloud/logging/v2/logging_service/client.rb +826 -0
  14. data/lib/google/cloud/logging/v2/logging_service/credentials.rb +55 -0
  15. data/lib/google/cloud/logging/v2/logging_service/paths.rb +154 -0
  16. data/lib/google/cloud/logging/v2/metrics_service.rb +49 -0
  17. data/lib/google/cloud/logging/v2/metrics_service/client.rb +726 -0
  18. data/lib/google/cloud/logging/v2/metrics_service/credentials.rb +55 -0
  19. data/lib/google/cloud/logging/v2/metrics_service/paths.rb +64 -0
  20. data/lib/google/cloud/logging/v2/version.rb +28 -0
  21. data/lib/google/logging/type/http_request_pb.rb +38 -0
  22. data/lib/google/logging/type/log_severity_pb.rb +31 -0
  23. data/lib/google/logging/v2/log_entry_pb.rb +62 -0
  24. data/lib/google/logging/v2/logging_config_pb.rb +176 -0
  25. data/lib/google/logging/v2/logging_config_services_pb.rb +113 -0
  26. data/lib/google/logging/v2/logging_metrics_pb.rb +75 -0
  27. data/lib/google/logging/v2/logging_metrics_services_pb.rb +53 -0
  28. data/lib/google/logging/v2/logging_pb.rb +83 -0
  29. data/lib/google/logging/v2/logging_services_pb.rb +65 -0
  30. data/proto_docs/README.md +4 -0
  31. data/proto_docs/google/api/distribution.rb +225 -0
  32. data/proto_docs/google/api/field_behavior.rb +59 -0
  33. data/proto_docs/google/api/label.rb +49 -0
  34. data/proto_docs/google/api/metric.rb +203 -0
  35. data/proto_docs/google/api/monitored_resource.rb +137 -0
  36. data/proto_docs/google/api/resource.rb +247 -0
  37. data/proto_docs/google/logging/type/http_request.rb +95 -0
  38. data/proto_docs/google/logging/type/log_severity.rb +71 -0
  39. data/proto_docs/google/logging/v2/log_entry.rb +203 -0
  40. data/proto_docs/google/logging/v2/logging.rb +303 -0
  41. data/proto_docs/google/logging/v2/logging_config.rb +735 -0
  42. data/proto_docs/google/logging/v2/logging_metrics.rb +256 -0
  43. data/proto_docs/google/protobuf/any.rb +138 -0
  44. data/proto_docs/google/protobuf/duration.rb +98 -0
  45. data/proto_docs/google/protobuf/empty.rb +36 -0
  46. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  47. data/proto_docs/google/protobuf/struct.rb +96 -0
  48. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  49. data/proto_docs/google/rpc/status.rb +46 -0
  50. metadata +231 -0
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/logging/v2/version"
24
+
25
+ require "google/cloud/logging/v2/logging_service/credentials"
26
+ require "google/cloud/logging/v2/logging_service/paths"
27
+ require "google/cloud/logging/v2/logging_service/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module Logging
32
+ module V2
33
+ ##
34
+ # Service for ingesting and querying logs.
35
+ #
36
+ # To load this service and instantiate a client:
37
+ #
38
+ # require "google/cloud/logging/v2/logging_service"
39
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new
40
+ #
41
+ module LoggingService
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ helper_path = ::File.join __dir__, "logging_service", "helpers.rb"
49
+ require "google/cloud/logging/v2/logging_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,826 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/logging/v2/logging_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Logging
25
+ module V2
26
+ module LoggingService
27
+ ##
28
+ # Client for the LoggingService service.
29
+ #
30
+ # Service for ingesting and querying logs.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :logging_service_stub
37
+
38
+ ##
39
+ # Configure the LoggingService Client class.
40
+ #
41
+ # See {::Google::Cloud::Logging::V2::LoggingService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all LoggingService clients:
47
+ #
48
+ # ::Google::Cloud::Logging::V2::LoggingService::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "Logging", "V2"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const&.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.rpcs.delete_log.timeout = 60.0
69
+ default_config.rpcs.delete_log.retry_policy = {
70
+ initial_delay: 0.1,
71
+ max_delay: 60.0,
72
+ multiplier: 1.3,
73
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
74
+ }
75
+
76
+ default_config.rpcs.write_log_entries.timeout = 60.0
77
+ default_config.rpcs.write_log_entries.retry_policy = {
78
+ initial_delay: 0.1,
79
+ max_delay: 60.0,
80
+ multiplier: 1.3,
81
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
82
+ }
83
+
84
+ default_config.rpcs.list_log_entries.timeout = 60.0
85
+ default_config.rpcs.list_log_entries.retry_policy = {
86
+ initial_delay: 0.1,
87
+ max_delay: 60.0,
88
+ multiplier: 1.3,
89
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
90
+ }
91
+
92
+ default_config.rpcs.list_monitored_resource_descriptors.timeout = 60.0
93
+ default_config.rpcs.list_monitored_resource_descriptors.retry_policy = {
94
+ initial_delay: 0.1,
95
+ max_delay: 60.0,
96
+ multiplier: 1.3,
97
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
98
+ }
99
+
100
+ default_config.rpcs.list_logs.timeout = 60.0
101
+ default_config.rpcs.list_logs.retry_policy = {
102
+ initial_delay: 0.1,
103
+ max_delay: 60.0,
104
+ multiplier: 1.3,
105
+ retry_codes: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
106
+ }
107
+
108
+ default_config
109
+ end
110
+ yield @configure if block_given?
111
+ @configure
112
+ end
113
+
114
+ ##
115
+ # Configure the LoggingService Client instance.
116
+ #
117
+ # The configuration is set to the derived mode, meaning that values can be changed,
118
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
119
+ # should be made on {Client.configure}.
120
+ #
121
+ # See {::Google::Cloud::Logging::V2::LoggingService::Client::Configuration}
122
+ # for a description of the configuration fields.
123
+ #
124
+ # @yield [config] Configure the Client client.
125
+ # @yieldparam config [Client::Configuration]
126
+ #
127
+ # @return [Client::Configuration]
128
+ #
129
+ def configure
130
+ yield @config if block_given?
131
+ @config
132
+ end
133
+
134
+ ##
135
+ # Create a new LoggingService client object.
136
+ #
137
+ # ## Examples
138
+ #
139
+ # To create a new LoggingService client with the default
140
+ # configuration:
141
+ #
142
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new
143
+ #
144
+ # To create a new LoggingService client with a custom
145
+ # configuration:
146
+ #
147
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
148
+ # config.timeout = 10.0
149
+ # end
150
+ #
151
+ # @yield [config] Configure the LoggingService client.
152
+ # @yieldparam config [Client::Configuration]
153
+ #
154
+ def initialize
155
+ # These require statements are intentionally placed here to initialize
156
+ # the gRPC module only when it's required.
157
+ # See https://github.com/googleapis/toolkit/issues/446
158
+ require "gapic/grpc"
159
+ require "google/logging/v2/logging_services_pb"
160
+
161
+ # Create the configuration object
162
+ @config = Configuration.new Client.configure
163
+
164
+ # Yield the configuration if needed
165
+ yield @config if block_given?
166
+
167
+ # Create credentials
168
+ credentials = @config.credentials
169
+ credentials ||= Credentials.default scope: @config.scope
170
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
171
+ credentials = Credentials.new credentials, scope: @config.scope
172
+ end
173
+ @quota_project_id = @config.quota_project
174
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
175
+
176
+ @logging_service_stub = ::Gapic::ServiceStub.new(
177
+ ::Google::Cloud::Logging::V2::LoggingServiceV2::Stub,
178
+ credentials: credentials,
179
+ endpoint: @config.endpoint,
180
+ channel_args: @config.channel_args,
181
+ interceptors: @config.interceptors
182
+ )
183
+ end
184
+
185
+ # Service calls
186
+
187
+ ##
188
+ # Deletes all the log entries in a log. The log reappears if it receives new
189
+ # entries. Log entries written shortly before the delete operation might not
190
+ # be deleted. Entries received after the delete operation with a timestamp
191
+ # before the operation will be deleted.
192
+ #
193
+ # @overload delete_log(request, options = nil)
194
+ # Pass arguments to `delete_log` via a request object, either of type
195
+ # {::Google::Cloud::Logging::V2::DeleteLogRequest} or an equivalent Hash.
196
+ #
197
+ # @param request [::Google::Cloud::Logging::V2::DeleteLogRequest, ::Hash]
198
+ # A request object representing the call parameters. Required. To specify no
199
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
200
+ # @param options [::Gapic::CallOptions, ::Hash]
201
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
202
+ #
203
+ # @overload delete_log(log_name: nil)
204
+ # Pass arguments to `delete_log` via keyword arguments. Note that at
205
+ # least one keyword argument is required. To specify no parameters, or to keep all
206
+ # the default parameter values, pass an empty Hash as a request object (see above).
207
+ #
208
+ # @param log_name [::String]
209
+ # Required. The resource name of the log to delete:
210
+ #
211
+ # "projects/[PROJECT_ID]/logs/[LOG_ID]"
212
+ # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
213
+ # "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
214
+ # "folders/[FOLDER_ID]/logs/[LOG_ID]"
215
+ #
216
+ # `[LOG_ID]` must be URL-encoded. For example,
217
+ # `"projects/my-project-id/logs/syslog"`,
218
+ # `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`.
219
+ # For more information about log names, see
220
+ # {::Google::Cloud::Logging::V2::LogEntry LogEntry}.
221
+ #
222
+ # @yield [response, operation] Access the result along with the RPC operation
223
+ # @yieldparam response [::Google::Protobuf::Empty]
224
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
225
+ #
226
+ # @return [::Google::Protobuf::Empty]
227
+ #
228
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
229
+ #
230
+ def delete_log request, options = nil
231
+ raise ::ArgumentError, "request must be provided" if request.nil?
232
+
233
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Logging::V2::DeleteLogRequest
234
+
235
+ # Converts hash and nil to an options object
236
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
237
+
238
+ # Customize the options with defaults
239
+ metadata = @config.rpcs.delete_log.metadata.to_h
240
+
241
+ # Set x-goog-api-client and x-goog-user-project headers
242
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
243
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
244
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
245
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
246
+
247
+ header_params = {
248
+ "log_name" => request.log_name
249
+ }
250
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
+ metadata[:"x-goog-request-params"] ||= request_params_header
252
+
253
+ options.apply_defaults timeout: @config.rpcs.delete_log.timeout,
254
+ metadata: metadata,
255
+ retry_policy: @config.rpcs.delete_log.retry_policy
256
+ options.apply_defaults metadata: @config.metadata,
257
+ retry_policy: @config.retry_policy
258
+
259
+ @logging_service_stub.call_rpc :delete_log, request, options: options do |response, operation|
260
+ yield response, operation if block_given?
261
+ return response
262
+ end
263
+ rescue ::GRPC::BadStatus => e
264
+ raise ::Google::Cloud::Error.from_error(e)
265
+ end
266
+
267
+ ##
268
+ # Writes log entries to Logging. This API method is the
269
+ # only way to send log entries to Logging. This method
270
+ # is used, directly or indirectly, by the Logging agent
271
+ # (fluentd) and all logging libraries configured to use Logging.
272
+ # A single request may contain log entries for a maximum of 1000
273
+ # different resources (projects, organizations, billing accounts or
274
+ # folders)
275
+ #
276
+ # @overload write_log_entries(request, options = nil)
277
+ # Pass arguments to `write_log_entries` via a request object, either of type
278
+ # {::Google::Cloud::Logging::V2::WriteLogEntriesRequest} or an equivalent Hash.
279
+ #
280
+ # @param request [::Google::Cloud::Logging::V2::WriteLogEntriesRequest, ::Hash]
281
+ # A request object representing the call parameters. Required. To specify no
282
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
283
+ # @param options [::Gapic::CallOptions, ::Hash]
284
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
285
+ #
286
+ # @overload write_log_entries(log_name: nil, resource: nil, labels: nil, entries: nil, partial_success: nil, dry_run: nil)
287
+ # Pass arguments to `write_log_entries` via keyword arguments. Note that at
288
+ # least one keyword argument is required. To specify no parameters, or to keep all
289
+ # the default parameter values, pass an empty Hash as a request object (see above).
290
+ #
291
+ # @param log_name [::String]
292
+ # Optional. A default log resource name that is assigned to all log entries
293
+ # in `entries` that do not specify a value for `log_name`:
294
+ #
295
+ # "projects/[PROJECT_ID]/logs/[LOG_ID]"
296
+ # "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]"
297
+ # "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]"
298
+ # "folders/[FOLDER_ID]/logs/[LOG_ID]"
299
+ #
300
+ # `[LOG_ID]` must be URL-encoded. For example:
301
+ #
302
+ # "projects/my-project-id/logs/syslog"
303
+ # "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"
304
+ #
305
+ # The permission `logging.logEntries.create` is needed on each project,
306
+ # organization, billing account, or folder that is receiving new log
307
+ # entries, whether the resource is specified in `logName` or in an
308
+ # individual log entry.
309
+ # @param resource [::Google::Api::MonitoredResource, ::Hash]
310
+ # Optional. A default monitored resource object that is assigned to all log
311
+ # entries in `entries` that do not specify a value for `resource`. Example:
312
+ #
313
+ # { "type": "gce_instance",
314
+ # "labels": {
315
+ # "zone": "us-central1-a", "instance_id": "00000000000000000000" }}
316
+ #
317
+ # See {::Google::Cloud::Logging::V2::LogEntry LogEntry}.
318
+ # @param labels [::Hash{::String => ::String}]
319
+ # Optional. Default labels that are added to the `labels` field of all log
320
+ # entries in `entries`. If a log entry already has a label with the same key
321
+ # as a label in this parameter, then the log entry's label is not changed.
322
+ # See {::Google::Cloud::Logging::V2::LogEntry LogEntry}.
323
+ # @param entries [::Array<::Google::Cloud::Logging::V2::LogEntry, ::Hash>]
324
+ # Required. The log entries to send to Logging. The order of log
325
+ # entries in this list does not matter. Values supplied in this method's
326
+ # `log_name`, `resource`, and `labels` fields are copied into those log
327
+ # entries in this list that do not include values for their corresponding
328
+ # fields. For more information, see the
329
+ # {::Google::Cloud::Logging::V2::LogEntry LogEntry} type.
330
+ #
331
+ # If the `timestamp` or `insert_id` fields are missing in log entries, then
332
+ # this method supplies the current time or a unique identifier, respectively.
333
+ # The supplied values are chosen so that, among the log entries that did not
334
+ # supply their own values, the entries earlier in the list will sort before
335
+ # the entries later in the list. See the `entries.list` method.
336
+ #
337
+ # Log entries with timestamps that are more than the
338
+ # [logs retention period](https://cloud.google.com/logging/quota-policy) in the past or more than
339
+ # 24 hours in the future will not be available when calling `entries.list`.
340
+ # However, those log entries can still be
341
+ # [exported with LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs).
342
+ #
343
+ # To improve throughput and to avoid exceeding the
344
+ # [quota limit](https://cloud.google.com/logging/quota-policy) for calls to `entries.write`,
345
+ # you should try to include several log entries in this list,
346
+ # rather than calling this method for each individual log entry.
347
+ # @param partial_success [::Boolean]
348
+ # Optional. Whether valid entries should be written even if some other
349
+ # entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any
350
+ # entry is not written, then the response status is the error associated
351
+ # with one of the failed entries and the response includes error details
352
+ # keyed by the entries' zero-based index in the `entries.write` method.
353
+ # @param dry_run [::Boolean]
354
+ # Optional. If true, the request should expect normal response, but the
355
+ # entries won't be persisted nor exported. Useful for checking whether the
356
+ # logging API endpoints are working properly before sending valuable data.
357
+ #
358
+ # @yield [response, operation] Access the result along with the RPC operation
359
+ # @yieldparam response [::Google::Cloud::Logging::V2::WriteLogEntriesResponse]
360
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
361
+ #
362
+ # @return [::Google::Cloud::Logging::V2::WriteLogEntriesResponse]
363
+ #
364
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
365
+ #
366
+ def write_log_entries request, options = nil
367
+ raise ::ArgumentError, "request must be provided" if request.nil?
368
+
369
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Logging::V2::WriteLogEntriesRequest
370
+
371
+ # Converts hash and nil to an options object
372
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
373
+
374
+ # Customize the options with defaults
375
+ metadata = @config.rpcs.write_log_entries.metadata.to_h
376
+
377
+ # Set x-goog-api-client and x-goog-user-project headers
378
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
379
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
380
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
381
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
382
+
383
+ options.apply_defaults timeout: @config.rpcs.write_log_entries.timeout,
384
+ metadata: metadata,
385
+ retry_policy: @config.rpcs.write_log_entries.retry_policy
386
+ options.apply_defaults metadata: @config.metadata,
387
+ retry_policy: @config.retry_policy
388
+
389
+ @logging_service_stub.call_rpc :write_log_entries, request, options: options do |response, operation|
390
+ yield response, operation if block_given?
391
+ return response
392
+ end
393
+ rescue ::GRPC::BadStatus => e
394
+ raise ::Google::Cloud::Error.from_error(e)
395
+ end
396
+
397
+ ##
398
+ # Lists log entries. Use this method to retrieve log entries that originated
399
+ # from a project/folder/organization/billing account. For ways to export log
400
+ # entries, see [Exporting Logs](https://cloud.google.com/logging/docs/export).
401
+ #
402
+ # @overload list_log_entries(request, options = nil)
403
+ # Pass arguments to `list_log_entries` via a request object, either of type
404
+ # {::Google::Cloud::Logging::V2::ListLogEntriesRequest} or an equivalent Hash.
405
+ #
406
+ # @param request [::Google::Cloud::Logging::V2::ListLogEntriesRequest, ::Hash]
407
+ # A request object representing the call parameters. Required. To specify no
408
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
409
+ # @param options [::Gapic::CallOptions, ::Hash]
410
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
411
+ #
412
+ # @overload list_log_entries(resource_names: nil, filter: nil, order_by: nil, page_size: nil, page_token: nil)
413
+ # Pass arguments to `list_log_entries` via keyword arguments. Note that at
414
+ # least one keyword argument is required. To specify no parameters, or to keep all
415
+ # the default parameter values, pass an empty Hash as a request object (see above).
416
+ #
417
+ # @param resource_names [::Array<::String>]
418
+ # Required. Names of one or more parent resources from which to
419
+ # retrieve log entries:
420
+ #
421
+ # "projects/[PROJECT_ID]"
422
+ # "organizations/[ORGANIZATION_ID]"
423
+ # "billingAccounts/[BILLING_ACCOUNT_ID]"
424
+ # "folders/[FOLDER_ID]"
425
+ #
426
+ #
427
+ # Projects listed in the `project_ids` field are added to this list.
428
+ # @param filter [::String]
429
+ # Optional. A filter that chooses which log entries to return. See [Advanced
430
+ # Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). Only log entries that
431
+ # match the filter are returned. An empty filter matches all log entries in
432
+ # the resources listed in `resource_names`. Referencing a parent resource
433
+ # that is not listed in `resource_names` will cause the filter to return no
434
+ # results.
435
+ # The maximum length of the filter is 20000 characters.
436
+ # @param order_by [::String]
437
+ # Optional. How the results should be sorted. Presently, the only permitted
438
+ # values are `"timestamp asc"` (default) and `"timestamp desc"`. The first
439
+ # option returns entries in order of increasing values of
440
+ # `LogEntry.timestamp` (oldest first), and the second option returns entries
441
+ # in order of decreasing timestamps (newest first). Entries with equal
442
+ # timestamps are returned in order of their `insert_id` values.
443
+ # @param page_size [::Integer]
444
+ # Optional. The maximum number of results to return from this request.
445
+ # Non-positive values are ignored. The presence of `next_page_token` in the
446
+ # response indicates that more results might be available.
447
+ # @param page_token [::String]
448
+ # Optional. If present, then retrieve the next batch of results from the
449
+ # preceding call to this method. `page_token` must be the value of
450
+ # `next_page_token` from the previous response. The values of other method
451
+ # parameters should be identical to those in the previous call.
452
+ #
453
+ # @yield [response, operation] Access the result along with the RPC operation
454
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogEntry>]
455
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
456
+ #
457
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Logging::V2::LogEntry>]
458
+ #
459
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
460
+ #
461
+ def list_log_entries request, options = nil
462
+ raise ::ArgumentError, "request must be provided" if request.nil?
463
+
464
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Logging::V2::ListLogEntriesRequest
465
+
466
+ # Converts hash and nil to an options object
467
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
468
+
469
+ # Customize the options with defaults
470
+ metadata = @config.rpcs.list_log_entries.metadata.to_h
471
+
472
+ # Set x-goog-api-client and x-goog-user-project headers
473
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
474
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
475
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
476
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
477
+
478
+ options.apply_defaults timeout: @config.rpcs.list_log_entries.timeout,
479
+ metadata: metadata,
480
+ retry_policy: @config.rpcs.list_log_entries.retry_policy
481
+ options.apply_defaults metadata: @config.metadata,
482
+ retry_policy: @config.retry_policy
483
+
484
+ @logging_service_stub.call_rpc :list_log_entries, request, options: options do |response, operation|
485
+ response = ::Gapic::PagedEnumerable.new @logging_service_stub, :list_log_entries, request, response, operation, options
486
+ yield response, operation if block_given?
487
+ return response
488
+ end
489
+ rescue ::GRPC::BadStatus => e
490
+ raise ::Google::Cloud::Error.from_error(e)
491
+ end
492
+
493
+ ##
494
+ # Lists the descriptors for monitored resource types used by Logging.
495
+ #
496
+ # @overload list_monitored_resource_descriptors(request, options = nil)
497
+ # Pass arguments to `list_monitored_resource_descriptors` via a request object, either of type
498
+ # {::Google::Cloud::Logging::V2::ListMonitoredResourceDescriptorsRequest} or an equivalent Hash.
499
+ #
500
+ # @param request [::Google::Cloud::Logging::V2::ListMonitoredResourceDescriptorsRequest, ::Hash]
501
+ # A request object representing the call parameters. Required. To specify no
502
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
503
+ # @param options [::Gapic::CallOptions, ::Hash]
504
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
505
+ #
506
+ # @overload list_monitored_resource_descriptors(page_size: nil, page_token: nil)
507
+ # Pass arguments to `list_monitored_resource_descriptors` via keyword arguments. Note that at
508
+ # least one keyword argument is required. To specify no parameters, or to keep all
509
+ # the default parameter values, pass an empty Hash as a request object (see above).
510
+ #
511
+ # @param page_size [::Integer]
512
+ # Optional. The maximum number of results to return from this request.
513
+ # Non-positive values are ignored. The presence of `nextPageToken` in the
514
+ # response indicates that more results might be available.
515
+ # @param page_token [::String]
516
+ # Optional. If present, then retrieve the next batch of results from the
517
+ # preceding call to this method. `pageToken` must be the value of
518
+ # `nextPageToken` from the previous response. The values of other method
519
+ # parameters should be identical to those in the previous call.
520
+ #
521
+ # @yield [response, operation] Access the result along with the RPC operation
522
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Api::MonitoredResourceDescriptor>]
523
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
524
+ #
525
+ # @return [::Gapic::PagedEnumerable<::Google::Api::MonitoredResourceDescriptor>]
526
+ #
527
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
528
+ #
529
+ def list_monitored_resource_descriptors request, options = nil
530
+ raise ::ArgumentError, "request must be provided" if request.nil?
531
+
532
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Logging::V2::ListMonitoredResourceDescriptorsRequest
533
+
534
+ # Converts hash and nil to an options object
535
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
536
+
537
+ # Customize the options with defaults
538
+ metadata = @config.rpcs.list_monitored_resource_descriptors.metadata.to_h
539
+
540
+ # Set x-goog-api-client and x-goog-user-project headers
541
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
542
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
543
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
544
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
545
+
546
+ options.apply_defaults timeout: @config.rpcs.list_monitored_resource_descriptors.timeout,
547
+ metadata: metadata,
548
+ retry_policy: @config.rpcs.list_monitored_resource_descriptors.retry_policy
549
+ options.apply_defaults metadata: @config.metadata,
550
+ retry_policy: @config.retry_policy
551
+
552
+ @logging_service_stub.call_rpc :list_monitored_resource_descriptors, request, options: options do |response, operation|
553
+ response = ::Gapic::PagedEnumerable.new @logging_service_stub, :list_monitored_resource_descriptors, request, response, operation, options
554
+ yield response, operation if block_given?
555
+ return response
556
+ end
557
+ rescue ::GRPC::BadStatus => e
558
+ raise ::Google::Cloud::Error.from_error(e)
559
+ end
560
+
561
+ ##
562
+ # Lists the logs in projects, organizations, folders, or billing accounts.
563
+ # Only logs that have entries are listed.
564
+ #
565
+ # @overload list_logs(request, options = nil)
566
+ # Pass arguments to `list_logs` via a request object, either of type
567
+ # {::Google::Cloud::Logging::V2::ListLogsRequest} or an equivalent Hash.
568
+ #
569
+ # @param request [::Google::Cloud::Logging::V2::ListLogsRequest, ::Hash]
570
+ # A request object representing the call parameters. Required. To specify no
571
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
572
+ # @param options [::Gapic::CallOptions, ::Hash]
573
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
574
+ #
575
+ # @overload list_logs(parent: nil, page_size: nil, page_token: nil)
576
+ # Pass arguments to `list_logs` via keyword arguments. Note that at
577
+ # least one keyword argument is required. To specify no parameters, or to keep all
578
+ # the default parameter values, pass an empty Hash as a request object (see above).
579
+ #
580
+ # @param parent [::String]
581
+ # Required. The resource name that owns the logs:
582
+ #
583
+ # "projects/[PROJECT_ID]"
584
+ # "organizations/[ORGANIZATION_ID]"
585
+ # "billingAccounts/[BILLING_ACCOUNT_ID]"
586
+ # "folders/[FOLDER_ID]"
587
+ # @param page_size [::Integer]
588
+ # Optional. The maximum number of results to return from this request.
589
+ # Non-positive values are ignored. The presence of `nextPageToken` in the
590
+ # response indicates that more results might be available.
591
+ # @param page_token [::String]
592
+ # Optional. If present, then retrieve the next batch of results from the
593
+ # preceding call to this method. `pageToken` must be the value of
594
+ # `nextPageToken` from the previous response. The values of other method
595
+ # parameters should be identical to those in the previous call.
596
+ #
597
+ # @yield [response, operation] Access the result along with the RPC operation
598
+ # @yieldparam response [::Google::Cloud::Logging::V2::ListLogsResponse]
599
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
600
+ #
601
+ # @return [::Google::Cloud::Logging::V2::ListLogsResponse]
602
+ #
603
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
604
+ #
605
+ def list_logs request, options = nil
606
+ raise ::ArgumentError, "request must be provided" if request.nil?
607
+
608
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Logging::V2::ListLogsRequest
609
+
610
+ # Converts hash and nil to an options object
611
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
612
+
613
+ # Customize the options with defaults
614
+ metadata = @config.rpcs.list_logs.metadata.to_h
615
+
616
+ # Set x-goog-api-client and x-goog-user-project headers
617
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
618
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
619
+ gapic_version: ::Google::Cloud::Logging::V2::VERSION
620
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
621
+
622
+ header_params = {
623
+ "parent" => request.parent
624
+ }
625
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
626
+ metadata[:"x-goog-request-params"] ||= request_params_header
627
+
628
+ options.apply_defaults timeout: @config.rpcs.list_logs.timeout,
629
+ metadata: metadata,
630
+ retry_policy: @config.rpcs.list_logs.retry_policy
631
+ options.apply_defaults metadata: @config.metadata,
632
+ retry_policy: @config.retry_policy
633
+
634
+ @logging_service_stub.call_rpc :list_logs, request, options: options do |response, operation|
635
+ yield response, operation if block_given?
636
+ return response
637
+ end
638
+ rescue ::GRPC::BadStatus => e
639
+ raise ::Google::Cloud::Error.from_error(e)
640
+ end
641
+
642
+ ##
643
+ # Configuration class for the LoggingService API.
644
+ #
645
+ # This class represents the configuration for LoggingService,
646
+ # providing control over timeouts, retry behavior, logging, transport
647
+ # parameters, and other low-level controls. Certain parameters can also be
648
+ # applied individually to specific RPCs. See
649
+ # {::Google::Cloud::Logging::V2::LoggingService::Client::Configuration::Rpcs}
650
+ # for a list of RPCs that can be configured independently.
651
+ #
652
+ # Configuration can be applied globally to all clients, or to a single client
653
+ # on construction.
654
+ #
655
+ # # Examples
656
+ #
657
+ # To modify the global config, setting the timeout for delete_log
658
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
659
+ #
660
+ # ::Google::Cloud::Logging::V2::LoggingService::Client.configure do |config|
661
+ # config.timeout = 10.0
662
+ # config.rpcs.delete_log.timeout = 20.0
663
+ # end
664
+ #
665
+ # To apply the above configuration only to a new client:
666
+ #
667
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
668
+ # config.timeout = 10.0
669
+ # config.rpcs.delete_log.timeout = 20.0
670
+ # end
671
+ #
672
+ # @!attribute [rw] endpoint
673
+ # The hostname or hostname:port of the service endpoint.
674
+ # Defaults to `"logging.googleapis.com"`.
675
+ # @return [::String]
676
+ # @!attribute [rw] credentials
677
+ # Credentials to send with calls. You may provide any of the following types:
678
+ # * (`String`) The path to a service account key file in JSON format
679
+ # * (`Hash`) A service account key as a Hash
680
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
681
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
682
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
683
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
684
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
685
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
686
+ # * (`nil`) indicating no credentials
687
+ # @return [::Object]
688
+ # @!attribute [rw] scope
689
+ # The OAuth scopes
690
+ # @return [::Array<::String>]
691
+ # @!attribute [rw] lib_name
692
+ # The library name as recorded in instrumentation and logging
693
+ # @return [::String]
694
+ # @!attribute [rw] lib_version
695
+ # The library version as recorded in instrumentation and logging
696
+ # @return [::String]
697
+ # @!attribute [rw] channel_args
698
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
699
+ # `GRPC::Core::Channel` object is provided as the credential.
700
+ # @return [::Hash]
701
+ # @!attribute [rw] interceptors
702
+ # An array of interceptors that are run before calls are executed.
703
+ # @return [::Array<::GRPC::ClientInterceptor>]
704
+ # @!attribute [rw] timeout
705
+ # The call timeout in seconds.
706
+ # @return [::Numeric]
707
+ # @!attribute [rw] metadata
708
+ # Additional gRPC headers to be sent with the call.
709
+ # @return [::Hash{::Symbol=>::String}]
710
+ # @!attribute [rw] retry_policy
711
+ # The retry policy. The value is a hash with the following keys:
712
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
713
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
714
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
715
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
716
+ # trigger a retry.
717
+ # @return [::Hash]
718
+ # @!attribute [rw] quota_project
719
+ # A separate project against which to charge quota.
720
+ # @return [::String]
721
+ #
722
+ class Configuration
723
+ extend ::Gapic::Config
724
+
725
+ config_attr :endpoint, "logging.googleapis.com", ::String
726
+ config_attr :credentials, nil do |value|
727
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
728
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
729
+ allowed.any? { |klass| klass === value }
730
+ end
731
+ config_attr :scope, nil, ::String, ::Array, nil
732
+ config_attr :lib_name, nil, ::String, nil
733
+ config_attr :lib_version, nil, ::String, nil
734
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
735
+ config_attr :interceptors, nil, ::Array, nil
736
+ config_attr :timeout, nil, ::Numeric, nil
737
+ config_attr :metadata, nil, ::Hash, nil
738
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
739
+ config_attr :quota_project, nil, ::String, nil
740
+
741
+ # @private
742
+ def initialize parent_config = nil
743
+ @parent_config = parent_config unless parent_config.nil?
744
+
745
+ yield self if block_given?
746
+ end
747
+
748
+ ##
749
+ # Configurations for individual RPCs
750
+ # @return [Rpcs]
751
+ #
752
+ def rpcs
753
+ @rpcs ||= begin
754
+ parent_rpcs = nil
755
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
756
+ Rpcs.new parent_rpcs
757
+ end
758
+ end
759
+
760
+ ##
761
+ # Configuration RPC class for the LoggingService API.
762
+ #
763
+ # Includes fields providing the configuration for each RPC in this service.
764
+ # Each configuration object is of type `Gapic::Config::Method` and includes
765
+ # the following configuration fields:
766
+ #
767
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
768
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
769
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
770
+ # include the following keys:
771
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
772
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
773
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
774
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
775
+ # trigger a retry.
776
+ #
777
+ class Rpcs
778
+ ##
779
+ # RPC-specific configuration for `delete_log`
780
+ # @return [::Gapic::Config::Method]
781
+ #
782
+ attr_reader :delete_log
783
+ ##
784
+ # RPC-specific configuration for `write_log_entries`
785
+ # @return [::Gapic::Config::Method]
786
+ #
787
+ attr_reader :write_log_entries
788
+ ##
789
+ # RPC-specific configuration for `list_log_entries`
790
+ # @return [::Gapic::Config::Method]
791
+ #
792
+ attr_reader :list_log_entries
793
+ ##
794
+ # RPC-specific configuration for `list_monitored_resource_descriptors`
795
+ # @return [::Gapic::Config::Method]
796
+ #
797
+ attr_reader :list_monitored_resource_descriptors
798
+ ##
799
+ # RPC-specific configuration for `list_logs`
800
+ # @return [::Gapic::Config::Method]
801
+ #
802
+ attr_reader :list_logs
803
+
804
+ # @private
805
+ def initialize parent_rpcs = nil
806
+ delete_log_config = parent_rpcs&.delete_log if parent_rpcs&.respond_to? :delete_log
807
+ @delete_log = ::Gapic::Config::Method.new delete_log_config
808
+ write_log_entries_config = parent_rpcs&.write_log_entries if parent_rpcs&.respond_to? :write_log_entries
809
+ @write_log_entries = ::Gapic::Config::Method.new write_log_entries_config
810
+ list_log_entries_config = parent_rpcs&.list_log_entries if parent_rpcs&.respond_to? :list_log_entries
811
+ @list_log_entries = ::Gapic::Config::Method.new list_log_entries_config
812
+ list_monitored_resource_descriptors_config = parent_rpcs&.list_monitored_resource_descriptors if parent_rpcs&.respond_to? :list_monitored_resource_descriptors
813
+ @list_monitored_resource_descriptors = ::Gapic::Config::Method.new list_monitored_resource_descriptors_config
814
+ list_logs_config = parent_rpcs&.list_logs if parent_rpcs&.respond_to? :list_logs
815
+ @list_logs = ::Gapic::Config::Method.new list_logs_config
816
+
817
+ yield self if block_given?
818
+ end
819
+ end
820
+ end
821
+ end
822
+ end
823
+ end
824
+ end
825
+ end
826
+ end