|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import json as jsonlib
|
4 |
| -import warnings |
5 | 4 | from contextlib import asynccontextmanager, contextmanager
|
6 | 5 | from http import HTTPStatus
|
7 | 6 | from typing import TYPE_CHECKING, Any
|
8 | 7 |
|
9 | 8 | from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields
|
10 | 9 |
|
11 |
| -from apify_client._errors import ApifyApiError |
12 | 10 | from apify_client._utils import (
|
13 | 11 | catch_not_found_or_throw,
|
14 | 12 | encode_key_value_store_record_value,
|
15 | 13 | maybe_parse_response,
|
16 | 14 | pluck_data,
|
17 | 15 | )
|
18 | 16 | from apify_client.clients.base import ResourceClient, ResourceClientAsync
|
| 17 | +from apify_client.errors import ApifyApiError |
19 | 18 |
|
20 | 19 | if TYPE_CHECKING:
|
21 | 20 | from collections.abc import AsyncIterator, Iterator
|
@@ -107,43 +106,18 @@ def list_keys(
|
107 | 106 |
|
108 | 107 | return parse_date_fields(pluck_data(jsonlib.loads(response.text)))
|
109 | 108 |
|
110 |
| - def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) -> dict | None: |
| 109 | + def get_record(self, key: str) -> dict | None: |
111 | 110 | """Retrieve the given record from the key-value store.
|
112 | 111 |
|
113 | 112 | https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record
|
114 | 113 |
|
115 | 114 | Args:
|
116 | 115 | key: Key of the record to retrieve.
|
117 |
| - as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, |
118 |
| - default False. |
119 |
| - as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, |
120 |
| - default False. |
121 | 116 |
|
122 | 117 | Returns:
|
123 | 118 | The requested record, or None, if the record does not exist.
|
124 | 119 | """
|
125 | 120 | try:
|
126 |
| - if as_bytes and as_file: |
127 |
| - raise ValueError('You cannot have both as_bytes and as_file set.') |
128 |
| - |
129 |
| - if as_bytes: |
130 |
| - warnings.warn( |
131 |
| - '`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, ' |
132 |
| - 'use `KeyValueStoreClient.get_record_as_bytes()` instead.', |
133 |
| - DeprecationWarning, |
134 |
| - stacklevel=2, |
135 |
| - ) |
136 |
| - return self.get_record_as_bytes(key) |
137 |
| - |
138 |
| - if as_file: |
139 |
| - warnings.warn( |
140 |
| - '`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, ' |
141 |
| - 'use `KeyValueStoreClient.stream_record()` instead.', |
142 |
| - DeprecationWarning, |
143 |
| - stacklevel=2, |
144 |
| - ) |
145 |
| - return self.stream_record(key) # type: ignore[return-value] |
146 |
| - |
147 | 121 | response = self.http_client.call(
|
148 | 122 | url=self._url(f'records/{key}'),
|
149 | 123 | method='GET',
|
@@ -380,10 +354,6 @@ async def get_record(self, key: str) -> dict | None:
|
380 | 354 |
|
381 | 355 | Args:
|
382 | 356 | key: Key of the record to retrieve.
|
383 |
| - as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes, |
384 |
| - default False. |
385 |
| - as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object, |
386 |
| - default False. |
387 | 357 |
|
388 | 358 | Returns:
|
389 | 359 | The requested record, or None, if the record does not exist.
|
|
0 commit comments