google-cloud-asset-v1 0.7.0 → 0.11.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.
@@ -33,3 +33,6 @@ module Google
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ helper_path = ::File.join __dir__, "v1", "_helpers.rb"
38
+ require "google/cloud/asset/v1/_helpers" if ::File.file? helper_path
@@ -60,7 +60,7 @@ module Google
60
60
  parent_config = while namespace.any?
61
61
  parent_name = namespace.join "::"
62
62
  parent_const = const_get parent_name
63
- break parent_const.configure if parent_const&.respond_to? :configure
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
64
  namespace.pop
65
65
  end
66
66
  default_config = Client::Configuration.new parent_config
@@ -70,9 +70,9 @@ module Google
70
70
  default_config.rpcs.batch_get_assets_history.timeout = 60.0
71
71
  default_config.rpcs.batch_get_assets_history.retry_policy = {
72
72
  initial_delay: 0.1,
73
- max_delay: 60.0,
74
- multiplier: 1.3,
75
- retry_codes: [4, 14]
73
+ max_delay: 60.0,
74
+ multiplier: 1.3,
75
+ retry_codes: [4, 14]
76
76
  }
77
77
 
78
78
  default_config.rpcs.create_feed.timeout = 60.0
@@ -80,17 +80,17 @@ module Google
80
80
  default_config.rpcs.get_feed.timeout = 60.0
81
81
  default_config.rpcs.get_feed.retry_policy = {
82
82
  initial_delay: 0.1,
83
- max_delay: 60.0,
84
- multiplier: 1.3,
85
- retry_codes: [4, 14]
83
+ max_delay: 60.0,
84
+ multiplier: 1.3,
85
+ retry_codes: [4, 14]
86
86
  }
87
87
 
88
88
  default_config.rpcs.list_feeds.timeout = 60.0
89
89
  default_config.rpcs.list_feeds.retry_policy = {
90
90
  initial_delay: 0.1,
91
- max_delay: 60.0,
92
- multiplier: 1.3,
93
- retry_codes: [4, 14]
91
+ max_delay: 60.0,
92
+ multiplier: 1.3,
93
+ retry_codes: [4, 14]
94
94
  }
95
95
 
96
96
  default_config.rpcs.update_feed.timeout = 60.0
@@ -98,27 +98,37 @@ module Google
98
98
  default_config.rpcs.delete_feed.timeout = 60.0
99
99
  default_config.rpcs.delete_feed.retry_policy = {
100
100
  initial_delay: 0.1,
101
- max_delay: 60.0,
102
- multiplier: 1.3,
103
- retry_codes: [4, 14]
101
+ max_delay: 60.0,
102
+ multiplier: 1.3,
103
+ retry_codes: [4, 14]
104
104
  }
105
105
 
106
106
  default_config.rpcs.search_all_resources.timeout = 15.0
107
107
  default_config.rpcs.search_all_resources.retry_policy = {
108
108
  initial_delay: 0.1,
109
- max_delay: 60.0,
110
- multiplier: 1.3,
111
- retry_codes: [4, 14]
109
+ max_delay: 60.0,
110
+ multiplier: 1.3,
111
+ retry_codes: [4, 14]
112
112
  }
113
113
 
114
114
  default_config.rpcs.search_all_iam_policies.timeout = 15.0
115
115
  default_config.rpcs.search_all_iam_policies.retry_policy = {
116
116
  initial_delay: 0.1,
117
- max_delay: 60.0,
118
- multiplier: 1.3,
119
- retry_codes: [4, 14]
117
+ max_delay: 60.0,
118
+ multiplier: 1.3,
119
+ retry_codes: [4, 14]
120
120
  }
121
121
 
122
+ default_config.rpcs.analyze_iam_policy.timeout = 300.0
123
+ default_config.rpcs.analyze_iam_policy.retry_policy = {
124
+ initial_delay: 0.1,
125
+ max_delay: 60.0,
126
+ multiplier: 1.3,
127
+ retry_codes: [14]
128
+ }
129
+
130
+ default_config.rpcs.analyze_iam_policy_longrunning.timeout = 60.0
131
+
122
132
  default_config
123
133
  end
124
134
  yield @configure if block_given?
@@ -180,7 +190,13 @@ module Google
180
190
 
181
191
  # Create credentials
182
192
  credentials = @config.credentials
183
- credentials ||= Credentials.default scope: @config.scope
193
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
194
+ # but only if the default endpoint does not have a region prefix.
195
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
196
+ @config.endpoint == Client.configure.endpoint &&
197
+ !@config.endpoint.split(".").first.include?("-")
198
+ credentials ||= Credentials.default scope: @config.scope,
199
+ enable_self_signed_jwt: enable_self_signed_jwt
184
200
  if credentials.is_a?(String) || credentials.is_a?(Hash)
185
201
  credentials = Credentials.new credentials, scope: @config.scope
186
202
  end
@@ -1028,6 +1044,161 @@ module Google
1028
1044
  raise ::Google::Cloud::Error.from_error(e)
1029
1045
  end
1030
1046
 
1047
+ ##
1048
+ # Analyzes IAM policies to answer which identities have what accesses on
1049
+ # which resources.
1050
+ #
1051
+ # @overload analyze_iam_policy(request, options = nil)
1052
+ # Pass arguments to `analyze_iam_policy` via a request object, either of type
1053
+ # {::Google::Cloud::Asset::V1::AnalyzeIamPolicyRequest} or an equivalent Hash.
1054
+ #
1055
+ # @param request [::Google::Cloud::Asset::V1::AnalyzeIamPolicyRequest, ::Hash]
1056
+ # A request object representing the call parameters. Required. To specify no
1057
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1058
+ # @param options [::Gapic::CallOptions, ::Hash]
1059
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1060
+ #
1061
+ # @overload analyze_iam_policy(analysis_query: nil, execution_timeout: nil)
1062
+ # Pass arguments to `analyze_iam_policy` via keyword arguments. Note that at
1063
+ # least one keyword argument is required. To specify no parameters, or to keep all
1064
+ # the default parameter values, pass an empty Hash as a request object (see above).
1065
+ #
1066
+ # @param analysis_query [::Google::Cloud::Asset::V1::IamPolicyAnalysisQuery, ::Hash]
1067
+ # Required. The request query.
1068
+ # @param execution_timeout [::Google::Protobuf::Duration, ::Hash]
1069
+ # Optional. Amount of time executable has to complete. See JSON representation of
1070
+ # [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json).
1071
+ #
1072
+ # If this field is set with a value less than the RPC deadline, and the
1073
+ # execution of your query hasn't finished in the specified
1074
+ # execution timeout, you will get a response with partial result.
1075
+ # Otherwise, your query's execution will continue until the RPC deadline.
1076
+ # If it's not finished until then, you will get a DEADLINE_EXCEEDED error.
1077
+ #
1078
+ # Default is empty.
1079
+ #
1080
+ # @yield [response, operation] Access the result along with the RPC operation
1081
+ # @yieldparam response [::Google::Cloud::Asset::V1::AnalyzeIamPolicyResponse]
1082
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1083
+ #
1084
+ # @return [::Google::Cloud::Asset::V1::AnalyzeIamPolicyResponse]
1085
+ #
1086
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1087
+ #
1088
+ def analyze_iam_policy request, options = nil
1089
+ raise ::ArgumentError, "request must be provided" if request.nil?
1090
+
1091
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Asset::V1::AnalyzeIamPolicyRequest
1092
+
1093
+ # Converts hash and nil to an options object
1094
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1095
+
1096
+ # Customize the options with defaults
1097
+ metadata = @config.rpcs.analyze_iam_policy.metadata.to_h
1098
+
1099
+ # Set x-goog-api-client and x-goog-user-project headers
1100
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1101
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1102
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
1103
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1104
+
1105
+ header_params = {
1106
+ "analysis_query.scope" => request.analysis_query.scope
1107
+ }
1108
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1109
+ metadata[:"x-goog-request-params"] ||= request_params_header
1110
+
1111
+ options.apply_defaults timeout: @config.rpcs.analyze_iam_policy.timeout,
1112
+ metadata: metadata,
1113
+ retry_policy: @config.rpcs.analyze_iam_policy.retry_policy
1114
+ options.apply_defaults metadata: @config.metadata,
1115
+ retry_policy: @config.retry_policy
1116
+
1117
+ @asset_service_stub.call_rpc :analyze_iam_policy, request, options: options do |response, operation|
1118
+ yield response, operation if block_given?
1119
+ return response
1120
+ end
1121
+ rescue ::GRPC::BadStatus => e
1122
+ raise ::Google::Cloud::Error.from_error(e)
1123
+ end
1124
+
1125
+ ##
1126
+ # Analyzes IAM policies asynchronously to answer which identities have what
1127
+ # accesses on which resources, and writes the analysis results to a Google
1128
+ # Cloud Storage or a BigQuery destination. For Cloud Storage destination, the
1129
+ # output format is the JSON format that represents a
1130
+ # {::Google::Cloud::Asset::V1::AnalyzeIamPolicyResponse AnalyzeIamPolicyResponse}. This method implements the
1131
+ # {::Google::Longrunning::Operation google.longrunning.Operation}, which allows you to track the operation
1132
+ # status. We recommend intervals of at least 2 seconds with exponential
1133
+ # backoff retry to poll the operation result. The metadata contains the
1134
+ # request to help callers to map responses to requests.
1135
+ #
1136
+ # @overload analyze_iam_policy_longrunning(request, options = nil)
1137
+ # Pass arguments to `analyze_iam_policy_longrunning` via a request object, either of type
1138
+ # {::Google::Cloud::Asset::V1::AnalyzeIamPolicyLongrunningRequest} or an equivalent Hash.
1139
+ #
1140
+ # @param request [::Google::Cloud::Asset::V1::AnalyzeIamPolicyLongrunningRequest, ::Hash]
1141
+ # A request object representing the call parameters. Required. To specify no
1142
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1143
+ # @param options [::Gapic::CallOptions, ::Hash]
1144
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1145
+ #
1146
+ # @overload analyze_iam_policy_longrunning(analysis_query: nil, output_config: nil)
1147
+ # Pass arguments to `analyze_iam_policy_longrunning` via keyword arguments. Note that at
1148
+ # least one keyword argument is required. To specify no parameters, or to keep all
1149
+ # the default parameter values, pass an empty Hash as a request object (see above).
1150
+ #
1151
+ # @param analysis_query [::Google::Cloud::Asset::V1::IamPolicyAnalysisQuery, ::Hash]
1152
+ # Required. The request query.
1153
+ # @param output_config [::Google::Cloud::Asset::V1::IamPolicyAnalysisOutputConfig, ::Hash]
1154
+ # Required. Output configuration indicating where the results will be output to.
1155
+ #
1156
+ # @yield [response, operation] Access the result along with the RPC operation
1157
+ # @yieldparam response [::Gapic::Operation]
1158
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1159
+ #
1160
+ # @return [::Gapic::Operation]
1161
+ #
1162
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1163
+ #
1164
+ def analyze_iam_policy_longrunning request, options = nil
1165
+ raise ::ArgumentError, "request must be provided" if request.nil?
1166
+
1167
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Asset::V1::AnalyzeIamPolicyLongrunningRequest
1168
+
1169
+ # Converts hash and nil to an options object
1170
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1171
+
1172
+ # Customize the options with defaults
1173
+ metadata = @config.rpcs.analyze_iam_policy_longrunning.metadata.to_h
1174
+
1175
+ # Set x-goog-api-client and x-goog-user-project headers
1176
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1177
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1178
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
1179
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1180
+
1181
+ header_params = {
1182
+ "analysis_query.scope" => request.analysis_query.scope
1183
+ }
1184
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1185
+ metadata[:"x-goog-request-params"] ||= request_params_header
1186
+
1187
+ options.apply_defaults timeout: @config.rpcs.analyze_iam_policy_longrunning.timeout,
1188
+ metadata: metadata,
1189
+ retry_policy: @config.rpcs.analyze_iam_policy_longrunning.retry_policy
1190
+ options.apply_defaults metadata: @config.metadata,
1191
+ retry_policy: @config.retry_policy
1192
+
1193
+ @asset_service_stub.call_rpc :analyze_iam_policy_longrunning, request, options: options do |response, operation|
1194
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1195
+ yield response, operation if block_given?
1196
+ return response
1197
+ end
1198
+ rescue ::GRPC::BadStatus => e
1199
+ raise ::Google::Cloud::Error.from_error(e)
1200
+ end
1201
+
1031
1202
  ##
