google-cloud-workstations-v1beta 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -226,14 +226,26 @@ module Google
226
226
  endpoint: @config.endpoint,
227
227
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
228
228
  universe_domain: @config.universe_domain,
229
- credentials: credentials
229
+ credentials: credentials,
230
+ logger: @config.logger
230
231
  )
231
232
 
233
+ @workstations_stub.logger(stub: true)&.info do |entry|
234
+ entry.set_system_name
235
+ entry.set_service
236
+ entry.message = "Created client for #{entry.service}"
237
+ entry.set_credentials_fields credentials
238
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
239
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
240
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
241
+ end
242
+
232
243
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
233
244
  config.credentials = credentials
234
245
  config.quota_project = @quota_project_id
235
246
  config.endpoint = @workstations_stub.endpoint
236
247
  config.universe_domain = @workstations_stub.universe_domain
248
+ config.logger = @workstations_stub.logger if config.respond_to? :logger=
237
249
  end
238
250
 
239
251
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
@@ -242,6 +254,7 @@ module Google
242
254
  config.endpoint = @workstations_stub.endpoint
243
255
  config.universe_domain = @workstations_stub.universe_domain
244
256
  config.bindings_override = @config.bindings_override
257
+ config.logger = @workstations_stub.logger if config.respond_to? :logger=
245
258
  end
246
259
  end
247
260
 
@@ -266,6 +279,15 @@ module Google
266
279
  #
267
280
  attr_reader :iam_policy_client
268
281
 
282
+ ##
283
+ # The logger used for request/response debug logging.
284
+ #
285
+ # @return [Logger]
286
+ #
287
+ def logger
288
+ @workstations_stub.logger
289
+ end
290
+
269
291
  # Service calls
270
292
 
271
293
  ##
@@ -341,7 +363,6 @@ module Google
341
363
 
342
364
  @workstations_stub.get_workstation_cluster request, options do |result, operation|
343
365
  yield result, operation if block_given?
344
- return result
345
366
  end
346
367
  rescue ::Gapic::Rest::Error => e
347
368
  raise ::Google::Cloud::Error.from_error(e)
@@ -429,7 +450,6 @@ module Google
429
450
 
430
451
  @workstations_stub.list_workstation_clusters request, options do |result, operation|
431
452
  yield result, operation if block_given?
432
- return result
433
453
  end
434
454
  rescue ::Gapic::Rest::Error => e
435
455
  raise ::Google::Cloud::Error.from_error(e)
@@ -523,7 +543,7 @@ module Google
523
543
  @workstations_stub.create_workstation_cluster request, options do |result, operation|
524
544
  result = ::Gapic::Operation.new result, @operations_client, options: options
525
545
  yield result, operation if block_given?
526
- return result
546
+ throw :response, result
527
547
  end
528
548
  rescue ::Gapic::Rest::Error => e
529
549
  raise ::Google::Cloud::Error.from_error(e)
@@ -620,7 +640,7 @@ module Google
620
640
  @workstations_stub.update_workstation_cluster request, options do |result, operation|
621
641
  result = ::Gapic::Operation.new result, @operations_client, options: options
622
642
  yield result, operation if block_given?
623
- return result
643
+ throw :response, result
624
644
  end
625
645
  rescue ::Gapic::Rest::Error => e
626
646
  raise ::Google::Cloud::Error.from_error(e)
@@ -717,7 +737,7 @@ module Google
717
737
  @workstations_stub.delete_workstation_cluster request, options do |result, operation|
718
738
  result = ::Gapic::Operation.new result, @operations_client, options: options
719
739
  yield result, operation if block_given?
720
- return result
740
+ throw :response, result
721
741
  end
722
742
  rescue ::Gapic::Rest::Error => e
723
743
  raise ::Google::Cloud::Error.from_error(e)
@@ -796,7 +816,6 @@ module Google
796
816
 
797
817
  @workstations_stub.get_workstation_config request, options do |result, operation|
798
818
  yield result, operation if block_given?
799
- return result
800
819
  end
801
820
  rescue ::Gapic::Rest::Error => e
802
821
  raise ::Google::Cloud::Error.from_error(e)
@@ -884,7 +903,6 @@ module Google
884
903
 
885
904
  @workstations_stub.list_workstation_configs request, options do |result, operation|
886
905
  yield result, operation if block_given?
887
- return result
888
906
  end
889
907
  rescue ::Gapic::Rest::Error => e
890
908
  raise ::Google::Cloud::Error.from_error(e)
@@ -973,7 +991,6 @@ module Google
973
991
 
974
992
  @workstations_stub.list_usable_workstation_configs request, options do |result, operation|
975
993
  yield result, operation if block_given?
976
- return result
977
994
  end
978
995
  rescue ::Gapic::Rest::Error => e
979
996
  raise ::Google::Cloud::Error.from_error(e)
@@ -1067,7 +1084,7 @@ module Google
1067
1084
  @workstations_stub.create_workstation_config request, options do |result, operation|
1068
1085
  result = ::Gapic::Operation.new result, @operations_client, options: options
1069
1086
  yield result, operation if block_given?
1070
- return result
1087
+ throw :response, result
1071
1088
  end
1072
1089
  rescue ::Gapic::Rest::Error => e
1073
1090
  raise ::Google::Cloud::Error.from_error(e)
@@ -1164,7 +1181,7 @@ module Google
1164
1181
  @workstations_stub.update_workstation_config request, options do |result, operation|
1165
1182
  result = ::Gapic::Operation.new result, @operations_client, options: options
1166
1183
  yield result, operation if block_given?
1167
- return result
1184
+ throw :response, result
1168
1185
  end
1169
1186
  rescue ::Gapic::Rest::Error => e
1170
1187
  raise ::Google::Cloud::Error.from_error(e)
@@ -1261,7 +1278,7 @@ module Google
1261
1278
  @workstations_stub.delete_workstation_config request, options do |result, operation|
1262
1279
  result = ::Gapic::Operation.new result, @operations_client, options: options
1263
1280
  yield result, operation if block_given?
1264
- return result
1281
+ throw :response, result
1265
1282
  end
1266
1283
  rescue ::Gapic::Rest::Error => e
1267
1284
  raise ::Google::Cloud::Error.from_error(e)
@@ -1340,7 +1357,6 @@ module Google
1340
1357
 
1341
1358
  @workstations_stub.get_workstation request, options do |result, operation|
1342
1359
  yield result, operation if block_given?
1343
- return result
1344
1360
  end
1345
1361
  rescue ::Gapic::Rest::Error => e
1346
1362
  raise ::Google::Cloud::Error.from_error(e)
@@ -1428,7 +1444,6 @@ module Google
1428
1444
 
1429
1445
  @workstations_stub.list_workstations request, options do |result, operation|
1430
1446
  yield result, operation if block_given?
1431
- return result
1432
1447
  end
1433
1448
  rescue ::Gapic::Rest::Error => e
1434
1449
  raise ::Google::Cloud::Error.from_error(e)
@@ -1517,7 +1532,6 @@ module Google
1517
1532
 
1518
1533
  @workstations_stub.list_usable_workstations request, options do |result, operation|
1519
1534
  yield result, operation if block_given?
1520
- return result
1521
1535
  end
1522
1536
  rescue ::Gapic::Rest::Error => e
1523
1537
  raise ::Google::Cloud::Error.from_error(e)
@@ -1611,7 +1625,7 @@ module Google
1611
1625
  @workstations_stub.create_workstation request, options do |result, operation|
1612
1626
  result = ::Gapic::Operation.new result, @operations_client, options: options
1613
1627
  yield result, operation if block_given?
1614
- return result
1628
+ throw :response, result
1615
1629
  end
1616
1630
  rescue ::Gapic::Rest::Error => e
1617
1631
  raise ::Google::Cloud::Error.from_error(e)
@@ -1708,7 +1722,7 @@ module Google
1708
1722
  @workstations_stub.update_workstation request, options do |result, operation|
1709
1723
  result = ::Gapic::Operation.new result, @operations_client, options: options
1710
1724
  yield result, operation if block_given?
1711
- return result
1725
+ throw :response, result
1712
1726
  end
1713
1727
  rescue ::Gapic::Rest::Error => e
1714
1728
  raise ::Google::Cloud::Error.from_error(e)
@@ -1801,7 +1815,7 @@ module Google
1801
1815
  @workstations_stub.delete_workstation request, options do |result, operation|
1802
1816
  result = ::Gapic::Operation.new result, @operations_client, options: options
1803
1817
  yield result, operation if block_given?
1804
- return result
1818
+ throw :response, result
1805
1819
  end
1806
1820
  rescue ::Gapic::Rest::Error => e
1807
1821
  raise ::Google::Cloud::Error.from_error(e)
@@ -1894,7 +1908,7 @@ module Google
1894
1908
  @workstations_stub.start_workstation request, options do |result, operation|
1895
1909
  result = ::Gapic::Operation.new result, @operations_client, options: options
1896
1910
  yield result, operation if block_given?
1897
- return result
1911
+ throw :response, result
1898
1912
  end
1899
1913
  rescue ::Gapic::Rest::Error => e
1900
1914
  raise ::Google::Cloud::Error.from_error(e)
@@ -1987,7 +2001,7 @@ module Google
1987
2001
  @workstations_stub.stop_workstation request, options do |result, operation|
1988
2002
  result = ::Gapic::Operation.new result, @operations_client, options: options
1989
2003
  yield result, operation if block_given?
1990
- return result
2004
+ throw :response, result
1991
2005
  end
1992
2006
  rescue ::Gapic::Rest::Error => e
1993
2007
  raise ::Google::Cloud::Error.from_error(e)
@@ -2017,10 +2031,14 @@ module Google
2017
2031
  # be at most 24 hours in the future. If a value is not specified, the
2018
2032
  # token's expiration time will be set to a default value of 1 hour in the
2019
2033
  # future.
2034
+ #
2035
+ # Note: The following fields are mutually exclusive: `expire_time`, `ttl`. If a field in that set is populated, all other fields in the set will automatically be cleared.
2020
2036
  # @param ttl [::Google::Protobuf::Duration, ::Hash]
2021
2037
  # Desired lifetime duration of the access token. This value must
2022
2038
  # be at most 24 hours. If a value is not specified, the token's lifetime
2023
2039
  # will be set to a default value of 1 hour.
2040
+ #
2041
+ # Note: The following fields are mutually exclusive: `ttl`, `expire_time`. If a field in that set is populated, all other fields in the set will automatically be cleared.
2024
2042
  # @param workstation [::String]
2025
2043
  # Required. Name of the workstation for which the access token should be
2026
2044
  # generated.
@@ -2077,7 +2095,6 @@ module Google
2077
2095
 
2078
2096
  @workstations_stub.generate_access_token request, options do |result, operation|
2079
2097
  yield result, operation if block_given?
2080
- return result
2081
2098
  end
2082
2099
  rescue ::Gapic::Rest::Error => e
2083
2100
  raise ::Google::Cloud::Error.from_error(e)
@@ -2125,6 +2142,13 @@ module Google
2125
2142
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2126
2143
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2127
2144
  # * (`nil`) indicating no credentials
2145
+ #
2146
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
2147
+ # external source for authentication to Google Cloud, you must validate it before
2148
+ # providing it to a Google API client library. Providing an unvalidated credential
2149
+ # configuration to Google APIs can compromise the security of your systems and data.
2150
+ # For more information, refer to [Validate credential configurations from external
2151
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2128
2152
  # @return [::Object]
2129
2153
  # @!attribute [rw] scope
2130
2154
  # The OAuth scopes
@@ -2157,6 +2181,11 @@ module Google
2157
2181
  # default endpoint URL. The default value of nil uses the environment
2158
2182
  # universe (usually the default "googleapis.com" universe).
2159
2183
  # @return [::String,nil]
2184
+ # @!attribute [rw] logger
2185
+ # A custom logger to use for request/response debug logging, or the value
2186
+ # `:default` (the default) to construct a default logger, or `nil` to
2187
+ # explicitly disable logging.
2188
+ # @return [::Logger,:default,nil]
2160
2189
  #
2161
2190
  class Configuration
2162
2191
  extend ::Gapic::Config
@@ -2185,6 +2214,7 @@ module Google
2185
2214
  # by the host service.
2186
2215
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2187
2216
  config_attr :bindings_override, {}, ::Hash, nil
2217
+ config_attr :logger, :default, ::Logger, nil, :default
2188
2218
 
2189
2219
  # @private
2190
2220
  def initialize parent_config = nil
@@ -196,7 +196,7 @@ module Google
196
196
  @operations_stub.list_operations request, options do |result, operation|
197
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
198
198
  yield result, operation if block_given?
199
- return result
199
+ throw :response, result
200
200
  end
201
201
  rescue ::Gapic::Rest::Error => e
202
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -285,7 +285,7 @@ module Google
285
285
  @operations_stub.get_operation request, options do |result, operation|
286
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
287
287
  yield result, operation if block_given?
288
- return result
288
+ throw :response, result
289
289
  end
290
290
  rescue ::Gapic::Rest::Error => e
291
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -367,7 +367,6 @@ module Google
367
367
 
368
368
  @operations_stub.delete_operation request, options do |result, operation|
369
369
  yield result, operation if block_given?
370
- return result
371
370
  end
372
371
  rescue ::Gapic::Rest::Error => e
373
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -456,7 +455,6 @@ module Google
456
455
 
457
456
  @operations_stub.cancel_operation request, options do |result, operation|
458
457
  yield result, operation if block_given?
459
- return result
460
458
  end
461
459
  rescue ::Gapic::Rest::Error => e
462
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -504,6 +502,13 @@ module Google
504
502
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
505
503
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
506
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).
507
512
  # @return [::Object]
508
513
  # @!attribute [rw] scope
509
514
  # The OAuth scopes
@@ -536,6 +541,11 @@ module Google
536
541
  # default endpoint URL. The default value of nil uses the environment
537
542
  # universe (usually the default "googleapis.com" universe).
538
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]
539
549
  #
540
550
  class Configuration
541
551
  extend ::Gapic::Config
@@ -557,6 +567,7 @@ module Google
557
567
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
558
568
  config_attr :quota_project, nil, ::String, nil
559
569
  config_attr :universe_domain, nil, ::String, nil
570
+ config_attr :logger, :default, ::Logger, nil, :default
560
571
 
561
572
  # @private
562
573
  def initialize parent_config = nil
@@ -676,16 +687,18 @@ module Google
676
687
 
677
688
  response = @client_stub.make_http_request(
678
689
  verb,
679
- uri: uri,
680
- body: body || "",
681
- params: query_string_params,
690
+ uri: uri,
691
+ body: body || "",
692
+ params: query_string_params,
693
+ method_name: "list_operations",
682
694
  options: options
683
695
  )
684
696
  operation = ::Gapic::Rest::TransportOperation.new response
685
697
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
686
-
687
- yield result, operation if block_given?
688
- result
698
+ catch :response do
699
+ yield result, operation if block_given?
700
+ result
701
+ end
689
702
  end
690
703
 
691
704
  ##
@@ -714,16 +727,18 @@ module Google
714
727
 
715
728
  response = @client_stub.make_http_request(
716
729
  verb,
717
- uri: uri,
718
- body: body || "",
719
- params: query_string_params,
730
+ uri: uri,
731
+ body: body || "",
732
+ params: query_string_params,
733
+ method_name: "get_operation",
720
734
  options: options
721
735
  )
722
736
  operation = ::Gapic::Rest::TransportOperation.new response
723
737
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
724
-
725
- yield result, operation if block_given?
726
- result
738
+ catch :response do
739
+ yield result, operation if block_given?
740
+ result
741
+ end
727
742
  end
728
743
 
729
744
  ##
@@ -752,16 +767,18 @@ module Google
752
767
 
753
768
  response = @client_stub.make_http_request(
754
769
  verb,
755
- uri: uri,
756
- body: body || "",
757
- params: query_string_params,
770
+ uri: uri,
771
+ body: body || "",
772
+ params: query_string_params,
773
+ method_name: "delete_operation",
758
774
  options: options
759
775
  )
760
776
  operation = ::Gapic::Rest::TransportOperation.new response
761
777
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
762
-
763
- yield result, operation if block_given?
764
- result
778
+ catch :response do
779
+ yield result, operation if block_given?
780
+ result
781
+ end
765
782
  end
766
783
 
767
784
  ##
@@ -790,16 +807,18 @@ module Google
790
807
 
791
808
  response = @client_stub.make_http_request(
792
809
  verb,
793
- uri: uri,
794
- body: body || "",
795
- params: query_string_params,
810
+ uri: uri,
811
+ body: body || "",
812
+ params: query_string_params,
813
+ method_name: "cancel_operation",
796
814
  options: options
797
815
  )
798
816
  operation = ::Gapic::Rest::TransportOperation.new response
799
817
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
800
-
801
- yield result, operation if block_given?
802
- result
818
+ catch :response do
819
+ yield result, operation if block_given?
820
+ result
821
+ end
803
822
  end
804
823
 
805
824
  ##