From f98a7dbb2c18952bb08582984f4afc4afa7767ed Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Wed, 15 May 2024 11:10:22 -0500 Subject: [PATCH 1/2] fix: add tutorial prerequisites --- .../influxdb/v2/api-guide/tutorials/nodejs.md | 20 ++++++++++--------- .../influxdb/v2/api-guide/tutorials/python.md | 19 +++++------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/content/influxdb/v2/api-guide/tutorials/nodejs.md b/content/influxdb/v2/api-guide/tutorials/nodejs.md index e5fd17972..8424f60a9 100644 --- a/content/influxdb/v2/api-guide/tutorials/nodejs.md +++ b/content/influxdb/v2/api-guide/tutorials/nodejs.md @@ -19,8 +19,8 @@ influxdb/v2/tags: [api, javascript, nodejs] - [Contents](#contents) - [Set up InfluxDB](#set-up-influxdb) - - [Authenticate with an InfluxDB API token](#authenticate-with-an-influxdb-api-token) - [Introducing IoT Starter](#introducing-iot-starter) +- [Install Yarn](#install-yarn) - [Create the application](#create-the-application) - [Install InfluxDB client library](#install-influxdb-client-library) - [Configure the client library](#configure-the-client-library) @@ -37,18 +37,20 @@ influxdb/v2/tags: [api, javascript, nodejs] If you haven't already, [create an InfluxDB Cloud account](https://www.influxdata.com/products/influxdb-cloud/) or [install InfluxDB OSS](https://www.influxdata.com/products/influxdb/). -### Authenticate with an InfluxDB API token +The IoT Starter example app assumes the following prerequisites: -For convenience in development, -[create an _All Access_ token](/influxdb/v2/admin/tokens/create-token/) -for your application. This grants your application full read and write -permissions on all resources within your InfluxDB organization. +- An InfluxDB [org ID](/influxdb/v2/admin/organizations/view-orgs/) +- An [API token](/influxdb/v2/admin/tokens/create-token/) (for example, an **All Access token**) that has read and write permissions for the buckets +- A [bucket](/influxdb/v2/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) named `iot_center` for storing time series data from devices +- A [bucket](/influxdb/v2/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) named `iot_center_devices` for storing device metadata and API token IDs {{% note %}} -For a production application, create and use a -{{% cloud-only %}}custom{{% /cloud-only %}}{{% oss-only %}}read-write{{% /oss-only %}} -token with minimal permissions and only use it with your application. +#### Use restricted tokens for production apps + +For a production application, create and use a +{{% cloud-only %}}custom{{% /cloud-only %}}{{% oss-only %}}read-write{{% /oss-only %}} +token with minimal permissions and only use it with a single client or application. {{% /note %}} diff --git a/content/influxdb/v2/api-guide/tutorials/python.md b/content/influxdb/v2/api-guide/tutorials/python.md index 3479daf63..8b06a9381 100644 --- a/content/influxdb/v2/api-guide/tutorials/python.md +++ b/content/influxdb/v2/api-guide/tutorials/python.md @@ -21,7 +21,6 @@ influxdb/v2/tags: [api, python] - [Contents](#contents) - [Set up InfluxDB](#set-up-influxdb) - - [Authenticate with an InfluxDB API token](#authenticate-with-an-influxdb-api-token) - [Introducing IoT Starter](#introducing-iot-starter) - [Create the application](#create-the-application) - [Install InfluxDB client library](#install-influxdb-client-library) @@ -41,20 +40,12 @@ influxdb/v2/tags: [api, python] If you haven't already, [create an InfluxDB Cloud account](https://www.influxdata.com/products/influxdb-cloud/) or [install InfluxDB OSS](https://www.influxdata.com/products/influxdb/). -### Authenticate with an InfluxDB API token +The IoT Starter example app assumes the following prerequisites: -For convenience in development, -[create an _All Access_ token](/influxdb/v2/admin/tokens/create-token/) -for your application. This grants your application full read and write -permissions on all resources within your InfluxDB organization. - -{{% note %}} - -For a production application, create and use a -{{% cloud-only %}}custom{{% /cloud-only %}}{{% oss-only %}}read-write{{% /oss-only %}} -token with minimal permissions and only use it with your application. - -{{% /note %}} +- An InfluxDB [org ID](/influxdb/v2/admin/organizations/view-orgs/) +- An [API token](/influxdb/v2/admin/tokens/create-token/) (for example, an **All Access token**) that has read and write permissions for the buckets +- A [bucket](/influxdb/v2/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) named `iot_center` for storing time series data from devices +- A [bucket](/influxdb/v2/admin/buckets/create-bucket/#create-a-bucket-using-the-influxdb-api) named `iot_center_devices` for storing device metadata and API token IDs ## Introducing IoT Starter From aa518674861f83305e1fdd2c7b495e9410361cb6 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Wed, 15 May 2024 11:21:48 -0500 Subject: [PATCH 2/2] fix: remove truncate - nesting breaks the layout --- content/influxdb/v2/api-guide/tutorials/python.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/content/influxdb/v2/api-guide/tutorials/python.md b/content/influxdb/v2/api-guide/tutorials/python.md index 8b06a9381..78f96e1f2 100644 --- a/content/influxdb/v2/api-guide/tutorials/python.md +++ b/content/influxdb/v2/api-guide/tutorials/python.md @@ -347,8 +347,6 @@ Add the `/api/devices` API endpoint that retrieves, processes, and lists registe In `./api/devices.py`, add the following: - {{% truncate %}} - ```python def get_device(device_id=None) -> {}: influxdb_client = InfluxDBClient(url=config.get('APP', 'INFLUX_URL'), @@ -381,14 +379,12 @@ Add the `/api/devices` API endpoint that retrieves, processes, and lists registe return result ``` -{{% /truncate %}} + {{% caption %}}[iot-api-python/api/devices.py get_device()](https://github.com/influxdata/iot-api-python/blob/9bf44a659424a27eb937d545dc0455754354aef5/api/devices.py#L30){{% /caption %}} -{{% caption %}}[iot-api-python/api/devices.py get_device()](https://github.com/influxdata/iot-api-python/blob/9bf44a659424a27eb937d545dc0455754354aef5/api/devices.py#L30){{% /caption %}} + The `get_device(device_id)` function does the following: -The `get_device(device_id)` function does the following: - -1. Instantiates a `QueryApi` client and sends the Flux query to InfluxDB. -2. Iterates over the `FluxTable` in the response and returns a list of tuples. + 1. Instantiates a `QueryApi` client and sends the Flux query to InfluxDB. + 2. Iterates over the `FluxTable` in the response and returns a list of tuples. ## Create IoT virtual device