Skip to content

Commit 15cba79

Browse files
authored
docs: add an example how to create a task (influxdata#395)
1 parent 86c2d62 commit 15cba79

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
## 1.25.0 [unreleased]
22

3+
### Features
4+
1. [#393](https://github.com/influxdata/influxdb-client-python/pull/393): Added callback function for getting profilers output with example and test
5+
36
### Bug Fixes
47
1. [#375](https://github.com/influxdata/influxdb-client-python/pull/375): Construct `InfluxDBError` without HTTP response
58
1. [#378](https://github.com/influxdata/influxdb-client-python/pull/378): Correct serialization DataFrame with nan values [DataFrame]
69
1. [#384](https://github.com/influxdata/influxdb-client-python/pull/384): Timeout can be specified as a `float`
710
1. [#380](https://github.com/influxdata/influxdb-client-python/pull/380): Correct data types for querying [DataFrame]
811
1. [#391](https://github.com/influxdata/influxdb-client-python/pull/391): Ping function uses debug for log
912

10-
### Features
11-
1. [#393](https://github.com/influxdata/influxdb-client-python/pull/393): Added callback function for getting profilers output with example and test
13+
### Documentation
14+
1. [#395](https://github.com/influxdata/influxdb-client-python/pull/395): Add an example How to use create a Task by API
1215

1316
### CI
1417
1. [#370](https://github.com/influxdata/influxdb-client-python/pull/370): Add Python 3.10 to CI builds

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
## Management API
2121
- [buckets_management.py](buckets_management.py) - How to create, list and delete Buckets
2222
- [monitoring_and_alerting.py](monitoring_and_alerting.py) - How to create the Check with Slack notification.
23+
- [task_example.py](task_example.py) - How to create a Task by API
2324

2425
## Others
2526
- [influx_cloud.py](influx_cloud.py) - How to connect to InfluxDB 2 Cloud

examples/task_example.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from influxdb_client import InfluxDBClient, TaskCreateRequest
2+
3+
url = "http://localhost:8086"
4+
org = "my-org"
5+
bucket = "my-bucket"
6+
token = "my-token"
7+
8+
with InfluxDBClient(url=url, token=token, org=org, debug=True) as client:
9+
tasks_api = client.tasks_api()
10+
11+
flux = \
12+
'''
13+
option task = {{
14+
name: "{task_name}",
15+
every: 1d
16+
}}
17+
18+
from(bucket: "{from_bucket}")
19+
|> range(start: -task.every)
20+
|> filter(fn: (r) => (r._measurement == "m"))
21+
|> aggregateWindow(every: 1h, fn: mean)
22+
|> to(bucket: "{to_bucket}", org: "{org}")
23+
'''.format(task_name="my-task", from_bucket=bucket, to_bucket="to-my-bucket", org=org)
24+
25+
task_request = TaskCreateRequest(flux=flux, org=org, description="Task Description", status="active")
26+
task = tasks_api.create_task(task_create_request=task_request)
27+
print(task)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy