From 65da71385936254892bbb77a234928418b33744e Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 09:01:13 -0700 Subject: [PATCH 1/7] added experimental http.get function, resolves #601 --- .../flux/stdlib/experimental/http/_index.md | 31 ++++++++++ .../flux/stdlib/experimental/http/get.md | 56 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 content/v2.0/reference/flux/stdlib/experimental/http/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/experimental/http/get.md diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md new file mode 100644 index 000000000..7febbaa09 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md @@ -0,0 +1,31 @@ +--- +title: Flux HTTP package +list_title: HTTP package +description: > + The Flux Experimental HTTP package provides experimental functions for transferring + data using the HTTP protocol. + Import the `experimental/http` package. +menu: + v2_0_ref: + name: HTTP + identifier: HTTP-exp + parent: Experimental +weight: 202 +v2.0/tags: [functions, http, package] +--- + +The Flux Experimental HTTP package provides experimental functions for transferring +data using the HTTP protocol. + +{{% warn %}} +The experimental HTTP package is subject to change at any time. +By using this package, you accept the [risks of experimental functions](/v2.0/reference/flux/stdlib/experimental/#use-experimental-functions-at-your-own-risk). +{{% /warn %}} + +Import the `experimental/http` package: + +```js +import "experimental/http" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md new file mode 100644 index 000000000..76e5eeca0 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -0,0 +1,56 @@ +--- +title: http.get() function +description: > + The `http.get()` function submits an HTTP GET request to the specified URL with headers + and returns the HTTP status code and body as a byte array. +menu: + v2_0_ref: + name: http.get + parent: HTTP-exp +weight: 202 +--- + +The `http.get()` function submits an HTTP GET request to the specified URL with headers +and returns the HTTP status code and body as a byte array. + +_**Function type:** Miscellaneous_ + +{{% warn %}} +The `http.get()` function is currently experimental and subject to change at any time. +By using this function, you accept the [risks of experimental functions](/v2.0/reference/flux/stdlib/experimental/#use-experimental-functions-at-your-own-risk). +{{% /warn %}} + +```js +import "experimental/http" + +http.get( + url: "http://localhost:9999/", + headers: {x:"a", y:"b", z:"c"} +) +``` + +## Parameters + +### url +The URL to send the GET request to. + +_**Data type:** String_ + +### headers +Headers to include with the GET request. + +_**Data type:** Object_ + +## Examples + +##### Get the status of InfluxDB +```js +import "experimental/http" + +response = http.get( + url: "http://localhost.com:9999/health", + headers: {} + ) + +status = string(v: response.body) +``` From a446a98d1d32335987345ac97abcc8dfab5c2e93 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 09:04:43 -0700 Subject: [PATCH 2/7] updated weights of experimental http package --- content/v2.0/reference/flux/stdlib/experimental/http/_index.md | 2 +- content/v2.0/reference/flux/stdlib/experimental/http/get.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md index 7febbaa09..4be46b606 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md @@ -10,7 +10,7 @@ menu: name: HTTP identifier: HTTP-exp parent: Experimental -weight: 202 +weight: 201 v2.0/tags: [functions, http, package] --- diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index 76e5eeca0..2a3ed4015 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -7,7 +7,7 @@ menu: v2_0_ref: name: http.get parent: HTTP-exp -weight: 202 +weight: 301 --- The `http.get()` function submits an HTTP GET request to the specified URL with headers From 19af0a7ec3205e86bb0286dba22ff8522ccdb283 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 09:29:14 -0700 Subject: [PATCH 3/7] updated experimental http.get example --- content/v2.0/reference/flux/stdlib/experimental/http/get.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index 2a3ed4015..cec408c10 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -52,5 +52,6 @@ response = http.get( headers: {} ) -status = string(v: response.body) +status = string(v: response.statusCode) +body = string(v: response.body) ``` From 8dd20a8ed7a0dc3cdd1f5197813ae04bf1d51603 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 09:43:14 -0700 Subject: [PATCH 4/7] updated http.get to address PR review, updated http.get example --- .../reference/flux/stdlib/experimental/http/_index.md | 8 ++++---- .../v2.0/reference/flux/stdlib/experimental/http/get.md | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md index 4be46b606..d56bfae6a 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/_index.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/_index.md @@ -2,8 +2,8 @@ title: Flux HTTP package list_title: HTTP package description: > - The Flux Experimental HTTP package provides experimental functions for transferring - data using the HTTP protocol. + The Flux Experimental HTTP package provides functions for transferring data + using HTTP protocol. Import the `experimental/http` package. menu: v2_0_ref: @@ -14,8 +14,8 @@ weight: 201 v2.0/tags: [functions, http, package] --- -The Flux Experimental HTTP package provides experimental functions for transferring -data using the HTTP protocol. +The Flux Experimental HTTP package provides functions for transferring data +using HTTP protocol. {{% warn %}} The experimental HTTP package is subject to change at any time. diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index cec408c10..25e5a7c80 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -38,6 +38,7 @@ _**Data type:** String_ ### headers Headers to include with the GET request. +Headers are represented by key-value pairs. _**Data type:** Object_ @@ -45,11 +46,14 @@ _**Data type:** Object_ ##### Get the status of InfluxDB ```js +import "influxdata/influxdb/secrets" import "experimental/http" +token = secrets.get(key: "READONLY_TOKEN") + response = http.get( url: "http://localhost.com:9999/health", - headers: {} + headers: {Authorization: "Token ${token}"} ) status = string(v: response.statusCode) From 5c164bd658bc3aade727a09278908c85d5ef1275 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 10:18:48 -0700 Subject: [PATCH 5/7] updated http.get with format of repsonse --- content/v2.0/reference/flux/stdlib/experimental/http/get.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index 25e5a7c80..689b248d5 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -2,7 +2,7 @@ title: http.get() function description: > The `http.get()` function submits an HTTP GET request to the specified URL with headers - and returns the HTTP status code and body as a byte array. + and returns the HTTP status code as an integer and the response body as a byte array. menu: v2_0_ref: name: http.get @@ -11,7 +11,7 @@ weight: 301 --- The `http.get()` function submits an HTTP GET request to the specified URL with headers -and returns the HTTP status code and body as a byte array. +and returns the HTTP status code as an integer and the response body as a byte array. _**Function type:** Miscellaneous_ @@ -56,6 +56,6 @@ response = http.get( headers: {Authorization: "Token ${token}"} ) -status = string(v: response.statusCode) +status = response.statusCode body = string(v: response.body) ``` From 68156ba0c1eaead45be430b8ad4fedfd7faacb79 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 14:06:51 -0700 Subject: [PATCH 6/7] updated http.get doc --- content/v2.0/reference/flux/stdlib/experimental/http/get.md | 1 - 1 file changed, 1 deletion(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index 689b248d5..60c43651a 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -38,7 +38,6 @@ _**Data type:** String_ ### headers Headers to include with the GET request. -Headers are represented by key-value pairs. _**Data type:** Object_ From 85bb26530daf6f31f9916d8f9476e4eb82d1f663 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 20 Nov 2019 15:05:56 -0700 Subject: [PATCH 7/7] minor update to the http.get function description --- .../v2.0/reference/flux/stdlib/experimental/http/get.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/v2.0/reference/flux/stdlib/experimental/http/get.md b/content/v2.0/reference/flux/stdlib/experimental/http/get.md index 60c43651a..8a3bd0a38 100644 --- a/content/v2.0/reference/flux/stdlib/experimental/http/get.md +++ b/content/v2.0/reference/flux/stdlib/experimental/http/get.md @@ -1,8 +1,8 @@ --- title: http.get() function description: > - The `http.get()` function submits an HTTP GET request to the specified URL with headers - and returns the HTTP status code as an integer and the response body as a byte array. + The `http.get()` function submits an HTTP GET request to the specified URL and + returns the HTTP status code as an integer and the response body as a byte array. menu: v2_0_ref: name: http.get @@ -10,8 +10,8 @@ menu: weight: 301 --- -The `http.get()` function submits an HTTP GET request to the specified URL with headers -and returns the HTTP status code as an integer and the response body as a byte array. +The `http.get()` function submits an HTTP GET request to the specified URL and +returns the HTTP status code as an integer and the response body as a byte array. _**Function type:** Miscellaneous_