Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RS-418: Add Bucket.rename_entry method #117

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- RS-418: `Bucket.remove_record`, `Bucket.remove_batch` and `Bucket.remove_query` to remove records, [PR-114](https://github.com/reductstore/reduct-py/pull/114)
- RS-389: QuotaType.HARD, [PR-115](https://github.com/reductstore/reduct-py/pulls/115)
- RS-318: Add `Bucket.rename_entry` method, [PR-117](https://github.com/reductstore/reduct-py/pull/117)

## [1.11.0] - 2024-08-19

Expand Down
13 changes: 13 additions & 0 deletions reduct/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ async def remove_query(

return json.loads(resp)["removed_records"]

async def rename_entry(self, old_name: str, new_name: str):
"""
Rename entry
Args:
old_name: old name of entry
new_name: new name of entry
Raises:
ReductError: if there is an HTTP error
"""
await self._http.request_all(
"PUT", f"/b/{self.name}/{old_name}/rename", json={"new_name": new_name}
)

@asynccontextmanager
async def read(
self,
Expand Down
9 changes: 9 additions & 0 deletions tests/bucket_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,12 @@ async def test_remove_query(bucket_1):
records = [record async for record in bucket_1.query("entry-2")]
assert len(records) == 1
assert records[0].timestamp == 5000000


@pytest.mark.asyncio
@requires_api("1.12")
async def test_rename_entry(bucket_1):
"""Should rename an entry"""
await bucket_1.rename_entry("entry-2", "new-entry")
entries = await bucket_1.get_entry_list()
assert entries[1].name == "new-entry"
Loading