influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
724 stars 187 forks source link

Unable to use the buckets_api on Influx 1.8.10 #541

Closed Pitastic closed 1 year ago

Pitastic commented 1 year ago

Specifications

Reproduce:

On Influx 1.8 I am dealing with databases and not yet with buckets. The only problem is, that there is no client.create_database() anymore. Thanks to your migration guide and the examples in this repo it is clear that I should use the client.buckets_api() for that instead. These API Endpoints don't exist on 1.8 what makes sense to me.

But as this should be backwards compatible with 1.8 is there a workaround for this or am I missing something?

Code sample to reproduce problem

from influxdb_client import InfluxDBClient, BucketRetentionRules

org = ''

with InfluxDBClient(url='http://myserver:8086', token='user:password', org=org) 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)

Expected behavior

Create a "database" instead of a "bucket".

Actual behavior

Endpoint for API call is not found.

Additional info

influxdb_client.rest.ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': '1.8.10', 'Date': 'Tue, 20 Dec 2022 21:42:34 GMT', 'Content-Length': '19'})
HTTP response body: 404 page not found
Pitastic commented 1 year ago

Found this old Issue which suggests to use requests to call the API v1 directly. Do I really have to 😋 ?

bednar commented 1 year ago

Hi @Pitastic,

thanks for using our client.

But as this should be backwards compatible with 1.8 is there a workaround for this or am I missing something?

The client is not backwards compatible with 1.8. You can only use this client with InfluxDB 2.0 API compatibility endpoints.

Found this old Issue which suggests to use requests to call the API v1 directly. Do I really have to 😋 ?

Yes, you have to, but every Pull Request is welcome. If you want to add a helper for this into client code base ... feel free to create PR.

Regards

Pitastic commented 1 year ago

The client is not backwards compatible with 1.8

Ah ok. But just want to mention that this example in your repo is not valid then.

Thanks for your work. I will have a look if I am professional enough to help out here 😃 I would really like to...