google-cloud-logging-v2 0.5.1 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,13 +41,12 @@ module Google
41
41
  # See {::Google::Cloud::Logging::V2::LoggingService::Client::Configuration}
42
42
  # for a description of the configuration fields.
43
43
  #
44
- # ## Example
44
+ # @example
45
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
46
+ # # Modify the configuration for all LoggingService clients
47
+ # ::Google::Cloud::Logging::V2::LoggingService::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
51
50
  #
52
51
  # @yield [config] Configure the Client client.
53
52
  # @yieldparam config [Client::Configuration]
@@ -67,50 +66,32 @@ module Google
67
66
 
68
67
  default_config.rpcs.delete_log.timeout = 60.0
69
68
  default_config.rpcs.delete_log.retry_policy = {
70
- initial_delay: 0.1,
71
- max_delay: 60.0,
72
- multiplier: 1.3,
73
- retry_codes: [4, 13, 14]
69
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
74
70
  }
75
71
 
76
72
  default_config.rpcs.write_log_entries.timeout = 60.0
77
73
  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: [4, 13, 14]
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
82
75
  }
83
76
 
84
77
  default_config.rpcs.list_log_entries.timeout = 60.0
85
78
  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: [4, 13, 14]
79
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
90
80
  }
91
81
 
92
82
  default_config.rpcs.list_monitored_resource_descriptors.timeout = 60.0
93
83
  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: [4, 13, 14]
84
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
98
85
  }
99
86
 
100
87
  default_config.rpcs.list_logs.timeout = 60.0
101
88
  default_config.rpcs.list_logs.retry_policy = {
102
- initial_delay: 0.1,
103
- max_delay: 60.0,
104
- multiplier: 1.3,
105
- retry_codes: [4, 13, 14]
89
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
106
90
  }
107
91
 
108
92
  default_config.rpcs.tail_log_entries.timeout = 3600.0
109
93
  default_config.rpcs.tail_log_entries.retry_policy = {
110
- initial_delay: 0.1,
111
- max_delay: 60.0,
112
- multiplier: 1.3,
113
- retry_codes: [4, 13, 14]
94
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 13, 14]
114
95
  }
115
96
 
116
97
  default_config
@@ -142,19 +123,15 @@ module Google
142
123
  ##
143
124
  # Create a new LoggingService client object.
144
125
  #
145
- # ## Examples
146
- #
147
- # To create a new LoggingService client with the default
148
- # configuration:
149
- #
150
- # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new
126
+ # @example
151
127
  #
152
- # To create a new LoggingService client with a custom
153
- # configuration:
128
+ # # Create a client using the default configuration
129
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new
154
130
  #
155
- # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
156
- # config.timeout = 10.0
157
- # end
131
+ # # Create a client using a custom configuration
132
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
133
+ # config.timeout = 10.0
134
+ # end
158
135
  #
159
136
  # @yield [config] Configure the LoggingService client.
160
137
  # @yieldparam config [Client::Configuration]
@@ -174,14 +151,13 @@ module Google
174
151
 
175
152
  # Create credentials
176
153
  credentials = @config.credentials
177
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
154
+ # Use self-signed JWT if the endpoint is unchanged from default,
178
155
  # but only if the default endpoint does not have a region prefix.
179
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
180
- @config.endpoint == Client.configure.endpoint &&
156
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
181
157
  !@config.endpoint.split(".").first.include?("-")
182
158
  credentials ||= Credentials.default scope: @config.scope,
183
159
  enable_self_signed_jwt: enable_self_signed_jwt
184
- if credentials.is_a?(String) || credentials.is_a?(Hash)
160
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
185
161
  credentials = Credentials.new credentials, scope: @config.scope
186
162
  end
187
163
  @quota_project_id = @config.quota_project
@@ -241,6 +217,21 @@ module Google
241
217
  #
242
218
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
243
219
  #
