Skip to content

Commit

Permalink
Add limit and search_direction
Browse files Browse the repository at this point in the history
  • Loading branch information
davitmamrikishvili committed Nov 29, 2024
1 parent 12a5e5a commit d16a93a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions th2_data_services/data_source/lwdp/commands/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,8 @@ def __init__(
response_formats: Union[List[str], str] = None,
streams: Optional[T_streams] = [],
fast_fail: bool = True,
limit: Optional[int] = None,
search_direction: str = "next",
):
"""DownloadMessagesByPageByGroupsGzip Constructor.
Expand All @@ -1514,6 +1516,8 @@ def __init__(
}
]
fast_fail: If true, stops task execution right after first error.
limit: Limit for messages in the response. No limit if not specified.
search_direction: Defines the order of the messages.
"""
if sort is not None:
warnings.warn(
Expand All @@ -1533,6 +1537,8 @@ def __init__(
self._sort = sort
self._response_formats = response_formats
self._fast_fail = fast_fail
self._limit = limit
self._search_direction = search_direction

_check_list_or_tuple(self._groups, var_name="groups")
if streams is not None:
Expand All @@ -1559,6 +1565,8 @@ def handle(self, data_source: DataSource) -> Data:
streams=self._streams,
response_formats=self._response_formats,
fast_fail=self._fast_fail,
limit=self._limit,
search_direction=self._search_direction,
)

status = _download_messages(api, url, body, headers, self._filename)
Expand Down Expand Up @@ -1596,6 +1604,8 @@ def __init__(
response_formats: Union[List[str], str] = None,
streams: Optional[T_streams] = [],
fast_fail: bool = True,
limit: Optional[int] = None,
search_direction: str = "next",
):
"""DownloadMessagesByBookByGroupsGzip Constructor.
Expand All @@ -1622,6 +1632,8 @@ def __init__(
}
]
fast_fail: If true, stops task execution right after first error.
limit: Limit for messages in the response. No limit if not specified.
search_direction: Defines the order of the messages.
"""
if sort is not None:
warnings.warn(
Expand Down Expand Up @@ -1654,6 +1666,8 @@ def __init__(
self._response_formats = response_formats
self._book_id = book_id
self._fast_fail = fast_fail
self._limit = limit
self._search_direction = search_direction

_check_list_or_tuple(self._groups, var_name="groups")
if streams is not None:
Expand All @@ -1671,6 +1685,8 @@ def handle(self, data_source: DataSource):
streams=self._streams,
response_formats=self._response_formats,
fast_fail=self._fast_fail,
limit=self._limit,
search_direction=self._search_direction,
)

status = _download_messages(api, url, body, headers, self._filename)
Expand Down Expand Up @@ -1801,6 +1817,8 @@ def __init__(
streams: Optional[T_streams] = [],
fast_fail: bool = True,
cache: bool = False,
limit: Optional[int] = None,
search_direction: str = "next",
):
"""GetMessagesByBookByGroupsJson Constructor.
Expand All @@ -1826,6 +1844,8 @@ def __init__(
]
fast_fail: If true, stops task execution right after first error.
cache: If True, all requested data from lw-data-provider will be saved to cache.
limit: Limit for messages in the response. No limit if not specified.
search_direction: Defines the order of the messages.
"""
if sort is not None:
warnings.warn(
Expand Down Expand Up @@ -1856,6 +1876,8 @@ def __init__(
self._book_id = book_id
self._fast_fail = fast_fail
self._cache = cache
self._limit = limit
self._search_direction = search_direction

_check_list_or_tuple(self._groups, var_name="groups")
if streams is not None:
Expand All @@ -1871,6 +1893,8 @@ def handle(self, data_source: DataSource):
streams=self._streams,
response_formats=self._response_formats,
fast_fail=self._fast_fail,
limit=self._limit,
search_direction=self._search_direction,
)
headers = {"Accept": "application/stream+json", "Accept-Encoding": "gzip, deflate"}

Expand Down Expand Up @@ -2297,6 +2321,8 @@ def __init__(
streams: Optional[T_streams] = [],
fast_fail: bool = True,
cache: bool = False,
limit: Optional[int] = None,
search_direction: str = "next",
):
"""GetMessagesByPageByGroupsJson Constructor.
Expand All @@ -2319,6 +2345,8 @@ def __init__(
]
fast_fail: If true, stops task execution right after first error.
cache: If True, all requested data from lw-data-provider will be saved to cache.
limit: Limit for messages in the response. No limit if not specified.
search_direction: Defines the order of the messages.
"""
if sort is not None:
warnings.warn(
Expand All @@ -2336,6 +2364,8 @@ def __init__(
self._response_formats = response_formats
self._fast_fail = fast_fail
self._cache = cache
self._limit = limit
self._search_direction = search_direction

_check_list_or_tuple(self._groups, var_name="groups")
if streams is not None:
Expand All @@ -2359,6 +2389,8 @@ def handle(self, data_source: DataSource) -> Data:
streams=self._streams,
response_formats=self._response_formats,
fast_fail=self._fast_fail,
limit=self._limit,
search_direction=self._search_direction,
)

headers = {"Accept": "application/stream+json", "Accept-Encoding": "gzip, deflate"}
Expand Down
2 changes: 1 addition & 1 deletion th2_data_services/data_source/lwdp/source_api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def post_download_messages(
response_formats: Response format
streams: List of streams (optionally with direction) to include in the response.
fast_fail: If true, stops task execution right after first error.
limit: Limit for events in the response. No limit if not specified.
limit: Limit for messages in the response. No limit if not specified.
search_direction: Defines the order of the messages.
Returns:
Expand Down

0 comments on commit d16a93a

Please sign in to comment.