google-cloud-privileged_access_manager-v1 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -177,15 +177,27 @@ module Google
177
177
  endpoint: @config.endpoint,
178
178
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
179
179
  universe_domain: @config.universe_domain,
180
- credentials: credentials
180
+ credentials: credentials,
181
+ logger: @config.logger
181
182
  )
182
183
 
184
+ @privileged_access_manager_stub.logger(stub: true)&.info do |entry|
185
+ entry.set_system_name
186
+ entry.set_service
187
+ entry.message = "Created client for #{entry.service}"
188
+ entry.set_credentials_fields credentials
189
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
190
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
191
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
192
+ end
193
+
183
194
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
184
195
  config.credentials = credentials
185
196
  config.quota_project = @quota_project_id
186
197
  config.endpoint = @privileged_access_manager_stub.endpoint
187
198
  config.universe_domain = @privileged_access_manager_stub.universe_domain
188
199
  config.bindings_override = @config.bindings_override
200
+ config.logger = @privileged_access_manager_stub.logger if config.respond_to? :logger=
189
201
  end
190
202
  end
191
203
 
@@ -203,10 +215,19 @@ module Google
203
215
  #
204
216
  attr_reader :location_client
205
217
 
218
+ ##
219
+ # The logger used for request/response debug logging.
220
+ #
221
+ # @return [Logger]
222
+ #
223
+ def logger
224
+ @privileged_access_manager_stub.logger
225
+ end
226
+
206
227
  # Service calls
207
228
 
208
229
  ##
209
- # CheckOnboardingStatus reports the onboarding status for a
230
+ # `CheckOnboardingStatus` reports the onboarding status for a
210
231
  # project/folder/organization. Any findings reported by this API need to be
211
232
  # fixed before PAM can be used on the resource.
212
233
  #
@@ -285,7 +306,6 @@ module Google
285
306
 
286
307
  @privileged_access_manager_stub.check_onboarding_status request, options do |result, operation|
287
308
  yield result, operation if block_given?
288
- return result
289
309
  end
290
310
  rescue ::Gapic::Rest::Error => e
291
311
  raise ::Google::Cloud::Error.from_error(e)
@@ -377,7 +397,6 @@ module Google
377
397
 
378
398
  @privileged_access_manager_stub.list_entitlements request, options do |result, operation|
379
399
  yield result, operation if block_given?
380
- return result
381
400
  end
382
401
  rescue ::Gapic::Rest::Error => e
383
402
  raise ::Google::Cloud::Error.from_error(e)
@@ -473,7 +492,7 @@ module Google
473
492
  @privileged_access_manager_stub.search_entitlements request, options do |result, operation|
474
493
  result = ::Gapic::Rest::PagedEnumerable.new @privileged_access_manager_stub, :search_entitlements, "entitlements", request, result, options
475
494
  yield result, operation if block_given?
476
- return result
495
+ throw :response, result
477
496
  end
478
497
  rescue ::Gapic::Rest::Error => e
479
498
  raise ::Google::Cloud::Error.from_error(e)
@@ -552,7 +571,6 @@ module Google
552
571
 
553
572
  @privileged_access_manager_stub.get_entitlement request, options do |result, operation|
554
573
  yield result, operation if block_given?
555
- return result
556
574
  end
557
575
  rescue ::Gapic::Rest::Error => e
558
576
  raise ::Google::Cloud::Error.from_error(e)
@@ -606,7 +624,7 @@ module Google
606
624
  # ID, the server can check if original operation with the same request ID
607
625
  # was received, and if so, ignores the second request and returns the
608
626
  # previous operation's response. This prevents clients from accidentally
609
- # creating duplicate commitments.
627
+ # creating duplicate entitlements.
610
628
  #
611
629
  # The request ID must be a valid UUID with the exception that zero UUID is
612
630
  # not supported (00000000-0000-0000-0000-000000000000).
@@ -671,7 +689,7 @@ module Google
671
689
  @privileged_access_manager_stub.create_entitlement request, options do |result, operation|
672
690
  result = ::Gapic::Operation.new result, @operations_client, options: options
673
691
  yield result, operation if block_given?
674
- return result
692
+ throw :response, result
675
693
  end
676
694
  rescue ::Gapic::Rest::Error => e
677
695
  raise ::Google::Cloud::Error.from_error(e)
@@ -679,7 +697,7 @@ module Google
679
697
 
680
698
  ##
681
699
  # Deletes a single entitlement. This method can only be called when there
