diff --git a/google-cloud-ai_platform-v1/.owlbot-manifest.json b/google-cloud-ai_platform-v1/.owlbot-manifest.json index 3c30f10c5aab..8e3a1c3d83d8 100644 --- a/google-cloud-ai_platform-v1/.owlbot-manifest.json +++ b/google-cloud-ai_platform-v1/.owlbot-manifest.json @@ -91,6 +91,13 @@ "lib/google/cloud/ai_platform/v1/featurestore_service/rest/client.rb", "lib/google/cloud/ai_platform/v1/featurestore_service/rest/operations.rb", "lib/google/cloud/ai_platform/v1/featurestore_service/rest/service_stub.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/client.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/credentials.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/paths.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/client.rb", + "lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/service_stub.rb", "lib/google/cloud/ai_platform/v1/gen_ai_tuning_service.rb", "lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/client.rb", "lib/google/cloud/ai_platform/v1/gen_ai_tuning_service/credentials.rb", @@ -269,6 +276,7 @@ "lib/google/cloud/aiplatform/v1/api_auth_pb.rb", "lib/google/cloud/aiplatform/v1/artifact_pb.rb", "lib/google/cloud/aiplatform/v1/batch_prediction_job_pb.rb", + "lib/google/cloud/aiplatform/v1/cached_content_pb.rb", "lib/google/cloud/aiplatform/v1/completion_stats_pb.rb", "lib/google/cloud/aiplatform/v1/content_pb.rb", "lib/google/cloud/aiplatform/v1/context_pb.rb", @@ -316,6 +324,8 @@ "lib/google/cloud/aiplatform/v1/featurestore_pb.rb", "lib/google/cloud/aiplatform/v1/featurestore_service_pb.rb", "lib/google/cloud/aiplatform/v1/featurestore_service_services_pb.rb", + "lib/google/cloud/aiplatform/v1/gen_ai_cache_service_pb.rb", + "lib/google/cloud/aiplatform/v1/gen_ai_cache_service_services_pb.rb", "lib/google/cloud/aiplatform/v1/genai_tuning_service_pb.rb", "lib/google/cloud/aiplatform/v1/genai_tuning_service_services_pb.rb", "lib/google/cloud/aiplatform/v1/hyperparameter_tuning_job_pb.rb", @@ -417,6 +427,7 @@ "proto_docs/google/cloud/aiplatform/v1/api_auth.rb", "proto_docs/google/cloud/aiplatform/v1/artifact.rb", "proto_docs/google/cloud/aiplatform/v1/batch_prediction_job.rb", + "proto_docs/google/cloud/aiplatform/v1/cached_content.rb", "proto_docs/google/cloud/aiplatform/v1/completion_stats.rb", "proto_docs/google/cloud/aiplatform/v1/content.rb", "proto_docs/google/cloud/aiplatform/v1/context.rb", @@ -455,6 +466,7 @@ "proto_docs/google/cloud/aiplatform/v1/featurestore_monitoring.rb", "proto_docs/google/cloud/aiplatform/v1/featurestore_online_service.rb", "proto_docs/google/cloud/aiplatform/v1/featurestore_service.rb", + "proto_docs/google/cloud/aiplatform/v1/gen_ai_cache_service.rb", "proto_docs/google/cloud/aiplatform/v1/genai_tuning_service.rb", "proto_docs/google/cloud/aiplatform/v1/hyperparameter_tuning_job.rb", "proto_docs/google/cloud/aiplatform/v1/index.rb", @@ -572,6 +584,7 @@ "proto_docs/google/type/date.rb", "proto_docs/google/type/expr.rb", "proto_docs/google/type/interval.rb", + "proto_docs/google/type/latlng.rb", "proto_docs/google/type/money.rb", "snippets/Gemfile", "snippets/dataset_service/create_dataset.rb", @@ -659,6 +672,11 @@ "snippets/featurestore_service/update_entity_type.rb", "snippets/featurestore_service/update_feature.rb", "snippets/featurestore_service/update_featurestore.rb", + "snippets/gen_ai_cache_service/create_cached_content.rb", + "snippets/gen_ai_cache_service/delete_cached_content.rb", + "snippets/gen_ai_cache_service/get_cached_content.rb", + "snippets/gen_ai_cache_service/list_cached_contents.rb", + "snippets/gen_ai_cache_service/update_cached_content.rb", "snippets/gen_ai_tuning_service/cancel_tuning_job.rb", "snippets/gen_ai_tuning_service/create_tuning_job.rb", "snippets/gen_ai_tuning_service/get_tuning_job.rb", @@ -922,6 +940,9 @@ "test/google/cloud/ai_platform/v1/featurestore_service_paths_test.rb", "test/google/cloud/ai_platform/v1/featurestore_service_rest_test.rb", "test/google/cloud/ai_platform/v1/featurestore_service_test.rb", + "test/google/cloud/ai_platform/v1/gen_ai_cache_service_paths_test.rb", + "test/google/cloud/ai_platform/v1/gen_ai_cache_service_rest_test.rb", + "test/google/cloud/ai_platform/v1/gen_ai_cache_service_test.rb", "test/google/cloud/ai_platform/v1/gen_ai_tuning_service_operations_test.rb", "test/google/cloud/ai_platform/v1/gen_ai_tuning_service_paths_test.rb", "test/google/cloud/ai_platform/v1/gen_ai_tuning_service_rest_test.rb", diff --git a/google-cloud-ai_platform-v1/gapic_metadata.json b/google-cloud-ai_platform-v1/gapic_metadata.json index 53379375bb01..3e56b4b1de56 100644 --- a/google-cloud-ai_platform-v1/gapic_metadata.json +++ b/google-cloud-ai_platform-v1/gapic_metadata.json @@ -511,6 +511,40 @@ } } }, + "GenAiCacheService": { + "clients": { + "grpc": { + "libraryClient": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client", + "rpcs": { + "CreateCachedContent": { + "methods": [ + "create_cached_content" + ] + }, + "GetCachedContent": { + "methods": [ + "get_cached_content" + ] + }, + "UpdateCachedContent": { + "methods": [ + "update_cached_content" + ] + }, + "DeleteCachedContent": { + "methods": [ + "delete_cached_content" + ] + }, + "ListCachedContents": { + "methods": [ + "list_cached_contents" + ] + } + } + } + } + }, "GenAiTuningService": { "clients": { "grpc": { diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1.rb index 2c11ac41eeed..42c2bcca7f0d 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1.rb @@ -25,6 +25,7 @@ require "google/cloud/ai_platform/v1/feature_online_store_service" require "google/cloud/ai_platform/v1/featurestore_service" require "google/cloud/ai_platform/v1/feature_registry_service" +require "google/cloud/ai_platform/v1/gen_ai_cache_service" require "google/cloud/ai_platform/v1/gen_ai_tuning_service" require "google/cloud/ai_platform/v1/index_endpoint_service" require "google/cloud/ai_platform/v1/index_service" diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service.rb new file mode 100644 index 000000000000..8adcb4b183f9 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# 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 +# +# 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/ai_platform/v1/version" + +require "google/cloud/ai_platform/v1/gen_ai_cache_service/credentials" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/paths" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/client" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest" + +module Google + module Cloud + module AIPlatform + module V1 + ## + # Service for managing Vertex AI's CachedContent resource. + # + # @example Load this service and instantiate a gRPC client + # + # require "google/cloud/ai_platform/v1/gen_ai_cache_service" + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # @example Load this service and instantiate a REST client + # + # require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest" + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + module GenAiCacheService + end + end + end + end +end + +helper_path = ::File.join __dir__, "gen_ai_cache_service", "helpers.rb" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/helpers" if ::File.file? helper_path diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/client.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/client.rb new file mode 100644 index 000000000000..a06fffb056d2 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/client.rb @@ -0,0 +1,872 @@ +# frozen_string_literal: true + +# 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 +# +# 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/aiplatform/v1/gen_ai_cache_service_pb" +require "google/cloud/location" +require "google/iam/v1" + +module Google + module Cloud + module AIPlatform + module V1 + module GenAiCacheService + ## + # Client for the GenAiCacheService service. + # + # Service for managing Vertex AI's CachedContent resource. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :gen_ai_cache_service_stub + + ## + # Configure the GenAiCacheService Client class. + # + # See {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all GenAiCacheService clients + # ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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", "AIPlatform", "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 + end + yield @configure if block_given? + @configure + end + + ## + # Configure the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::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 + @gen_ai_cache_service_stub.universe_domain + end + + ## + # Create a new GenAiCacheService client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the GenAiCacheService 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/aiplatform/v1/gen_ai_cache_service_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 + + @gen_ai_cache_service_stub = ::Gapic::ServiceStub.new( + ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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 + ) + + @gen_ai_cache_service_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 = @gen_ai_cache_service_stub.endpoint + config.universe_domain = @gen_ai_cache_service_stub.universe_domain + config.logger = @gen_ai_cache_service_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 = @gen_ai_cache_service_stub.endpoint + config.universe_domain = @gen_ai_cache_service_stub.universe_domain + config.logger = @gen_ai_cache_service_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 + @gen_ai_cache_service_stub.logger + end + + # Service calls + + ## + # Creates cached content, this call will initialize the cached content in the + # data storage, and users need to pay for the cache data storage. + # + # @overload create_cached_content(request, options = nil) + # Pass arguments to `create_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest, ::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 create_cached_content(parent: nil, cached_content: nil) + # Pass arguments to `create_cached_content` 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 parent resource where the cached content will be created + # @param cached_content [::Google::Cloud::AIPlatform::V1::CachedContent, ::Hash] + # Required. The cached content to create + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new + # + # # Call the create_cached_content method. + # result = client.create_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def create_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest + + # 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.create_cached_content.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::AIPlatform::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.create_cached_content.timeout, + metadata: metadata, + retry_policy: @config.rpcs.create_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.call_rpc :create_cached_content, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Gets cached content configurations + # + # @overload get_cached_content(request, options = nil) + # Pass arguments to `get_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::GetCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::GetCachedContentRequest, ::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 get_cached_content(name: nil) + # Pass arguments to `get_cached_content` 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 name [::String] + # Required. The resource name referring to the cached content + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new + # + # # Call the get_cached_content method. + # result = client.get_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def get_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest + + # 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.get_cached_content.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::AIPlatform::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.name + header_params["name"] = request.name + 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.get_cached_content.timeout, + metadata: metadata, + retry_policy: @config.rpcs.get_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.call_rpc :get_cached_content, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates cached content configurations + # + # @overload update_cached_content(request, options = nil) + # Pass arguments to `update_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest, ::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 update_cached_content(cached_content: nil, update_mask: nil) + # Pass arguments to `update_cached_content` 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 cached_content [::Google::Cloud::AIPlatform::V1::CachedContent, ::Hash] + # Required. The cached content to update + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. The list of fields to update. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new + # + # # Call the update_cached_content method. + # result = client.update_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def update_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest + + # 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.update_cached_content.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::AIPlatform::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.cached_content&.name + header_params["cached_content.name"] = request.cached_content.name + 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.update_cached_content.timeout, + metadata: metadata, + retry_policy: @config.rpcs.update_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.call_rpc :update_cached_content, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes cached content + # + # @overload delete_cached_content(request, options = nil) + # Pass arguments to `delete_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest, ::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 delete_cached_content(name: nil) + # Pass arguments to `delete_cached_content` 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 name [::String] + # Required. The resource name referring to the cached content + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Google::Protobuf::Empty] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new + # + # # Call the delete_cached_content method. + # result = client.delete_cached_content request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest + + # 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.delete_cached_content.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::AIPlatform::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.name + header_params["name"] = request.name + 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.delete_cached_content.timeout, + metadata: metadata, + retry_policy: @config.rpcs.delete_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.call_rpc :delete_cached_content, request, options: options do |response, operation| + yield response, operation if block_given? + end + rescue ::GRPC::BadStatus => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists cached contents in a project + # + # @overload list_cached_contents(request, options = nil) + # Pass arguments to `list_cached_contents` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest, ::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_cached_contents(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_cached_contents` 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 parent, which owns this collection of cached contents. + # @param page_size [::Integer] + # Optional. The maximum number of cached contents to return. The service may + # return fewer than this value. If unspecified, some default (under maximum) + # number of items will be returned. The maximum value is 1000; values above + # 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListCachedContents` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCachedContents` must + # match the call that provided the page token. + # + # @yield [response, operation] Access the result along with the RPC operation + # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::AIPlatform::V1::CachedContent>] + # @yieldparam operation [::GRPC::ActiveCall::Operation] + # + # @return [::Gapic::PagedEnumerable<::Google::Cloud::AIPlatform::V1::CachedContent>] + # + # @raise [::Google::Cloud::Error] if the RPC is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new + # + # # Call the list_cached_contents method. + # result = client.list_cached_contents 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::AIPlatform::V1::CachedContent. + # p item + # end + # + def list_cached_contents request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest + + # 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_cached_contents.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::AIPlatform::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_cached_contents.timeout, + metadata: metadata, + retry_policy: @config.rpcs.list_cached_contents.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.call_rpc :list_cached_contents, request, options: options do |response, operation| + response = ::Gapic::PagedEnumerable.new @gen_ai_cache_service_stub, :list_cached_contents, 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 GenAiCacheService API. + # + # This class represents the configuration for GenAiCacheService, + # 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::AIPlatform::V1::GenAiCacheService::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 + # # create_cached_content to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.create_cached_content.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.create_cached_content.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)) + # * (`GRPC::Core::Channel`) a gRPC channel with included credentials + # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object + # * (`nil`) indicating no 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 = "aiplatform.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC + 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 GenAiCacheService 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 `create_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :create_cached_content + ## + # RPC-specific configuration for `get_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :get_cached_content + ## + # RPC-specific configuration for `update_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :update_cached_content + ## + # RPC-specific configuration for `delete_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_cached_content + ## + # RPC-specific configuration for `list_cached_contents` + # @return [::Gapic::Config::Method] + # + attr_reader :list_cached_contents + + # @private + def initialize parent_rpcs = nil + create_cached_content_config = parent_rpcs.create_cached_content if parent_rpcs.respond_to? :create_cached_content + @create_cached_content = ::Gapic::Config::Method.new create_cached_content_config + get_cached_content_config = parent_rpcs.get_cached_content if parent_rpcs.respond_to? :get_cached_content + @get_cached_content = ::Gapic::Config::Method.new get_cached_content_config + update_cached_content_config = parent_rpcs.update_cached_content if parent_rpcs.respond_to? :update_cached_content + @update_cached_content = ::Gapic::Config::Method.new update_cached_content_config + delete_cached_content_config = parent_rpcs.delete_cached_content if parent_rpcs.respond_to? :delete_cached_content + @delete_cached_content = ::Gapic::Config::Method.new delete_cached_content_config + list_cached_contents_config = parent_rpcs.list_cached_contents if parent_rpcs.respond_to? :list_cached_contents + @list_cached_contents = ::Gapic::Config::Method.new list_cached_contents_config + + yield self if block_given? + end + end + end + end + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/credentials.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/credentials.rb new file mode 100644 index 000000000000..b1de1b675c33 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/credentials.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# 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 +# +# 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 AIPlatform + module V1 + module GenAiCacheService + # Credentials for the GenAiCacheService 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-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/paths.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/paths.rb new file mode 100644 index 000000000000..9206d9c7cc0e --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/paths.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +# 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 +# +# 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 AIPlatform + module V1 + module GenAiCacheService + # Path helper methods for the GenAiCacheService API. + module Paths + ## + # Create a fully-qualified CachedContent resource string. + # + # The resource will be in the following format: + # + # `projects/{project}/locations/{location}/cachedContents/{cached_content}` + # + # @param project [String] + # @param location [String] + # @param cached_content [String] + # + # @return [::String] + def cached_content_path project:, location:, cached_content: + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + + "projects/#{project}/locations/#{location}/cachedContents/#{cached_content}" + end + + ## + # 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 + + ## + # Create a fully-qualified RagCorpus resource string. + # + # The resource will be in the following format: + # + # `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}` + # + # @param project [String] + # @param location [String] + # @param rag_corpus [String] + # + # @return [::String] + def rag_corpus_path project:, location:, rag_corpus: + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + + "projects/#{project}/locations/#{location}/ragCorpora/#{rag_corpus}" + end + + extend self + end + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest.rb new file mode 100644 index 000000000000..b93e659d7754 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +# 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 +# +# 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/ai_platform/v1/version" +require "google/cloud/ai_platform/v1/bindings_override" + +require "google/cloud/ai_platform/v1/gen_ai_cache_service/credentials" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/paths" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest/client" + +module Google + module Cloud + module AIPlatform + module V1 + ## + # Service for managing Vertex AI's CachedContent resource. + # + # To load this service and instantiate a REST client: + # + # require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest" + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + module GenAiCacheService + # Client for the REST transport + module Rest + end + end + end + end + end +end + +helper_path = ::File.join __dir__, "rest", "helpers.rb" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest/helpers" if ::File.file? helper_path diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/client.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/client.rb new file mode 100644 index 000000000000..2220e0bc8034 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/client.rb @@ -0,0 +1,820 @@ +# frozen_string_literal: true + +# 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 +# +# 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/aiplatform/v1/gen_ai_cache_service_pb" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest/service_stub" +require "google/cloud/location/rest" +require "google/iam/v1/rest" + +module Google + module Cloud + module AIPlatform + module V1 + module GenAiCacheService + module Rest + ## + # REST client for the GenAiCacheService service. + # + # Service for managing Vertex AI's CachedContent resource. + # + class Client + # @private + API_VERSION = "" + + # @private + DEFAULT_ENDPOINT_TEMPLATE = "aiplatform.$UNIVERSE_DOMAIN$" + + include Paths + + # @private + attr_reader :gen_ai_cache_service_stub + + ## + # Configure the GenAiCacheService Client class. + # + # See {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client::Configuration} + # for a description of the configuration fields. + # + # @example + # + # # Modify the configuration for all GenAiCacheService clients + # ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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", "AIPlatform", "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 + end + yield @configure if block_given? + @configure + end + + ## + # Configure the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::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 + @gen_ai_cache_service_stub.universe_domain + end + + ## + # Create a new GenAiCacheService REST client object. + # + # @example + # + # # Create a client using the default configuration + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a client using a custom configuration + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + # config.timeout = 10.0 + # end + # + # @yield [config] Configure the GenAiCacheService 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 + + @gen_ai_cache_service_stub = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.new( + endpoint: @config.endpoint, + endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, + universe_domain: @config.universe_domain, + credentials: credentials, + logger: @config.logger + ) + + @gen_ai_cache_service_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 = @gen_ai_cache_service_stub.endpoint + config.universe_domain = @gen_ai_cache_service_stub.universe_domain + config.bindings_override = @config.bindings_override + config.logger = @gen_ai_cache_service_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 = @gen_ai_cache_service_stub.endpoint + config.universe_domain = @gen_ai_cache_service_stub.universe_domain + config.bindings_override = @config.bindings_override + config.logger = @gen_ai_cache_service_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 + @gen_ai_cache_service_stub.logger + end + + # Service calls + + ## + # Creates cached content, this call will initialize the cached content in the + # data storage, and users need to pay for the cache data storage. + # + # @overload create_cached_content(request, options = nil) + # Pass arguments to `create_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest, ::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 create_cached_content(parent: nil, cached_content: nil) + # Pass arguments to `create_cached_content` 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 parent resource where the cached content will be created + # @param cached_content [::Google::Cloud::AIPlatform::V1::CachedContent, ::Hash] + # Required. The cached content to create + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new + # + # # Call the create_cached_content method. + # result = client.create_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def create_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest + + # 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.create_cached_content.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::AIPlatform::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.create_cached_content.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.create_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.create_cached_content request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Gets cached content configurations + # + # @overload get_cached_content(request, options = nil) + # Pass arguments to `get_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::GetCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::GetCachedContentRequest, ::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 get_cached_content(name: nil) + # Pass arguments to `get_cached_content` 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 name [::String] + # Required. The resource name referring to the cached content + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new + # + # # Call the get_cached_content method. + # result = client.get_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def get_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest + + # 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.get_cached_content.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::AIPlatform::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.get_cached_content.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.get_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.get_cached_content request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Updates cached content configurations + # + # @overload update_cached_content(request, options = nil) + # Pass arguments to `update_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest, ::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 update_cached_content(cached_content: nil, update_mask: nil) + # Pass arguments to `update_cached_content` 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 cached_content [::Google::Cloud::AIPlatform::V1::CachedContent, ::Hash] + # Required. The cached content to update + # @param update_mask [::Google::Protobuf::FieldMask, ::Hash] + # Required. The list of fields to update. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Cloud::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new + # + # # Call the update_cached_content method. + # result = client.update_cached_content request + # + # # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + # p result + # + def update_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest + + # 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.update_cached_content.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::AIPlatform::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.update_cached_content.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.update_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.update_cached_content request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Deletes cached content + # + # @overload delete_cached_content(request, options = nil) + # Pass arguments to `delete_cached_content` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest, ::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 delete_cached_content(name: nil) + # Pass arguments to `delete_cached_content` 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 name [::String] + # Required. The resource name referring to the cached content + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new + # + # # Call the delete_cached_content method. + # result = client.delete_cached_content request + # + # # The returned object is of type Google::Protobuf::Empty. + # p result + # + def delete_cached_content request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest + + # 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.delete_cached_content.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::AIPlatform::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.delete_cached_content.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.delete_cached_content.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.delete_cached_content request, options do |result, operation| + yield result, operation if block_given? + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## + # Lists cached contents in a project + # + # @overload list_cached_contents(request, options = nil) + # Pass arguments to `list_cached_contents` via a request object, either of type + # {::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest, ::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_cached_contents(parent: nil, page_size: nil, page_token: nil) + # Pass arguments to `list_cached_contents` 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 parent, which owns this collection of cached contents. + # @param page_size [::Integer] + # Optional. The maximum number of cached contents to return. The service may + # return fewer than this value. If unspecified, some default (under maximum) + # number of items will be returned. The maximum value is 1000; values above + # 1000 will be coerced to 1000. + # @param page_token [::String] + # Optional. A page token, received from a previous `ListCachedContents` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCachedContents` must + # match the call that provided the page token. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::AIPlatform::V1::CachedContent>] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::AIPlatform::V1::CachedContent>] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/ai_platform/v1" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new + # + # # Call the list_cached_contents method. + # result = client.list_cached_contents 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::AIPlatform::V1::CachedContent. + # p item + # end + # + def list_cached_contents request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest + + # 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_cached_contents.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::AIPlatform::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_cached_contents.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.list_cached_contents.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @gen_ai_cache_service_stub.list_cached_contents request, options do |result, operation| + result = ::Gapic::Rest::PagedEnumerable.new @gen_ai_cache_service_stub, :list_cached_contents, "cached_contents", 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 GenAiCacheService REST API. + # + # This class represents the configuration for GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::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 + # # create_cached_content to 20 seconds, + # # and all remaining timeouts to 10 seconds. + # ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.configure do |config| + # config.timeout = 10.0 + # config.rpcs.create_cached_content.timeout = 20.0 + # end + # + # # Apply the above configuration only to a new client. + # client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + # config.timeout = 10.0 + # config.rpcs.create_cached_content.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 + # @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 = "aiplatform.googleapis.com" + + config_attr :endpoint, nil, ::String, nil + config_attr :credentials, nil do |value| + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::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 GenAiCacheService 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 `create_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :create_cached_content + ## + # RPC-specific configuration for `get_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :get_cached_content + ## + # RPC-specific configuration for `update_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :update_cached_content + ## + # RPC-specific configuration for `delete_cached_content` + # @return [::Gapic::Config::Method] + # + attr_reader :delete_cached_content + ## + # RPC-specific configuration for `list_cached_contents` + # @return [::Gapic::Config::Method] + # + attr_reader :list_cached_contents + + # @private + def initialize parent_rpcs = nil + create_cached_content_config = parent_rpcs.create_cached_content if parent_rpcs.respond_to? :create_cached_content + @create_cached_content = ::Gapic::Config::Method.new create_cached_content_config + get_cached_content_config = parent_rpcs.get_cached_content if parent_rpcs.respond_to? :get_cached_content + @get_cached_content = ::Gapic::Config::Method.new get_cached_content_config + update_cached_content_config = parent_rpcs.update_cached_content if parent_rpcs.respond_to? :update_cached_content + @update_cached_content = ::Gapic::Config::Method.new update_cached_content_config + delete_cached_content_config = parent_rpcs.delete_cached_content if parent_rpcs.respond_to? :delete_cached_content + @delete_cached_content = ::Gapic::Config::Method.new delete_cached_content_config + list_cached_contents_config = parent_rpcs.list_cached_contents if parent_rpcs.respond_to? :list_cached_contents + @list_cached_contents = ::Gapic::Config::Method.new list_cached_contents_config + + yield self if block_given? + end + end + end + end + end + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/service_stub.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/service_stub.rb new file mode 100644 index 000000000000..52e1a988f774 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/gen_ai_cache_service/rest/service_stub.rb @@ -0,0 +1,388 @@ +# frozen_string_literal: true + +# 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 +# +# 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/aiplatform/v1/gen_ai_cache_service_pb" + +module Google + module Cloud + module AIPlatform + module V1 + module GenAiCacheService + module Rest + ## + # REST service stub for the GenAiCacheService 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 create_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest] + # 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::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # A result object deserialized from the server's reply + def create_cached_content request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_create_cached_content_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: "create_cached_content", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Cloud::AIPlatform::V1::CachedContent.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the get_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::GetCachedContentRequest] + # 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::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # A result object deserialized from the server's reply + def get_cached_content request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_get_cached_content_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: "get_cached_content", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Cloud::AIPlatform::V1::CachedContent.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the update_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest] + # 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::AIPlatform::V1::CachedContent] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # A result object deserialized from the server's reply + def update_cached_content request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_update_cached_content_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: "update_cached_content", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Cloud::AIPlatform::V1::CachedContent.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the delete_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest] + # 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::Protobuf::Empty] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Protobuf::Empty] + # A result object deserialized from the server's reply + def delete_cached_content request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_delete_cached_content_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: "delete_cached_content", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true + catch :response do + yield result, operation if block_given? + result + end + end + + ## + # Baseline implementation for the list_cached_contents REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest] + # 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::AIPlatform::V1::ListCachedContentsResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse] + # A result object deserialized from the server's reply + def list_cached_contents request_pb, options = nil + raise ::ArgumentError, "request must be provided" if request_pb.nil? + + verb, uri, query_string_params, body = ServiceStub.transcode_list_cached_contents_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_cached_contents", + options: options + ) + operation = ::Gapic::Rest::TransportOperation.new response + result = ::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse.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 create_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_create_cached_content_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :post, + uri_template: "/v1/{parent}/cachedContents", + body: "cached_content", + matches: [ + ["parent", %r{^projects/[^/]+/locations/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the get_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::GetCachedContentRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_get_cached_content_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^projects/[^/]+/locations/[^/]+/cachedContents/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the update_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_update_cached_content_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :patch, + uri_template: "/v1/{cached_content.name}", + body: "cached_content", + matches: [ + ["cached_content.name", %r{^projects/[^/]+/locations/[^/]+/cachedContents/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the delete_cached_content REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest] + # A request object representing the call parameters. Required. + # @return [Array(String, [String, nil], Hash{String => String})] + # Uri, Body, Query string parameters + def self.transcode_delete_cached_content_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :delete, + uri_template: "/v1/{name}", + matches: [ + ["name", %r{^projects/[^/]+/locations/[^/]+/cachedContents/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + + ## + # @private + # + # GRPC transcoding helper method for the list_cached_contents REST call + # + # @param request_pb [::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest] + # 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_cached_contents_request request_pb + transcoder = Gapic::Rest::GrpcTranscoder.new + .with_bindings( + uri_method: :get, + uri_template: "/v1/{parent}/cachedContents", + matches: [ + ["parent", %r{^projects/[^/]+/locations/[^/]+/?$}, false] + ] + ) + transcoder.transcode request_pb + end + end + end + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/client.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/client.rb index ef5fe3164793..4ac42d6942da 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/client.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/client.rb @@ -1262,7 +1262,7 @@ def explain request, options = nil # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. # - # @overload generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) + # @overload generate_content(model: nil, contents: nil, system_instruction: nil, cached_content: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) # Pass arguments to `generate_content` 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). @@ -1286,6 +1286,12 @@ def explain request, options = nil # Optional. The user provided system instructions for the model. # Note: only text should be used in parts and content in each part will be in # a separate paragraph. + # @param cached_content [::String] + # Optional. The name of the cached content used as context to serve the + # prediction. Note: only used in explicit caching, where users can have + # control over caching (e.g. what content to cache) and enjoy guaranteed cost + # savings. Format: + # `projects/{project}/locations/{location}/cachedContents/{cachedContent}` # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>] # Optional. A list of `Tools` the model may use to generate the next # response. @@ -1387,7 +1393,7 @@ def generate_content request, options = nil # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. # - # @overload stream_generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) + # @overload stream_generate_content(model: nil, contents: nil, system_instruction: nil, cached_content: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) # Pass arguments to `stream_generate_content` 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). @@ -1411,6 +1417,12 @@ def generate_content request, options = nil # Optional. The user provided system instructions for the model. # Note: only text should be used in parts and content in each part will be in # a separate paragraph. + # @param cached_content [::String] + # Optional. The name of the cached content used as context to serve the + # prediction. Note: only used in explicit caching, where users can have + # control over caching (e.g. what content to cache) and enjoy guaranteed cost + # savings. Format: + # `projects/{project}/locations/{location}/cachedContents/{cachedContent}` # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>] # Optional. A list of `Tools` the model may use to generate the next # response. diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/paths.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/paths.rb index e7eaa5ae524f..22b16a8e84a3 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/paths.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/paths.rb @@ -24,6 +24,25 @@ module V1 module PredictionService # Path helper methods for the PredictionService API. module Paths + ## + # Create a fully-qualified CachedContent resource string. + # + # The resource will be in the following format: + # + # `projects/{project}/locations/{location}/cachedContents/{cached_content}` + # + # @param project [String] + # @param location [String] + # @param cached_content [String] + # + # @return [::String] + def cached_content_path project:, location:, cached_content: + raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/" + raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/" + + "projects/#{project}/locations/#{location}/cachedContents/#{cached_content}" + end + ## # Create a fully-qualified Endpoint resource string. # diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/rest/client.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/rest/client.rb index 6ee6d98a7eb4..8d5da07513a1 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/rest/client.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/prediction_service/rest/client.rb @@ -897,7 +897,7 @@ def explain request, options = nil # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # - # @overload generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) + # @overload generate_content(model: nil, contents: nil, system_instruction: nil, cached_content: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) # Pass arguments to `generate_content` 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). @@ -921,6 +921,12 @@ def explain request, options = nil # Optional. The user provided system instructions for the model. # Note: only text should be used in parts and content in each part will be in # a separate paragraph. + # @param cached_content [::String] + # Optional. The name of the cached content used as context to serve the + # prediction. Note: only used in explicit caching, where users can have + # control over caching (e.g. what content to cache) and enjoy guaranteed cost + # savings. Format: + # `projects/{project}/locations/{location}/cachedContents/{cachedContent}` # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>] # Optional. A list of `Tools` the model may use to generate the next # response. @@ -1015,7 +1021,7 @@ def generate_content request, options = nil # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # - # @overload stream_generate_content(model: nil, contents: nil, system_instruction: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) + # @overload stream_generate_content(model: nil, contents: nil, system_instruction: nil, cached_content: nil, tools: nil, tool_config: nil, labels: nil, safety_settings: nil, generation_config: nil) # Pass arguments to `stream_generate_content` 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). @@ -1039,6 +1045,12 @@ def generate_content request, options = nil # Optional. The user provided system instructions for the model. # Note: only text should be used in parts and content in each part will be in # a separate paragraph. + # @param cached_content [::String] + # Optional. The name of the cached content used as context to serve the + # prediction. Note: only used in explicit caching, where users can have + # control over caching (e.g. what content to cache) and enjoy guaranteed cost + # savings. Format: + # `projects/{project}/locations/{location}/cachedContents/{cachedContent}` # @param tools [::Array<::Google::Cloud::AIPlatform::V1::Tool, ::Hash>] # Optional. A list of `Tools` the model may use to generate the next # response. diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/rest.rb b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/rest.rb index 5e52ff7565d4..42082cc19471 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/rest.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/ai_platform/v1/rest.rb @@ -25,6 +25,7 @@ require "google/cloud/ai_platform/v1/feature_online_store_service/rest" require "google/cloud/ai_platform/v1/featurestore_service/rest" require "google/cloud/ai_platform/v1/feature_registry_service/rest" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest" require "google/cloud/ai_platform/v1/gen_ai_tuning_service/rest" require "google/cloud/ai_platform/v1/index_endpoint_service/rest" require "google/cloud/ai_platform/v1/index_service/rest" diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/cached_content_pb.rb b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/cached_content_pb.rb new file mode 100644 index 000000000000..0f86e07ccdbd --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/cached_content_pb.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/aiplatform/v1/cached_content.proto + +require 'google/protobuf' + +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/cloud/aiplatform/v1/content_pb' +require 'google/cloud/aiplatform/v1/tool_pb' +require 'google/protobuf/duration_pb' +require 'google/protobuf/timestamp_pb' + + +descriptor_data = "\n/google/cloud/aiplatform/v1/cached_content.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/aiplatform/v1/content.proto\x1a%google/cloud/aiplatform/v1/tool.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xc9\x07\n\rCachedContent\x12\x31\n\x0b\x65xpire_time\x18\t \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12-\n\x03ttl\x18\n \x01(\x0b\x32\x19.google.protobuf.DurationB\x03\xe0\x41\x04H\x00\x12\x14\n\x04name\x18\x01 \x01(\tB\x06\xe0\x41\x08\xe0\x41\x05\x12\x1c\n\x0c\x64isplay_name\x18\x0b \x01(\tB\x06\xe0\x41\x01\xe0\x41\x05\x12\x12\n\x05model\x18\x02 \x01(\tB\x03\xe0\x41\x05\x12J\n\x12system_instruction\x18\x03 \x01(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\t\xe0\x41\x01\xe0\x41\x05\xe0\x41\x04\x12@\n\x08\x63ontents\x18\x04 \x03(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\t\xe0\x41\x01\xe0\x41\x05\xe0\x41\x04\x12:\n\x05tools\x18\x05 \x03(\x0b\x32 .google.cloud.aiplatform.v1.ToolB\t\xe0\x41\x01\xe0\x41\x05\xe0\x41\x04\x12\x46\n\x0btool_config\x18\x06 \x01(\x0b\x32&.google.cloud.aiplatform.v1.ToolConfigB\t\xe0\x41\x01\xe0\x41\x05\xe0\x41\x04\x12\x34\n\x0b\x63reate_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x34\n\x0bupdate_time\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12T\n\x0eusage_metadata\x18\x0c \x01(\x0b\x32\x37.google.cloud.aiplatform.v1.CachedContent.UsageMetadataB\x03\xe0\x41\x03\x1a\x93\x01\n\rUsageMetadata\x12\x19\n\x11total_token_count\x18\x01 \x01(\x05\x12\x12\n\ntext_count\x18\x02 \x01(\x05\x12\x13\n\x0bimage_count\x18\x03 \x01(\x05\x12\x1e\n\x16video_duration_seconds\x18\x04 \x01(\x05\x12\x1e\n\x16\x61udio_duration_seconds\x18\x05 \x01(\x05:\x95\x01\xea\x41\x91\x01\n\'aiplatform.googleapis.com/CachedContent\x12Gprojects/{project}/locations/{location}/cachedContents/{cached_content}*\x0e\x63\x61\x63hedContents2\rcachedContentB\x0c\n\nexpirationB\xd0\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\x12\x43\x61\x63hedContentProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::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"], + ["google.protobuf.Duration", "google/protobuf/duration.proto"], + ["google.cloud.aiplatform.v1.Content", "google/cloud/aiplatform/v1/content.proto"], + ["google.cloud.aiplatform.v1.Tool", "google/cloud/aiplatform/v1/tool.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 AIPlatform + module V1 + CachedContent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.CachedContent").msgclass + CachedContent::UsageMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.CachedContent.UsageMetadata").msgclass + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_pb.rb b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_pb.rb new file mode 100644 index 000000000000..3db6dd9ebd68 --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_pb.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/aiplatform/v1/gen_ai_cache_service.proto + +require 'google/protobuf' + +require 'google/api/annotations_pb' +require 'google/api/client_pb' +require 'google/api/field_behavior_pb' +require 'google/api/resource_pb' +require 'google/cloud/aiplatform/v1/cached_content_pb' +require 'google/protobuf/empty_pb' +require 'google/protobuf/field_mask_pb' + + +descriptor_data = "\n5google/cloud/aiplatform/v1/gen_ai_cache_service.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a/google/cloud/aiplatform/v1/cached_content.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"\xa5\x01\n\x1a\x43reateCachedContentRequest\x12?\n\x06parent\x18\x01 \x01(\tB/\xe0\x41\x02\xfa\x41)\x12\'aiplatform.googleapis.com/CachedContent\x12\x46\n\x0e\x63\x61\x63hed_content\x18\x02 \x01(\x0b\x32).google.cloud.aiplatform.v1.CachedContentB\x03\xe0\x41\x02\"X\n\x17GetCachedContentRequest\x12=\n\x04name\x18\x01 \x01(\tB/\xe0\x41\x02\xfa\x41)\n\'aiplatform.googleapis.com/CachedContent\"\x9a\x01\n\x1aUpdateCachedContentRequest\x12\x46\n\x0e\x63\x61\x63hed_content\x18\x01 \x01(\x0b\x32).google.cloud.aiplatform.v1.CachedContentB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02\"[\n\x1a\x44\x65leteCachedContentRequest\x12=\n\x04name\x18\x01 \x01(\tB/\xe0\x41\x02\xfa\x41)\n\'aiplatform.googleapis.com/CachedContent\"\x8d\x01\n\x19ListCachedContentsRequest\x12?\n\x06parent\x18\x01 \x01(\tB/\xe0\x41\x02\xfa\x41)\x12\'aiplatform.googleapis.com/CachedContent\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\"y\n\x1aListCachedContentsResponse\x12\x42\n\x0f\x63\x61\x63hed_contents\x18\x01 \x03(\x0b\x32).google.cloud.aiplatform.v1.CachedContent\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t2\xe2\x08\n\x11GenAiCacheService\x12\xdc\x01\n\x13\x43reateCachedContent\x12\x36.google.cloud.aiplatform.v1.CreateCachedContentRequest\x1a).google.cloud.aiplatform.v1.CachedContent\"b\xda\x41\x15parent,cached_content\x82\xd3\xe4\x93\x02\x44\"2/v1/{parent=projects/*/locations/*}/cachedContents:\x0e\x63\x61\x63hed_content\x12\xb5\x01\n\x10GetCachedContent\x12\x33.google.cloud.aiplatform.v1.GetCachedContentRequest\x1a).google.cloud.aiplatform.v1.CachedContent\"A\xda\x41\x04name\x82\xd3\xe4\x93\x02\x34\x12\x32/v1/{name=projects/*/locations/*/cachedContents/*}\x12\xf0\x01\n\x13UpdateCachedContent\x12\x36.google.cloud.aiplatform.v1.UpdateCachedContentRequest\x1a).google.cloud.aiplatform.v1.CachedContent\"v\xda\x41\x1a\x63\x61\x63hed_content,update_mask\x82\xd3\xe4\x93\x02S2A/v1/{cached_content.name=projects/*/locations/*/cachedContents/*}:\x0e\x63\x61\x63hed_content\x12\xa8\x01\n\x13\x44\x65leteCachedContent\x12\x36.google.cloud.aiplatform.v1.DeleteCachedContentRequest\x1a\x16.google.protobuf.Empty\"A\xda\x41\x04name\x82\xd3\xe4\x93\x02\x34*2/v1/{name=projects/*/locations/*/cachedContents/*}\x12\xc8\x01\n\x12ListCachedContents\x12\x35.google.cloud.aiplatform.v1.ListCachedContentsRequest\x1a\x36.google.cloud.aiplatform.v1.ListCachedContentsResponse\"C\xda\x41\x06parent\x82\xd3\xe4\x93\x02\x34\x12\x32/v1/{parent=projects/*/locations/*}/cachedContents\x1aM\xca\x41\x19\x61iplatform.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xd4\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\x16GenAiCacheServiceProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::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.cloud.aiplatform.v1.CachedContent", "google/cloud/aiplatform/v1/cached_content.proto"], + ["google.protobuf.FieldMask", "google/protobuf/field_mask.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 AIPlatform + module V1 + CreateCachedContentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.CreateCachedContentRequest").msgclass + GetCachedContentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.GetCachedContentRequest").msgclass + UpdateCachedContentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.UpdateCachedContentRequest").msgclass + DeleteCachedContentRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.DeleteCachedContentRequest").msgclass + ListCachedContentsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.ListCachedContentsRequest").msgclass + ListCachedContentsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.ListCachedContentsResponse").msgclass + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_services_pb.rb b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_services_pb.rb new file mode 100644 index 000000000000..ea89eac8a86f --- /dev/null +++ b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/gen_ai_cache_service_services_pb.rb @@ -0,0 +1,54 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: google/cloud/aiplatform/v1/gen_ai_cache_service.proto for package 'Google.Cloud.AIPlatform.V1' +# Original file comments: +# Copyright 2024 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/aiplatform/v1/gen_ai_cache_service_pb' + +module Google + module Cloud + module AIPlatform + module V1 + module GenAiCacheService + # Service for managing Vertex AI's CachedContent resource. + class Service + + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'google.cloud.aiplatform.v1.GenAiCacheService' + + # Creates cached content, this call will initialize the cached content in the + # data storage, and users need to pay for the cache data storage. + rpc :CreateCachedContent, ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest, ::Google::Cloud::AIPlatform::V1::CachedContent + # Gets cached content configurations + rpc :GetCachedContent, ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest, ::Google::Cloud::AIPlatform::V1::CachedContent + # Updates cached content configurations + rpc :UpdateCachedContent, ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest, ::Google::Cloud::AIPlatform::V1::CachedContent + # Deletes cached content + rpc :DeleteCachedContent, ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest, ::Google::Protobuf::Empty + # Lists cached contents in a project + rpc :ListCachedContents, ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest, ::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse + end + + Stub = Service.rpc_stub_class + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/prediction_service_pb.rb b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/prediction_service_pb.rb index 5dbe36c8a28d..2d3559634a70 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/prediction_service_pb.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/prediction_service_pb.rb @@ -16,7 +16,7 @@ require 'google/protobuf/struct_pb' -descriptor_data = "\n3google/cloud/aiplatform/v1/prediction_service.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/httpbody.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/aiplatform/v1/content.proto\x1a,google/cloud/aiplatform/v1/explanation.proto\x1a%google/cloud/aiplatform/v1/tool.proto\x1a&google/cloud/aiplatform/v1/types.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xaa\x01\n\x0ePredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x02\x12*\n\nparameters\x18\x03 \x01(\x0b\x32\x16.google.protobuf.Value\"\x80\x02\n\x0fPredictResponse\x12+\n\x0bpredictions\x18\x01 \x03(\x0b\x32\x16.google.protobuf.Value\x12\x19\n\x11\x64\x65ployed_model_id\x18\x02 \x01(\t\x12\x36\n\x05model\x18\x03 \x01(\tB\'\xe0\x41\x03\xfa\x41!\n\x1f\x61iplatform.googleapis.com/Model\x12\x1d\n\x10model_version_id\x18\x05 \x01(\tB\x03\xe0\x41\x03\x12\x1f\n\x12model_display_name\x18\x04 \x01(\tB\x03\xe0\x41\x03\x12-\n\x08metadata\x18\x06 \x01(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x03\"z\n\x11RawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\'\n\thttp_body\x18\x02 \x01(\x0b\x32\x14.google.api.HttpBody\"\x80\x01\n\x17StreamRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\'\n\thttp_body\x18\x02 \x01(\x0b\x32\x14.google.api.HttpBody\"\xc0\x01\n\x14\x44irectPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x32\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x84\x01\n\x15\x44irectPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"{\n\x17\x44irectRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\r\n\x05input\x18\x03 \x01(\x0c\"*\n\x18\x44irectRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\xd0\x01\n\x1aStreamDirectPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x37\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.TensorB\x03\xe0\x41\x01\x12;\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.TensorB\x03\xe0\x41\x01\"\x8a\x01\n\x1bStreamDirectPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x8b\x01\n\x1dStreamDirectRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x18\n\x0bmethod_name\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x12\n\x05input\x18\x03 \x01(\x0c\x42\x03\xe0\x41\x01\"0\n\x1eStreamDirectRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\xc3\x01\n\x17StreamingPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x32\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x87\x01\n\x18StreamingPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"~\n\x1aStreamingRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\r\n\x05input\x18\x03 \x01(\x0c\"-\n\x1bStreamingRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\x9d\x02\n\x0e\x45xplainRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x02\x12*\n\nparameters\x18\x04 \x01(\x0b\x32\x16.google.protobuf.Value\x12V\n\x19\x65xplanation_spec_override\x18\x05 \x01(\x0b\x32\x33.google.cloud.aiplatform.v1.ExplanationSpecOverride\x12\x19\n\x11\x64\x65ployed_model_id\x18\x03 \x01(\t\"\x98\x01\n\x0f\x45xplainResponse\x12=\n\x0c\x65xplanations\x18\x01 \x03(\x0b\x32\'.google.cloud.aiplatform.v1.Explanation\x12\x19\n\x11\x64\x65ployed_model_id\x18\x02 \x01(\t\x12+\n\x0bpredictions\x18\x03 \x03(\x0b\x32\x16.google.protobuf.Value\"\xd3\x03\n\x12\x43ountTokensRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x12\n\x05model\x18\x03 \x01(\tB\x03\xe0\x41\x01\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x01\x12:\n\x08\x63ontents\x18\x04 \x03(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01\x12I\n\x12system_instruction\x18\x05 \x01(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12\x34\n\x05tools\x18\x06 \x03(\x0b\x32 .google.cloud.aiplatform.v1.ToolB\x03\xe0\x41\x01\x12Q\n\x11generation_config\x18\x07 \x01(\x0b\x32,.google.cloud.aiplatform.v1.GenerationConfigB\x03\xe0\x41\x01H\x01\x88\x01\x01\x42\x15\n\x13_system_instructionB\x14\n\x12_generation_config\"N\n\x13\x43ountTokensResponse\x12\x14\n\x0ctotal_tokens\x18\x01 \x01(\x05\x12!\n\x19total_billable_characters\x18\x02 \x01(\x05\"\xdd\x04\n\x16GenerateContentRequest\x12\x12\n\x05model\x18\x05 \x01(\tB\x03\xe0\x41\x02\x12:\n\x08\x63ontents\x18\x02 \x03(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x02\x12I\n\x12system_instruction\x18\x08 \x01(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12\x34\n\x05tools\x18\x06 \x03(\x0b\x32 .google.cloud.aiplatform.v1.ToolB\x03\xe0\x41\x01\x12@\n\x0btool_config\x18\x07 \x01(\x0b\x32&.google.cloud.aiplatform.v1.ToolConfigB\x03\xe0\x41\x01\x12S\n\x06labels\x18\n \x03(\x0b\x32>.google.cloud.aiplatform.v1.GenerateContentRequest.LabelsEntryB\x03\xe0\x41\x01\x12G\n\x0fsafety_settings\x18\x03 \x03(\x0b\x32).google.cloud.aiplatform.v1.SafetySettingB\x03\xe0\x41\x01\x12L\n\x11generation_config\x18\x04 \x01(\x0b\x32,.google.cloud.aiplatform.v1.GenerationConfigB\x03\xe0\x41\x01\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\x15\n\x13_system_instruction\"\xf3\x05\n\x17GenerateContentResponse\x12>\n\ncandidates\x18\x02 \x03(\x0b\x32%.google.cloud.aiplatform.v1.CandidateB\x03\xe0\x41\x03\x12\x1a\n\rmodel_version\x18\x0b \x01(\tB\x03\xe0\x41\x03\x12`\n\x0fprompt_feedback\x18\x03 \x01(\x0b\x32\x42.google.cloud.aiplatform.v1.GenerateContentResponse.PromptFeedbackB\x03\xe0\x41\x03\x12Y\n\x0eusage_metadata\x18\x04 \x01(\x0b\x32\x41.google.cloud.aiplatform.v1.GenerateContentResponse.UsageMetadata\x1a\xd6\x02\n\x0ePromptFeedback\x12k\n\x0c\x62lock_reason\x18\x01 \x01(\x0e\x32P.google.cloud.aiplatform.v1.GenerateContentResponse.PromptFeedback.BlockedReasonB\x03\xe0\x41\x03\x12\x45\n\x0esafety_ratings\x18\x02 \x03(\x0b\x32(.google.cloud.aiplatform.v1.SafetyRatingB\x03\xe0\x41\x03\x12!\n\x14\x62lock_reason_message\x18\x03 \x01(\tB\x03\xe0\x41\x03\"m\n\rBlockedReason\x12\x1e\n\x1a\x42LOCKED_REASON_UNSPECIFIED\x10\x00\x12\n\n\x06SAFETY\x10\x01\x12\t\n\x05OTHER\x10\x02\x12\r\n\tBLOCKLIST\x10\x03\x12\x16\n\x12PROHIBITED_CONTENT\x10\x04\x1a\x66\n\rUsageMetadata\x12\x1a\n\x12prompt_token_count\x18\x01 \x01(\x05\x12\x1e\n\x16\x63\x61ndidates_token_count\x18\x02 \x01(\x05\x12\x19\n\x11total_token_count\x18\x03 \x01(\x05\x32\xf2\x19\n\x11PredictionService\x12\x94\x02\n\x07Predict\x12*.google.cloud.aiplatform.v1.PredictRequest\x1a+.google.cloud.aiplatform.v1.PredictResponse\"\xaf\x01\xda\x41\x1d\x65ndpoint,instances,parameters\x82\xd3\xe4\x93\x02\x88\x01\"9/v1/{endpoint=projects/*/locations/*/endpoints/*}:predict:\x01*ZH\"C/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:predict:\x01*\x12\xfe\x01\n\nRawPredict\x12-.google.cloud.aiplatform.v1.RawPredictRequest\x1a\x14.google.api.HttpBody\"\xaa\x01\xda\x41\x12\x65ndpoint,http_body\x82\xd3\xe4\x93\x02\x8e\x01\"\"9/v1/{endpoint=projects/*/locations/*/endpoints/*}:explain:\x01*\x12\x8d\x03\n\x0fGenerateContent\x12\x32.google.cloud.aiplatform.v1.GenerateContentRequest\x1a\x33.google.cloud.aiplatform.v1.GenerateContentResponse\"\x90\x02\xda\x41\x0emodel,contents\x82\xd3\xe4\x93\x02\xf8\x01\">/v1/{model=projects/*/locations/*/endpoints/*}:generateContent:\x01*ZM\"H/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent:\x01*Z,\"\'/v1/{model=endpoints/*}:generateContent:\x01*Z6\"1/v1/{model=publishers/*/models/*}:generateContent:\x01*\x12\xad\x03\n\x15StreamGenerateContent\x12\x32.google.cloud.aiplatform.v1.GenerateContentRequest\x1a\x33.google.cloud.aiplatform.v1.GenerateContentResponse\"\xa8\x02\xda\x41\x0emodel,contents\x82\xd3\xe4\x93\x02\x90\x02\"D/v1/{model=projects/*/locations/*/endpoints/*}:streamGenerateContent:\x01*ZS\"N/v1/{model=projects/*/locations/*/publishers/*/models/*}:streamGenerateContent:\x01*Z2\"-/v1/{model=endpoints/*}:streamGenerateContent:\x01*Z<\"7/v1/{model=publishers/*/models/*}:streamGenerateContent:\x01*0\x01\x1a\x86\x01\xca\x41\x19\x61iplatform.googleapis.com\xd2\x41ghttps://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-onlyB\xd4\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\x16PredictionServiceProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::V1b\x06proto3" +descriptor_data = "\n3google/cloud/aiplatform/v1/prediction_service.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/httpbody.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/aiplatform/v1/content.proto\x1a,google/cloud/aiplatform/v1/explanation.proto\x1a%google/cloud/aiplatform/v1/tool.proto\x1a&google/cloud/aiplatform/v1/types.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xaa\x01\n\x0ePredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x02\x12*\n\nparameters\x18\x03 \x01(\x0b\x32\x16.google.protobuf.Value\"\x80\x02\n\x0fPredictResponse\x12+\n\x0bpredictions\x18\x01 \x03(\x0b\x32\x16.google.protobuf.Value\x12\x19\n\x11\x64\x65ployed_model_id\x18\x02 \x01(\t\x12\x36\n\x05model\x18\x03 \x01(\tB\'\xe0\x41\x03\xfa\x41!\n\x1f\x61iplatform.googleapis.com/Model\x12\x1d\n\x10model_version_id\x18\x05 \x01(\tB\x03\xe0\x41\x03\x12\x1f\n\x12model_display_name\x18\x04 \x01(\tB\x03\xe0\x41\x03\x12-\n\x08metadata\x18\x06 \x01(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x03\"z\n\x11RawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\'\n\thttp_body\x18\x02 \x01(\x0b\x32\x14.google.api.HttpBody\"\x80\x01\n\x17StreamRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\'\n\thttp_body\x18\x02 \x01(\x0b\x32\x14.google.api.HttpBody\"\xc0\x01\n\x14\x44irectPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x32\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x84\x01\n\x15\x44irectPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"{\n\x17\x44irectRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\r\n\x05input\x18\x03 \x01(\x0c\"*\n\x18\x44irectRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\xd0\x01\n\x1aStreamDirectPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x37\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.TensorB\x03\xe0\x41\x01\x12;\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.TensorB\x03\xe0\x41\x01\"\x8a\x01\n\x1bStreamDirectPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x8b\x01\n\x1dStreamDirectRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x18\n\x0bmethod_name\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12\x12\n\x05input\x18\x03 \x01(\x0c\x42\x03\xe0\x41\x01\"0\n\x1eStreamDirectRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\xc3\x01\n\x17StreamingPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x32\n\x06inputs\x18\x02 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"\x87\x01\n\x18StreamingPredictResponse\x12\x33\n\x07outputs\x18\x01 \x03(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\x12\x36\n\nparameters\x18\x02 \x01(\x0b\x32\".google.cloud.aiplatform.v1.Tensor\"~\n\x1aStreamingRawPredictRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\r\n\x05input\x18\x03 \x01(\x0c\"-\n\x1bStreamingRawPredictResponse\x12\x0e\n\x06output\x18\x01 \x01(\x0c\"\x9d\x02\n\x0e\x45xplainRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x02\x12*\n\nparameters\x18\x04 \x01(\x0b\x32\x16.google.protobuf.Value\x12V\n\x19\x65xplanation_spec_override\x18\x05 \x01(\x0b\x32\x33.google.cloud.aiplatform.v1.ExplanationSpecOverride\x12\x19\n\x11\x64\x65ployed_model_id\x18\x03 \x01(\t\"\x98\x01\n\x0f\x45xplainResponse\x12=\n\x0c\x65xplanations\x18\x01 \x03(\x0b\x32\'.google.cloud.aiplatform.v1.Explanation\x12\x19\n\x11\x64\x65ployed_model_id\x18\x02 \x01(\t\x12+\n\x0bpredictions\x18\x03 \x03(\x0b\x32\x16.google.protobuf.Value\"\xd3\x03\n\x12\x43ountTokensRequest\x12<\n\x08\x65ndpoint\x18\x01 \x01(\tB*\xe0\x41\x02\xfa\x41$\n\"aiplatform.googleapis.com/Endpoint\x12\x12\n\x05model\x18\x03 \x01(\tB\x03\xe0\x41\x01\x12.\n\tinstances\x18\x02 \x03(\x0b\x32\x16.google.protobuf.ValueB\x03\xe0\x41\x01\x12:\n\x08\x63ontents\x18\x04 \x03(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01\x12I\n\x12system_instruction\x18\x05 \x01(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12\x34\n\x05tools\x18\x06 \x03(\x0b\x32 .google.cloud.aiplatform.v1.ToolB\x03\xe0\x41\x01\x12Q\n\x11generation_config\x18\x07 \x01(\x0b\x32,.google.cloud.aiplatform.v1.GenerationConfigB\x03\xe0\x41\x01H\x01\x88\x01\x01\x42\x15\n\x13_system_instructionB\x14\n\x12_generation_config\"N\n\x13\x43ountTokensResponse\x12\x14\n\x0ctotal_tokens\x18\x01 \x01(\x05\x12!\n\x19total_billable_characters\x18\x02 \x01(\x05\"\xa6\x05\n\x16GenerateContentRequest\x12\x12\n\x05model\x18\x05 \x01(\tB\x03\xe0\x41\x02\x12:\n\x08\x63ontents\x18\x02 \x03(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x02\x12I\n\x12system_instruction\x18\x08 \x01(\x0b\x32#.google.cloud.aiplatform.v1.ContentB\x03\xe0\x41\x01H\x00\x88\x01\x01\x12G\n\x0e\x63\x61\x63hed_content\x18\t \x01(\tB/\xe0\x41\x01\xfa\x41)\n\'aiplatform.googleapis.com/CachedContent\x12\x34\n\x05tools\x18\x06 \x03(\x0b\x32 .google.cloud.aiplatform.v1.ToolB\x03\xe0\x41\x01\x12@\n\x0btool_config\x18\x07 \x01(\x0b\x32&.google.cloud.aiplatform.v1.ToolConfigB\x03\xe0\x41\x01\x12S\n\x06labels\x18\n \x03(\x0b\x32>.google.cloud.aiplatform.v1.GenerateContentRequest.LabelsEntryB\x03\xe0\x41\x01\x12G\n\x0fsafety_settings\x18\x03 \x03(\x0b\x32).google.cloud.aiplatform.v1.SafetySettingB\x03\xe0\x41\x01\x12L\n\x11generation_config\x18\x04 \x01(\x0b\x32,.google.cloud.aiplatform.v1.GenerationConfigB\x03\xe0\x41\x01\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\x42\x15\n\x13_system_instruction\"\x9d\x06\n\x17GenerateContentResponse\x12>\n\ncandidates\x18\x02 \x03(\x0b\x32%.google.cloud.aiplatform.v1.CandidateB\x03\xe0\x41\x03\x12\x1a\n\rmodel_version\x18\x0b \x01(\tB\x03\xe0\x41\x03\x12`\n\x0fprompt_feedback\x18\x03 \x01(\x0b\x32\x42.google.cloud.aiplatform.v1.GenerateContentResponse.PromptFeedbackB\x03\xe0\x41\x03\x12Y\n\x0eusage_metadata\x18\x04 \x01(\x0b\x32\x41.google.cloud.aiplatform.v1.GenerateContentResponse.UsageMetadata\x1a\xd6\x02\n\x0ePromptFeedback\x12k\n\x0c\x62lock_reason\x18\x01 \x01(\x0e\x32P.google.cloud.aiplatform.v1.GenerateContentResponse.PromptFeedback.BlockedReasonB\x03\xe0\x41\x03\x12\x45\n\x0esafety_ratings\x18\x02 \x03(\x0b\x32(.google.cloud.aiplatform.v1.SafetyRatingB\x03\xe0\x41\x03\x12!\n\x14\x62lock_reason_message\x18\x03 \x01(\tB\x03\xe0\x41\x03\"m\n\rBlockedReason\x12\x1e\n\x1a\x42LOCKED_REASON_UNSPECIFIED\x10\x00\x12\n\n\x06SAFETY\x10\x01\x12\t\n\x05OTHER\x10\x02\x12\r\n\tBLOCKLIST\x10\x03\x12\x16\n\x12PROHIBITED_CONTENT\x10\x04\x1a\x8f\x01\n\rUsageMetadata\x12\x1a\n\x12prompt_token_count\x18\x01 \x01(\x05\x12\x1e\n\x16\x63\x61ndidates_token_count\x18\x02 \x01(\x05\x12\x19\n\x11total_token_count\x18\x03 \x01(\x05\x12\'\n\x1a\x63\x61\x63hed_content_token_count\x18\x05 \x01(\x05\x42\x03\xe0\x41\x03\x32\xf2\x19\n\x11PredictionService\x12\x94\x02\n\x07Predict\x12*.google.cloud.aiplatform.v1.PredictRequest\x1a+.google.cloud.aiplatform.v1.PredictResponse\"\xaf\x01\xda\x41\x1d\x65ndpoint,instances,parameters\x82\xd3\xe4\x93\x02\x88\x01\"9/v1/{endpoint=projects/*/locations/*/endpoints/*}:predict:\x01*ZH\"C/v1/{endpoint=projects/*/locations/*/publishers/*/models/*}:predict:\x01*\x12\xfe\x01\n\nRawPredict\x12-.google.cloud.aiplatform.v1.RawPredictRequest\x1a\x14.google.api.HttpBody\"\xaa\x01\xda\x41\x12\x65ndpoint,http_body\x82\xd3\xe4\x93\x02\x8e\x01\"\"9/v1/{endpoint=projects/*/locations/*/endpoints/*}:explain:\x01*\x12\x8d\x03\n\x0fGenerateContent\x12\x32.google.cloud.aiplatform.v1.GenerateContentRequest\x1a\x33.google.cloud.aiplatform.v1.GenerateContentResponse\"\x90\x02\xda\x41\x0emodel,contents\x82\xd3\xe4\x93\x02\xf8\x01\">/v1/{model=projects/*/locations/*/endpoints/*}:generateContent:\x01*ZM\"H/v1/{model=projects/*/locations/*/publishers/*/models/*}:generateContent:\x01*Z,\"\'/v1/{model=endpoints/*}:generateContent:\x01*Z6\"1/v1/{model=publishers/*/models/*}:generateContent:\x01*\x12\xad\x03\n\x15StreamGenerateContent\x12\x32.google.cloud.aiplatform.v1.GenerateContentRequest\x1a\x33.google.cloud.aiplatform.v1.GenerateContentResponse\"\xa8\x02\xda\x41\x0emodel,contents\x82\xd3\xe4\x93\x02\x90\x02\"D/v1/{model=projects/*/locations/*/endpoints/*}:streamGenerateContent:\x01*ZS\"N/v1/{model=projects/*/locations/*/publishers/*/models/*}:streamGenerateContent:\x01*Z2\"-/v1/{model=endpoints/*}:streamGenerateContent:\x01*Z<\"7/v1/{model=publishers/*/models/*}:streamGenerateContent:\x01*0\x01\x1a\x86\x01\xca\x41\x19\x61iplatform.googleapis.com\xd2\x41ghttps://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-onlyB\xd4\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\x16PredictionServiceProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::V1b\x06proto3" pool = Google::Protobuf::DescriptorPool.generated_pool diff --git a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/tool_pb.rb b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/tool_pb.rb index 174e52c33c4e..3e896109df9a 100644 --- a/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/tool_pb.rb +++ b/google-cloud-ai_platform-v1/lib/google/cloud/aiplatform/v1/tool_pb.rb @@ -8,9 +8,10 @@ require 'google/api/resource_pb' require 'google/cloud/aiplatform/v1/openapi_pb' require 'google/protobuf/struct_pb' +require 'google/type/latlng_pb' -descriptor_data = "\n%google/cloud/aiplatform/v1/tool.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/aiplatform/v1/openapi.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xf3\x01\n\x04Tool\x12S\n\x15\x66unction_declarations\x18\x01 \x03(\x0b\x32/.google.cloud.aiplatform.v1.FunctionDeclarationB\x03\xe0\x41\x01\x12=\n\tretrieval\x18\x02 \x01(\x0b\x32%.google.cloud.aiplatform.v1.RetrievalB\x03\xe0\x41\x01\x12W\n\x17google_search_retrieval\x18\x03 \x01(\x0b\x32\x31.google.cloud.aiplatform.v1.GoogleSearchRetrievalB\x03\xe0\x41\x01\"\xba\x01\n\x13\x46unctionDeclaration\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x18\n\x0b\x64\x65scription\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12;\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.SchemaB\x03\xe0\x41\x01\x12\x39\n\x08response\x18\x04 \x01(\x0b\x32\".google.cloud.aiplatform.v1.SchemaB\x03\xe0\x41\x01\"M\n\x0c\x46unctionCall\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12*\n\x04\x61rgs\x18\x02 \x01(\x0b\x32\x17.google.protobuf.StructB\x03\xe0\x41\x01\"U\n\x10\x46unctionResponse\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12.\n\x08response\x18\x02 \x01(\x0b\x32\x17.google.protobuf.StructB\x03\xe0\x41\x02\"\xc9\x01\n\tRetrieval\x12\x46\n\x10vertex_ai_search\x18\x02 \x01(\x0b\x32*.google.cloud.aiplatform.v1.VertexAISearchH\x00\x12\x46\n\x10vertex_rag_store\x18\x04 \x01(\x0b\x32*.google.cloud.aiplatform.v1.VertexRagStoreH\x00\x12\"\n\x13\x64isable_attribution\x18\x03 \x01(\x08\x42\x05\x18\x01\xe0\x41\x01\x42\x08\n\x06source\"\xaa\x03\n\x0eVertexRagStore\x12R\n\rrag_resources\x18\x04 \x03(\x0b\x32\x36.google.cloud.aiplatform.v1.VertexRagStore.RagResourceB\x03\xe0\x41\x01\x12$\n\x10similarity_top_k\x18\x02 \x01(\x05\x42\x05\x18\x01\xe0\x41\x01H\x00\x88\x01\x01\x12-\n\x19vector_distance_threshold\x18\x03 \x01(\x01\x42\x05\x18\x01\xe0\x41\x01H\x01\x88\x01\x01\x12Q\n\x14rag_retrieval_config\x18\x06 \x01(\x0b\x32..google.cloud.aiplatform.v1.RagRetrievalConfigB\x03\xe0\x41\x01\x1ai\n\x0bRagResource\x12?\n\nrag_corpus\x18\x01 \x01(\tB+\xe0\x41\x01\xfa\x41%\n#aiplatform.googleapis.com/RagCorpus\x12\x19\n\x0crag_file_ids\x18\x02 \x03(\tB\x03\xe0\x41\x01\x42\x13\n\x11_similarity_top_kB\x1c\n\x1a_vector_distance_threshold\"(\n\x0eVertexAISearch\x12\x16\n\tdatastore\x18\x01 \x01(\tB\x03\xe0\x41\x02\"m\n\x15GoogleSearchRetrieval\x12T\n\x18\x64ynamic_retrieval_config\x18\x02 \x01(\x0b\x32\x32.google.cloud.aiplatform.v1.DynamicRetrievalConfig\"\xca\x01\n\x16\x44ynamicRetrievalConfig\x12\x45\n\x04mode\x18\x01 \x01(\x0e\x32\x37.google.cloud.aiplatform.v1.DynamicRetrievalConfig.Mode\x12#\n\x11\x64ynamic_threshold\x18\x02 \x01(\x02\x42\x03\xe0\x41\x01H\x00\x88\x01\x01\".\n\x04Mode\x12\x14\n\x10MODE_UNSPECIFIED\x10\x00\x12\x10\n\x0cMODE_DYNAMIC\x10\x01\x42\x14\n\x12_dynamic_threshold\"e\n\nToolConfig\x12W\n\x17\x66unction_calling_config\x18\x01 \x01(\x0b\x32\x31.google.cloud.aiplatform.v1.FunctionCallingConfigB\x03\xe0\x41\x01\"\xc2\x01\n\x15\x46unctionCallingConfig\x12I\n\x04mode\x18\x01 \x01(\x0e\x32\x36.google.cloud.aiplatform.v1.FunctionCallingConfig.ModeB\x03\xe0\x41\x01\x12#\n\x16\x61llowed_function_names\x18\x02 \x03(\tB\x03\xe0\x41\x01\"9\n\x04Mode\x12\x14\n\x10MODE_UNSPECIFIED\x10\x00\x12\x08\n\x04\x41UTO\x10\x01\x12\x07\n\x03\x41NY\x10\x02\x12\x08\n\x04NONE\x10\x03\"\x8a\x02\n\x12RagRetrievalConfig\x12\x12\n\x05top_k\x18\x01 \x01(\x05\x42\x03\xe0\x41\x01\x12J\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x35.google.cloud.aiplatform.v1.RagRetrievalConfig.FilterB\x03\xe0\x41\x01\x1a\x93\x01\n\x06\x46ilter\x12(\n\x19vector_distance_threshold\x18\x03 \x01(\x01\x42\x03\xe0\x41\x01H\x00\x12*\n\x1bvector_similarity_threshold\x18\x04 \x01(\x01\x42\x03\xe0\x41\x01H\x00\x12\x1c\n\x0fmetadata_filter\x18\x02 \x01(\tB\x03\xe0\x41\x01\x42\x15\n\x13vector_db_thresholdB\xc7\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\tToolProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::V1b\x06proto3" +descriptor_data = "\n%google/cloud/aiplatform/v1/tool.proto\x12\x1agoogle.cloud.aiplatform.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/aiplatform/v1/openapi.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x18google/type/latlng.proto\"\xf3\x01\n\x04Tool\x12S\n\x15\x66unction_declarations\x18\x01 \x03(\x0b\x32/.google.cloud.aiplatform.v1.FunctionDeclarationB\x03\xe0\x41\x01\x12=\n\tretrieval\x18\x02 \x01(\x0b\x32%.google.cloud.aiplatform.v1.RetrievalB\x03\xe0\x41\x01\x12W\n\x17google_search_retrieval\x18\x03 \x01(\x0b\x32\x31.google.cloud.aiplatform.v1.GoogleSearchRetrievalB\x03\xe0\x41\x01\"\xba\x01\n\x13\x46unctionDeclaration\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x18\n\x0b\x64\x65scription\x18\x02 \x01(\tB\x03\xe0\x41\x01\x12;\n\nparameters\x18\x03 \x01(\x0b\x32\".google.cloud.aiplatform.v1.SchemaB\x03\xe0\x41\x01\x12\x39\n\x08response\x18\x04 \x01(\x0b\x32\".google.cloud.aiplatform.v1.SchemaB\x03\xe0\x41\x01\"M\n\x0c\x46unctionCall\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12*\n\x04\x61rgs\x18\x02 \x01(\x0b\x32\x17.google.protobuf.StructB\x03\xe0\x41\x01\"U\n\x10\x46unctionResponse\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12.\n\x08response\x18\x02 \x01(\x0b\x32\x17.google.protobuf.StructB\x03\xe0\x41\x02\"\xc9\x01\n\tRetrieval\x12\x46\n\x10vertex_ai_search\x18\x02 \x01(\x0b\x32*.google.cloud.aiplatform.v1.VertexAISearchH\x00\x12\x46\n\x10vertex_rag_store\x18\x04 \x01(\x0b\x32*.google.cloud.aiplatform.v1.VertexRagStoreH\x00\x12\"\n\x13\x64isable_attribution\x18\x03 \x01(\x08\x42\x05\x18\x01\xe0\x41\x01\x42\x08\n\x06source\"\xaa\x03\n\x0eVertexRagStore\x12R\n\rrag_resources\x18\x04 \x03(\x0b\x32\x36.google.cloud.aiplatform.v1.VertexRagStore.RagResourceB\x03\xe0\x41\x01\x12$\n\x10similarity_top_k\x18\x02 \x01(\x05\x42\x05\x18\x01\xe0\x41\x01H\x00\x88\x01\x01\x12-\n\x19vector_distance_threshold\x18\x03 \x01(\x01\x42\x05\x18\x01\xe0\x41\x01H\x01\x88\x01\x01\x12Q\n\x14rag_retrieval_config\x18\x06 \x01(\x0b\x32..google.cloud.aiplatform.v1.RagRetrievalConfigB\x03\xe0\x41\x01\x1ai\n\x0bRagResource\x12?\n\nrag_corpus\x18\x01 \x01(\tB+\xe0\x41\x01\xfa\x41%\n#aiplatform.googleapis.com/RagCorpus\x12\x19\n\x0crag_file_ids\x18\x02 \x03(\tB\x03\xe0\x41\x01\x42\x13\n\x11_similarity_top_kB\x1c\n\x1a_vector_distance_threshold\"(\n\x0eVertexAISearch\x12\x16\n\tdatastore\x18\x01 \x01(\tB\x03\xe0\x41\x02\"m\n\x15GoogleSearchRetrieval\x12T\n\x18\x64ynamic_retrieval_config\x18\x02 \x01(\x0b\x32\x32.google.cloud.aiplatform.v1.DynamicRetrievalConfig\"\xca\x01\n\x16\x44ynamicRetrievalConfig\x12\x45\n\x04mode\x18\x01 \x01(\x0e\x32\x37.google.cloud.aiplatform.v1.DynamicRetrievalConfig.Mode\x12#\n\x11\x64ynamic_threshold\x18\x02 \x01(\x02\x42\x03\xe0\x41\x01H\x00\x88\x01\x01\".\n\x04Mode\x12\x14\n\x10MODE_UNSPECIFIED\x10\x00\x12\x10\n\x0cMODE_DYNAMIC\x10\x01\x42\x14\n\x12_dynamic_threshold\"\xb1\x01\n\nToolConfig\x12W\n\x17\x66unction_calling_config\x18\x01 \x01(\x0b\x32\x31.google.cloud.aiplatform.v1.FunctionCallingConfigB\x03\xe0\x41\x01\x12J\n\x10retrieval_config\x18\x02 \x01(\x0b\x32+.google.cloud.aiplatform.v1.RetrievalConfigB\x03\xe0\x41\x01\"\xc2\x01\n\x15\x46unctionCallingConfig\x12I\n\x04mode\x18\x01 \x01(\x0e\x32\x36.google.cloud.aiplatform.v1.FunctionCallingConfig.ModeB\x03\xe0\x41\x01\x12#\n\x16\x61llowed_function_names\x18\x02 \x03(\tB\x03\xe0\x41\x01\"9\n\x04Mode\x12\x14\n\x10MODE_UNSPECIFIED\x10\x00\x12\x08\n\x04\x41UTO\x10\x01\x12\x07\n\x03\x41NY\x10\x02\x12\x08\n\x04NONE\x10\x03\"v\n\x0fRetrievalConfig\x12)\n\x07lat_lng\x18\x01 \x01(\x0b\x32\x13.google.type.LatLngH\x00\x88\x01\x01\x12\x1a\n\rlanguage_code\x18\x02 \x01(\tH\x01\x88\x01\x01\x42\n\n\x08_lat_lngB\x10\n\x0e_language_code\"\x8a\x02\n\x12RagRetrievalConfig\x12\x12\n\x05top_k\x18\x01 \x01(\x05\x42\x03\xe0\x41\x01\x12J\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x35.google.cloud.aiplatform.v1.RagRetrievalConfig.FilterB\x03\xe0\x41\x01\x1a\x93\x01\n\x06\x46ilter\x12(\n\x19vector_distance_threshold\x18\x03 \x01(\x01\x42\x03\xe0\x41\x01H\x00\x12*\n\x1bvector_similarity_threshold\x18\x04 \x01(\x01\x42\x03\xe0\x41\x01H\x00\x12\x1c\n\x0fmetadata_filter\x18\x02 \x01(\tB\x03\xe0\x41\x01\x42\x15\n\x13vector_db_thresholdB\xc7\x01\n\x1e\x63om.google.cloud.aiplatform.v1B\tToolProtoP\x01Z>cloud.google.com/go/aiplatform/apiv1/aiplatformpb;aiplatformpb\xaa\x02\x1aGoogle.Cloud.AIPlatform.V1\xca\x02\x1aGoogle\\Cloud\\AIPlatform\\V1\xea\x02\x1dGoogle::Cloud::AIPlatform::V1b\x06proto3" pool = Google::Protobuf::DescriptorPool.generated_pool @@ -27,6 +28,7 @@ imports = [ ["google.cloud.aiplatform.v1.Schema", "google/cloud/aiplatform/v1/openapi.proto"], ["google.protobuf.Struct", "google/protobuf/struct.proto"], + ["google.type.LatLng", "google/type/latlng.proto"], ] imports.each do |type_name, expected_filename| import_file = pool.lookup(type_name).file_descriptor @@ -56,6 +58,7 @@ module V1 ToolConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.ToolConfig").msgclass FunctionCallingConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.FunctionCallingConfig").msgclass FunctionCallingConfig::Mode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.FunctionCallingConfig.Mode").enummodule + RetrievalConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.RetrievalConfig").msgclass RagRetrievalConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.RagRetrievalConfig").msgclass RagRetrievalConfig::Filter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.aiplatform.v1.RagRetrievalConfig.Filter").msgclass end diff --git a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/cached_content.rb b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/cached_content.rb new file mode 100644 index 000000000000..a8263bce687b --- /dev/null +++ b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/cached_content.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true + +# 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 +# +# 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 AIPlatform + module V1 + # A resource used in LLM queries for users to explicitly specify what to cache + # and how to cache. + # @!attribute [rw] expire_time + # @return [::Google::Protobuf::Timestamp] + # Timestamp of when this resource is considered expired. + # This is *always* provided on output, regardless of what was sent + # on input. + # @!attribute [rw] ttl + # @return [::Google::Protobuf::Duration] + # Input only. The TTL for this resource. The expiration time is computed: + # now + TTL. + # @!attribute [rw] name + # @return [::String] + # Immutable. Identifier. The server-generated resource name of the cached + # content Format: + # projects/\\{project}/locations/\\{location}/cachedContents/\\{cached_content} + # @!attribute [rw] display_name + # @return [::String] + # Optional. Immutable. The user-generated meaningful display name of the + # cached content. + # @!attribute [rw] model + # @return [::String] + # Immutable. The name of the publisher model to use for cached content. + # Format: + # projects/\\{project}/locations/\\{location}/publishers/\\{publisher}/models/\\{model} + # @!attribute [rw] system_instruction + # @return [::Google::Cloud::AIPlatform::V1::Content] + # Optional. Input only. Immutable. Developer set system instruction. + # Currently, text only + # @!attribute [rw] contents + # @return [::Array<::Google::Cloud::AIPlatform::V1::Content>] + # Optional. Input only. Immutable. The content to cache + # @!attribute [rw] tools + # @return [::Array<::Google::Cloud::AIPlatform::V1::Tool>] + # Optional. Input only. Immutable. A list of `Tools` the model may use to + # generate the next response + # @!attribute [rw] tool_config + # @return [::Google::Cloud::AIPlatform::V1::ToolConfig] + # Optional. Input only. Immutable. Tool config. This config is shared for all + # tools + # @!attribute [r] create_time + # @return [::Google::Protobuf::Timestamp] + # Output only. Creatation time of the cache entry. + # @!attribute [r] update_time + # @return [::Google::Protobuf::Timestamp] + # Output only. When the cache entry was last updated in UTC time. + # @!attribute [r] usage_metadata + # @return [::Google::Cloud::AIPlatform::V1::CachedContent::UsageMetadata] + # Output only. Metadata on the usage of the cached content. + class CachedContent + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + + # Metadata on the usage of the cached content. + # @!attribute [rw] total_token_count + # @return [::Integer] + # Total number of tokens that the cached content consumes. + # @!attribute [rw] text_count + # @return [::Integer] + # Number of text characters. + # @!attribute [rw] image_count + # @return [::Integer] + # Number of images. + # @!attribute [rw] video_duration_seconds + # @return [::Integer] + # Duration of video in seconds. + # @!attribute [rw] audio_duration_seconds + # @return [::Integer] + # Duration of audio in seconds. + class UsageMetadata + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/gen_ai_cache_service.rb b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/gen_ai_cache_service.rb new file mode 100644 index 000000000000..a1a3113a61e0 --- /dev/null +++ b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/gen_ai_cache_service.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +# 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 +# +# 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 AIPlatform + module V1 + # Request message for + # {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#create_cached_content GenAiCacheService.CreateCachedContent}. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent resource where the cached content will be created + # @!attribute [rw] cached_content + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # Required. The cached content to create + class CreateCachedContentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for + # {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#get_cached_content GenAiCacheService.GetCachedContent}. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name referring to the cached content + class GetCachedContentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for + # {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#update_cached_content GenAiCacheService.UpdateCachedContent}. + # Only expire_time or ttl can be updated. + # @!attribute [rw] cached_content + # @return [::Google::Cloud::AIPlatform::V1::CachedContent] + # Required. The cached content to update + # @!attribute [rw] update_mask + # @return [::Google::Protobuf::FieldMask] + # Required. The list of fields to update. + class UpdateCachedContentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request message for + # {::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#delete_cached_content GenAiCacheService.DeleteCachedContent}. + # @!attribute [rw] name + # @return [::String] + # Required. The resource name referring to the cached content + class DeleteCachedContentRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Request to list CachedContents. + # @!attribute [rw] parent + # @return [::String] + # Required. The parent, which owns this collection of cached contents. + # @!attribute [rw] page_size + # @return [::Integer] + # Optional. The maximum number of cached contents to return. The service may + # return fewer than this value. If unspecified, some default (under maximum) + # number of items will be returned. The maximum value is 1000; values above + # 1000 will be coerced to 1000. + # @!attribute [rw] page_token + # @return [::String] + # Optional. A page token, received from a previous `ListCachedContents` call. + # Provide this to retrieve the subsequent page. + # + # When paginating, all other parameters provided to `ListCachedContents` must + # match the call that provided the page token. + class ListCachedContentsRequest + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + + # Response with a list of CachedContents. + # @!attribute [rw] cached_contents + # @return [::Array<::Google::Cloud::AIPlatform::V1::CachedContent>] + # List of cached contents. + # @!attribute [rw] next_page_token + # @return [::String] + # A token, which can be sent as `page_token` to retrieve the next page. + # If this field is omitted, there are no subsequent pages. + class ListCachedContentsResponse + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end + end + end +end diff --git a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/prediction_service.rb b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/prediction_service.rb index 5593df9f7d52..c126e605a924 100644 --- a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/prediction_service.rb +++ b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/prediction_service.rb @@ -499,6 +499,13 @@ class CountTokensResponse # Optional. The user provided system instructions for the model. # Note: only text should be used in parts and content in each part will be in # a separate paragraph. + # @!attribute [rw] cached_content + # @return [::String] + # Optional. The name of the cached content used as context to serve the + # prediction. Note: only used in explicit caching, where users can have + # control over caching (e.g. what content to cache) and enjoy guaranteed cost + # savings. Format: + # `projects/{project}/locations/{location}/cachedContents/{cachedContent}` # @!attribute [rw] tools # @return [::Array<::Google::Cloud::AIPlatform::V1::Tool>] # Optional. A list of `Tools` the model may use to generate the next @@ -606,6 +613,10 @@ module BlockedReason # @!attribute [rw] total_token_count # @return [::Integer] # Total token count for prompt and response candidates. + # @!attribute [r] cached_content_token_count + # @return [::Integer] + # Output only. Number of tokens in the cached part in the input (the cached + # content). class UsageMetadata include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods diff --git a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/tool.rb b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/tool.rb index 360ea26cc0c6..4d83234d7ad6 100644 --- a/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/tool.rb +++ b/google-cloud-ai_platform-v1/proto_docs/google/cloud/aiplatform/v1/tool.rb @@ -232,6 +232,9 @@ module Mode # @!attribute [rw] function_calling_config # @return [::Google::Cloud::AIPlatform::V1::FunctionCallingConfig] # Optional. Function calling config. + # @!attribute [rw] retrieval_config + # @return [::Google::Cloud::AIPlatform::V1::RetrievalConfig] + # Optional. Retrieval config. class ToolConfig include ::Google::Protobuf::MessageExts extend ::Google::Protobuf::MessageExts::ClassMethods @@ -271,6 +274,18 @@ module Mode end end + # Retrieval config. + # @!attribute [rw] lat_lng + # @return [::Google::Type::LatLng] + # The location of the user. + # @!attribute [rw] language_code + # @return [::String] + # The language code of the user. + class RetrievalConfig + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + # Specifies the context retrieval config. # @!attribute [rw] top_k # @return [::Integer] diff --git a/google-cloud-ai_platform-v1/proto_docs/google/type/latlng.rb b/google-cloud-ai_platform-v1/proto_docs/google/type/latlng.rb new file mode 100644 index 000000000000..6a65558604f7 --- /dev/null +++ b/google-cloud-ai_platform-v1/proto_docs/google/type/latlng.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# 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 +# +# 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 Type + # An object that represents a latitude/longitude pair. This is expressed as a + # pair of doubles to represent degrees latitude and degrees longitude. Unless + # specified otherwise, this must conform to the + # WGS84 + # standard. Values must be within normalized ranges. + # @!attribute [rw] latitude + # @return [::Float] + # The latitude in degrees. It must be in the range [-90.0, +90.0]. + # @!attribute [rw] longitude + # @return [::Float] + # The longitude in degrees. It must be in the range [-180.0, +180.0]. + class LatLng + include ::Google::Protobuf::MessageExts + extend ::Google::Protobuf::MessageExts::ClassMethods + end + end +end diff --git a/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/create_cached_content.rb b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/create_cached_content.rb new file mode 100644 index 000000000000..ad3fab0096e1 --- /dev/null +++ b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/create_cached_content.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# 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 +# +# 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 aiplatform_v1_generated_GenAiCacheService_CreateCachedContent_sync] +require "google/cloud/ai_platform/v1" + +## +# Snippet for the create_cached_content call in the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::Client#create_cached_content. +# +def create_cached_content + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new + + # Call the create_cached_content method. + result = client.create_cached_content request + + # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + p result +end +# [END aiplatform_v1_generated_GenAiCacheService_CreateCachedContent_sync] diff --git a/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/delete_cached_content.rb b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/delete_cached_content.rb new file mode 100644 index 000000000000..a1303d90d620 --- /dev/null +++ b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/delete_cached_content.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# 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 +# +# 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 aiplatform_v1_generated_GenAiCacheService_DeleteCachedContent_sync] +require "google/cloud/ai_platform/v1" + +## +# Snippet for the delete_cached_content call in the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::Client#delete_cached_content. +# +def delete_cached_content + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new + + # Call the delete_cached_content method. + result = client.delete_cached_content request + + # The returned object is of type Google::Protobuf::Empty. + p result +end +# [END aiplatform_v1_generated_GenAiCacheService_DeleteCachedContent_sync] diff --git a/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/get_cached_content.rb b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/get_cached_content.rb new file mode 100644 index 000000000000..209babf20c18 --- /dev/null +++ b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/get_cached_content.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# 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 +# +# 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 aiplatform_v1_generated_GenAiCacheService_GetCachedContent_sync] +require "google/cloud/ai_platform/v1" + +## +# Snippet for the get_cached_content call in the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::Client#get_cached_content. +# +def get_cached_content + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new + + # Call the get_cached_content method. + result = client.get_cached_content request + + # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + p result +end +# [END aiplatform_v1_generated_GenAiCacheService_GetCachedContent_sync] diff --git a/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/list_cached_contents.rb b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/list_cached_contents.rb new file mode 100644 index 000000000000..acee86857e3b --- /dev/null +++ b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/list_cached_contents.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +# 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 +# +# 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 aiplatform_v1_generated_GenAiCacheService_ListCachedContents_sync] +require "google/cloud/ai_platform/v1" + +## +# Snippet for the list_cached_contents call in the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::Client#list_cached_contents. +# +def list_cached_contents + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new + + # Call the list_cached_contents method. + result = client.list_cached_contents 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::AIPlatform::V1::CachedContent. + p item + end +end +# [END aiplatform_v1_generated_GenAiCacheService_ListCachedContents_sync] diff --git a/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/update_cached_content.rb b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/update_cached_content.rb new file mode 100644 index 000000000000..4a4edf950e3a --- /dev/null +++ b/google-cloud-ai_platform-v1/snippets/gen_ai_cache_service/update_cached_content.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +# 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 +# +# 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 aiplatform_v1_generated_GenAiCacheService_UpdateCachedContent_sync] +require "google/cloud/ai_platform/v1" + +## +# Snippet for the update_cached_content call in the GenAiCacheService 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::AIPlatform::V1::GenAiCacheService::Client#update_cached_content. +# +def update_cached_content + # Create a client object. The client can be reused for multiple calls. + client = Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new + + # Create a request. To set request fields, pass in keyword arguments. + request = Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new + + # Call the update_cached_content method. + result = client.update_cached_content request + + # The returned object is of type Google::Cloud::AIPlatform::V1::CachedContent. + p result +end +# [END aiplatform_v1_generated_GenAiCacheService_UpdateCachedContent_sync] diff --git a/google-cloud-ai_platform-v1/snippets/snippet_metadata_google.cloud.aiplatform.v1.json b/google-cloud-ai_platform-v1/snippets/snippet_metadata_google.cloud.aiplatform.v1.json index 4c059bee6e5b..a0eb3031cd59 100644 --- a/google-cloud-ai_platform-v1/snippets/snippet_metadata_google.cloud.aiplatform.v1.json +++ b/google-cloud-ai_platform-v1/snippets/snippet_metadata_google.cloud.aiplatform.v1.json @@ -3411,6 +3411,206 @@ } ] }, + { + "region_tag": "aiplatform_v1_generated_GenAiCacheService_CreateCachedContent_sync", + "title": "Snippet for the create_cached_content call in the GenAiCacheService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#create_cached_content.", + "file": "gen_ai_cache_service/create_cached_content.rb", + "language": "RUBY", + "client_method": { + "short_name": "create_cached_content", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#create_cached_content", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::AIPlatform::V1::CachedContent", + "client": { + "short_name": "GenAiCacheService::Client", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client" + }, + "method": { + "short_name": "CreateCachedContent", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService.CreateCachedContent", + "service": { + "short_name": "GenAiCacheService", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "aiplatform_v1_generated_GenAiCacheService_GetCachedContent_sync", + "title": "Snippet for the get_cached_content call in the GenAiCacheService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#get_cached_content.", + "file": "gen_ai_cache_service/get_cached_content.rb", + "language": "RUBY", + "client_method": { + "short_name": "get_cached_content", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#get_cached_content", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::AIPlatform::V1::GetCachedContentRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::AIPlatform::V1::CachedContent", + "client": { + "short_name": "GenAiCacheService::Client", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client" + }, + "method": { + "short_name": "GetCachedContent", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService.GetCachedContent", + "service": { + "short_name": "GenAiCacheService", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "aiplatform_v1_generated_GenAiCacheService_UpdateCachedContent_sync", + "title": "Snippet for the update_cached_content call in the GenAiCacheService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#update_cached_content.", + "file": "gen_ai_cache_service/update_cached_content.rb", + "language": "RUBY", + "client_method": { + "short_name": "update_cached_content", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#update_cached_content", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::AIPlatform::V1::CachedContent", + "client": { + "short_name": "GenAiCacheService::Client", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client" + }, + "method": { + "short_name": "UpdateCachedContent", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService.UpdateCachedContent", + "service": { + "short_name": "GenAiCacheService", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "aiplatform_v1_generated_GenAiCacheService_DeleteCachedContent_sync", + "title": "Snippet for the delete_cached_content call in the GenAiCacheService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#delete_cached_content.", + "file": "gen_ai_cache_service/delete_cached_content.rb", + "language": "RUBY", + "client_method": { + "short_name": "delete_cached_content", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#delete_cached_content", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest", + "name": "request" + } + ], + "result_type": "::Google::Protobuf::Empty", + "client": { + "short_name": "GenAiCacheService::Client", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client" + }, + "method": { + "short_name": "DeleteCachedContent", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService.DeleteCachedContent", + "service": { + "short_name": "GenAiCacheService", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 46, + "type": "FULL" + } + ] + }, + { + "region_tag": "aiplatform_v1_generated_GenAiCacheService_ListCachedContents_sync", + "title": "Snippet for the list_cached_contents call in the GenAiCacheService service", + "description": "This is an auto-generated example demonstrating basic usage of Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#list_cached_contents.", + "file": "gen_ai_cache_service/list_cached_contents.rb", + "language": "RUBY", + "client_method": { + "short_name": "list_cached_contents", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client#list_cached_contents", + "async": false, + "parameters": [ + { + "type": "::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest", + "name": "request" + } + ], + "result_type": "::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse", + "client": { + "short_name": "GenAiCacheService::Client", + "full_name": "::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client" + }, + "method": { + "short_name": "ListCachedContents", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService.ListCachedContents", + "service": { + "short_name": "GenAiCacheService", + "full_name": "google.cloud.aiplatform.v1.GenAiCacheService" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 50, + "type": "FULL" + } + ] + }, { "region_tag": "aiplatform_v1_generated_GenAiTuningService_CreateTuningJob_sync", "title": "Snippet for the create_tuning_job call in the GenAiTuningService service", diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_paths_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_paths_test.rb new file mode 100644 index 000000000000..799acba9643e --- /dev/null +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_paths_test.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +# 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 +# +# 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/ai_platform/v1/gen_ai_cache_service" + +class ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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_cached_content_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.cached_content_path project: "value0", location: "value1", cached_content: "value2" + assert_equal "projects/value0/locations/value1/cachedContents/value2", path + 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::AIPlatform::V1::GenAiCacheService::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 + + def test_rag_corpus_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.rag_corpus_path project: "value0", location: "value1", rag_corpus: "value2" + assert_equal "projects/value0/locations/value1/ragCorpora/value2", path + end + end +end diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_rest_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_rest_test.rb new file mode 100644 index 000000000000..15aece051262 --- /dev/null +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_rest_test.rb @@ -0,0 +1,373 @@ +# frozen_string_literal: true + +# 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 +# +# 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/aiplatform/v1/gen_ai_cache_service_pb" +require "google/cloud/ai_platform/v1/gen_ai_cache_service/rest" + + +class ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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_create_cached_content + # Create test objects. + client_result = ::Google::Cloud::AIPlatform::V1::CachedContent.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + parent = "hello world" + cached_content = {} + + create_cached_content_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::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.stub :transcode_create_cached_content_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, create_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.create_cached_content({ parent: parent, cached_content: cached_content }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.create_cached_content parent: parent, cached_content: cached_content do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.create_cached_content ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new(parent: parent, cached_content: cached_content) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.create_cached_content({ parent: parent, cached_content: cached_content }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.create_cached_content(::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new(parent: parent, cached_content: cached_content), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, create_cached_content_client_stub.call_count + end + end + end + + def test_get_cached_content + # Create test objects. + client_result = ::Google::Cloud::AIPlatform::V1::CachedContent.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + get_cached_content_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::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.stub :transcode_get_cached_content_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, get_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.get_cached_content({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.get_cached_content name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.get_cached_content ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.get_cached_content({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.get_cached_content(::Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, get_cached_content_client_stub.call_count + end + end + end + + def test_update_cached_content + # Create test objects. + client_result = ::Google::Cloud::AIPlatform::V1::CachedContent.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + cached_content = {} + update_mask = {} + + update_cached_content_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::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.stub :transcode_update_cached_content_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, update_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.update_cached_content({ cached_content: cached_content, update_mask: update_mask }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.update_cached_content cached_content: cached_content, update_mask: update_mask do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.update_cached_content ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new(cached_content: cached_content, update_mask: update_mask) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.update_cached_content({ cached_content: cached_content, update_mask: update_mask }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.update_cached_content(::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new(cached_content: cached_content, update_mask: update_mask), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, update_cached_content_client_stub.call_count + end + end + end + + def test_delete_cached_content + # Create test objects. + client_result = ::Google::Protobuf::Empty.new + http_response = OpenStruct.new body: client_result.to_json + + call_options = {} + + # Create request parameters for a unary method. + name = "hello world" + + delete_cached_content_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::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.stub :transcode_delete_cached_content_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, delete_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.delete_cached_content({ name: name }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.delete_cached_content name: name do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.delete_cached_content ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new(name: name) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.delete_cached_content({ name: name }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.delete_cached_content(::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new(name: name), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, delete_cached_content_client_stub.call_count + end + end + end + + def test_list_cached_contents + # Create test objects. + client_result = ::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse.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" + + list_cached_contents_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::AIPlatform::V1::GenAiCacheService::Rest::ServiceStub.stub :transcode_list_cached_contents_request, ["", "", {}] do + Gapic::Rest::ClientStub.stub :new, list_cached_contents_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Rest::Client.new do |config| + config.credentials = :dummy_value + end + + # Use hash object + client.list_cached_contents({ parent: parent, page_size: page_size, page_token: page_token }) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use named arguments + client.list_cached_contents parent: parent, page_size: page_size, page_token: page_token do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object + client.list_cached_contents ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new(parent: parent, page_size: page_size, page_token: page_token) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use hash object with options + client.list_cached_contents({ parent: parent, page_size: page_size, page_token: page_token }, call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Use protobuf object with options + client.list_cached_contents(::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new(parent: parent, page_size: page_size, page_token: page_token), call_options) do |_result, response| + assert_equal http_response, response.underlying_op + end + + # Verify method calls + assert_equal 5, list_cached_contents_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::AIPlatform::V1::GenAiCacheService::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::AIPlatform::V1::GenAiCacheService::Rest::Client::Configuration, config + end +end diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_test.rb new file mode 100644 index 000000000000..1ebfda342178 --- /dev/null +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/gen_ai_cache_service_test.rb @@ -0,0 +1,388 @@ +# frozen_string_literal: true + +# 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 +# +# 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/aiplatform/v1/gen_ai_cache_service_pb" +require "google/cloud/aiplatform/v1/gen_ai_cache_service_services_pb" +require "google/cloud/ai_platform/v1/gen_ai_cache_service" + +class ::Google::Cloud::AIPlatform::V1::GenAiCacheService::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_create_cached_content + # Create GRPC objects. + grpc_response = ::Google::Cloud::AIPlatform::V1::CachedContent.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" + cached_content = {} + + create_cached_content_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :create_cached_content, name + assert_kind_of ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest, request + assert_equal "hello world", request["parent"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::CachedContent), request["cached_content"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, create_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.create_cached_content({ parent: parent, cached_content: cached_content }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.create_cached_content parent: parent, cached_content: cached_content do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.create_cached_content ::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new(parent: parent, cached_content: cached_content) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.create_cached_content({ parent: parent, cached_content: cached_content }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.create_cached_content(::Google::Cloud::AIPlatform::V1::CreateCachedContentRequest.new(parent: parent, cached_content: cached_content), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, create_cached_content_client_stub.call_rpc_count + end + end + + def test_get_cached_content + # Create GRPC objects. + grpc_response = ::Google::Cloud::AIPlatform::V1::CachedContent.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. + name = "hello world" + + get_cached_content_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :get_cached_content, name + assert_kind_of ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, get_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.get_cached_content({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.get_cached_content name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.get_cached_content ::Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.get_cached_content({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.get_cached_content(::Google::Cloud::AIPlatform::V1::GetCachedContentRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, get_cached_content_client_stub.call_rpc_count + end + end + + def test_update_cached_content + # Create GRPC objects. + grpc_response = ::Google::Cloud::AIPlatform::V1::CachedContent.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. + cached_content = {} + update_mask = {} + + update_cached_content_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :update_cached_content, name + assert_kind_of ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest, request + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::CachedContent), request["cached_content"] + assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Protobuf::FieldMask), request["update_mask"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, update_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.update_cached_content({ cached_content: cached_content, update_mask: update_mask }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.update_cached_content cached_content: cached_content, update_mask: update_mask do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.update_cached_content ::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new(cached_content: cached_content, update_mask: update_mask) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.update_cached_content({ cached_content: cached_content, update_mask: update_mask }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.update_cached_content(::Google::Cloud::AIPlatform::V1::UpdateCachedContentRequest.new(cached_content: cached_content, update_mask: update_mask), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, update_cached_content_client_stub.call_rpc_count + end + end + + def test_delete_cached_content + # Create GRPC objects. + grpc_response = ::Google::Protobuf::Empty.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. + name = "hello world" + + delete_cached_content_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :delete_cached_content, name + assert_kind_of ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest, request + assert_equal "hello world", request["name"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, delete_cached_content_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.delete_cached_content({ name: name }) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use named arguments + client.delete_cached_content name: name do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object + client.delete_cached_content ::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new(name: name) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use hash object with options + client.delete_cached_content({ name: name }, grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Use protobuf object with options + client.delete_cached_content(::Google::Cloud::AIPlatform::V1::DeleteCachedContentRequest.new(name: name), grpc_options) do |response, operation| + assert_equal grpc_response, response + assert_equal grpc_operation, operation + end + + # Verify method calls + assert_equal 5, delete_cached_content_client_stub.call_rpc_count + end + end + + def test_list_cached_contents + # Create GRPC objects. + grpc_response = ::Google::Cloud::AIPlatform::V1::ListCachedContentsResponse.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" + + list_cached_contents_client_stub = ClientStub.new grpc_response, grpc_operation do |name, request, options:| + assert_equal :list_cached_contents, name + assert_kind_of ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest, request + assert_equal "hello world", request["parent"] + assert_equal 42, request["page_size"] + assert_equal "hello world", request["page_token"] + refute_nil options + end + + Gapic::ServiceStub.stub :new, list_cached_contents_client_stub do + # Create client + client = ::Google::Cloud::AIPlatform::V1::GenAiCacheService::Client.new do |config| + config.credentials = grpc_channel + end + + # Use hash object + client.list_cached_contents({ parent: parent, page_size: page_size, page_token: page_token }) 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_cached_contents parent: parent, page_size: page_size, page_token: page_token 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_cached_contents ::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new(parent: parent, page_size: page_size, page_token: page_token) 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_cached_contents({ parent: parent, page_size: page_size, page_token: page_token }, 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_cached_contents(::Google::Cloud::AIPlatform::V1::ListCachedContentsRequest.new(parent: parent, page_size: page_size, page_token: page_token), 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_cached_contents_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::AIPlatform::V1::GenAiCacheService::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::AIPlatform::V1::GenAiCacheService::Client::Configuration, config + end +end diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_paths_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_paths_test.rb index 294f2c81a37e..24d4d8823201 100644 --- a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_paths_test.rb +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_paths_test.rb @@ -41,6 +41,18 @@ def logger end end + def test_cached_content_path + grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + ::Gapic::ServiceStub.stub :new, DummyStub.new do + client = ::Google::Cloud::AIPlatform::V1::PredictionService::Client.new do |config| + config.credentials = grpc_channel + end + + path = client.cached_content_path project: "value0", location: "value1", cached_content: "value2" + assert_equal "projects/value0/locations/value1/cachedContents/value2", path + end + end + def test_endpoint_path grpc_channel = ::GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure ::Gapic::ServiceStub.stub :new, DummyStub.new do diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_rest_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_rest_test.rb index 07583d42f606..1b65746e7b15 100644 --- a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_rest_test.rb +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_rest_test.rb @@ -481,6 +481,7 @@ def test_generate_content model = "hello world" contents = [{}] system_instruction = {} + cached_content = "hello world" tools = [{}] tool_config = {} labels = {} @@ -501,27 +502,27 @@ def test_generate_content end # Use hash object - client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |_result, response| + client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |_result, response| assert_equal http_response, response.underlying_op end # Use named arguments - client.generate_content model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |_result, response| + client.generate_content model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |_result, response| assert_equal http_response, response.underlying_op end # Use protobuf object - client.generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |_result, response| + client.generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |_result, response| assert_equal http_response, response.underlying_op end # Use hash object with options - client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, call_options) do |_result, response| + client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, call_options) do |_result, response| assert_equal http_response, response.underlying_op end # Use protobuf object with options - client.generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), call_options) do |_result, response| + client.generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), call_options) do |_result, response| assert_equal http_response, response.underlying_op end @@ -542,6 +543,7 @@ def test_stream_generate_content model = "hello world" contents = [{}] system_instruction = {} + cached_content = "hello world" tools = [{}] tool_config = {} labels = {} @@ -562,27 +564,27 @@ def test_stream_generate_content end # Use hash object - client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |_result, response| + client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |_result, response| assert_equal http_response, response.underlying_op end.first # Use named arguments - client.stream_generate_content model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |_result, response| + client.stream_generate_content model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |_result, response| assert_equal http_response, response.underlying_op end.first # Use protobuf object - client.stream_generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |_result, response| + client.stream_generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |_result, response| assert_equal http_response, response.underlying_op end.first # Use hash object with options - client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, call_options) do |_result, response| + client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, call_options) do |_result, response| assert_equal http_response, response.underlying_op end.first # Use protobuf object with options - client.stream_generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), call_options) do |_result, response| + client.stream_generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), call_options) do |_result, response| assert_equal http_response, response.underlying_op end.first diff --git a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_test.rb b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_test.rb index 1ce39b5f7465..47aa3e11a07c 100644 --- a/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_test.rb +++ b/google-cloud-ai_platform-v1/test/google/cloud/ai_platform/v1/prediction_service_test.rb @@ -907,6 +907,7 @@ def test_generate_content model = "hello world" contents = [{}] system_instruction = {} + cached_content = "hello world" tools = [{}] tool_config = {} labels = {} @@ -920,6 +921,7 @@ def test_generate_content assert_kind_of ::Google::Cloud::AIPlatform::V1::Content, request["contents"].first assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::Content), request["system_instruction"] assert request.has_system_instruction? + assert_equal "hello world", request["cached_content"] assert_kind_of ::Google::Cloud::AIPlatform::V1::Tool, request["tools"].first assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::ToolConfig), request["tool_config"] assert_equal({}, request["labels"].to_h) @@ -935,31 +937,31 @@ def test_generate_content end # Use hash object - client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |response, operation| + client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |response, operation| assert_equal grpc_response, response assert_equal grpc_operation, operation end # Use named arguments - client.generate_content model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |response, operation| + client.generate_content model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |response, operation| assert_equal grpc_response, response assert_equal grpc_operation, operation end # Use protobuf object - client.generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |response, operation| + client.generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |response, operation| assert_equal grpc_response, response assert_equal grpc_operation, operation end # Use hash object with options - client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, grpc_options) do |response, operation| + client.generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, grpc_options) do |response, operation| assert_equal grpc_response, response assert_equal grpc_operation, operation end # Use protobuf object with options - client.generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), grpc_options) do |response, operation| + client.generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), grpc_options) do |response, operation| assert_equal grpc_response, response assert_equal grpc_operation, operation end @@ -980,6 +982,7 @@ def test_stream_generate_content model = "hello world" contents = [{}] system_instruction = {} + cached_content = "hello world" tools = [{}] tool_config = {} labels = {} @@ -993,6 +996,7 @@ def test_stream_generate_content assert_kind_of ::Google::Cloud::AIPlatform::V1::Content, request["contents"].first assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::Content), request["system_instruction"] assert request.has_system_instruction? + assert_equal "hello world", request["cached_content"] assert_kind_of ::Google::Cloud::AIPlatform::V1::Tool, request["tools"].first assert_equal Gapic::Protobuf.coerce({}, to: ::Google::Cloud::AIPlatform::V1::ToolConfig), request["tool_config"] assert_equal({}, request["labels"].to_h) @@ -1008,7 +1012,7 @@ def test_stream_generate_content end # Use hash object - client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |response, operation| + client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }) do |response, operation| assert_kind_of Enumerable, response response.to_a.each do |r| assert_kind_of ::Google::Cloud::AIPlatform::V1::GenerateContentResponse, r @@ -1017,7 +1021,7 @@ def test_stream_generate_content end # Use named arguments - client.stream_generate_content model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |response, operation| + client.stream_generate_content model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config do |response, operation| assert_kind_of Enumerable, response response.to_a.each do |r| assert_kind_of ::Google::Cloud::AIPlatform::V1::GenerateContentResponse, r @@ -1026,7 +1030,7 @@ def test_stream_generate_content end # Use protobuf object - client.stream_generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |response, operation| + client.stream_generate_content ::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config) do |response, operation| assert_kind_of Enumerable, response response.to_a.each do |r| assert_kind_of ::Google::Cloud::AIPlatform::V1::GenerateContentResponse, r @@ -1035,7 +1039,7 @@ def test_stream_generate_content end # Use hash object with options - client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, grpc_options) do |response, operation| + client.stream_generate_content({ model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config }, grpc_options) do |response, operation| assert_kind_of Enumerable, response response.to_a.each do |r| assert_kind_of ::Google::Cloud::AIPlatform::V1::GenerateContentResponse, r @@ -1044,7 +1048,7 @@ def test_stream_generate_content end # Use protobuf object with options - client.stream_generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), grpc_options) do |response, operation| + client.stream_generate_content(::Google::Cloud::AIPlatform::V1::GenerateContentRequest.new(model: model, contents: contents, system_instruction: system_instruction, cached_content: cached_content, tools: tools, tool_config: tool_config, labels: labels, safety_settings: safety_settings, generation_config: generation_config), grpc_options) do |response, operation| assert_kind_of Enumerable, response response.to_a.each do |r| assert_kind_of ::Google::Cloud::AIPlatform::V1::GenerateContentResponse, r