1032
1203
  # Configuration class for the AssetService API.
1033
1204
  #
@@ -1120,7 +1291,7 @@ module Google
1120
1291
  config_attr :scope, nil, ::String, ::Array, nil
1121
1292
  config_attr :lib_name, nil, ::String, nil
1122
1293
  config_attr :lib_version, nil, ::String, nil
1123
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1294
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1124
1295
  config_attr :interceptors, nil, ::Array, nil
1125
1296
  config_attr :timeout, nil, ::Numeric, nil
1126
1297
  config_attr :metadata, nil, ::Hash, nil
@@ -1141,7 +1312,7 @@ module Google
1141
1312
  def rpcs
1142
1313
  @rpcs ||= begin
1143
1314
  parent_rpcs = nil
1144
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1315
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1145
1316
  Rpcs.new parent_rpcs
1146
1317
  end
1147
1318
  end
@@ -1153,7 +1324,7 @@ module Google
1153
1324
  # Each configuration object is of type `Gapic::Config::Method` and includes
1154
1325
  # the following configuration fields:
1155
1326
  #
1156
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1327
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1157
1328
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1158
1329
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1159
1330
  # include the following keys:
@@ -1209,27 +1380,41 @@ module Google
1209
1380
  # @return [::Gapic::Config::Method]