220
+ # @example Basic example
221
+ # require "google/cloud/logging/v2"
222
+ #
223
+ # # Create a client object. The client can be reused for multiple calls.
224
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
225
+ #
226
+ # # Create a request. To set request fields, pass in keyword arguments.
227
+ # request = Google::Cloud::Logging::V2::DeleteLogRequest.new
228
+ #
229
+ # # Call the delete_log method.
230
+ # result = client.delete_log request
231
+ #
232
+ # # The returned object is of type Google::Protobuf::Empty.
233
+ # p result
234
+ #
244
235
  def delete_log request, options = nil
245
236
  raise ::ArgumentError, "request must be provided" if request.nil?
246
237
 
@@ -258,16 +249,20 @@ module Google
258
249
  gapic_version: ::Google::Cloud::Logging::V2::VERSION
259
250
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
260
251
 
261
- header_params = {
262
- "log_name" => request.log_name
263
- }
252
+ header_params = {}
253
+ if request.log_name
254
+ header_params["log_name"] = request.log_name
255
+ end
256
+
264
257
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
265
258
  metadata[:"x-goog-request-params"] ||= request_params_header
266
259
 
267
260
  options.apply_defaults timeout: @config.rpcs.delete_log.timeout,
268
261
  metadata: metadata,
269
262
  retry_policy: @config.rpcs.delete_log.retry_policy
270
- options.apply_defaults metadata: @config.metadata,
263
+
264
+ options.apply_defaults timeout: @config.timeout,
265
+ metadata: @config.metadata,
271
266
  retry_policy: @config.retry_policy
272
267
 
273
268
  @logging_service_stub.call_rpc :delete_log, request, options: options do |response, operation|
@@ -378,6 +373,21 @@ module Google
378
373
  #
379
374
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
380
375
  #
376
+ # @example Basic example
377
+ # require "google/cloud/logging/v2"
378
+ #
379
+ # # Create a client object. The client can be reused for multiple calls.
380
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
381
+ #
382
+ # # Create a request. To set request fields, pass in keyword arguments.
383
+ # request = Google::Cloud::Logging::V2::WriteLogEntriesRequest.new
384
+ #
385
+ # # Call the write_log_entries method.
386
+ # result = client.write_log_entries request
387
+ #
388
+ # # The returned object is of type Google::Cloud::Logging::V2::WriteLogEntriesResponse.
389
+ # p result
390
+ #
381
391
  def write_log_entries request, options = nil
382
392
  raise ::ArgumentError, "request must be provided" if request.nil?
383
393
 
@@ -398,7 +408,9 @@ module Google
398
408
  options.apply_defaults timeout: @config.rpcs.write_log_entries.timeout,
399
409
  metadata: metadata,
400
410
  retry_policy: @config.rpcs.write_log_entries.retry_policy
401
- options.apply_defaults metadata: @config.metadata,
411
+
412
+ options.apply_defaults timeout: @config.timeout,
413
+ metadata: @config.metadata,
402
414
  retry_policy: @config.retry_policy
403
415
 
404
416
  @logging_service_stub.call_rpc :write_log_entries, request, options: options do |response, operation|
@@ -480,6 +492,27 @@ module Google
480
492
  #
481
493
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
482
494
  #
495
+ # @example Basic example
496
+ # require "google/cloud/logging/v2"
497
+ #
498
+ # # Create a client object. The client can be reused for multiple calls.
499
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
500
+ #
501
+ # # Create a request. To set request fields, pass in keyword arguments.
502
+ # request = Google::Cloud::Logging::V2::ListLogEntriesRequest.new
503
+ #
504
+ # # Call the list_log_entries method.
505
+ # result = client.list_log_entries request
506
+ #
507
+ # # The returned object is of type Gapic::PagedEnumerable. You can
508
+ # # iterate over all elements by calling #each, and the enumerable
509
+ # # will lazily make API calls to fetch subsequent pages. Other
510
+ # # methods are also available for managing paging directly.
511
+ # result.each do |response|
512
+ # # Each element is of type ::Google::Cloud::Logging::V2::LogEntry.
513
+ # p response
514
+ # end
515
+ #
483
516
  def list_log_entries request, options = nil
484
517
  raise ::ArgumentError, "request must be provided" if request.nil?
485
518
 
@@ -500,7 +533,9 @@ module Google
500
533
  options.apply_defaults timeout: @config.rpcs.list_log_entries.timeout,
501
534
  metadata: metadata,
502
535
  retry_policy: @config.rpcs.list_log_entries.retry_policy
503
- options.apply_defaults metadata: @config.metadata,
536
+
537
+ options.apply_defaults timeout: @config.timeout,
538
+ metadata: @config.metadata,
504
539
  retry_policy: @config.retry_policy
505
540
 
506
541
  @logging_service_stub.call_rpc :list_log_entries, request, options: options do |response, operation|
@@ -548,6 +583,27 @@ module Google
548
583
  #
549
584
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
550
585
  #
586
+ # @example Basic example
587
+ # require "google/cloud/logging/v2"
588
+ #
589
+ # # Create a client object. The client can be reused for multiple calls.
590
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
591
+ #
592
+ # # Create a request. To set request fields, pass in keyword arguments.
593
+ # request = Google::Cloud::Logging::V2::ListMonitoredResourceDescriptorsRequest.new
594
+ #
595
+ # # Call the list_monitored_resource_descriptors method.
596
+ # result = client.list_monitored_resource_descriptors request
597
+ #
598
+ # # The returned object is of type Gapic::PagedEnumerable. You can
599
+ # # iterate over all elements by calling #each, and the enumerable
600
+ # # will lazily make API calls to fetch subsequent pages. Other
601
+ # # methods are also available for managing paging directly.
602
+ # result.each do |response|
603
+ # # Each element is of type ::Google::Api::MonitoredResourceDescriptor.
604
+ # p response
605
+ # end
606
+ #
551
607
  def list_monitored_resource_descriptors request, options = nil
552
608
  raise ::ArgumentError, "request must be provided" if request.nil?
553
609
 
@@ -568,7 +624,9 @@ module Google
568
624
  options.apply_defaults timeout: @config.rpcs.list_monitored_resource_descriptors.timeout,
569
625
  metadata: metadata,
570
626
  retry_policy: @config.rpcs.list_monitored_resource_descriptors.retry_policy
571
- options.apply_defaults metadata: @config.metadata,
627
+
628
+ options.apply_defaults timeout: @config.timeout,
629
+ metadata: @config.metadata,
572
630
  retry_policy: @config.retry_policy
573
631
 
574
632
  @logging_service_stub.call_rpc :list_monitored_resource_descriptors, request, options: options do |response, operation|
@@ -636,6 +694,21 @@ module Google
636
694
  #
637
695
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
638
696
  #
697
+ # @example Basic example
698
+ # require "google/cloud/logging/v2"
699
+ #
700
+ # # Create a client object. The client can be reused for multiple calls.
701
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
702
+ #
703
+ # # Create a request. To set request fields, pass in keyword arguments.
704
+ # request = Google::Cloud::Logging::V2::ListLogsRequest.new
705
+ #
706
+ # # Call the list_logs method.
707
+ # result = client.list_logs request
708
+ #
709
+ # # The returned object is of type Google::Cloud::Logging::V2::ListLogsResponse.
710
+ # p result
711
+ #
639
712
  def list_logs request, options = nil
640
713
  raise ::ArgumentError, "request must be provided" if request.nil?
641
714
 
@@ -653,16 +726,20 @@ module Google
653
726
  gapic_version: ::Google::Cloud::Logging::V2::VERSION
654
727
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
655
728
 
656
- header_params = {
657
- "parent" => request.parent
658
- }
729
+ header_params = {}
730
+ if request.parent
731
+ header_params["parent"] = request.parent
732
+ end
733
+
659
734
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
660
735
  metadata[:"x-goog-request-params"] ||= request_params_header
661
736
 
662
737
  options.apply_defaults timeout: @config.rpcs.list_logs.timeout,
663
738
  metadata: metadata,
664
739
  retry_policy: @config.rpcs.list_logs.retry_policy
665
- options.apply_defaults metadata: @config.metadata,
740
+
741
+ options.apply_defaults timeout: @config.timeout,
742
+ metadata: @config.metadata,
666
743
  retry_policy: @config.retry_policy
667
744
 
668
745
  @logging_service_stub.call_rpc :list_logs, request, options: options do |response, operation|
@@ -690,6 +767,30 @@ module Google
690
767
  #
691
768
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
692
769
  #
770
+ # @example Basic example
771
+ # require "google/cloud/logging/v2"
772
+ #
773
+ # # Create a client object. The client can be reused for multiple calls.
774
+ # client = Google::Cloud::Logging::V2::LoggingService::Client.new
775
+ #
776
+ # # Create an input stream
777
+ # input = Gapic::StreamInput.new
778
+ #
779
+ # # Call the tail_log_entries method to start streaming.
780
+ # output = client.tail_log_entries input
781
+ #
782
+ # # Send requests on the stream. For each request, pass in keyword
783
+ # # arguments to set fields. Be sure to close the stream when done.
784
+ # input << Google::Cloud::Logging::V2::TailLogEntriesRequest.new
785
+ # input << Google::Cloud::Logging::V2::TailLogEntriesRequest.new
786
+ # input.close
787
+ #
788
+ # # Handle streamed responses. These may be interleaved with inputs.
789
+ # # Each response is of type ::Google::Cloud::Logging::V2::TailLogEntriesResponse.
790
+ # output.each do |response|
791
+ # p response
792
+ # end
793
+ #
693
794
  def tail_log_entries request, options = nil
694
795
  unless request.is_a? ::Enumerable
695
796
  raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
@@ -715,7 +816,9 @@ module Google
715
816
  options.apply_defaults timeout: @config.rpcs.tail_log_entries.timeout,
716
817
  metadata: metadata,
717
818
  retry_policy: @config.rpcs.tail_log_entries.retry_policy
718
- options.apply_defaults metadata: @config.metadata,
819
+
820
+ options.apply_defaults timeout: @config.timeout,
821
+ metadata: @config.metadata,
719
822
  retry_policy: @config.retry_policy
720
823
 
721
824
  @logging_service_stub.call_rpc :tail_log_entries, request, options: options do |response, operation|
@@ -739,22 +842,21 @@ module Google
739
842
  # Configuration can be applied globally to all clients, or to a single client
740
843
  # on construction.
741
844
  #
742
- # # Examples
743
- #
744
- # To modify the global config, setting the timeout for delete_log
745
- # to 20 seconds, and all remaining timeouts to 10 seconds:
746
- #
747
- # ::Google::Cloud::Logging::V2::LoggingService::Client.configure do |config|
748
- # config.timeout = 10.0
749
- # config.rpcs.delete_log.timeout = 20.0
750
- # end
751
- #
752
- # To apply the above configuration only to a new client:
753
- #
754
- # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
755
- # config.timeout = 10.0
756
- # config.rpcs.delete_log.timeout = 20.0
757
- # end
845
+ # @example
846
+ #
847
+ # # Modify the global config, setting the timeout for
848
+ # # delete_log to 20 seconds,
849
+ # # and all remaining timeouts to 10 seconds.
850
+ # ::Google::Cloud::Logging::V2::LoggingService::Client.configure do |config|
851
+ # config.timeout = 10.0
852
+ # config.rpcs.delete_log.timeout = 20.0
853
+ # end
854
+ #
855
+ # # Apply the above configuration only to a new client.
856
+ # client = ::Google::Cloud::Logging::V2::LoggingService::Client.new do |config|
857
+ # config.timeout = 10.0
858
+ # config.rpcs.delete_log.timeout = 20.0
859
+ # end
758
860
  #
759
861
  # @!attribute [rw] endpoint
760
862
  # The hostname or hostname:port of the service endpoint.