Skip to content

Commit a186fbc

Browse files
authored
Support an "all namespaces" option on ListIndexes in the Search SDK a… (#94)
* Support an "all namespaces" option on ListIndexes in the Search SDK and dev stub. * Update search_service.proto with new field.
1 parent 31ceb17 commit a186fbc

File tree

4 files changed

+123
-70
lines changed

4 files changed

+123
-70
lines changed

src/google/appengine/api/search/search.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def _ListIndexesResponsePbToGetResponse(response, include_schema):
883883
def get_indexes(namespace='', offset=None, limit=20,
884884
start_index_name=None, include_start_index=True,
885885
index_name_prefix=None, fetch_schema=False, deadline=None,
886-
**kwargs):
886+
all_namespaces=None, **kwargs):
887887
"""Returns a list of available indexes.
888888
889889
Args:
@@ -895,9 +895,9 @@ def get_indexes(namespace='', offset=None, limit=20,
895895
include_start_index: Whether or not to return the start index.
896896
index_name_prefix: The prefix used to select returned indexes.
897897
fetch_schema: Whether to retrieve Schema for each Index or not.
898-
899-
Kwargs:
900-
deadline: Deadline for RPC call in seconds; if None use the default.
898+
deadline: Deadline for RPC calls in seconds; if None use the default.
899+
all_namespaces: Whether to return indexes from all namespaces.
900+
**kwargs: Additional kwargs.
901901
902902
Returns:
903903
The GetResponse containing a list of available indexes.
@@ -911,18 +911,42 @@ def get_indexes(namespace='', offset=None, limit=20,
911911
"""
912912
return get_indexes_async(
913913
namespace, offset, limit, start_index_name, include_start_index,
914-
index_name_prefix, fetch_schema, deadline=deadline, **kwargs).get_result()
914+
index_name_prefix, fetch_schema, deadline=deadline,
915+
all_namespaces=all_namespaces, **kwargs).get_result()
915916

916917

917918
@datastore_rpc._positional(7)
918919
def get_indexes_async(namespace='', offset=None, limit=20,
919920
start_index_name=None, include_start_index=True,
920921
index_name_prefix=None, fetch_schema=False, deadline=None,
921-
**kwargs):
922+
all_namespaces=None, **kwargs):
922923
"""Asynchronously returns a list of available indexes.
923924
924-
Identical to get_indexes() except that it returns a future. Call
925-
get_result() on the return value to block on the call and get its result.
925+
Identical to get_indexes() except that it returns a future.
926+
927+
Args:
928+
namespace: The namespace of indexes to be returned. If not set
929+
then the current namespace is used.
930+
offset: The offset of the first returned index.
931+
limit: The number of indexes to return.
932+
start_index_name: The name of the first index to be returned.
933+
include_start_index: Whether or not to return the start index.
934+
index_name_prefix: The prefix used to select returned indexes.
935+
fetch_schema: Whether to retrieve Schema for each Index or not.
936+
deadline: Deadline for RPC calls in seconds; if None use the default.
937+
all_namespaces: Whether to return indexes from all namespaces.
938+
**kwargs: Additional kwargs.
939+
940+
Returns:
941+
A future. Call get_result() on the return value to block on the call and get
942+
its result.
943+
944+
Raises:
945+
InternalError: If the request fails on internal servers.
946+
TypeError: If any of the parameters have invalid types, or an unknown
947+
attribute is passed.
948+
ValueError: If any of the parameters have invalid values (e.g., a
949+
negative deadline).
926950
"""
927951

928952
app_id = kwargs.pop('app_id', None)
@@ -960,6 +984,8 @@ def get_indexes_async(namespace='', offset=None, limit=20,
960984
'index_name_prefix',
961985
MAXIMUM_INDEX_NAME_LENGTH,
962986
empty_ok=False)
987+
if all_namespaces is not None:
988+
params.all_namespaces = bool(all_namespaces)
963989
params.fetch_schema = fetch_schema
964990

965991
response = search_service_pb2.ListIndexesResponse()

0 commit comments

Comments
 (0)