lib/google/cloud/compute/v1/projects/rest/client.rb in google-cloud-compute-v1-1.8.0 vs lib/google/cloud/compute/v1/projects/rest/client.rb in google-cloud-compute-v1-1.9.0

- old
+ new

@@ -149,17 +149,26 @@ # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials - credentials ||= Credentials.default scope: @config.scope + # Use self-signed JWT if the endpoint is unchanged from default, + # but only if the default endpoint does not have a region prefix. + enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint && + !@config.endpoint.split(".").first.include?("-") + credentials ||= Credentials.default scope: @config.scope, + enable_self_signed_jwt: enable_self_signed_jwt 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 + @global_operations = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::Client.new do |config| config.credentials = credentials + config.quota_project = @quota_project_id config.endpoint = @config.endpoint end @projects_stub = ::Google::Cloud::Compute::V1::Projects::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials end @@ -183,12 +192,10 @@ # @param request [::Google::Cloud::Compute::V1::DisableXpnHostProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload disable_xpn_host(project: nil, request_id: nil) # Pass arguments to `disable_xpn_host` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -213,21 +220,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.disable_xpn_host.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.disable_xpn_host.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.disable_xpn_host.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.disable_xpn_host request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -237,16 +248,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Disable a service resource (also known as service project) associated with this host project. # @@ -257,12 +264,10 @@ # @param request [::Google::Cloud::Compute::V1::DisableXpnResourceProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload disable_xpn_resource(project: nil, projects_disable_xpn_resource_request_resource: nil, request_id: nil) # Pass arguments to `disable_xpn_resource` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -289,21 +294,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.disable_xpn_resource.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.disable_xpn_resource.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.disable_xpn_resource.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.disable_xpn_resource request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -313,16 +322,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Enable this project as a shared VPC host project. # @@ -333,12 +338,10 @@ # @param request [::Google::Cloud::Compute::V1::EnableXpnHostProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload enable_xpn_host(project: nil, request_id: nil) # Pass arguments to `enable_xpn_host` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -363,21 +366,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.enable_xpn_host.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.enable_xpn_host.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.enable_xpn_host.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.enable_xpn_host request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -387,16 +394,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project. # @@ -407,12 +410,10 @@ # @param request [::Google::Cloud::Compute::V1::EnableXpnResourceProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload enable_xpn_resource(project: nil, projects_enable_xpn_resource_request_resource: nil, request_id: nil) # Pass arguments to `enable_xpn_resource` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -439,21 +440,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.enable_xpn_resource.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.enable_xpn_resource.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.enable_xpn_resource.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.enable_xpn_resource request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -463,16 +468,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request. # @@ -483,12 +484,10 @@ # @param request [::Google::Cloud::Compute::V1::GetProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload get(project: nil) # Pass arguments to `get` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -511,32 +510,32 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.get.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.get.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.get.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.get request, options do |result, response| yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Gets the shared VPC host project that this project links to. May be empty if no link exists. # @@ -547,12 +546,10 @@ # @param request [::Google::Cloud::Compute::V1::GetXpnHostProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload get_xpn_host(project: nil) # Pass arguments to `get_xpn_host` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -575,32 +572,32 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.get_xpn_host.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.get_xpn_host.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.get_xpn_host.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.get_xpn_host request, options do |result, response| yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Gets service resources (a.k.a service project) associated with this host project. # @@ -611,12 +608,10 @@ # @param request [::Google::Cloud::Compute::V1::GetXpnResourcesProjectsRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload get_xpn_resources(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, return_partial_success: nil) # Pass arguments to `get_xpn_resources` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -649,33 +644,33 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.get_xpn_resources.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.get_xpn_resources.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.get_xpn_resources.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.get_xpn_resources request, options do |result, response| result = ::Gapic::Rest::PagedEnumerable.new @projects_stub, :get_xpn_resources, "resources", request, result, options yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Lists all shared VPC host projects visible to the user in an organization. # @@ -686,12 +681,10 @@ # @param request [::Google::Cloud::Compute::V1::ListXpnHostsProjectsRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload list_xpn_hosts(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, projects_list_xpn_hosts_request_resource: nil, return_partial_success: nil) # Pass arguments to `list_xpn_hosts` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -726,33 +719,33 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.list_xpn_hosts.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.list_xpn_hosts.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.list_xpn_hosts.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.list_xpn_hosts request, options do |result, response| result = ::Gapic::Rest::PagedEnumerable.new @projects_stub, :list_xpn_hosts, "items", request, result, options yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Moves a persistent disk from one zone to another. # @@ -763,12 +756,10 @@ # @param request [::Google::Cloud::Compute::V1::MoveDiskProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload move_disk(disk_move_request_resource: nil, project: nil, request_id: nil) # Pass arguments to `move_disk` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -795,21 +786,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.move_disk.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.move_disk.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.move_disk.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.move_disk request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -819,16 +814,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior). # @@ -839,12 +830,10 @@ # @param request [::Google::Cloud::Compute::V1::MoveInstanceProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload move_instance(instance_move_request_resource: nil, project: nil, request_id: nil) # Pass arguments to `move_instance` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -871,21 +860,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.move_instance.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.move_instance.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.move_instance.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.move_instance request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -895,16 +888,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Sets metadata common to all instances within the specified project using the data included in the request. # @@ -915,12 +904,10 @@ # @param request [::Google::Cloud::Compute::V1::SetCommonInstanceMetadataProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload set_common_instance_metadata(metadata_resource: nil, project: nil, request_id: nil) # Pass arguments to `set_common_instance_metadata` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -947,21 +934,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.set_common_instance_metadata.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.set_common_instance_metadata.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.set_common_instance_metadata.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.set_common_instance_metadata request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -971,16 +962,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field. # @@ -991,12 +978,10 @@ # @param request [::Google::Cloud::Compute::V1::SetDefaultNetworkTierProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload set_default_network_tier(project: nil, projects_set_default_network_tier_request_resource: nil, request_id: nil) # Pass arguments to `set_default_network_tier` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -1023,21 +1008,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.set_default_network_tier.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.set_default_network_tier.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.set_default_network_tier.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.set_default_network_tier request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -1047,16 +1036,12 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled. # @@ -1067,12 +1052,10 @@ # @param request [::Google::Cloud::Compute::V1::SetUsageExportBucketProjectRequest, ::Hash] # A request object representing the call parameters. Required. To specify no # parameters, or to keep all the default parameter values, pass an empty Hash. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. - # Note: currently retry functionality is not implemented. While it is possible - # to set it using ::Gapic::CallOptions, it will not be applied # # @overload set_usage_export_bucket(project: nil, request_id: nil, usage_export_location_resource: nil) # Pass arguments to `set_usage_export_bucket` via keyword arguments. Note that at # least one keyword argument is required. To specify no parameters, or to keep all # the default parameter values, pass an empty Hash as a request object (see above). @@ -1099,21 +1082,25 @@ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults call_metadata = @config.rpcs.set_usage_export_bucket.metadata.to_h - # Set x-goog-api-client header + # Set x-goog-api-client and x-goog-user-project headers call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Compute::V1::VERSION, transports_version_send: [:rest] + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + options.apply_defaults timeout: @config.rpcs.set_usage_export_bucket.timeout, - metadata: call_metadata + metadata: call_metadata, + retry_policy: @config.rpcs.set_usage_export_bucket.retry_policy options.apply_defaults timeout: @config.timeout, - metadata: @config.metadata + metadata: @config.metadata, + retry_policy: @config.retry_policy @projects_stub.set_usage_export_bucket request, options do |result, response| result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( operation: result, client: global_operations, @@ -1123,41 +1110,43 @@ options: options ) yield result, response if block_given? return result end - rescue ::Faraday::Error => e - begin - raise ::Gapic::Rest::Error.wrap_faraday_error e - rescue ::Gapic::Rest::Error => gapic_error - raise ::Google::Cloud::Error.from_error gapic_error - end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) end ## # Configuration class for the Projects REST API. # # This class represents the configuration for Projects REST, - # providing control over credentials, timeouts, retry behavior, logging. + # providing control over timeouts, retry behavior, logging, transport + # parameters, and other low-level controls. Certain parameters can also be + # applied individually to specific RPCs. See + # {::Google::Cloud::Compute::V1::Projects::Rest::Client::Configuration::Rpcs} + # for a list of RPCs that can be configured independently. # # Configuration can be applied globally to all clients, or to a single client # on construction. # - # # Examples + # @example # - # To modify the global config, setting the timeout for all calls to 10 seconds: + # # Modify the global config, setting the timeout for + # # disable_xpn_host to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Cloud::Compute::V1::Projects::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.disable_xpn_host.timeout = 20.0 + # end # - # ::Google::Cloud::Compute::V1::Projects::Client.configure do |config| - # config.timeout = 10.0 - # end + # # Apply the above configuration only to a new client. + # client = ::Google::Cloud::Compute::V1::Projects::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.disable_xpn_host.timeout = 20.0 + # end # - # To apply the above configuration only to a new client: - # - # client = ::Google::Cloud::Compute::V1::Projects::Client.new do |config| - # config.timeout = 10.0 - # end - # # @!attribute [rw] endpoint # The hostname or hostname:port of the service endpoint. # Defaults to `"compute.googleapis.com"`. # @return [::String] # @!attribute [rw] credentials @@ -1181,12 +1170,23 @@ # @return [::String] # @!attribute [rw] timeout # The call timeout in seconds. # @return [::Numeric] # @!attribute [rw] metadata - # Additional REST headers to be sent with the call. + # Additional headers to be sent with the call. # @return [::Hash{::Symbol=>::String}] + # @!attribute [rw] retry_policy + # The retry policy. The value is a hash with the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] # class Configuration extend ::Gapic::Config config_attr :endpoint, "compute.googleapis.com", ::String @@ -1197,10 +1197,12 @@ config_attr :scope, nil, ::String, ::Array, nil config_attr :lib_name, nil, ::String, nil config_attr :lib_version, nil, ::String, nil config_attr :timeout, nil, ::Numeric, nil config_attr :metadata, nil, ::Hash, nil + config_attr :retry_policy, nil, ::Hash, ::Proc, nil + config_attr :quota_project, nil, ::String, nil # @private def initialize parent_config = nil @parent_config = parent_config unless parent_config.nil? @@ -1225,12 +1227,17 @@ # Includes fields providing the configuration for each RPC in this service. # Each configuration object is of type `Gapic::Config::Method` and includes # the following configuration fields: # # * `timeout` (*type:* `Numeric`) - The call timeout in seconds - # - # there is one other field (`retry_policy`) that can be set - # but is currently not supported for REST Gapic libraries. + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers + # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields + # include the following keys: + # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. + # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. + # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. + # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should + # trigger a retry. # class Rpcs ## # RPC-specific configuration for `disable_xpn_host` # @return [::Gapic::Config::Method]