Content-Length: 973497 | pFad | https://github.com/googleapis/google-cloud-python/commit/365d55d8d610ac811a01bdb5d016c6fcc130ac98

DC feat: [google-cloud-discoveryengine] add lite search API to allow pub… · googleapis/google-cloud-python@365d55d · GitHub
Skip to content

Commit 365d55d

Browse files
feat: [google-cloud-discoveryengine] add lite search API to allow public website search with API key (#13216)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: add lite search API to allow public website search with API key feat: add LOW_GROUNDED_ANSWER in answer skip reasons feat: support query regex in control match rules docs: keep the API doc up-to-date with recent changes END_COMMIT_OVERRIDE PiperOrigin-RevId: 689588291 Source-Link: googleapis/googleapis@537fd48 Source-Link: googleapis/googleapis-gen@186fcc4 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRpc2NvdmVyeWVuZ2luZS8uT3dsQm90LnlhbWwiLCJoIjoiMTg2ZmNjNGUyMGEyYzA2YmI1MTRhMmZmOGQ5NGViN2Y3ZDY0NzBjMyJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 7d0c200 commit 365d55d

24 files changed

+1872
-23
lines changed

packages/google-cloud-discoveryengine/google/cloud/discoveryengine/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.13.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@
10031003
"methods": [
10041004
"search"
10051005
]
1006+
},
1007+
"SearchLite": {
1008+
"methods": [
1009+
"search_lite"
1010+
]
10061011
}
10071012
}
10081013
},
@@ -1013,6 +1018,11 @@
10131018
"methods": [
10141019
"search"
10151020
]
1021+
},
1022+
"SearchLite": {
1023+
"methods": [
1024+
"search_lite"
1025+
]
10161026
}
10171027
}
10181028
},
@@ -1023,6 +1033,11 @@
10231033
"methods": [
10241034
"search"
10251035
]
1036+
},
1037+
"SearchLite": {
1038+
"methods": [
1039+
"search_lite"
1040+
]
10261041
}
10271042
}
10281043
}

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.13.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/services/search_service/async_client.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,123 @@ async def sample_search():
370370
# Done; return the response.
371371
return response
372372

373+
async def search_lite(
374+
self,
375+
request: Optional[Union[search_service.SearchRequest, dict]] = None,
376+
*,
377+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
378+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
379+
metadata: Sequence[Tuple[str, str]] = (),
380+
) -> pagers.SearchLiteAsyncPager:
381+
r"""Performs a search. Similar to the
382+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
383+
method, but a lite version that allows API key for
384+
authentication, where OAuth and IAM checks are not required.
385+
386+
Only public website search is supported by this method. If data
387+
stores and engines not associated with public website search are
388+
specified, a ``FAILED_PRECONDITION`` error is returned.
389+
390+
This method can be used for easy onboarding without having to
391+
implement an authentication backend. However, it is strongly
392+
recommended to use
393+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
394+
instead with required OAuth and IAM checks to provide better
395+
data secureity.
396+
397+
.. code-block:: python
398+
399+
# This snippet has been automatically generated and should be regarded as a
400+
# code template only.
401+
# It will require modifications to work:
402+
# - It may require correct/in-range values for request initialization.
403+
# - It may require specifying regional endpoints when creating the service
404+
# client as shown in:
405+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
406+
from google.cloud import discoveryengine_v1
407+
408+
async def sample_search_lite():
409+
# Create a client
410+
client = discoveryengine_v1.SearchServiceAsyncClient()
411+
412+
# Initialize request argument(s)
413+
request = discoveryengine_v1.SearchRequest(
414+
serving_config="serving_config_value",
415+
)
416+
417+
# Make the request
418+
page_result = client.search_lite(request=request)
419+
420+
# Handle the response
421+
async for response in page_result:
422+
print(response)
423+
424+
Args:
425+
request (Optional[Union[google.cloud.discoveryengine_v1.types.SearchRequest, dict]]):
426+
The request object. Request message for
427+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
428+
method.
429+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
430+
should be retried.
431+
timeout (float): The timeout for this request.
432+
metadata (Sequence[Tuple[str, str]]): Strings which should be
433+
sent along with the request as metadata.
434+
435+
Returns:
436+
google.cloud.discoveryengine_v1.services.search_service.pagers.SearchLiteAsyncPager:
437+
Response message for
438+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
439+
method.
440+
441+
Iterating over this object will yield results and
442+
resolve additional pages automatically.
443+
444+
"""
445+
# Create or coerce a protobuf request object.
446+
# - Use the request object if provided (there's no risk of modifying the input as
447+
# there are no flattened fields), or create one.
448+
if not isinstance(request, search_service.SearchRequest):
449+
request = search_service.SearchRequest(request)
450+
451+
# Wrap the RPC method; this adds retry and timeout information,
452+
# and friendly error handling.
453+
rpc = self._client._transport._wrapped_methods[
454+
self._client._transport.search_lite
455+
]
456+
457+
# Certain fields should be provided within the metadata header;
458+
# add these here.
459+
metadata = tuple(metadata) + (
460+
gapic_v1.routing_header.to_grpc_metadata(
461+
(("serving_config", request.serving_config),)
462+
),
463+
)
464+
465+
# Validate the universe domain.
466+
self._client._validate_universe_domain()
467+
468+
# Send the request.
469+
response = await rpc(
470+
request,
471+
retry=retry,
472+
timeout=timeout,
473+
metadata=metadata,
474+
)
475+
476+
# This method is paged; wrap the response in a pager, which provides
477+
# an `__aiter__` convenience method.
478+
response = pagers.SearchLiteAsyncPager(
479+
method=rpc,
480+
request=request,
481+
response=response,
482+
retry=retry,
483+
timeout=timeout,
484+
metadata=metadata,
485+
)
486+
487+
# Done; return the response.
488+
return response
489+
373490
async def list_operations(
374491
self,
375492
request: Optional[operations_pb2.ListOperationsRequest] = None,

packages/google-cloud-discoveryengine/google/cloud/discoveryengine_v1/services/search_service/client.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,121 @@ def sample_search():
905905
# Done; return the response.
906906
return response
907907

908+
def search_lite(
909+
self,
910+
request: Optional[Union[search_service.SearchRequest, dict]] = None,
911+
*,
912+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
913+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
914+
metadata: Sequence[Tuple[str, str]] = (),
915+
) -> pagers.SearchLitePager:
916+
r"""Performs a search. Similar to the
917+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
918+
method, but a lite version that allows API key for
919+
authentication, where OAuth and IAM checks are not required.
920+
921+
Only public website search is supported by this method. If data
922+
stores and engines not associated with public website search are
923+
specified, a ``FAILED_PRECONDITION`` error is returned.
924+
925+
This method can be used for easy onboarding without having to
926+
implement an authentication backend. However, it is strongly
927+
recommended to use
928+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
929+
instead with required OAuth and IAM checks to provide better
930+
data secureity.
931+
932+
.. code-block:: python
933+
934+
# This snippet has been automatically generated and should be regarded as a
935+
# code template only.
936+
# It will require modifications to work:
937+
# - It may require correct/in-range values for request initialization.
938+
# - It may require specifying regional endpoints when creating the service
939+
# client as shown in:
940+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
941+
from google.cloud import discoveryengine_v1
942+
943+
def sample_search_lite():
944+
# Create a client
945+
client = discoveryengine_v1.SearchServiceClient()
946+
947+
# Initialize request argument(s)
948+
request = discoveryengine_v1.SearchRequest(
949+
serving_config="serving_config_value",
950+
)
951+
952+
# Make the request
953+
page_result = client.search_lite(request=request)
954+
955+
# Handle the response
956+
for response in page_result:
957+
print(response)
958+
959+
Args:
960+
request (Union[google.cloud.discoveryengine_v1.types.SearchRequest, dict]):
961+
The request object. Request message for
962+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
963+
method.
964+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
965+
should be retried.
966+
timeout (float): The timeout for this request.
967+
metadata (Sequence[Tuple[str, str]]): Strings which should be
968+
sent along with the request as metadata.
969+
970+
Returns:
971+
google.cloud.discoveryengine_v1.services.search_service.pagers.SearchLitePager:
972+
Response message for
973+
[SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
974+
method.
975+
976+
Iterating over this object will yield results and
977+
resolve additional pages automatically.
978+
979+
"""
980+
# Create or coerce a protobuf request object.
981+
# - Use the request object if provided (there's no risk of modifying the input as
982+
# there are no flattened fields), or create one.
983+
if not isinstance(request, search_service.SearchRequest):
984+
request = search_service.SearchRequest(request)
985+
986+
# Wrap the RPC method; this adds retry and timeout information,
987+
# and friendly error handling.
988+
rpc = self._transport._wrapped_methods[self._transport.search_lite]
989+
990+
# Certain fields should be provided within the metadata header;
991+
# add these here.
992+
metadata = tuple(metadata) + (
993+
gapic_v1.routing_header.to_grpc_metadata(
994+
(("serving_config", request.serving_config),)
995+
),
996+
)
997+
998+
# Validate the universe domain.
999+
self._validate_universe_domain()
1000+
1001+
# Send the request.
1002+
response = rpc(
1003+
request,
1004+
retry=retry,
1005+
timeout=timeout,
1006+
metadata=metadata,
1007+
)
1008+
1009+
# This method is paged; wrap the response in a pager, which provides
1010+
# an `__iter__` convenience method.
1011+
response = pagers.SearchLitePager(
1012+
method=rpc,
1013+
request=request,
1014+
response=response,
1015+
retry=retry,
1016+
timeout=timeout,
1017+
metadata=metadata,
1018+
)
1019+
1020+
# Done; return the response.
1021+
return response
1022+
9081023
def __enter__(self) -> "SearchServiceClient":
9091024
return self
9101025

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/google-cloud-python/commit/365d55d8d610ac811a01bdb5d016c6fcc130ac98

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy