Class: Google::Cloud::Asset::V1::AssetService::Operations
- Inherits:
-
Object
- Object
- Google::Cloud::Asset::V1::AssetService::Operations
- Defined in:
- lib/google/cloud/asset/v1/asset_service/operations.rb
Overview
Service that implements Longrunning Operations API.
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Operations::Configuration
Configuration for the AssetService Operations API.
Instance Method Summary collapse
-
#cancel_operation(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Starts asynchronous cancellation on a long-running operation.
-
#configure {|config| ... } ⇒ Operations::Configuration
Configure the AssetService Operations instance.
-
#delete_operation(request, options = nil) {|response, operation| ... } ⇒ ::Google::Protobuf::Empty
Deletes a long-running operation.
-
#get_operation(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Gets the latest state of a long-running operation.
-
#initialize {|config| ... } ⇒ Operations
constructor
Create a new Operations client object.
-
#list_operations(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>
Lists operations that match the specified filter in the request.
-
#wait_operation(request, options = nil) {|response, operation| ... } ⇒ ::Gapic::Operation
Waits for the specified long-running operation until it is done or reaches at most a specified timeout, returning the latest state.
Constructor Details
#initialize {|config| ... } ⇒ Operations
Create a new Operations client object.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 69 def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/longrunning/operations_services_pb" # Create the configuration object @config = Configuration.new Operations.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials credentials ||= Credentials.default scope: @config.scope if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @operations_stub = ::Gapic::ServiceStub.new( ::Google::Longrunning::Operations::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end |
Class Method Details
.configure {|config| ... } ⇒ Operations::Configuration
Configuration for the AssetService Operations API.
40 41 42 43 44 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 40 def self.configure @configure ||= Operations::Configuration.new yield @configure if block_given? @configure end |
Instance Method Details
#cancel_operation(request, options = nil) ⇒ ::Google::Protobuf::Empty #cancel_operation(name: nil) ⇒ ::Google::Protobuf::Empty
Starts asynchronous cancellation on a long-running operation. The server
makes a best effort to cancel the operation, but success is not
guaranteed. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
. Clients can use
Operations.GetOperation or
other methods to check whether the cancellation succeeded or whether the
operation completed despite cancellation. On successful cancellation,
the operation is not deleted; instead, it becomes an operation with
an Operation.error value with a google.rpc.Status.code of 1,
corresponding to Code.CANCELLED
.
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 367 def cancel_operation request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.cancel_operation..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Asset::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.cancel_operation.timeout, metadata: , retry_policy: @config.rpcs.cancel_operation.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @operations_stub.call_rpc :cancel_operation, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#configure {|config| ... } ⇒ Operations::Configuration
Configure the AssetService Operations instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.
58 59 60 61 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 58 def configure yield @config if block_given? @config end |
#delete_operation(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_operation(name: nil) ⇒ ::Google::Protobuf::Empty
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 290 def delete_operation request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_operation..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Asset::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.delete_operation.timeout, metadata: , retry_policy: @config.rpcs.delete_operation.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @operations_stub.call_rpc :delete_operation, request, options: do |response, operation| yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#get_operation(request, options = nil) ⇒ ::Gapic::Operation #get_operation(name: nil) ⇒ ::Gapic::Operation
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 218 def get_operation request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_operation..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Asset::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.get_operation.timeout, metadata: , retry_policy: @config.rpcs.get_operation.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @operations_stub.call_rpc :get_operation, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#list_operations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation> #list_operations(name: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Gapic::Operation>
Lists operations that match the specified filter in the request. If the
server doesn't support this method, it returns UNIMPLEMENTED
.
NOTE: the name
binding allows API services to override the binding
to use different resource name schemes, such as users/*/operations
. To
override the binding, API services can add a binding such as
"/v1/{name=users/*}/operations"
to their service configuration.
For backwards compatibility, the default name includes the operations
collection id, however overriding users must ensure the name binding
is the parent resource, without the operations collection id.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 146 def list_operations request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_operations..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Asset::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") [:"x-goog-request-params"] ||= request_params_header .apply_defaults timeout: @config.rpcs.list_operations.timeout, metadata: , retry_policy: @config.rpcs.list_operations.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @operations_stub.call_rpc :list_operations, request, options: do |response, operation| wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client } response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, , format_resource: wrap_lro_operation yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |
#wait_operation(request, options = nil) ⇒ ::Gapic::Operation #wait_operation(name: nil, timeout: nil) ⇒ ::Gapic::Operation
Waits for the specified long-running operation until it is done or reaches
at most a specified timeout, returning the latest state. If the operation
is already done, the latest state is immediately returned. If the timeout
specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
timeout is used. If the server does not support this method, it returns
google.rpc.Code.UNIMPLEMENTED
.
Note that this method is on a best-effort basis. It may return the latest
state before the specified timeout (including immediately), meaning even an
immediate response is no guarantee that the operation is done.
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/google/cloud/asset/v1/asset_service/operations.rb', line 447 def wait_operation request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.wait_operation..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Asset::V1::VERSION [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.wait_operation.timeout, metadata: , retry_policy: @config.rpcs.wait_operation.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @operations_stub.call_rpc :wait_operation, request, options: do |response, operation| response = ::Gapic::Operation.new response, @operations_client, options: yield response, operation if block_given? return response end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end |