diff --git a/poetry.lock b/poetry.lock index f5b778ee..5695f273 100644 --- a/poetry.lock +++ b/poetry.lock @@ -300,13 +300,13 @@ files = [ [[package]] name = "momento-wire-types" -version = "0.135.0" +version = "0.139.0" description = "Momento Client Proto Generated Files" optional = false python-versions = "<4.0,>=3.10" files = [ - {file = "momento_wire_types-0.135.0-py3-none-any.whl", hash = "sha256:bb86c1d78fed84d8e7392875e2846376bc78bdeb32829ebbffe212ce5e103354"}, - {file = "momento_wire_types-0.135.0.tar.gz", hash = "sha256:1fe7ed1adcbd33dd34cd692eec703f5c571562c14a80223a28bd0dfb01c2928f"}, + {file = "momento_wire_types-0.139.0-py3-none-any.whl", hash = "sha256:ff2f6ecf5b1f172dc06355b5fad6241335f659e2b70f6d3d2bb0088ccdb17ffd"}, + {file = "momento_wire_types-0.139.0.tar.gz", hash = "sha256:c3117eaf519fda0fdc2354d9e963d3bb7c3542ac7bbdcb849ba0a6315319d9c9"}, ] [package.dependencies] @@ -804,4 +804,4 @@ typing-extensions = ">=3.7.4" [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "cef98a883315fcac29deff896fbd40465d692f352ab438f0ad5ec36c3b774109" +content-hash = "dc239a50df3f00cdff69cb9b42c34631c79a9cb34ed7fe65ba8b7bfca149c7a2" diff --git a/pyproject.toml b/pyproject.toml index ea7d2fb3..c338670c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ exclude = ["src/momento/internal/codegen.py"] [tool.poetry.dependencies] python = "^3.10" -momento-wire-types = "^0.135.0" +momento-wire-types = "^0.139.0" # momento-wire-types 0.135's generated stubs refuse to import on grpcio < 1.83.1 grpcio = "^1.83.1" # note if you bump this presigned url test need be updated diff --git a/src/momento/responses/control/cache/list.py b/src/momento/responses/control/cache/list.py index 6e9dd10a..af821aba 100644 --- a/src/momento/responses/control/cache/list.py +++ b/src/momento/responses/control/cache/list.py @@ -43,11 +43,14 @@ class ListCachesResponse(ControlResponse): @dataclass class CacheInfo: - """Contains a Momento cache's name.""" + """Contains a Momento cache's name and id.""" name: str """Holds the name of the cache.""" + id: str = "" + """Holds the id of the cache. Empty if the server does not report one.""" + class ListCaches(ABC): """Groups all `ListCachesResponse` derived types under a common namespace.""" @@ -66,7 +69,7 @@ def from_grpc_response(grpc_list_cache_response: ctrl_pb._ListCachesResponse) -> Args: grpc_list_cache_response: Protobuf based response returned by Scs. """ - caches = [CacheInfo(cache.cache_name) for cache in grpc_list_cache_response.cache] # type: ignore[misc] + caches = [CacheInfo(cache.cache_name, cache.cache_id) for cache in grpc_list_cache_response.cache] # type: ignore[misc] return ListCaches.Success(caches=caches) class Error(ListCachesResponse, ErrorResponseMixin): diff --git a/tests/momento/responses/test_list_caches_response.py b/tests/momento/responses/test_list_caches_response.py new file mode 100644 index 00000000..2a5c78e8 --- /dev/null +++ b/tests/momento/responses/test_list_caches_response.py @@ -0,0 +1,18 @@ +from __future__ import annotations + +from momento.responses import ListCaches +from momento.responses.control.cache.list import CacheInfo +from momento_wire_types import controlclient_pb2 as ctrl_pb + + +def test_list_caches_success_maps_cache_name_and_id() -> None: + grpc_response = ctrl_pb._ListCachesResponse( + cache=[ + ctrl_pb._Cache(cache_name="with-id", cache_id="0f1e2d3c"), + ctrl_pb._Cache(cache_name="without-id"), + ] + ) + + response = ListCaches.Success.from_grpc_response(grpc_response) + + assert response.caches == [CacheInfo(name="with-id", id="0f1e2d3c"), CacheInfo(name="without-id", id="")]