diff --git a/google-cloud-backupdr-v1/.owlbot-manifest.json b/google-cloud-backupdr-v1/.owlbot-manifest.json index 65d67c349918..7c341f383ce3 100644 --- a/google-cloud-backupdr-v1/.owlbot-manifest.json +++ b/google-cloud-backupdr-v1/.owlbot-manifest.json @@ -15,6 +15,13 @@ "google-cloud-backupdr-v1.gemspec", "lib/google-cloud-backupdr-v1.rb", "lib/google/cloud/backupdr/v1.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/client.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/credentials.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/paths.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/client.rb", + "lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/service_stub.rb", "lib/google/cloud/backupdr/v1/backupdr.rb", "lib/google/cloud/backupdr/v1/backupdr/client.rb", "lib/google/cloud/backupdr/v1/backupdr/credentials.rb", @@ -35,6 +42,8 @@ "lib/google/cloud/backupdr/v1/backupvault_pb.rb", "lib/google/cloud/backupdr/v1/bindings_override.rb", "lib/google/cloud/backupdr/v1/datasourcereference_pb.rb", + "lib/google/cloud/backupdr/v1/protection_summary_pb.rb", + "lib/google/cloud/backupdr/v1/protection_summary_services_pb.rb", "lib/google/cloud/backupdr/v1/rest.rb", "lib/google/cloud/backupdr/v1/version.rb", "proto_docs/README.md", @@ -52,6 +61,7 @@ "proto_docs/google/cloud/backupdr/v1/backupvault_disk.rb", "proto_docs/google/cloud/backupdr/v1/backupvault_gce.rb", "proto_docs/google/cloud/backupdr/v1/datasourcereference.rb", + "proto_docs/google/cloud/backupdr/v1/protection_summary.rb", "proto_docs/google/longrunning/operations.rb", "proto_docs/google/protobuf/any.rb", "proto_docs/google/protobuf/duration.rb", @@ -64,6 +74,7 @@ "proto_docs/google/type/expr.rb", "proto_docs/google/type/month.rb", "snippets/Gemfile", + "snippets/backup_dr_protection_summary/list_resource_backup_configs.rb", "snippets/backupdr/create_backup_plan.rb", "snippets/backupdr/create_backup_plan_association.rb", "snippets/backupdr/create_backup_vault.rb", @@ -102,6 +113,9 @@ "snippets/backupdr/update_backup_vault.rb", "snippets/backupdr/update_data_source.rb", "snippets/snippet_metadata_google.cloud.backupdr.v1.json", + "test/google/cloud/backupdr/v1/backup_dr_protection_summary_paths_test.rb", + "test/google/cloud/backupdr/v1/backup_dr_protection_summary_rest_test.rb", + "test/google/cloud/backupdr/v1/backup_dr_protection_summary_test.rb", "test/google/cloud/backupdr/v1/backupdr_operations_test.rb", "test/google/cloud/backupdr/v1/backupdr_paths_test.rb", "test/google/cloud/backupdr/v1/backupdr_rest_test.rb", diff --git a/google-cloud-backupdr-v1/gapic_metadata.json b/google-cloud-backupdr-v1/gapic_metadata.json index 8c1867fc2fc8..590f02f148a1 100644 --- a/google-cloud-backupdr-v1/gapic_metadata.json +++ b/google-cloud-backupdr-v1/gapic_metadata.json @@ -198,6 +198,20 @@ } } } + }, + "BackupDrProtectionSummary": { + "clients": { + "grpc": { + "libraryClient": "::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client", + "rpcs": { + "ListResourceBackupConfigs": { + "methods": [ + "list_resource_backup_configs" + ] + } + } + } + } } } } diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1.rb index 35c0b953bf9f..76959762c891 100644 --- a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1.rb +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1.rb @@ -17,6 +17,7 @@ # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/cloud/backupdr/v1/backupdr" +require "google/cloud/backupdr/v1/backup_dr_protection_summary" require "google/cloud/backupdr/v1/version" module Google diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary.rb new file mode 100644 index 000000000000..52b98449e819 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/common" +require "gapic/config" +require "gapic/config/method" + +require "google/cloud/backupdr/v1/version" + +require "google/cloud/backupdr/v1/backup_dr_protection_summary/credentials" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/paths" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/client" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest" + +module Google + module Cloud + module BackupDR + module V1 + ## + # The Protection Summary service. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/cloud/backupdr/v1/backup_dr_protection_summary" + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest" + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new + # + module BackupDrProtectionSummary + end + end + end + end +end + +helper_path = ::File.join __dir__, "backup_dr_protection_summary", "helpers.rb" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/helpers" if ::File.file? helper_path diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/client.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/client.rb new file mode 100644 index 000000000000..4c2e0d3c63ad --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/client.rb @@ -0,0 +1,530 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/cloud/backupdr/v1/protection_summary_pb" +require "google/cloud/location" +require "google/iam/v1" + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + ## + # Client for the BackupDrProtectionSummary service. + # + # The Protection Summary service. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "backupdr.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :backup_dr_protection_summary_stub + + ## + # Configure the BackupDrProtectionSummary Client class. + # + # See {::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BackupDrProtectionSummary clients + # ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Cloud", "BackupDR", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_resource_backup_configs.timeout = 60.0 + default_config.rpcs.list_resource_backup_configs.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BackupDrProtectionSummary Client 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 {Client.configure}. + # + # See {::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @backup_dr_protection_summary_stub.universe_domain + end + + ## + # Create a new BackupDrProtectionSummary client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BackupDrProtectionSummary client. + # @yieldparam config [Client::Configuration] + # + 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/cloud/backupdr/v1/protection_summary_services_pb" + + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # 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.nil? || + (@config.endpoint == Configuration::DEFAULT_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 + + @backup_dr_protection_summary_stub = ::Gapic::ServiceStub.new( + ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Stub, + credentials: credentials, + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + channel_args: @config.channel_args, + interceptors: @config.interceptors, + channel_pool_config: @config.channel_pool, + logger: @config.logger + ) + + @backup_dr_protection_summary_stub.stub_logger&.info do |entry| + entry.set_system_name + entry.set_service + entry.message = "Created client for #{entry.service}" + entry.set_credentials_fields credentials + entry.set "customEndpoint", @config.endpoint if @config.endpoint + entry.set "defaultTimeout", @config.timeout if @config.timeout + entry.set "quotaProject", @quota_project_id if @quota_project_id + end + + @location_client = Google::Cloud::Location::Locations::Client.new do |config| + config.credentials = credentials + config.quota_project = @quota_project_id + config.endpoint = @backup_dr_protection_summary_stub.endpoint + config.universe_domain = @backup_dr_protection_summary_stub.universe_domain + config.logger = @backup_dr_protection_summary_stub.logger if config.respond_to? :logger= + end + + @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config| + config.credentials = credentials + config.quota_project = @quota_project_id + config.endpoint = @backup_dr_protection_summary_stub.endpoint + config.universe_domain = @backup_dr_protection_summary_stub.universe_domain + config.logger = @backup_dr_protection_summary_stub.logger if config.respond_to? :logger= + end + end + + ## + # Get the associated client for mix-in of the Locations. + # + # @return [Google::Cloud::Location::Locations::Client] + # + attr_reader :location_client + + ## + # Get the associated client for mix-in of the IAMPolicy. + # + # @return [Google::Iam::V1::IAMPolicy::Client] + # + attr_reader :iam_policy_client + + ## + # The logger used for request/response debug logging. + # + # @return [Logger] + # + def logger + @backup_dr_protection_summary_stub.logger + end + + # Service calls + + ## + # Lists ResourceBackupConfigs. + # + # @overload list_resource_backup_configs(request, options = nil) + # Pass arguments to `list_resource_backup_configs` via a request object, either of type + # {::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest, ::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. + # + # @overload list_resource_backup_configs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) + # Pass arguments to `list_resource_backup_configs` 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 parent [::String] + # Required. The project and location for which to retrieve resource backup + # configs. Format: 'projects/\\{project_id}/locations/\\{location}'. In Google + # Cloud Backup and DR, locations map to Google Cloud regions, for example + # **us-central1**. + # @param page_size [::Integer] + # Optional. Requested page size. Server may return fewer items than + # requested. If unspecified, server will use 100 as default. Maximum value is + # 500 and values above 500 will be coerced to 500. + # @param page_token [::String] + # Optional. A token identifying a page of results the server should return. + # @param filter [::String] + # Optional. Filtering results. + # @param order_by [::String] + # Optional. Hint for how to order the results. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::BackupDR::V1::ResourceBackupConfig>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Cloud::BackupDR::V1::ResourceBackupConfig>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/backupdr/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new + # + # # Call the list_resource_backup_configs method. + # result = client.list_resource_backup_configs request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Cloud::BackupDR::V1::ResourceBackupConfig. + # p item + # end + # + def list_resource_backup_configs request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest + + # 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 + metadata = @config.rpcs.list_resource_backup_configs.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + 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::BackupDR::V1::VERSION + metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + header_params = {} + if request.parent + header_params["parent"] = request.parent + end + + request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") + metadata[:"x-goog-request-params"] ||= request_params_header + + options.apply_defaults timeout: @config.rpcs.list_resource_backup_configs.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_resource_backup_configs.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @backup_dr_protection_summary_stub.call_rpc :list_resource_backup_configs, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @backup_dr_protection_summary_stub, :list_resource_backup_configs, request, response, operation, options + yield response, operation if block_given? + throw :response, response + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BackupDrProtectionSummary API. + # + # This class represents the configuration for BackupDrProtectionSummary, + # 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::BackupDR::V1::BackupDrProtectionSummary::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. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_resource_backup_configs to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_resource_backup_configs.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_resource_backup_configs.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no credentials + # + # @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials + # is deprecated. Providing an unvalidated credential configuration to + # Google APIs can compromise the security of your systems and data. + # + # @example + # + # # The recommended way to provide credentials is to use the `make_creds` method + # # on the appropriate credentials class for your environment. + # + # require "googleauth" + # + # credentials = ::Google::Auth::ServiceAccountCredentials.make_creds( + # json_key_io: ::File.open("/path/to/keyfile.json") + # ) + # + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + # config.credentials = credentials + # end + # + # @note Warning: If you accept a credential configuration (JSON file or Hash) from an + # external source for authentication to Google Cloud, you must validate it before + # providing it to a Google API client library. Providing an unvalidated credential + # configuration to Google APIs can compromise the security of your systems and data. + # For more information, refer to [Validate credential configurations from external + # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials). + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] channel_args + # Extra parameters passed to the gRPC channel. Note: this is ignored if a + # `GRPC::Core::Channel` object is provided as the credential. + # @return [::Hash] + # @!attribute [rw] interceptors + # An array of interceptors that are run before calls are executed. + # @return [::Array<::GRPC::ClientInterceptor>] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # Additional gRPC 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`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # @!attribute [rw] logger + # A custom logger to use for request/response debug logging, or the value + # `:default` (the default) to construct a default logger, or `nil` to + # explicitly disable logging. + # @return [::Logger,:default,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "backupdr.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC::Core::Channel + allowed.any? { |klass| klass === value } + end + config_attr :scope, nil, ::String, ::Array, nil + config_attr :lib_name, nil, ::String, nil + config_attr :lib_version, nil, ::String, nil + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) + config_attr :interceptors, nil, ::Array, 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 + config_attr :universe_domain, nil, ::String, nil + config_attr :logger, :default, ::Logger, nil, :default + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration for the channel pool + # @return [::Gapic::ServiceStub::ChannelPool::Configuration] + # + def channel_pool + @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new + end + + ## + # Configuration RPC class for the BackupDrProtectionSummary API. + # + # 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 + # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC 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`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_resource_backup_configs` + # @return [::Gapic::Config::Method] + # + attr_reader :list_resource_backup_configs + + # @private + def initialize parent_rpcs = nil + list_resource_backup_configs_config = parent_rpcs.list_resource_backup_configs if parent_rpcs.respond_to? :list_resource_backup_configs + @list_resource_backup_configs = ::Gapic::Config::Method.new list_resource_backup_configs_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/credentials.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/credentials.rb new file mode 100644 index 000000000000..94614c32dfd5 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "googleauth" + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + # Credentials for the BackupDrProtectionSummary API. + class Credentials < ::Google::Auth::Credentials + self.scope = [ + "https://www.googleapis.com/auth/cloud-platform" + ] + self.env_vars = [ + "GOOGLE_CLOUD_CREDENTIALS", + "GOOGLE_CLOUD_KEYFILE", + "GCLOUD_KEYFILE", + "GOOGLE_CLOUD_CREDENTIALS_JSON", + "GOOGLE_CLOUD_KEYFILE_JSON", + "GCLOUD_KEYFILE_JSON" + ] + self.paths = [ + "~/.config/google_cloud/application_default_credentials.json" + ] + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/paths.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/paths.rb new file mode 100644 index 000000000000..cbaeba7a3956 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/paths.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + # Path helper methods for the BackupDrProtectionSummary API. + module Paths + ## + # Create a fully-qualified Location resource string. + # + # The resource will be in the following format: + # + # `projects/{project}/locations/{location}` + # + # @param project [String] + # @param location [String] + # + # @return [::String] + def location_path project:, location: + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + + "projects/#{project}/locations/#{location}" + end + + extend self + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest.rb new file mode 100644 index 000000000000..38b3a06e8a03 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "gapic/rest" +require "gapic/config" +require "gapic/config/method" + +require "google/cloud/backupdr/v1/version" +require "google/cloud/backupdr/v1/bindings_override" + +require "google/cloud/backupdr/v1/backup_dr_protection_summary/credentials" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/paths" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest/client" + +module Google + module Cloud + module BackupDR + module V1 + ## + # The Protection Summary service. + # + # To load this service and instantiate a REST client: + # + # require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest" + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new + # + module BackupDrProtectionSummary + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest/helpers" if ::File.file? helper_path diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/client.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/client.rb new file mode 100644 index 000000000000..e4d6e17e4350 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/client.rb @@ -0,0 +1,489 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/errors" +require "google/cloud/backupdr/v1/protection_summary_pb" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest/service_stub" +require "google/cloud/location/rest" +require "google/iam/v1/rest" + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + module Rest + ## + # REST client for the BackupDrProtectionSummary service. + # + # The Protection Summary service. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "backupdr.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :backup_dr_protection_summary_stub + + ## + # Configure the BackupDrProtectionSummary Client class. + # + # See {::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all BackupDrProtectionSummary clients + # ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.configure do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def self.configure + @configure ||= begin + namespace = ["Google", "Cloud", "BackupDR", "V1"] + parent_config = while namespace.any? + parent_name = namespace.join "::" + parent_const = const_get parent_name + break parent_const.configure if parent_const.respond_to? :configure + namespace.pop + end + default_config = Client::Configuration.new parent_config + + default_config.rpcs.list_resource_backup_configs.timeout = 60.0 + default_config.rpcs.list_resource_backup_configs.retry_policy = { + initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14] + } + + default_config + end + yield @configure if block_given? + @configure + end + + ## + # Configure the BackupDrProtectionSummary Client 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 {Client.configure}. + # + # See {::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @yield [config] Configure the Client client. + # @yieldparam config [Client::Configuration] + # + # @return [Client::Configuration] + # + def configure + yield @config if block_given? + @config + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @backup_dr_protection_summary_stub.universe_domain + end + + ## + # Create a new BackupDrProtectionSummary REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the BackupDrProtectionSummary client. + # @yieldparam config [Client::Configuration] + # + def initialize + # Create the configuration object + @config = Configuration.new Client.configure + + # Yield the configuration if needed + yield @config if block_given? + + # Create credentials + credentials = @config.credentials + # 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.nil? || + (@config.endpoint == Configuration::DEFAULT_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 + + @backup_dr_protection_summary_stub = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials, + logger: @config.logger + ) + + @backup_dr_protection_summary_stub.logger(stub: true)&.info do |entry| + entry.set_system_name + entry.set_service + entry.message = "Created client for #{entry.service}" + entry.set_credentials_fields credentials + entry.set "customEndpoint", @config.endpoint if @config.endpoint + entry.set "defaultTimeout", @config.timeout if @config.timeout + entry.set "quotaProject", @quota_project_id if @quota_project_id + end + + @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config| + config.credentials = credentials + config.quota_project = @quota_project_id + config.endpoint = @backup_dr_protection_summary_stub.endpoint + config.universe_domain = @backup_dr_protection_summary_stub.universe_domain + config.bindings_override = @config.bindings_override + config.logger = @backup_dr_protection_summary_stub.logger if config.respond_to? :logger= + end + + @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config| + config.credentials = credentials + config.quota_project = @quota_project_id + config.endpoint = @backup_dr_protection_summary_stub.endpoint + config.universe_domain = @backup_dr_protection_summary_stub.universe_domain + config.bindings_override = @config.bindings_override + config.logger = @backup_dr_protection_summary_stub.logger if config.respond_to? :logger= + end + end + + ## + # Get the associated client for mix-in of the Locations. + # + # @return [Google::Cloud::Location::Locations::Rest::Client] + # + attr_reader :location_client + + ## + # Get the associated client for mix-in of the IAMPolicy. + # + # @return [Google::Iam::V1::IAMPolicy::Rest::Client] + # + attr_reader :iam_policy_client + + ## + # The logger used for request/response debug logging. + # + # @return [Logger] + # + def logger + @backup_dr_protection_summary_stub.logger + end + + # Service calls + + ## + # Lists ResourceBackupConfigs. + # + # @overload list_resource_backup_configs(request, options = nil) + # Pass arguments to `list_resource_backup_configs` via a request object, either of type + # {::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest, ::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. + # + # @overload list_resource_backup_configs(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) + # Pass arguments to `list_resource_backup_configs` 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 parent [::String] + # Required. The project and location for which to retrieve resource backup + # configs. Format: 'projects/\\{project_id}/locations/\\{location}'. In Google + # Cloud Backup and DR, locations map to Google Cloud regions, for example + # **us-central1**. + # @param page_size [::Integer] + # Optional. Requested page size. Server may return fewer items than + # requested. If unspecified, server will use 100 as default. Maximum value is + # 500 and values above 500 will be coerced to 500. + # @param page_token [::String] + # Optional. A token identifying a page of results the server should return. + # @param filter [::String] + # Optional. Filtering results. + # @param order_by [::String] + # Optional. Hint for how to order the results. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::BackupDR::V1::ResourceBackupConfig>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::BackupDR::V1::ResourceBackupConfig>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/backupdr/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new + # + # # Call the list_resource_backup_configs method. + # result = client.list_resource_backup_configs request + # + # # The returned object is of type Gapic::PagedEnumerable. You can iterate + # # over elements, and API calls will be issued to fetch pages as needed. + # result.each do |item| + # # Each element is of type ::Google::Cloud::BackupDR::V1::ResourceBackupConfig. + # p item + # end + # + def list_resource_backup_configs request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest + + # 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.list_resource_backup_configs.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version 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::BackupDR::V1::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.list_resource_backup_configs.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_resource_backup_configs.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @backup_dr_protection_summary_stub.list_resource_backup_configs request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @backup_dr_protection_summary_stub, :list_resource_backup_configs, "resource_backup_configs", request, result, options + yield result, operation if block_given? + throw :response, result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Configuration class for the BackupDrProtectionSummary REST API. + # + # This class represents the configuration for BackupDrProtectionSummary REST, + # 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::BackupDR::V1::BackupDrProtectionSummary::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. + # + # @example + # + # # Modify the global config, setting the timeout for + # # list_resource_backup_configs to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.list_resource_backup_configs.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.list_resource_backup_configs.timeout = 20.0 + # end + # + # @!attribute [rw] endpoint + # A custom service endpoint, as a hostname or hostname:port. The default is + # nil, indicating to use the default endpoint in the current universe domain. + # @return [::String,nil] + # @!attribute [rw] credentials + # Credentials to send with calls. You may provide any of the following types: + # * (`String`) The path to a service account key file in JSON format + # * (`Hash`) A service account key as a Hash + # * (`Google::Auth::Credentials`) A googleauth credentials object + # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials)) + # * (`Signet::OAuth2::Client`) A signet oauth2 client object + # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client)) + # * (`nil`) indicating no credentials + # + # Warning: If you accept a credential configuration (JSON file or Hash) from an + # external source for authentication to Google Cloud, you must validate it before + # providing it to a Google API client library. Providing an unvalidated credential + # configuration to Google APIs can compromise the security of your systems and data. + # For more information, refer to [Validate credential configurations from external + # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials). + # @return [::Object] + # @!attribute [rw] scope + # The OAuth scopes + # @return [::Array<::String>] + # @!attribute [rw] lib_name + # The library name as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] lib_version + # The library version as recorded in instrumentation and logging + # @return [::String] + # @!attribute [rw] timeout + # The call timeout in seconds. + # @return [::Numeric] + # @!attribute [rw] metadata + # 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`) - The error codes that should + # trigger a retry. + # @return [::Hash] + # @!attribute [rw] quota_project + # A separate project against which to charge quota. + # @return [::String] + # @!attribute [rw] universe_domain + # The universe domain within which to make requests. This determines the + # default endpoint URL. The default value of nil uses the environment + # universe (usually the default "googleapis.com" universe). + # @return [::String,nil] + # @!attribute [rw] logger + # A custom logger to use for request/response debug logging, or the value + # `:default` (the default) to construct a default logger, or `nil` to + # explicitly disable logging. + # @return [::Logger,:default,nil] + # + class Configuration + extend ::Gapic::Config + + # @private + # The endpoint specific to the default "googleapis.com" universe. Deprecated. + DEFAULT_ENDPOINT = "backupdr.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Google::Auth::BaseClient, ::Signet::OAuth2::Client, nil] + allowed.any? { |klass| klass === value } + end + 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 + config_attr :universe_domain, nil, ::String, nil + + # @private + # Overrides for http bindings for the RPCs of this service + # are only used when this service is used as mixin, and only + # by the host service. + # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}] + config_attr :bindings_override, {}, ::Hash, nil + config_attr :logger, :default, ::Logger, nil, :default + + # @private + def initialize parent_config = nil + @parent_config = parent_config unless parent_config.nil? + + yield self if block_given? + end + + ## + # Configurations for individual RPCs + # @return [Rpcs] + # + def rpcs + @rpcs ||= begin + parent_rpcs = nil + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) + Rpcs.new parent_rpcs + end + end + + ## + # Configuration RPC class for the BackupDrProtectionSummary API. + # + # 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 + # * `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`) - The error codes that should + # trigger a retry. + # + class Rpcs + ## + # RPC-specific configuration for `list_resource_backup_configs` + # @return [::Gapic::Config::Method] + # + attr_reader :list_resource_backup_configs + + # @private + def initialize parent_rpcs = nil + list_resource_backup_configs_config = parent_rpcs.list_resource_backup_configs if parent_rpcs.respond_to? :list_resource_backup_configs + @list_resource_backup_configs = ::Gapic::Config::Method.new list_resource_backup_configs_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/service_stub.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/service_stub.rb new file mode 100644 index 000000000000..b788e5ec9af1 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/backup_dr_protection_summary/rest/service_stub.rb @@ -0,0 +1,142 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "google/cloud/backupdr/v1/protection_summary_pb" + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + module Rest + ## + # REST service stub for the BackupDrProtectionSummary service. + # Service stub contains baseline method implementations + # including transcoding, making the REST call, and deserialing the response. + # + class ServiceStub + # @private + def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger: + # These require statements are intentionally placed here to initialize + # the REST modules only when it's required. + require "gapic/rest" + + @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, + endpoint_template: endpoint_template, + universe_domain: universe_domain, + credentials: credentials, + numeric_enums: true, + service_name: self.class, + raise_faraday_errors: false, + logger: logger + end + + ## + # The effective universe domain + # + # @return [String] + # + def universe_domain + @client_stub.universe_domain + end + + ## + # The effective endpoint + # + # @return [String] + # + def endpoint + @client_stub.endpoint + end + + ## + # The logger used for request/response debug logging. + # + # @return [Logger] + # + def logger stub: false + stub ? @client_stub.stub_logger : @client_stub.logger + end + + ## + # Baseline implementation for the list_resource_backup_configs REST call + # + # @param request_pb [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest] + # A request object representing the call parameters. Required. + # @param options [::Gapic::CallOptions] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse] + # A result object deserialized from the server's reply + def list_resource_backup_configs request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_resource_backup_configs_request request_pb + query_string_params = if query_string_params.any? + query_string_params.to_h { |p| p.split "=", 2 } + else + {} + end + + response = @client_stub.make_http_request( + verb, + uri: uri, + body: body || "", + params: query_string_params, + method_name: "list_resource_backup_configs", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # @private + # + # GRPC transcoding helper method for the list_resource_backup_configs REST call + # + # @param request_pb [::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_list_resource_backup_configs_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{parent}/resourceBackupConfigs", + matches: [ + ["parent", %r{^projects/[^/]+/locations/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_pb.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_pb.rb new file mode 100644 index 000000000000..545a41d844c1 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_pb.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/backupdr/v1/protection_summary.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/field_info_pb' +require 'google/api/resource_pb' +require 'google/protobuf/timestamp_pb' + + +descriptor_data = "\n1google/cloud/backupdr/v1/protection_summary.proto\x12\x18google.cloud.backupdr.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/api/field_info.proto\x1a\x19google/api/resource.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xba\x01\n ListResourceBackupConfigsRequest\x12\x39\n\x06parent\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!locations.googleapis.com/Location\x12\x16\n\tpage_size\x18\x02 \x01(\x05\x42\x03\xe0\x41\x01\x12\x17\n\npage_token\x18\x03 \x01(\tB\x03\xe0\x41\x01\x12\x13\n\x06\x66ilter\x18\x04 \x01(\tB\x03\xe0\x41\x01\x12\x15\n\x08order_by\x18\x05 \x01(\tB\x03\xe0\x41\x01\"\x8d\x01\n!ListResourceBackupConfigsResponse\x12O\n\x17resource_backup_configs\x18\x01 \x03(\x0b\x32..google.cloud.backupdr.v1.ResourceBackupConfig\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\xec\x06\n\x14ResourceBackupConfig\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x08\x12\x18\n\x03uid\x18\x02 \x01(\tB\x0b\xe0\x41\x03\xe2\x8c\xcf\xd7\x08\x02\x08\x01\x12\x1c\n\x0ftarget_resource\x18\x03 \x01(\tB\x03\xe0\x41\x03\x12)\n\x1ctarget_resource_display_name\x18\x04 \x01(\tB\x03\xe0\x41\x03\x12^\n\x14target_resource_type\x18\x05 \x01(\x0e\x32;.google.cloud.backupdr.v1.ResourceBackupConfig.ResourceTypeB\x03\xe0\x41\x03\x12h\n\x16target_resource_labels\x18\x06 \x03(\x0b\x32H.google.cloud.backupdr.v1.ResourceBackupConfig.TargetResourceLabelsEntry\x12M\n\x16\x62\x61\x63kup_configs_details\x18\x07 \x03(\x0b\x32-.google.cloud.backupdr.v1.BackupConfigDetails\x12\x1e\n\x11\x62\x61\x63kup_configured\x18\x08 \x01(\x08\x42\x03\xe0\x41\x03\x12\x14\n\x07vaulted\x18\t \x01(\x08\x42\x03\xe0\x41\x03\x1a;\n\x19TargetResourceLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x97\x01\n\x0cResourceType\x12\x1d\n\x19RESOURCE_TYPE_UNSPECIFIED\x10\x00\x12\x16\n\x12\x43LOUD_SQL_INSTANCE\x10\x01\x12\x15\n\x11\x43OMPUTE_ENGINE_VM\x10\x02\x12\x17\n\x13\x43OMPUTE_ENGINE_DISK\x10\x03\x12 \n\x1c\x43OMPUTE_ENGINE_REGIONAL_DISK\x10\x04:\xb7\x01\xea\x41\xb3\x01\n,backupdr.googleapis.com/ResourceBackupConfig\x12Vprojects/{project}/locations/{location}/resourceBackupConfigs/{resource_backup_config}*\x15resourceBackupConfigs2\x14resourceBackupConfig\"\xa2\x07\n\x13\x42\x61\x63kupConfigDetails\x12!\n\x14\x62\x61\x63kup_config_source\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12.\n!backup_config_source_display_name\x18\x02 \x01(\tB\x03\xe0\x41\x03\x12\x45\n\x04type\x18\x03 \x01(\x0e\x32\x32.google.cloud.backupdr.v1.BackupConfigDetails.TypeB\x03\xe0\x41\x03\x12G\n\x05state\x18\x04 \x01(\x0e\x32\x33.google.cloud.backupdr.v1.BackupConfigDetails.StateB\x03\xe0\x41\x03\x12\x42\n\rpitr_settings\x18\x05 \x01(\x0b\x32&.google.cloud.backupdr.v1.PitrSettingsB\x03\xe0\x41\x03\x12\x46\n\x1dlatest_successful_backup_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12 \n\x13\x61pplicable_resource\x18\x07 \x01(\tB\x03\xe0\x41\x03\x12\x19\n\x0c\x62\x61\x63kup_vault\x18\x08 \x01(\tB\x03\xe0\x41\x03\x12\x42\n\x10\x62\x61\x63kup_locations\x18\x0c \x03(\x0b\x32(.google.cloud.backupdr.v1.BackupLocation\x12M\n\x15\x62\x61\x63kup_dr_plan_config\x18\n \x01(\x0b\x32,.google.cloud.backupdr.v1.BackupDrPlanConfigH\x00\x12U\n\x19\x62\x61\x63kup_dr_template_config\x18\x0b \x01(\x0b\x32\x30.google.cloud.backupdr.v1.BackupDrTemplateConfigH\x00\"\x97\x01\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12$\n CLOUD_SQL_INSTANCE_BACKUP_CONFIG\x10\x01\x12\"\n\x1e\x43OMPUTE_ENGINE_RESOURCE_POLICY\x10\x02\x12\x18\n\x14\x42\x41\x43KUPDR_BACKUP_PLAN\x10\x03\x12\x15\n\x11\x42\x41\x43KUPDR_TEMPLATE\x10\x04\"C\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\n\n\x06\x41\x43TIVE\x10\x01\x12\x0c\n\x08INACTIVE\x10\x02\x12\t\n\x05\x45RROR\x10\x03\x42\x16\n\x14plan_specific_config\"+\n\x0cPitrSettings\x12\x1b\n\x0eretention_days\x18\x01 \x01(\x05\x42\x03\xe0\x41\x03\"j\n\x16\x42\x61\x63kupDrTemplateConfig\x12\'\n\x1a\x66irst_party_management_uri\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\'\n\x1athird_party_management_uri\x18\x02 \x01(\tB\x03\xe0\x41\x03\"^\n\x12\x42\x61\x63kupDrPlanConfig\x12H\n\x14\x62\x61\x63kup_dr_plan_rules\x18\x01 \x03(\x0b\x32*.google.cloud.backupdr.v1.BackupDrPlanRule\"n\n\x10\x42\x61\x63kupDrPlanRule\x12\x14\n\x07rule_id\x18\x01 \x01(\tB\x03\xe0\x41\x03\x12\x44\n\x1blast_successful_backup_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\"\xb7\x01\n\x0e\x42\x61\x63kupLocation\x12@\n\x04type\x18\x01 \x01(\x0e\x32-.google.cloud.backupdr.v1.BackupLocation.TypeB\x03\xe0\x41\x03\x12\x18\n\x0blocation_id\x18\x02 \x01(\tB\x03\xe0\x41\x03\"I\n\x04Type\x12\x14\n\x10TYPE_UNSPECIFIED\x10\x00\x12\t\n\x05ZONAL\x10\x01\x12\x0c\n\x08REGIONAL\x10\x02\x12\x12\n\x0eMULTI_REGIONAL\x10\x03\x32\xcb\x02\n\x19\x42\x61\x63kupDrProtectionSummary\x12\xe0\x01\n\x19ListResourceBackupConfigs\x12:.google.cloud.backupdr.v1.ListResourceBackupConfigsRequest\x1a;.google.cloud.backupdr.v1.ListResourceBackupConfigsResponse\"J\xda\x41\x06parent\x82\xd3\xe4\x93\x02;\x12\x39/v1/{parent=projects/*/locations/*}/resourceBackupConfigs\x1aK\xca\x41\x17\x62\x61\x63kupdr.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xc6\x01\n\x1c\x63om.google.cloud.backupdr.v1B\x16ProtectionSummaryProtoP\x01Z8cloud.google.com/go/backupdr/apiv1/backupdrpb;backupdrpb\xaa\x02\x18Google.Cloud.BackupDR.V1\xca\x02\x18Google\\Cloud\\BackupDR\\V1\xea\x02\x1bGoogle::Cloud::BackupDR::V1b\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool + +begin + pool.add_serialized_file(descriptor_data) +rescue TypeError + # Compatibility code: will be removed in the next major version. + require 'google/protobuf/descriptor_pb' + parsed = Google::Protobuf::FileDescriptorProto.decode(descriptor_data) + parsed.clear_dependency + serialized = parsed.class.encode(parsed) + file = pool.add_serialized_file(serialized) + warn "Warning: Protobuf detected an import path issue while loading generated file #{__FILE__}" + imports = [ + ["google.protobuf.Timestamp", "google/protobuf/timestamp.proto"], + ] + imports.each do |type_name, expected_filename| + import_file = pool.lookup(type_name).file_descriptor + if import_file.name != expected_filename + warn "- #{file.name} imports #{expected_filename}, but that import was loaded as #{import_file.name}" + end + end + warn "Each proto file must use a consistent fully-qualified name." + warn "This will become an error in the next major version." +end + +module Google + module Cloud + module BackupDR + module V1 + ListResourceBackupConfigsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.ListResourceBackupConfigsRequest").msgclass + ListResourceBackupConfigsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.ListResourceBackupConfigsResponse").msgclass + ResourceBackupConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.ResourceBackupConfig").msgclass + ResourceBackupConfig::ResourceType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.ResourceBackupConfig.ResourceType").enummodule + BackupConfigDetails = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupConfigDetails").msgclass + BackupConfigDetails::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupConfigDetails.Type").enummodule + BackupConfigDetails::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupConfigDetails.State").enummodule + PitrSettings = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.PitrSettings").msgclass + BackupDrTemplateConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupDrTemplateConfig").msgclass + BackupDrPlanConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupDrPlanConfig").msgclass + BackupDrPlanRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupDrPlanRule").msgclass + BackupLocation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupLocation").msgclass + BackupLocation::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.backupdr.v1.BackupLocation.Type").enummodule + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_services_pb.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_services_pb.rb new file mode 100644 index 000000000000..6bad6df6a175 --- /dev/null +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/protection_summary_services_pb.rb @@ -0,0 +1,45 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/cloud/backupdr/v1/protection_summary.proto for package 'Google.Cloud.BackupDR.V1' +# Original file comments: +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'grpc' +require 'google/cloud/backupdr/v1/protection_summary_pb' + +module Google + module Cloud + module BackupDR + module V1 + module BackupDrProtectionSummary + # The Protection Summary service. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.cloud.backupdr.v1.BackupDrProtectionSummary' + + # Lists ResourceBackupConfigs. + rpc :ListResourceBackupConfigs, ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest, ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/rest.rb b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/rest.rb index 8d52866d5129..84f3712fd28f 100644 --- a/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/rest.rb +++ b/google-cloud-backupdr-v1/lib/google/cloud/backupdr/v1/rest.rb @@ -17,6 +17,7 @@ # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/cloud/backupdr/v1/backupdr/rest" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest" require "google/cloud/backupdr/v1/bindings_override" require "google/cloud/backupdr/v1/version" diff --git a/google-cloud-backupdr-v1/proto_docs/google/cloud/backupdr/v1/protection_summary.rb b/google-cloud-backupdr-v1/proto_docs/google/cloud/backupdr/v1/protection_summary.rb new file mode 100644 index 000000000000..79acc54ee206 --- /dev/null +++ b/google-cloud-backupdr-v1/proto_docs/google/cloud/backupdr/v1/protection_summary.rb @@ -0,0 +1,309 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + + +module Google + module Cloud + module BackupDR + module V1 + # Request for ListResourceBackupConfigs. + # @!attribute [rw] parent + # @return [::String] + # Required. The project and location for which to retrieve resource backup + # configs. Format: 'projects/\\{project_id}/locations/\\{location}'. In Google + # Cloud Backup and DR, locations map to Google Cloud regions, for example + # **us-central1**. + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. Requested page size. Server may return fewer items than + # requested. If unspecified, server will use 100 as default. Maximum value is + # 500 and values above 500 will be coerced to 500. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A token identifying a page of results the server should return. + # @!attribute [rw] filter + # @return [::String] + # Optional. Filtering results. + # @!attribute [rw] order_by + # @return [::String] + # Optional. Hint for how to order the results. + class ListResourceBackupConfigsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response for ListResourceBackupConfigs. + # @!attribute [rw] resource_backup_configs + # @return [::Array<::Google::Cloud::BackupDR::V1::ResourceBackupConfig>] + # The list of ResourceBackupConfigs for the specified scope. + # @!attribute [rw] next_page_token + # @return [::String] + # A token identifying a page of results the server should return. + class ListResourceBackupConfigsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # ResourceBackupConfig represents a resource along with its backup + # configurations. + # @!attribute [rw] name + # @return [::String] + # Identifier. The resource name of the ResourceBackupConfig. + # Format: + # projects/\\{project}/locations/\\{location}/resourceBackupConfigs/\\{uid} + # @!attribute [r] uid + # @return [::String] + # Output only. The unique identifier of the resource backup config. + # @!attribute [r] target_resource + # @return [::String] + # Output only. The [full resource + # name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + # of the cloud resource that this configuration applies to. Supported + # resource types are + # {::Google::Cloud::BackupDR::V1::ResourceBackupConfig::ResourceType ResourceBackupConfig.ResourceType}. + # @!attribute [r] target_resource_display_name + # @return [::String] + # Output only. The human friendly name of the target resource. + # @!attribute [r] target_resource_type + # @return [::Google::Cloud::BackupDR::V1::ResourceBackupConfig::ResourceType] + # Output only. The type of the target resource. + # @!attribute [rw] target_resource_labels + # @return [::Google::Protobuf::Map{::String => ::String}] + # Labels associated with the target resource. + # @!attribute [rw] backup_configs_details + # @return [::Array<::Google::Cloud::BackupDR::V1::BackupConfigDetails>] + # Backup configurations applying to the target resource, including those + # targeting its related/child resources. For example, backup configuration + # applicable to Compute Engine disks will be populated in this field for a + # Compute Engine VM which has the disk associated. + # @!attribute [r] backup_configured + # @return [::Boolean] + # Output only. Whether the target resource is configured for backup. This is + # true if the backup_configs_details is not empty. + # @!attribute [r] vaulted + # @return [::Boolean] + # Output only. Whether the target resource is protected by a backup vault. + # This is true if the backup_configs_details is not empty and any of the + # {::Google::Cloud::BackupDR::V1::ResourceBackupConfig#backup_configs_details ResourceBackupConfig.backup_configs_details} + # has a backup configuration with + # {::Google::Cloud::BackupDR::V1::BackupConfigDetails#backup_vault BackupConfigDetails.backup_vault} + # set. set. + class ResourceBackupConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # @!attribute [rw] key + # @return [::String] + # @!attribute [rw] value + # @return [::String] + class TargetResourceLabelsEntry + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # The type of the cloud resource. + module ResourceType + # Resource type not set. + RESOURCE_TYPE_UNSPECIFIED = 0 + + # Cloud SQL instance. + CLOUD_SQL_INSTANCE = 1 + + # Compute Engine VM. + COMPUTE_ENGINE_VM = 2 + + # Compute Engine Disk. + COMPUTE_ENGINE_DISK = 3 + + # Compute Engine Regional Disk. + COMPUTE_ENGINE_REGIONAL_DISK = 4 + end + end + + # BackupConfigDetails has information about how the resource is configured + # for backups and about the most recent backup taken for this configuration. + # @!attribute [r] backup_config_source + # @return [::String] + # Output only. The full resource name of the backup config source resource. + # For example, + # "//backupdr.googleapis.com/v1/projects/\\{project}/locations/\\{region}/backupPlans/\\{backupplanId}" + # or + # "//compute.googleapis.com/projects/\\{project}/locations/\\{region}/resourcePolicies/\\{resourcePolicyId}". + # @!attribute [r] backup_config_source_display_name + # @return [::String] + # Output only. The display name of the backup config source resource. + # @!attribute [r] type + # @return [::Google::Cloud::BackupDR::V1::BackupConfigDetails::Type] + # Output only. The type of the backup config resource. + # @!attribute [r] state + # @return [::Google::Cloud::BackupDR::V1::BackupConfigDetails::State] + # Output only. The state of the backup config resource. + # @!attribute [r] pitr_settings + # @return [::Google::Cloud::BackupDR::V1::PitrSettings] + # Output only. Point in time recovery settings of the backup configuration + # resource. + # @!attribute [r] latest_successful_backup_time + # @return [::Google::Protobuf::Timestamp] + # Output only. Timestamp of the latest successful backup created via this + # backup configuration. + # @!attribute [r] applicable_resource + # @return [::String] + # Output only. The [full resource + # name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + # of the resource that is applicable for the backup configuration. Example: + # "//compute.googleapis.com/projects/\\{project}/zones/\\{zone}/instances/\\{instance}" + # @!attribute [r] backup_vault + # @return [::String] + # Output only. The [full resource + # name](https://cloud.google.com/asset-inventory/docs/resource-name-format) + # of the backup vault that will store the backups generated through this + # backup configuration. Example: + # "//backupdr.googleapis.com/v1/projects/\\{project}/locations/\\{region}/backupVaults/\\{backupvaultId}" + # @!attribute [rw] backup_locations + # @return [::Array<::Google::Cloud::BackupDR::V1::BackupLocation>] + # The locations where the backups are to be stored. + # @!attribute [rw] backup_dr_plan_config + # @return [::Google::Cloud::BackupDR::V1::BackupDrPlanConfig] + # Google Cloud Backup and DR's Backup Plan specific data. + # + # Note: The following fields are mutually exclusive: `backup_dr_plan_config`, `backup_dr_template_config`. If a field in that set is populated, all other fields in the set will automatically be cleared. + # @!attribute [rw] backup_dr_template_config + # @return [::Google::Cloud::BackupDR::V1::BackupDrTemplateConfig] + # Google Cloud Backup and DR's Template specific data. + # + # Note: The following fields are mutually exclusive: `backup_dr_template_config`, `backup_dr_plan_config`. If a field in that set is populated, all other fields in the set will automatically be cleared. + class BackupConfigDetails + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Type of the backup configuration. + # This enum may receive new values in the future. + module Type + # Backup config type is unspecified. + TYPE_UNSPECIFIED = 0 + + # Backup config is Cloud SQL instance's automated backup config. + CLOUD_SQL_INSTANCE_BACKUP_CONFIG = 1 + + # Backup config is Compute Engine Resource Policy. + COMPUTE_ENGINE_RESOURCE_POLICY = 2 + + # Backup config is Google Cloud Backup and DR's Backup Plan. + BACKUPDR_BACKUP_PLAN = 3 + + # Backup config is Google Cloud Backup and DR's Template. + BACKUPDR_TEMPLATE = 4 + end + + # The state tells whether the backup config is active or not. + module State + # Backup config state not set. + STATE_UNSPECIFIED = 0 + + # The config is in an active state protecting the resource + ACTIVE = 1 + + # The config is currently not protecting the resource. Either because it is + # disabled or the owning project has been deleted without cleanup of the + # actual resource. + INACTIVE = 2 + + # The config still exists but because of some error state it is not + # protecting the resource. Like the source project is deleted. For eg. + # PlanAssociation, BackupPlan is deleted. + ERROR = 3 + end + end + + # Point in time recovery settings of the backup configuration resource. + # @!attribute [r] retention_days + # @return [::Integer] + # Output only. Number of days to retain the backup. + class PitrSettings + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Provides additional information about Google Cloud Backup + # and DR's Template backup configuration. + # @!attribute [r] first_party_management_uri + # @return [::String] + # Output only. The URI of the BackupDr template resource for the first party + # identity users. + # @!attribute [r] third_party_management_uri + # @return [::String] + # Output only. The URI of the BackupDr template resource for the third party + # identity users. + class BackupDrTemplateConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # BackupDrPlanConfig has additional information about Google Cloud Backup and + # DR's Plan backup configuration. + # @!attribute [rw] backup_dr_plan_rules + # @return [::Array<::Google::Cloud::BackupDR::V1::BackupDrPlanRule>] + # Backup rules of the backup plan resource. + class BackupDrPlanConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # BackupDrPlanRule has rule specific information of the backup plan resource. + # @!attribute [r] rule_id + # @return [::String] + # Output only. Unique Id of the backup rule. + # @!attribute [r] last_successful_backup_time + # @return [::Google::Protobuf::Timestamp] + # Output only. Timestamp of the latest successful backup created via this + # backup rule. + class BackupDrPlanRule + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # BackupLocation represents a cloud location where a backup can be stored. + # @!attribute [r] type + # @return [::Google::Cloud::BackupDR::V1::BackupLocation::Type] + # Output only. The type of the location. + # @!attribute [r] location_id + # @return [::String] + # Output only. The id of the cloud location. Example: "us-central1" + class BackupLocation + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # The type of the location. + module Type + # Location type is unspecified. + TYPE_UNSPECIFIED = 0 + + # Location type is zonal. + ZONAL = 1 + + # Location type is regional. + REGIONAL = 2 + + # Location type is multi regional. + MULTI_REGIONAL = 3 + end + end + end + end + end +end diff --git a/google-cloud-backupdr-v1/snippets/backup_dr_protection_summary/list_resource_backup_configs.rb b/google-cloud-backupdr-v1/snippets/backup_dr_protection_summary/list_resource_backup_configs.rb new file mode 100644 index 000000000000..2b79d9a8674f --- /dev/null +++ b/google-cloud-backupdr-v1/snippets/backup_dr_protection_summary/list_resource_backup_configs.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +# [START backupdr_v1_generated_BackupDrProtectionSummary_ListResourceBackupConfigs_sync] +require "google/cloud/backupdr/v1" + +## +# Snippet for the list_resource_backup_configs call in the BackupDrProtectionSummary service +# +# This snippet has been automatically generated and should be regarded as a code +# template only. It will require modifications to work: +# - It may require correct/in-range values for request initialization. +# - It may require specifying regional endpoints when creating the service +# client as shown in https://cloud.google.com/ruby/docs/reference. +# +# This is an auto-generated example demonstrating basic usage of +# Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client#list_resource_backup_configs. +# +def list_resource_backup_configs + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new + + # Call the list_resource_backup_configs method. + result = client.list_resource_backup_configs request + + # The returned object is of type Gapic::PagedEnumerable. You can iterate + # over elements, and API calls will be issued to fetch pages as needed. + result.each do |item| + # Each element is of type ::Google::Cloud::BackupDR::V1::ResourceBackupConfig. + p item + end +end +# [END backupdr_v1_generated_BackupDrProtectionSummary_ListResourceBackupConfigs_sync] diff --git a/google-cloud-backupdr-v1/snippets/snippet_metadata_google.cloud.backupdr.v1.json b/google-cloud-backupdr-v1/snippets/snippet_metadata_google.cloud.backupdr.v1.json index ad8beb1f189e..7ab8acaba73c 100644 --- a/google-cloud-backupdr-v1/snippets/snippet_metadata_google.cloud.backupdr.v1.json +++ b/google-cloud-backupdr-v1/snippets/snippet_metadata_google.cloud.backupdr.v1.json @@ -1490,6 +1490,46 @@ "type": "FULL" } ] + }, + { + "region_tag": "backupdr_v1_generated_BackupDrProtectionSummary_ListResourceBackupConfigs_sync", + "title": "Snippet for the list_resource_backup_configs call in the BackupDrProtectionSummary service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client#list_resource_backup_configs.", + "file": "backup_dr_protection_summary/list_resource_backup_configs.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_resource_backup_configs", + "full_name": "::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client#list_resource_backup_configs", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse", + "client": { + "short_name": "BackupDrProtectionSummary::Client", + "full_name": "::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client" + }, + "method": { + "short_name": "ListResourceBackupConfigs", + "full_name": "google.cloud.backupdr.v1.BackupDrProtectionSummary.ListResourceBackupConfigs", + "service": { + "short_name": "BackupDrProtectionSummary", + "full_name": "google.cloud.backupdr.v1.BackupDrProtectionSummary" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] } ] } \ No newline at end of file diff --git a/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_paths_test.rb b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_paths_test.rb new file mode 100644 index 000000000000..9d979a3cfce6 --- /dev/null +++ b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_paths_test.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/cloud/backupdr/v1/backup_dr_protection_summary" + +class ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::ClientPathsTest < Minitest::Test + class DummyStub + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + + def stub_logger + nil + end + + def logger + nil + end + end + + def test_location_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.location_path project: "value0", location: "value1" + assert_equal "projects/value0/locations/value1", path + end + end +end diff --git a/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_rest_test.rb b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_rest_test.rb new file mode 100644 index 000000000000..1d7d6c2b8954 --- /dev/null +++ b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_rest_test.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" +require "gapic/rest" +require "google/cloud/backupdr/v1/protection_summary_pb" +require "google/cloud/backupdr/v1/backup_dr_protection_summary/rest" + + +class ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_count, :requests + + def initialize response, &block + @response = response + @block = block + @call_count = 0 + @requests = [] + end + + def make_get_request uri:, params: {}, options: {}, method_name: nil + make_http_request :get, uri: uri, body: nil, params: params, options: options, method_name: method_name + end + + def make_delete_request uri:, params: {}, options: {}, method_name: nil + make_http_request :delete, uri: uri, body: nil, params: params, options: options, method_name: method_name + end + + def make_post_request uri:, body: nil, params: {}, options: {}, method_name: nil + make_http_request :post, uri: uri, body: body, params: params, options: options, method_name: method_name + end + + def make_patch_request uri:, body:, params: {}, options: {}, method_name: nil + make_http_request :patch, uri: uri, body: body, params: params, options: options, method_name: method_name + end + + def make_put_request uri:, body:, params: {}, options: {}, method_name: nil + make_http_request :put, uri: uri, body: body, params: params, options: options, method_name: method_name + end + + def make_http_request *args, **kwargs + @call_count += 1 + + @requests << @block&.call(*args, **kwargs) + + @response + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + + def stub_logger + nil + end + + def logger + nil + end + end + + def test_list_resource_backup_configs + # Create test objects. + client_result = ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + filter = "hello world" + order_by = "hello world" + + list_resource_backup_configs_client_stub = ClientStub.new http_response do |_verb, uri:, body:, params:, options:, method_name:| + assert options.metadata.key? :"x-goog-api-client" + assert options.metadata[:"x-goog-api-client"].include? "rest" + refute options.metadata[:"x-goog-api-client"].include? "grpc" + end + + ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::ServiceStub.stub :transcode_list_resource_backup_configs_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_resource_backup_configs_client_stub do + # Create client + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_resource_backup_configs({ parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_resource_backup_configs parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_resource_backup_configs ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new(parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_resource_backup_configs({ parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_resource_backup_configs(::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new(parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_resource_backup_configs_client_stub.call_count + end + end + end + + def test_configure + credentials_token = :dummy_value + + client = block_config = config = nil + dummy_stub = ClientStub.new nil + Gapic::Rest::ClientStub.stub :new, dummy_stub do + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client.new do |config| + config.credentials = credentials_token + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Rest::Client::Configuration, config + end +end diff --git a/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_test.rb b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_test.rb new file mode 100644 index 000000000000..721fe7b5b877 --- /dev/null +++ b/google-cloud-backupdr-v1/test/google/cloud/backupdr/v1/backup_dr_protection_summary_test.rb @@ -0,0 +1,175 @@ +# frozen_string_literal: true + +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Auto-generated by gapic-generator-ruby. DO NOT EDIT! + +require "helper" + +require "gapic/grpc/service_stub" + +require "google/cloud/backupdr/v1/protection_summary_pb" +require "google/cloud/backupdr/v1/backup_dr_protection_summary" + +class ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::ClientTest < Minitest::Test + class ClientStub + attr_accessor :call_rpc_count, :requests + + def initialize response, operation, &block + @response = response + @operation = operation + @block = block + @call_rpc_count = 0 + @requests = [] + end + + def call_rpc *args, **kwargs + @call_rpc_count += 1 + + @requests << @block&.call(*args, **kwargs) + + catch :response do + yield @response, @operation if block_given? + @response + end + end + + def endpoint + "endpoint.example.com" + end + + def universe_domain + "example.com" + end + + def stub_logger + nil + end + + def logger + nil + end + end + + def test_list_resource_backup_configs + # Create GRPC objects. + grpc_response = ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsResponse.new + grpc_operation = GRPC::ActiveCall::Operation.new nil + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + grpc_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + page_size = 42 + page_token = "hello world" + filter = "hello world" + order_by = "hello world" + + list_resource_backup_configs_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_resource_backup_configs, name + assert_kind_of ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + assert_equal "hello world", request["filter"] + assert_equal "hello world", request["order_by"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_resource_backup_configs_client_stub do + # Create client + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_resource_backup_configs({ parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by }) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.list_resource_backup_configs parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.list_resource_backup_configs ::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new(parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.list_resource_backup_configs({ parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by }, grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.list_resource_backup_configs(::Google::Cloud::BackupDR::V1::ListResourceBackupConfigsRequest.new(parent: parent, page_size: page_size, page_token: page_token, filter: filter, order_by: order_by), grpc_options) do |response, operation| + assert_kind_of Gapic::PagedEnumerable, response + assert_equal grpc_response, response.response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, list_resource_backup_configs_client_stub.call_rpc_count + end + end + + def test_configure + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + + client = block_config = config = nil + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + config.credentials = grpc_channel + end + end + + config = client.configure do |c| + block_config = c + end + + assert_same block_config, config + assert_kind_of ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client::Configuration, config + end + + def test_credentials + key = OpenSSL::PKey::RSA.new 2048 + cred_json = { + "private_key" => key.to_pem, + "client_email" => "app@developer.gserviceaccount.com", + "type" => "service_account" + } + key_file = StringIO.new cred_json.to_json + creds = Google::Auth::ServiceAccountCredentials.make_creds({ json_key_io: key_file }) + + dummy_stub = ClientStub.new nil, nil + Gapic::ServiceStub.stub :new, dummy_stub do + client = ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client.new do |config| + config.credentials = creds + end + assert_kind_of ::Google::Cloud::BackupDR::V1::BackupDrProtectionSummary::Client, client + assert_equal creds, client.configure.credentials + end + end +end