682
- # are no in-progress (ACTIVE/ACTIVATING/REVOKING) grants under the
700
+ # are no in-progress (`ACTIVE`/`ACTIVATING`/`REVOKING`) grants under the
683
701
  # entitlement.
684
702
  #
685
703
  # @overload delete_entitlement(request, options = nil)
@@ -708,8 +726,7 @@ module Google
708
726
  # For example, consider a situation where you make an initial request and the
709
727
  # request times out. If you make the request again with the same request
710
728
  # ID, the server can check if original operation with the same request ID
711
- # was received, and if so, ignores the second request. This prevents
712
- # clients from accidentally creating duplicate commitments.
729
+ # was received, and if so, ignores the second request.
713
730
  #
714
731
  # The request ID must be a valid UUID with the exception that zero UUID is
715
732
  # not supported (00000000-0000-0000-0000-000000000000).
@@ -778,7 +795,7 @@ module Google
778
795
  @privileged_access_manager_stub.delete_entitlement request, options do |result, operation|
779
796
  result = ::Gapic::Operation.new result, @operations_client, options: options
780
797
  yield result, operation if block_given?
781
- return result
798
+ throw :response, result
782
799
  end
783
800
  rescue ::Gapic::Rest::Error => e
784
801
  raise ::Google::Cloud::Error.from_error(e)
@@ -894,7 +911,7 @@ module Google
894
911
  @privileged_access_manager_stub.update_entitlement request, options do |result, operation|
895
912
  result = ::Gapic::Operation.new result, @operations_client, options: options
896
913
  yield result, operation if block_given?
897
- return result
914
+ throw :response, result
898
915
  end
899
916
  rescue ::Gapic::Rest::Error => e
900
917
  raise ::Google::Cloud::Error.from_error(e)
@@ -986,7 +1003,6 @@ module Google
986
1003
 
987
1004
  @privileged_access_manager_stub.list_grants request, options do |result, operation|
988
1005
  yield result, operation if block_given?
989
- return result
990
1006
  end
991
1007
  rescue ::Gapic::Rest::Error => e
992
1008
  raise ::Google::Cloud::Error.from_error(e)
@@ -1081,7 +1097,7 @@ module Google
1081
1097
  @privileged_access_manager_stub.search_grants request, options do |result, operation|
1082
1098
  result = ::Gapic::Rest::PagedEnumerable.new @privileged_access_manager_stub, :search_grants, "grants", request, result, options
1083
1099
  yield result, operation if block_given?
1084
- return result
1100
+ throw :response, result
1085
1101
  end
1086
1102
  rescue ::Gapic::Rest::Error => e
1087
1103
  raise ::Google::Cloud::Error.from_error(e)
@@ -1160,14 +1176,14 @@ module Google
1160
1176
 
1161
1177
  @privileged_access_manager_stub.get_grant request, options do |result, operation|
1162
1178
  yield result, operation if block_given?
1163
- return result
1164
1179
  end
1165
1180
  rescue ::Gapic::Rest::Error => e
1166
1181
  raise ::Google::Cloud::Error.from_error(e)
1167
1182
  end
1168
1183
 
1169
1184
  ##
1170
- # Creates a new grant in a given project and location.
1185
+ # Creates a new grant in a given project/folder/organization and
1186
+ # location.
1171
1187
  #
1172
1188
  # @overload create_grant(request, options = nil)
1173
1189
  # Pass arguments to `create_grant` via a request object, either of type
@@ -1199,7 +1215,7 @@ module Google
1199
1215
  # request times out. If you make the request again with the same request
1200
1216
  # ID, the server can check if original operation with the same request ID
1201
1217
  # was received, and if so, ignores the second request. This prevents
1202
- # clients from accidentally creating duplicate commitments.
1218
+ # clients from accidentally creating duplicate grants.
1203
1219
  #
1204
1220
  # The request ID must be a valid UUID with the exception that zero UUID is
1205
1221
  # not supported (00000000-0000-0000-0000-000000000000).
@@ -1256,7 +1272,6 @@ module Google
1256
1272
 
1257
1273
  @privileged_access_manager_stub.create_grant request, options do |result, operation|
1258
1274
  yield result, operation if block_given?
1259
- return result
1260
1275
  end
1261
1276
  rescue ::Gapic::Rest::Error => e
1262
1277
  raise ::Google::Cloud::Error.from_error(e)
@@ -1341,7 +1356,6 @@ module Google
1341
1356
 
1342
1357
  @privileged_access_manager_stub.approve_grant request, options do |result, operation|
1343
1358
  yield result, operation if block_given?
1344
- return result
1345
1359
  end