1210
1381
  #
1211
1382
  attr_reader :search_all_iam_policies
1383
+ ##
1384
+ # RPC-specific configuration for `analyze_iam_policy`
1385
+ # @return [::Gapic::Config::Method]
1386
+ #
1387
+ attr_reader :analyze_iam_policy
1388
+ ##
1389
+ # RPC-specific configuration for `analyze_iam_policy_longrunning`
1390
+ # @return [::Gapic::Config::Method]
1391
+ #
1392
+ attr_reader :analyze_iam_policy_longrunning
1212
1393
 
1213
1394
  # @private
1214
1395
  def initialize parent_rpcs = nil
1215
- export_assets_config = parent_rpcs&.export_assets if parent_rpcs&.respond_to? :export_assets
1396
+ export_assets_config = parent_rpcs.export_assets if parent_rpcs.respond_to? :export_assets
1216
1397
  @export_assets = ::Gapic::Config::Method.new export_assets_config
1217
- batch_get_assets_history_config = parent_rpcs&.batch_get_assets_history if parent_rpcs&.respond_to? :batch_get_assets_history
1398
+ batch_get_assets_history_config = parent_rpcs.batch_get_assets_history if parent_rpcs.respond_to? :batch_get_assets_history
1218
1399
  @batch_get_assets_history = ::Gapic::Config::Method.new batch_get_assets_history_config
1219
- create_feed_config = parent_rpcs&.create_feed if parent_rpcs&.respond_to? :create_feed
1400
+ create_feed_config = parent_rpcs.create_feed if parent_rpcs.respond_to? :create_feed
1220
1401
  @create_feed = ::Gapic::Config::Method.new create_feed_config
1221
- get_feed_config = parent_rpcs&.get_feed if parent_rpcs&.respond_to? :get_feed
1402
+ get_feed_config = parent_rpcs.get_feed if parent_rpcs.respond_to? :get_feed
1222
1403
  @get_feed = ::Gapic::Config::Method.new get_feed_config
1223
- list_feeds_config = parent_rpcs&.list_feeds if parent_rpcs&.respond_to? :list_feeds
1404
+ list_feeds_config = parent_rpcs.list_feeds if parent_rpcs.respond_to? :list_feeds
1224
1405
  @list_feeds = ::Gapic::Config::Method.new list_feeds_config
