Skip to content

Commit

Permalink
RS-318: Add Bucket.rename_entry method (#117)
Browse files Browse the repository at this point in the history
* add Bucket.rename_entry method

* update CHANGELOG
  • Loading branch information
atimin authored Oct 2, 2024
1 parent ad43f7b commit c4f57ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
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"

0 comments on commit c4f57ad

Please sign in to comment.