1346
1360
  rescue ::Gapic::Rest::Error => e
1347
1361
  raise ::Google::Cloud::Error.from_error(e)
@@ -1426,7 +1440,6 @@ module Google
1426
1440
 
1427
1441
  @privileged_access_manager_stub.deny_grant request, options do |result, operation|
1428
1442
  yield result, operation if block_given?
1429
- return result
1430
1443
  end
1431
1444
  rescue ::Gapic::Rest::Error => e
1432
1445
  raise ::Google::Cloud::Error.from_error(e)
@@ -1516,7 +1529,7 @@ module Google
1516
1529
  @privileged_access_manager_stub.revoke_grant request, options do |result, operation|
1517
1530
  result = ::Gapic::Operation.new result, @operations_client, options: options
1518
1531
  yield result, operation if block_given?
1519
- return result
1532
+ throw :response, result
1520
1533
  end
1521
1534
  rescue ::Gapic::Rest::Error => e
1522
1535
  raise ::Google::Cloud::Error.from_error(e)
@@ -1564,6 +1577,13 @@ module Google
1564
1577
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1565
1578
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1566
1579
  # * (`nil`) indicating no credentials
1580
+ #
1581
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
1582
+ # external source for authentication to Google Cloud, you must validate it before
1583
+ # providing it to a Google API client library. Providing an unvalidated credential
1584
+ # configuration to Google APIs can compromise the security of your systems and data.
1585
+ # For more information, refer to [Validate credential configurations from external
1586
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
1567
1587
  # @return [::Object]
1568
1588
  # @!attribute [rw] scope
1569
1589
  # The OAuth scopes
@@ -1596,6 +1616,11 @@ module Google
1596
1616
  # default endpoint URL. The default value of nil uses the environment
1597
1617
  # universe (usually the default "googleapis.com" universe).
1598
1618
  # @return [::String,nil]
1619
+ # @!attribute [rw] logger
1620
+ # A custom logger to use for request/response debug logging, or the value
1621
+ # `:default` (the default) to construct a default logger, or `nil` to
1622
+ # explicitly disable logging.
1623
+ # @return [::Logger,:default,nil]
1599
1624
  #
1600
1625
  class Configuration
1601
1626
  extend ::Gapic::Config
@@ -1624,6 +1649,7 @@ module Google
1624
1649
  # by the host service.
1625
1650
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
1626
1651
  config_attr :bindings_override, {}, ::Hash, nil
1652
+ config_attr :logger, :default, ::Logger, nil, :default
1627
1653
 
1628
1654
  # @private
1629
1655
  def initialize parent_config = nil
@@ -115,14 +115,6 @@ module Google
115
115
  # Lists operations that match the specified filter in the request. If the
116
116
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
117
117
  #
118
- # NOTE: the `name` binding allows API services to override the binding
119
- # to use different resource name schemes, such as `users/*/operations`. To
120
- # override the binding, API services can add a binding such as
121
- # `"/v1/{name=users/*}/operations"` to their service configuration.
122
- # For backwards compatibility, the default name includes the operations
123
- # collection id, however overriding users must ensure the name binding
124
- # is the parent resource, without the operations collection id.
125
- #
126
118
  # @overload list_operations(request, options = nil)
127
119
  # Pass arguments to `list_operations` via a request object, either of type
128
120
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -204,7 +196,7 @@ module Google
204
196
  @operations_stub.list_operations request, options do |result, operation|
205
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
206
198
  yield result, operation if block_given?
207
- return result
199
+ throw :response, result
208
200
  end
209
201
  rescue ::Gapic::Rest::Error => e
210
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -293,7 +285,7 @@ module Google
293
285
  @operations_stub.get_operation request, options do |result, operation|
294
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
295
287
  yield result, operation if block_given?
296
- return result
288
+ throw :response, result
297
289
  end
298
290
  rescue ::Gapic::Rest::Error => e
299
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -375,7 +367,6 @@ module Google
375
367
 
376
368
  @operations_stub.delete_operation request, options do |result, operation|
377
369
  yield result, operation if block_given?
378
- return result
379
370
  end
380
371
  rescue ::Gapic::Rest::Error => e
381
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -390,8 +381,9 @@ module Google
390
381
  # other methods to check whether the cancellation succeeded or whether the
391
382
  # operation completed despite cancellation. On successful cancellation,
392
383
  # the operation is not deleted; instead, it becomes an operation with
393
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
394
- # corresponding to `Code.CANCELLED`.
384
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
385
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
386
+ # `Code.CANCELLED`.
395
387
  #
