lib/google/cloud/compute/v1/security_policies/rest/client.rb in google-cloud-compute-v1-1.6.0 vs lib/google/cloud/compute/v1/security_policies/rest/client.rb in google-cloud-compute-v1-1.7.0

- old
+ new

@@ -100,10 +100,12 @@ default_config.rpcs.patch_rule.timeout = 600.0 default_config.rpcs.remove_rule.timeout = 600.0 + default_config.rpcs.set_labels.timeout = 600.0 + default_config end yield @configure if block_given? @configure end @@ -967,10 +969,83 @@ gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e raise ::Google::Cloud::Error.from_error(gapic_error) end ## + # Sets the labels on a security policy. To learn more about labels, read the Labeling Resources documentation. + # + # @overload set_labels(request, options = nil) + # Pass arguments to `set_labels` via a request object, either of type + # {::Google::Cloud::Compute::V1::SetLabelsSecurityPolicyRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::Compute::V1::SetLabelsSecurityPolicyRequest, ::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_labels(global_set_labels_request_resource: nil, project: nil, resource: nil) + # Pass arguments to `set_labels` 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). + # + # @param global_set_labels_request_resource [::Google::Cloud::Compute::V1::GlobalSetLabelsRequest, ::Hash] + # The body resource for this request + # @param project [::String] + # Project ID for this request. + # @param resource [::String] + # Name or id of the resource for this request. + # @yield [result, response] Access the result along with the Faraday response object + # @yieldparam result [::Gapic::GenericLRO::Operation] + # @yieldparam response [::Faraday::Response] + # + # @return [::Gapic::GenericLRO::Operation] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + def set_labels request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::SetLabelsSecurityPolicyRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.set_labels.metadata.to_h + + # Set x-goog-api-client header + 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] + + options.apply_defaults timeout: @config.rpcs.set_labels.timeout, + metadata: call_metadata + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata + + @security_policies_stub.set_labels request, options do |result, response| + result = ::Google::Cloud::Compute::V1::GlobalOperations::Rest::NonstandardLro.create_operation( + operation: result, + client: global_operations, + request_values: { + "project" => request.project + }, + options: options + ) + yield result, response if block_given? + return result + end + rescue ::Faraday::Error => e + gapic_error = ::Gapic::Rest::Error.wrap_faraday_error e + raise ::Google::Cloud::Error.from_error(gapic_error) + end + + ## # Configuration class for the SecurityPolicies REST API. # # This class represents the configuration for SecurityPolicies REST, # providing control over credentials, timeouts, retry behavior, logging. # @@ -1120,10 +1195,15 @@ ## # RPC-specific configuration for `remove_rule` # @return [::Gapic::Config::Method] # attr_reader :remove_rule + ## + # RPC-specific configuration for `set_labels` + # @return [::Gapic::Config::Method] + # + attr_reader :set_labels # @private def initialize parent_rpcs = nil add_rule_config = parent_rpcs.add_rule if parent_rpcs.respond_to? :add_rule @add_rule = ::Gapic::Config::Method.new add_rule_config @@ -1145,9 +1225,11 @@ @patch = ::Gapic::Config::Method.new patch_config patch_rule_config = parent_rpcs.patch_rule if parent_rpcs.respond_to? :patch_rule @patch_rule = ::Gapic::Config::Method.new patch_rule_config remove_rule_config = parent_rpcs.remove_rule if parent_rpcs.respond_to? :remove_rule @remove_rule = ::Gapic::Config::Method.new remove_rule_config + set_labels_config = parent_rpcs.set_labels if parent_rpcs.respond_to? :set_labels + @set_labels = ::Gapic::Config::Method.new set_labels_config yield self if block_given? end end end