Skip to content

Commit

Permalink
RS-419: Add Bucket.rename method (#118)
Browse files Browse the repository at this point in the history
* add `Bucket.rename` method

* update CHANGELOG
  • Loading branch information
atimin authored Oct 2, 2024
1 parent c4f57ad commit d463cbb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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)
- RS-419: Add `Bucket.rename` method, [PR-118](https://github.com/reductstore/reduct-py/pull/118)

## [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 @@ -260,6 +260,19 @@ async def rename_entry(self, old_name: str, new_name: str):
"PUT", f"/b/{self.name}/{old_name}/rename", json={"new_name": new_name}
)

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

@asynccontextmanager
async def read(
self,
Expand Down
8 changes: 8 additions & 0 deletions tests/bucket_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,11 @@ async def test_rename_entry(bucket_1):
await bucket_1.rename_entry("entry-2", "new-entry")
entries = await bucket_1.get_entry_list()
assert entries[1].name == "new-entry"


@pytest.mark.asyncio
@requires_api("1.12")
async def test_rename_bucket(bucket_1):
"""Should rename a bucket"""
await bucket_1.rename("new-bucket")
assert bucket_1.name == "new-bucket"

0 comments on commit d463cbb

Please sign in to comment.