396
388
  # @overload cancel_operation(request, options = nil)
397
389
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -463,7 +455,6 @@ module Google
463
455
 
464
456
  @operations_stub.cancel_operation request, options do |result, operation|
465
457
  yield result, operation if block_given?
466
- return result
467
458
  end
468
459
  rescue ::Gapic::Rest::Error => e
469
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -511,6 +502,13 @@ module Google
511
502
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
512
503
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
513
504
  # * (`nil`) indicating no credentials
505
+ #
506
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
507
+ # external source for authentication to Google Cloud, you must validate it before
508
+ # providing it to a Google API client library. Providing an unvalidated credential
509
+ # configuration to Google APIs can compromise the security of your systems and data.
510
+ # For more information, refer to [Validate credential configurations from external
511
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
514
512
  # @return [::Object]
515
513
  # @!attribute [rw] scope
516
514
  # The OAuth scopes
@@ -543,6 +541,11 @@ module Google
543
541
  # default endpoint URL. The default value of nil uses the environment
544
542
  # universe (usually the default "googleapis.com" universe).
545
543
  # @return [::String,nil]
544
+ # @!attribute [rw] logger
545
+ # A custom logger to use for request/response debug logging, or the value
546
+ # `:default` (the default) to construct a default logger, or `nil` to
547
+ # explicitly disable logging.
548
+ # @return [::Logger,:default,nil]
546
549
  #
547
550
  class Configuration
548
551
  extend ::Gapic::Config
@@ -564,6 +567,7 @@ module Google
564
567
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
565
568
  config_attr :quota_project, nil, ::String, nil
566
569
  config_attr :universe_domain, nil, ::String, nil
570
+ config_attr :logger, :default, ::Logger, nil, :default
567
571
 
568
572
  # @private
569
573
  def initialize parent_config = nil
@@ -683,16 +687,18 @@ module Google
683
687
 
684
688
  response = @client_stub.make_http_request(
685
689
  verb,
686
- uri: uri,
687
- body: body || "",
688
- params: query_string_params,
690
+ uri: uri,
691
+ body: body || "",
692
+ params: query_string_params,
693
+ method_name: "list_operations",
689
694
  options: options
690
695
  )
691
696
  operation = ::Gapic::Rest::TransportOperation.new response
692
697
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
693
-
694
- yield result, operation if block_given?
695
- result
698
+ catch :response do
699
+ yield result, operation if block_given?
700
+ result
701
+ end
696
702
  end
697
703
 
698
704
  ##
@@ -721,16 +727,18 @@ module Google
721
727
 
722
728
  response = @client_stub.make_http_request(
723
729
  verb,
724
- uri: uri,
725
- body: body || "",
726
- params: query_string_params,
730
+ uri: uri,
731
+ body: body || "",
732
+ params: query_string_params,
733
+ method_name: "get_operation",
727
734
  options: options
728
735
  )
729
736
  operation = ::Gapic::Rest::TransportOperation.new response
730
737
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
731
-
732
- yield result, operation if block_given?
733
- result
738
+ catch :response do
739
+ yield result, operation if block_given?
740
+ result
741
+ end
734
742
  end
735
743
 
736
744
  ##
@@ -759,16 +767,18 @@ module Google
759
767
 
760
768
  response = @client_stub.make_http_request(
761
769
  verb,
762
- uri: uri,
763
- body: body || "",
764
- params: query_string_params,
770
+ uri: uri,
771
+ body: body || "",
772
+ params: query_string_params,
773
+ method_name: "delete_operation",
765
774
  options: options
766
775
  )
767
776
  operation = ::Gapic::Rest::TransportOperation.new response
768
777
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
769
-
770
- yield result, operation if block_given?
771
- result
778
+ catch :response do
779
+ yield result, operation if block_given?
780
+ result
781
+ end
772
782
  end
773
783
 
774
784
  ##
@@ -797,16 +807,18 @@ module Google
797
807
 
798
808
  response = @client_stub.make_http_request(
799
809
  verb,
800
- uri: uri,
801
- body: body || "",
802
- params: query_string_params,
810
+ uri: uri,
811
+ body: body || "",
812
+ params: query_string_params,
813
+ method_name: "cancel_operation",
803
814
  options: options
804
815
  )
805
816
  operation = ::Gapic::Rest::TransportOperation.new response
806
817
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
807
-
808
- yield result, operation if block_given?
809
- result
818
+ catch :response do
819
+ yield result, operation if block_given?
820
+ result
821
+ end
810
822
  end
811
823
 
812
824
  ##