Skip to content

Implement updating a bucket #357

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

Closed
SimonMayerhofer opened this issue Nov 6, 2021 · 2 comments · Fixed by #358
Closed

Implement updating a bucket #357

SimonMayerhofer opened this issue Nov 6, 2021 · 2 comments · Fixed by #358
Labels
enhancement New feature or request
Milestone

Comments

@SimonMayerhofer
Copy link

SimonMayerhofer commented Nov 6, 2021

Proposal:
Currently there is no way of updating a bucket with the current BucketsApi. With the CLI it is e.g. possible to update the name or the retention period of a bucket.

Current behavior:
no way

Desired behavior:
Beeing able to change the name of the bucket.

Use case:
Why is this important (helps with prioritizing requests)?
In my use case of influx, I always need to delete all data and write it again in order to have all my data there. Currently I first need to delete and then write the data again. What would result in less downtime or less incomplete data during writing is a workflow where I can:

  1. create & write to 'temp' bucket
  2. rename 'production' bucket to 'old'
  3. rename 'temp' bucket to 'production'
  4. delete 'old' bucket

That way I could easily write data as long as I want to a separate bucket and still be able to use the main bucket, and quickly change them after the writing is done.

@bednar
Copy link
Contributor

bednar commented Nov 8, 2021

Hi @SimonMayerhofer,

thanks for using our client.

The BucketsApi is wrapper for generated BucketsService which cover full spec of InfluxDB 2 HTTP API.

As a workaround you can use something like:

from influxdb_client import InfluxDBClient, BucketRetentionRules, BucketsService, PatchBucketRequest

"""
Define credentials
"""
url = "http://localhost:8086"
token = "my-token"
org = "my-org"

with InfluxDBClient(url=url, token=token) as client:
    buckets_api = client.buckets_api()

    retention_rules = BucketRetentionRules(type="expire", every_seconds=3600)
    created_bucket = buckets_api.create_bucket(bucket_name="bucket-by-python",
                                               retention_rules=retention_rules,
                                               org=org)
    print(created_bucket)
    print("---")

    service = BucketsService(client.api_client)
    service.patch_buckets_id(bucket_id=created_bucket.id, patch_bucket_request=PatchBucketRequest(name="Updated name"))

    updated_bucket = buckets_api.find_bucket_by_id(created_bucket.id)
    print(updated_bucket)

Regards

@bednar bednar added the enhancement New feature or request label Nov 8, 2021
@SimonMayerhofer
Copy link
Author

Awesome! Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants