diff --git a/CHANGELOG.md b/CHANGELOG.md index 152b3e6d..ea2f420f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 1.25.0 [unreleased] +### Features +1. [#393](https://github.com/influxdata/influxdb-client-python/pull/393): Added callback function for getting profilers output with example and test + ### Bug Fixes 1. [#375](https://github.com/influxdata/influxdb-client-python/pull/375): Construct `InfluxDBError` without HTTP response 1. [#378](https://github.com/influxdata/influxdb-client-python/pull/378): Correct serialization DataFrame with nan values [DataFrame] @@ -7,8 +10,8 @@ 1. [#380](https://github.com/influxdata/influxdb-client-python/pull/380): Correct data types for querying [DataFrame] 1. [#391](https://github.com/influxdata/influxdb-client-python/pull/391): Ping function uses debug for log -### Features -1. [#393](https://github.com/influxdata/influxdb-client-python/pull/393): Added callback function for getting profilers output with example and test +### Documentation +1. [#395](https://github.com/influxdata/influxdb-client-python/pull/395): Add an example How to use create a Task by API ### CI 1. [#370](https://github.com/influxdata/influxdb-client-python/pull/370): Add Python 3.10 to CI builds diff --git a/examples/README.md b/examples/README.md index 9892a837..ef52b0ff 100644 --- a/examples/README.md +++ b/examples/README.md @@ -20,6 +20,7 @@ ## Management API - [buckets_management.py](buckets_management.py) - How to create, list and delete Buckets - [monitoring_and_alerting.py](monitoring_and_alerting.py) - How to create the Check with Slack notification. +- [task_example.py](task_example.py) - How to create a Task by API ## Others - [influx_cloud.py](influx_cloud.py) - How to connect to InfluxDB 2 Cloud diff --git a/examples/task_example.py b/examples/task_example.py new file mode 100644 index 00000000..55595ba9 --- /dev/null +++ b/examples/task_example.py @@ -0,0 +1,27 @@ +from influxdb_client import InfluxDBClient, TaskCreateRequest + +url = "http://localhost:8086" +org = "my-org" +bucket = "my-bucket" +token = "my-token" + +with InfluxDBClient(url=url, token=token, org=org, debug=True) as client: + tasks_api = client.tasks_api() + + flux = \ + ''' + option task = {{ + name: "{task_name}", + every: 1d + }} + + from(bucket: "{from_bucket}") + |> range(start: -task.every) + |> filter(fn: (r) => (r._measurement == "m")) + |> aggregateWindow(every: 1h, fn: mean) + |> to(bucket: "{to_bucket}", org: "{org}") +'''.format(task_name="my-task", from_bucket=bucket, to_bucket="to-my-bucket", org=org) + + task_request = TaskCreateRequest(flux=flux, org=org, description="Task Description", status="active") + task = tasks_api.create_task(task_create_request=task_request) + print(task)