Skip to content

Delete API Exposure #188

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
maxschommer opened this issue Jan 22, 2021 · 7 comments · Fixed by #189
Closed

Delete API Exposure #188

maxschommer opened this issue Jan 22, 2021 · 7 comments · Fixed by #189
Labels
bug Something isn't working documentation Improvements or additions to documentation
Milestone

Comments

@maxschommer
Copy link

Proposal:
Add Delete functionality to the api, exposing the /api/v2/delete endpoint.

Use case:
For automated tests, I'd like to be able to send a series of test data to influx, and then clean up afterwards by deleting the data.

@maxschommer
Copy link
Author

It appears that this exists, but is not exposed in the documentation?

delete_api = client.delete_api()
delete_api.delete(start, stop, '_measurement="sensorData"', bucket_id=bucket_id, org_id=organization_id)

@maxschommer
Copy link
Author

The README.md has no reference to the delete api, and the read_the_docs has a DeleteAPI section, which is empty:

https://influxdb-client.readthedocs.io/en/latest/api.html#deleteapi

@bednar
Copy link
Contributor

bednar commented Jan 22, 2021

@maxschommer thanks for using our client, we will take a look

@bednar bednar added bug Something isn't working documentation Improvements or additions to documentation labels Jan 22, 2021
@bednar bednar added this to the 1.14.0 milestone Jan 26, 2021
@zcattacz
Copy link

Could you make it clear in the doc how to delete from a open range? e.g. [2021-1-1, inf ) , I tried to pass none it didn't work.

@zcattacz
Copy link

Also it feels unreasonable the delete API use iso timestamp while the write API use datetime object.

@bednar
Copy link
Contributor

bednar commented Aug 18, 2021

Could you make it clear in the doc how to delete from a open range? e.g. [2021-1-1, inf ) , I tried to pass none it didn't work.

The InfluxDB Delete API requires the stop parameter, there is no option how to pass Infinity as a stop. You can define stop as 2200-01-01T00:00:00.000000000Z

Also it feels unreasonable the delete API use iso timestamp while the write API use datetime object.

Good catch. Can you please create new issue for that. Meanwhile you can use following workaround:

from datetime import datetime
from influxdb_client.client.util.date_utils import get_date_helper
date_helper = get_date_helper()
start = date_helper.to_utc(datetime(1970, 1, 1, 0, 0, 0, 0))
stop = date_helper.to_utc(datetime(2200, 1, 1, 0, 0, 0, 0))

self.delete_api.delete(start, stop, "", bucket=bucket.id, org=organization.id)

@zcattacz
Copy link

zcattacz commented Aug 18, 2021

hi @bednar, I dont know where to start so I tried 9999-12-30T23:59.... and got a error saying value needs to be before 2262-04-11T23:47:16.854775806Z. I guess it may be nice, if it can be sugar coated into a directive e.g. delete_api.max_date.

datetime parameter requested in #313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants