influxdata / influxdb-client-python

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

feat: Add database creation/deletion for Influx 1.8 #544

Open Pitastic opened 1 year ago

Pitastic commented 1 year ago

Add features related to #541 and #259

Proposed Changes

In order to maintain a minimum of compatibility to Influx v1.8 the creation an deletion of buckets (old: databases) should be supported. With these little enhancements the influxdb-client-python could easily.

I implemented two new methods for calls to v1 API if the method for creating or deleting a bucket fails with an ApiException. That way no code changes are necessary regardless which version of Influx you are running on.

I implemented this with a call to the method influxdb_client.api_client.call_api instead of using the _buckets_service.post_buckets as this was easier and with less code changes. I had to invoke the creation of some arguments and hope you find it clean enough.

Checklist

As I just changed functionallity which wasn't there before and doesn't effect any of the other methods I don't know what to test or how to write a test for this. If this or anything else is needed, please advice me to the right direction.

telegraf-tiger[bot] commented 1 year ago

Thanks so much for the pull request! :handshake: :black_nib: Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

Pitastic commented 1 year ago

!signed-cla

Pitastic commented 1 year ago

The fails left are related to a numpy problem.

Pitastic commented 1 year ago

Thanks for your PR 👍

Please rebase your sources to fix CI build - #543

Will do 👍

codecov-commenter commented 1 year ago

Codecov Report

Base: 90.36% // Head: 89.72% // Decreases project coverage by -0.64% :warning:

Coverage data is based on head (83deff4) compared to base (03f5bd7). Patch coverage: 13.79% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #544 +/- ## ========================================== - Coverage 90.36% 89.72% -0.65% ========================================== Files 39 39 Lines 3437 3466 +29 ========================================== + Hits 3106 3110 +4 - Misses 331 356 +25 ``` | [Impacted Files](https://codecov.io/gh/influxdata/influxdb-client-python/pull/544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata) | Coverage Δ | | |---|---|---| | [influxdb\_client/client/bucket\_api.py](https://codecov.io/gh/influxdata/influxdb-client-python/pull/544/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata#diff-aW5mbHV4ZGJfY2xpZW50L2NsaWVudC9idWNrZXRfYXBpLnB5) | `58.46% <13.79%> (-35.99%)` | :arrow_down: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=influxdata)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

Pitastic commented 1 year ago

(Sorry for the little mess. I merged my rebased master to early)

Thanks for your feedback. I really like your approach and implemented a version check (_is_below_v2()) and an attribute for this (self._build_version).

I use the docstrings and raise a DeprecationWarning when falling back to InfluxQL but I guess with well documented you mean more than that? Where can I add a little description for this behaviour?

Pitastic commented 1 year ago

I don't know how to fix the semantic error in the PR title. Wozld you mind to change it to your needs, please?

ZPascal commented 1 year ago

Hi @Pitastic, I think it would be best to merge the commit and change the commit title to feat: Adding InfluxDB 1.8 support for database creation/deletion operations. I think it is also necessary to adjust the title of the PR to match that of the squashed commit.

If you need support, feel free to add me as a contributor to the original forked repository.