1225
- update_feed_config = parent_rpcs&.update_feed if parent_rpcs&.respond_to? :update_feed
1406
+ update_feed_config = parent_rpcs.update_feed if parent_rpcs.respond_to? :update_feed
1226
1407
  @update_feed = ::Gapic::Config::Method.new update_feed_config
1227
- delete_feed_config = parent_rpcs&.delete_feed if parent_rpcs&.respond_to? :delete_feed
1408
+ delete_feed_config = parent_rpcs.delete_feed if parent_rpcs.respond_to? :delete_feed
1228
1409
  @delete_feed = ::Gapic::Config::Method.new delete_feed_config
1229
- search_all_resources_config = parent_rpcs&.search_all_resources if parent_rpcs&.respond_to? :search_all_resources
1410
+ search_all_resources_config = parent_rpcs.search_all_resources if parent_rpcs.respond_to? :search_all_resources
1230
1411
  @search_all_resources = ::Gapic::Config::Method.new search_all_resources_config
1231
- search_all_iam_policies_config = parent_rpcs&.search_all_iam_policies if parent_rpcs&.respond_to? :search_all_iam_policies
1412
+ search_all_iam_policies_config = parent_rpcs.search_all_iam_policies if parent_rpcs.respond_to? :search_all_iam_policies
1232
1413
  @search_all_iam_policies = ::Gapic::Config::Method.new search_all_iam_policies_config
1414
+ analyze_iam_policy_config = parent_rpcs.analyze_iam_policy if parent_rpcs.respond_to? :analyze_iam_policy
1415
+ @analyze_iam_policy = ::Gapic::Config::Method.new analyze_iam_policy_config
1416
+ analyze_iam_policy_longrunning_config = parent_rpcs.analyze_iam_policy_longrunning if parent_rpcs.respond_to? :analyze_iam_policy_longrunning
1417
+ @analyze_iam_policy_longrunning = ::Gapic::Config::Method.new analyze_iam_policy_longrunning_config
1233
1418
 
1234
1419
  yield self if block_given?
1235
1420
  end
@@ -103,8 +103,13 @@ module Google
103
103
  # Lists operations that match the specified filter in the request. If the
104
104
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
105
105
  #
106
- # NOTE: the `name` binding below allows API services to override the binding
107
- # to use different resource name schemes, such as `users/*/operations`.
106
+ # NOTE: the `name` binding allows API services to override the binding
107
+ # to use different resource name schemes, such as `users/*/operations`. To
108
+ # override the binding, API services can add a binding such as
109
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
110
+ # For backwards compatibility, the default name includes the operations
111
+ # collection id, however overriding users must ensure the name binding
112
+ # is the parent resource, without the operations collection id.
108
113
  #
109
114
  # @overload list_operations(request, options = nil)
110
115
  # Pass arguments to `list_operations` via a request object, either of type
@@ -122,7 +127,7 @@ module Google
122
127
  # the default parameter values, pass an empty Hash as a request object (see above).
123
128
  #
124
129
  # @param name [::String]
125
- # The name of the operation collection.
130
+ # The name of the operation's parent resource.
126
131
  # @param filter [::String]
127
132
  # The standard list filter.
128
133
  # @param page_size [::Integer]
@@ -390,6 +395,79 @@ module Google
390
395
  raise ::Google::Cloud::Error.from_error(e)
391
396
  end
392
397
 
