Skip to content

Commit

Permalink
feat: Support multiple parent patterns for controls (#25973)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] authored May 29, 2024
1 parent dba624a commit c5a8d2f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def initialize
# @param parent [::String]
# Required. Full resource name of parent data store. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @param control [::Google::Cloud::DiscoveryEngine::V1::Control, ::Hash]
# Required. The Control to create.
# @param control_id [::String]
Expand Down Expand Up @@ -584,6 +586,8 @@ def get_control request, options = nil
# @param parent [::String]
# Required. The data store resource name. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @param page_size [::Integer]
# Optional. Maximum number of results to return. If unspecified, defaults
# to 50. Max allowed value is 1000.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ def data_store_path **args
resource.call(**args)
end

##
# Create a fully-qualified Engine resource string.
#
# The resource will be in the following format:
#
# `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`
#
# @param project [String]
# @param location [String]
# @param collection [String]
# @param engine [String]
#
# @return [::String]
def engine_path project:, location:, collection:, engine:
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
raise ::ArgumentError, "location cannot contain /" if location.to_s.include? "/"
raise ::ArgumentError, "collection cannot contain /" if collection.to_s.include? "/"

"projects/#{project}/locations/#{location}/collections/#{collection}/engines/#{engine}"
end

extend self
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ def initialize
# @param parent [::String]
# Required. Full resource name of parent data store. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @param control [::Google::Cloud::DiscoveryEngine::V1::Control, ::Hash]
# Required. The Control to create.
# @param control_id [::String]
Expand Down Expand Up @@ -549,6 +551,8 @@ def get_control request, options = nil
# @param parent [::String]
# Required. The data store resource name. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @param page_size [::Integer]
# Optional. Maximum number of results to return. If unspecified, defaults
# to 50. Max allowed value is 1000.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module V1
# @return [::String]
# Required. Full resource name of parent data store. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @!attribute [rw] control
# @return [::Google::Cloud::DiscoveryEngine::V1::Control]
# Required. The Control to create.
Expand Down Expand Up @@ -85,6 +87,8 @@ class GetControlRequest
# @return [::String]
# Required. The data store resource name. Format:
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/dataStores/{data_store_id}`
# or
# `projects/{project_number}/locations/{location_id}/collections/{collection_id}/engines/{engine_id}`.
# @!attribute [rw] page_size
# @return [::Integer]
# Optional. Maximum number of results to return. If unspecified, defaults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,16 @@ def test_data_store_path
assert_equal "projects/value0/locations/value1/collections/value2/dataStores/value3", path
end
end

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

path = client.engine_path project: "value0", location: "value1", collection: "value2", engine: "value3"
assert_equal "projects/value0/locations/value1/collections/value2/engines/value3", path
end
end
end

0 comments on commit c5a8d2f

Please sign in to comment.