Skip to content

Commit

Permalink
feat: Promote various APIs to v1 GA (#25965)
Browse files Browse the repository at this point in the history
feat: Promote grounding check APIs to v1 GA
feat: Promote answer APIs to v1 GA
feat: Promote ranking APIs to v1 GA
feat: Add control service APIs
feat: Support writing user events for blended engines
feat: Support cancelling import operations
  • Loading branch information
gcf-owl-bot[bot] authored May 30, 2024
1 parent 03fbcb6 commit 0750d34
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 0 deletions.
140 changes: 140 additions & 0 deletions google-cloud-discovery_engine/lib/google/cloud/discovery_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,43 @@ def self.completion_service version: :v1, transport: :grpc, &block
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for ControlService.
#
# By default, this returns an instance of
# [Google::Cloud::DiscoveryEngine::V1::ControlService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/latest/Google-Cloud-DiscoveryEngine-V1-ControlService-Client)
# for a gRPC client for version V1 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the ControlService service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
# You can also specify a different transport by passing `:rest` or `:grpc` in
# the `transport` parameter.
#
# ## About ControlService
#
# Service for performing CRUD operations on Controls.
# Controls allow for custom logic to be implemented in the serving path.
# Controls need to be attached to a Serving Config to be considered during a
# request.
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1`.
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
# @return [::Object] A client object for the specified version.
#
def self.control_service version: :v1, transport: :grpc, &block
require "google/cloud/discovery_engine/#{version.to_s.downcase}"

package_name = Google::Cloud::DiscoveryEngine
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::DiscoveryEngine.const_get(package_name).const_get(:ControlService)
service_module = service_module.const_get(:Rest) if transport == :rest
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for SearchService.
#
Expand Down Expand Up @@ -252,6 +289,109 @@ def self.engine_service version: :v1, transport: :grpc, &block
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for GroundedGenerationService.
#
# By default, this returns an instance of
# [Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/latest/Google-Cloud-DiscoveryEngine-V1-GroundedGenerationService-Client)
# for a gRPC client for version V1 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the GroundedGenerationService service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
# You can also specify a different transport by passing `:rest` or `:grpc` in
# the `transport` parameter.
#
# ## About GroundedGenerationService
#
# Service for grounded generation.
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1`.
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
# @return [::Object] A client object for the specified version.
#
def self.grounded_generation_service version: :v1, transport: :grpc, &block
require "google/cloud/discovery_engine/#{version.to_s.downcase}"

package_name = Google::Cloud::DiscoveryEngine
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::DiscoveryEngine.const_get(package_name).const_get(:GroundedGenerationService)
service_module = service_module.const_get(:Rest) if transport == :rest
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for ProjectService.
#
# By default, this returns an instance of
# [Google::Cloud::DiscoveryEngine::V1::ProjectService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/latest/Google-Cloud-DiscoveryEngine-V1-ProjectService-Client)
# for a gRPC client for version V1 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the ProjectService service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
# You can also specify a different transport by passing `:rest` or `:grpc` in
# the `transport` parameter.
#
# ## About ProjectService
#
# Service for operations on the
# Project.
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1`.
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
# @return [::Object] A client object for the specified version.
#
def self.project_service version: :v1, transport: :grpc, &block
require "google/cloud/discovery_engine/#{version.to_s.downcase}"

package_name = Google::Cloud::DiscoveryEngine
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::DiscoveryEngine.const_get(package_name).const_get(:ProjectService)
service_module = service_module.const_get(:Rest) if transport == :rest
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for RankService.
#
# By default, this returns an instance of
# [Google::Cloud::DiscoveryEngine::V1::RankService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-discovery_engine-v1/latest/Google-Cloud-DiscoveryEngine-V1-RankService-Client)
# for a gRPC client for version V1 of the API.
# However, you can specify a different API version by passing it in the
# `version` parameter. If the RankService service is
# supported by that API version, and the corresponding gem is available, the
# appropriate versioned client will be returned.
# You can also specify a different transport by passing `:rest` or `:grpc` in
# the `transport` parameter.
#
# ## About RankService
#
# Service for ranking text records.
#
# @param version [::String, ::Symbol] The API version to connect to. Optional.
# Defaults to `:v1`.
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
# @return [::Object] A client object for the specified version.
#
def self.rank_service version: :v1, transport: :grpc, &block
require "google/cloud/discovery_engine/#{version.to_s.downcase}"

package_name = Google::Cloud::DiscoveryEngine
.constants
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
.first
service_module = Google::Cloud::DiscoveryEngine.const_get(package_name).const_get(:RankService)
service_module = service_module.const_get(:Rest) if transport == :rest
service_module.const_get(:Client).new(&block)
end

##
# Create a new client object for RecommendationService.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ def test_completion_service_rest
end
end

def test_control_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::DiscoveryEngine.control_service transport: :grpc do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::ControlService::Client, client
end
end

def test_control_service_rest
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::DiscoveryEngine.control_service transport: :rest do |config|
config.credentials = :dummy_credentials
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::ControlService::Rest::Client, client
end
end

def test_search_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
Expand Down Expand Up @@ -147,6 +166,63 @@ def test_engine_service_rest
end
end

def test_grounded_generation_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::DiscoveryEngine.grounded_generation_service transport: :grpc do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Client, client
end
end

def test_grounded_generation_service_rest
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::DiscoveryEngine.grounded_generation_service transport: :rest do |config|
config.credentials = :dummy_credentials
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::GroundedGenerationService::Rest::Client, client
end
end

def test_project_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::DiscoveryEngine.project_service transport: :grpc do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::ProjectService::Client, client
end
end

def test_project_service_rest
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::DiscoveryEngine.project_service transport: :rest do |config|
config.credentials = :dummy_credentials
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::ProjectService::Rest::Client, client
end
end

def test_rank_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
client = Google::Cloud::DiscoveryEngine.rank_service transport: :grpc do |config|
config.credentials = grpc_channel
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::RankService::Client, client
end
end

def test_rank_service_rest
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
client = Google::Cloud::DiscoveryEngine.rank_service transport: :rest do |config|
config.credentials = :dummy_credentials
end
assert_kind_of Google::Cloud::DiscoveryEngine::V1::RankService::Rest::Client, client
end
end

def test_recommendation_service_grpc
Gapic::ServiceStub.stub :new, DummyStub.new do
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
Expand Down

0 comments on commit 0750d34

Please sign in to comment.