398
+ ##
399
+ # Waits for the specified long-running operation until it is done or reaches
400
+ # at most a specified timeout, returning the latest state. If the operation
401
+ # is already done, the latest state is immediately returned. If the timeout
402
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
403
+ # timeout is used. If the server does not support this method, it returns
404
+ # `google.rpc.Code.UNIMPLEMENTED`.
405
+ # Note that this method is on a best-effort basis. It may return the latest
406
+ # state before the specified timeout (including immediately), meaning even an
407
+ # immediate response is no guarantee that the operation is done.
408
+ #
409
+ # @overload wait_operation(request, options = nil)
410
+ # Pass arguments to `wait_operation` via a request object, either of type
411
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
418
+ #
419
+ # @overload wait_operation(name: nil, timeout: nil)
420
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param name [::String]
425
+ # The name of the operation resource to wait on.
426
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
427
+ # The maximum duration to wait before timing out. If left blank, the wait
428
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
429
+ # If RPC context deadline is also specified, the shorter one will be used.
430
+ #
431
+ # @yield [response, operation] Access the result along with the RPC operation
432
+ # @yieldparam response [::Gapic::Operation]
433
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
434
+ #
435
+ # @return [::Gapic::Operation]
436
+ #
437
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
438
+ #
439
+ def wait_operation request, options = nil
440
+ raise ::ArgumentError, "request must be provided" if request.nil?
441
+
442
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
443
+
444
+ # Converts hash and nil to an options object
445
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
446
+
447
+ # Customize the options with defaults
448
+ metadata = @config.rpcs.wait_operation.metadata.to_h
449
+
450
+ # Set x-goog-api-client and x-goog-user-project headers
451
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
452
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
453
+ gapic_version: ::Google::Cloud::Asset::V1::VERSION
454
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
457
+ metadata: metadata,
458
+ retry_policy: @config.rpcs.wait_operation.retry_policy
459
+ options.apply_defaults metadata: @config.metadata,
460
+ retry_policy: @config.retry_policy
461
+
462
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
463
+ response = ::Gapic::Operation.new response, @operations_client, options: options
464
+ yield response, operation if block_given?
465
+ return response
466
+ end
467
+ rescue ::GRPC::BadStatus => e
468
+ raise ::Google::Cloud::Error.from_error(e)
469
+ end
470
+
393
471
  ##
394
472
  # Configuration class for the Operations API.
395
473
  #
@@ -482,7 +560,7 @@ module Google
482
560
  config_attr :scope, nil, ::String, ::Array, nil
483
561
  config_attr :lib_name, nil, ::String, nil
484
562
  config_attr :lib_version, nil, ::String, nil
485
- config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
563
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
486
564
  config_attr :interceptors, nil, ::Array, nil
487
565
  config_attr :timeout, nil, ::Numeric, nil
488
566
  config_attr :metadata, nil, ::Hash, nil
@@ -503,7 +581,7 @@ module Google
503
581
  def rpcs
504
582
  @rpcs ||= begin
505
583
  parent_rpcs = nil
506
- parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
584
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
507
585
  Rpcs.new parent_rpcs
508
586
  end
509
587
  end
@@ -515,7 +593,7 @@ module Google
515
593
  # Each configuration object is of type `Gapic::Config::Method` and includes
516
594
  # the following configuration fields:
517
595
  #
518
- # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
596
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
519
597
  # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
520
598
  # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
521
599
  # include the following keys:
@@ -546,17 +624,24 @@ module Google
546
624
  # @return [::Gapic::Config::Method]
547
625
  #
548
626
  attr_reader :cancel_operation
627
+ ##
628
+ # RPC-specific configuration for `wait_operation`
629
+ # @return [::Gapic::Config::Method]
630
+ #
631
+ attr_reader :wait_operation
549
632
 
550
633
  # @private
551
634
  def initialize parent_rpcs = nil
552
- list_operations_config = parent_rpcs&.list_operations if parent_rpcs&.respond_to? :list_operations
635
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
553
636
  @list_operations = ::Gapic::Config::Method.new list_operations_config
554
- get_operation_config = parent_rpcs&.get_operation if parent_rpcs&.respond_to? :get_operation
637
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
555
638
  @get_operation = ::Gapic::Config::Method.new get_operation_config
556
- delete_operation_config = parent_rpcs&.delete_operation if parent_rpcs&.respond_to? :delete_operation
639
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
557
640
  @delete_operation = ::Gapic::Config::Method.new delete_operation_config
558
- cancel_operation_config = parent_rpcs&.cancel_operation if parent_rpcs&.respond_to? :cancel_operation
641
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
559
642
  @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
643
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
644
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
560
645
 
561
646
  yield self if block_given?
562
647
  end