Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 1 addition & 31 deletions src/apify_client/clients/resource_clients/key_value_store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import warnings
from contextlib import asynccontextmanager, contextmanager
from http import HTTPStatus
from typing import TYPE_CHECKING, Any
Expand Down Expand Up @@ -101,43 +100,18 @@ def list_keys(

return parse_date_fields(pluck_data(response.json()))

def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) -> dict | None:
def get_record(self, key: str) -> dict | None:
"""Retrieve the given record from the key-value store.

https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record

Args:
key: Key of the record to retrieve.
as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes,
default False.
as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object,
default False.

Returns:
The requested record, or None, if the record does not exist.
"""
try:
if as_bytes and as_file:
raise ValueError('You cannot have both as_bytes and as_file set.')

if as_bytes:
warnings.warn(
'`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, '
'use `KeyValueStoreClient.get_record_as_bytes()` instead.',
DeprecationWarning,
stacklevel=2,
)
return self.get_record_as_bytes(key)

if as_file:
warnings.warn(
'`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, '
'use `KeyValueStoreClient.stream_record()` instead.',
DeprecationWarning,
stacklevel=2,
)
return self.stream_record(key) # type: ignore[return-value]

response = self.http_client.call(
url=self._url(f'records/{key}'),
method='GET',
Expand Down Expand Up @@ -376,10 +350,6 @@ async def get_record(self, key: str) -> dict | None:

Args:
key: Key of the record to retrieve.
as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes,
default False.
as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object,
default False.

Returns:
The requested record, or None, if the record does not exist.
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading