From 3ab08e09e5d489638511f853235d84fd2dc5064b Mon Sep 17 00:00:00 2001 From: Mike Hukiewitz Date: Tue, 30 May 2023 11:45:25 +0200 Subject: [PATCH] deprecate message_type in favor of message_types --- src/aleph/sdk/client.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/aleph/sdk/client.py b/src/aleph/sdk/client.py index 9877d716..556d0186 100644 --- a/src/aleph/sdk/client.py +++ b/src/aleph/sdk/client.py @@ -5,6 +5,7 @@ import queue import threading import time +import warnings from datetime import datetime from pathlib import Path from typing import ( @@ -630,6 +631,7 @@ async def get_messages( pagination: int = 200, page: int = 1, message_type: Optional[MessageType] = None, + message_types: Optional[List[MessageType]] = None, content_types: Optional[Iterable[str]] = None, content_keys: Optional[Iterable[str]] = None, refs: Optional[Iterable[str]] = None, @@ -648,7 +650,8 @@ async def get_messages( :param pagination: Number of items to fetch (Default: 200) :param page: Page to fetch, begins at 1 (Default: 1) - :param message_type: Filter by message type, can be "AGGREGATE", "POST", "PROGRAM", "VM", "STORE" or "FORGET" + :param message_type: [DEPRECATED] Filter by message type, can be "AGGREGATE", "POST", "PROGRAM", "VM", "STORE" or "FORGET" + :param message_types: Filter by message types, can be any combination of "AGGREGATE", "POST", "PROGRAM", "VM", "STORE" or "FORGET" :param content_types: Filter by content type :param content_keys: Filter by content key :param refs: If set, only fetch posts that reference these hashes (in the "refs" field) @@ -674,7 +677,13 @@ async def get_messages( params: Dict[str, Any] = dict(pagination=pagination, page=page) if message_type is not None: + warnings.warn( + "The message_type parameter is deprecated, please use message_types instead.", + DeprecationWarning, + ) params["msgType"] = message_type.value + if message_types is not None: + params["msgTypes"] = ",".join([t.value for t in message_types]) if content_types is not None: params["contentTypes"] = ",".join(content_types) if content_keys is not None: @@ -772,6 +781,7 @@ async def get_message( async def watch_messages( self, message_type: Optional[MessageType] = None, + message_types: Optional[Iterable[MessageType]] = None, content_types: Optional[Iterable[str]] = None, refs: Optional[Iterable[str]] = None, addresses: Optional[Iterable[str]] = None, @@ -785,7 +795,8 @@ async def watch_messages( """ Iterate over current and future matching messages asynchronously. - :param message_type: Type of message to watch + :param message_type: [DEPRECATED] Type of message to watch + :param message_types: Types of messages to watch :param content_types: Content types to watch :param refs: References to watch :param addresses: Addresses to watch @@ -799,7 +810,13 @@ async def watch_messages( params: Dict[str, Any] = dict() if message_type is not None: + warnings.warn( + "The message_type parameter is deprecated, please use message_types instead.", + DeprecationWarning, + ) params["msgType"] = message_type.value + if message_types is not None: + params["msgTypes"] = ",".join([t.value for t in message_types]) if content_types is not None: params["contentTypes"] = ",".join(content_types) if refs is not None: