diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 6bb1e861..b1954127 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -233,6 +233,10 @@ paths: summary: Retrieve a script description: | Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -249,12 +253,37 @@ paths: application/json: schema: $ref: '#/components/schemas/Script' + examples: + successResponse: + value: + id: 09afa3b220fe4000 + orgID: bea7ea952287f70d + name: getLastPoint + script: 'from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)' + description: getLastPoint finds the last point in a bucket + language: flux + createdAt: '2022-07-17T23:49:45.731237Z' + updatedAt: '2022-07-17T23:49:45.731237Z' '401': $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested script was not found. + value: + code: not found + message: script "09afa3b220fe400" not found '500': $ref: '#/components/responses/InternalServerError' default: - description: Unexpected error. + description: Internal server error. $ref: '#/components/responses/ServerError' patch: operationId: PatchScriptsID @@ -262,11 +291,24 @@ paths: - Invokable Scripts summary: Update a script description: | - Updates a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and returns the script. + Updates an invokable script. + + Use this endpoint to modify values for script properties (`description` and `script`). + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - If you send an empty request body, the script will neither update nor + store an empty script, but InfluxDB will respond with an HTTP `200` status + code. - Use this endpoint to update the properties (`name`, `description`, and `script`) of an invokable script. + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: The script update to apply. + description: | + An object that contains the updated script properties to apply. required: true content: application/json: @@ -288,21 +330,68 @@ paths: application/json: schema: $ref: '#/components/schemas/Script' - '400': - $ref: '#/components/responses/BadRequestError' + examples: + successResponse: + value: + id: 09afa3b220fe4000 + orgID: bea7ea952287f70d + name: getLastPoint + script: 'from(bucket: newBucket) |> range(start: -7d) |> limit(n:1)' + description: get last point from new bucket + language: flux + createdAt: '2022-07-17T23:49:45.731237Z' + updatedAt: '2022-07-19T22:27:23.185436Z' '401': $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested script wasn't found. + value: + code: not found + message: script "09afa3b220fe400" not found '500': $ref: '#/components/responses/InternalServerError' default: - description: Unexpected error + description: Internal server error $ref: '#/components/responses/ServerError' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'PATCH' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" + --header "Content-Type: application/json" + --data '{ + "description": "get last point from new bucket", + "script": "from(bucket: updatedBucket) |> range(start: -7d) |> limit(n:1)", "language": "flux" + }' delete: operationId: DeleteScriptsID tags: - Invokable Scripts summary: Delete a script - description: 'Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records.' + description: | + Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. + + #### Limitations + + - You can delete only one script per request. + - If the script ID you provide doesn't exist for the organization, InfluxDB + responds with an HTTP `204` status code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -314,7 +403,9 @@ paths: Deletes the specified script. responses: '204': - description: Success. The script is deleted. + description: | + Success. + The script is queued for deletion. '401': $ref: '#/components/responses/AuthorizationError' '500': @@ -322,6 +413,14 @@ paths: default: description: Unexpected error $ref: '#/components/responses/ServerError' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'DELETE' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' '/scripts/{scriptID}/invoke': post: operationId: PostScriptsIDInvoke @@ -730,12 +829,11 @@ components: ScriptUpdateRequest: type: object properties: - name: - type: string description: + description: A description of the script. type: string script: - description: script is script to be executed + description: The script to execute. type: string ScriptHTTPResponseData: description: | diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index b855849b..40f5c765 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -4428,11 +4428,10 @@ components: ScriptUpdateRequest: properties: description: - type: string - name: + description: A description of the script. type: string script: - description: script is script to be executed + description: The script to execute. type: string type: object Scripts: @@ -13875,8 +13874,18 @@ paths: }' /api/v2/scripts/{scriptID}: delete: - description: Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) - and all associated records. + description: | + Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. + + #### Limitations + + - You can delete only one script per request. + - If the script ID you provide doesn't exist for the organization, InfluxDB + responds with an HTTP `204` status code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) operationId: DeleteScriptsID parameters: - description: | @@ -13889,7 +13898,9 @@ paths: type: string responses: "204": - description: Success. The script is deleted. + description: | + Success. + The script is queued for deletion. "401": $ref: '#/components/responses/AuthorizationError' "500": @@ -13900,9 +13911,21 @@ paths: summary: Delete a script tags: - Invokable Scripts + x-codeSamples: + - label: cURL + lang: Shell + source: | + curl -X 'DELETE' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' get: description: | Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) operationId: GetScriptsID parameters: - description: | @@ -13917,25 +13940,62 @@ paths: "200": content: application/json: + examples: + successResponse: + value: + createdAt: "2022-07-17T23:49:45.731237Z" + description: getLastPoint finds the last point in a bucket + id: 09afa3b220fe4000 + language: flux + name: getLastPoint + orgID: bea7ea952287f70d + script: 'from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)' + updatedAt: "2022-07-17T23:49:45.731237Z" schema: $ref: '#/components/schemas/Script' description: Success. The response body contains the script. "401": $ref: '#/components/responses/AuthorizationError' + "404": + content: + application/json: + examples: + notFound: + summary: | + The requested script was not found. + value: + code: not found + message: script "09afa3b220fe400" not found + schema: + $ref: '#/components/schemas/Error' + description: | + Not found. "500": $ref: '#/components/responses/InternalServerError' default: $ref: '#/components/responses/ServerError' - description: Unexpected error. + description: Internal server error. summary: Retrieve a script tags: - Data I/O endpoints - Invokable Scripts patch: description: | - Updates a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and returns the script. + Updates an invokable script. + + Use this endpoint to modify values for script properties (`description` and `script`). + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations - Use this endpoint to update the properties (`name`, `description`, and `script`) of an invokable script. + - If you send an empty request body, the script will neither update nor + store an empty script, but InfluxDB will respond with an HTTP `200` status + code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) operationId: PatchScriptsID parameters: - description: | @@ -13951,27 +14011,64 @@ paths: application/json: schema: $ref: '#/components/schemas/ScriptUpdateRequest' - description: The script update to apply. + description: | + An object that contains the updated script properties to apply. required: true responses: "200": content: application/json: + examples: + successResponse: + value: + createdAt: "2022-07-17T23:49:45.731237Z" + description: get last point from new bucket + id: 09afa3b220fe4000 + language: flux + name: getLastPoint + orgID: bea7ea952287f70d + script: 'from(bucket: newBucket) |> range(start: -7d) |> limit(n:1)' + updatedAt: "2022-07-19T22:27:23.185436Z" schema: $ref: '#/components/schemas/Script' description: Success. The response body contains the updated script. - "400": - $ref: '#/components/responses/BadRequestError' "401": $ref: '#/components/responses/AuthorizationError' + "404": + content: + application/json: + examples: + notFound: + summary: | + The requested script wasn't found. + value: + code: not found + message: script "09afa3b220fe400" not found + schema: + $ref: '#/components/schemas/Error' + description: | + Not found. "500": $ref: '#/components/responses/InternalServerError' default: $ref: '#/components/responses/ServerError' - description: Unexpected error + description: Internal server error summary: Update a script tags: - Invokable Scripts + x-codeSamples: + - label: cURL + lang: Shell + source: | + curl -X 'PATCH' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" + --header "Content-Type: application/json" + --data '{ + "description": "get last point from new bucket", + "script": "from(bucket: updatedBucket) |> range(start: -7d) |> limit(n:1)", "language": "flux" + }' /api/v2/scripts/{scriptID}/invoke: post: description: | diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index 9802d14b..84330238 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -233,6 +233,10 @@ paths: summary: Retrieve a script description: | Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -249,12 +253,37 @@ paths: application/json: schema: $ref: '#/components/schemas/Script' + examples: + successResponse: + value: + id: 09afa3b220fe4000 + orgID: bea7ea952287f70d + name: getLastPoint + script: 'from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)' + description: getLastPoint finds the last point in a bucket + language: flux + createdAt: '2022-07-17T23:49:45.731237Z' + updatedAt: '2022-07-17T23:49:45.731237Z' '401': $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested script was not found. + value: + code: not found + message: script "09afa3b220fe400" not found '500': $ref: '#/components/responses/InternalServerError' default: - description: Unexpected error. + description: Internal server error. $ref: '#/components/responses/ServerError' patch: operationId: PatchScriptsID @@ -262,11 +291,24 @@ paths: - Invokable Scripts summary: Update a script description: | - Updates a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and returns the script. + Updates an invokable script. + + Use this endpoint to modify values for script properties (`description` and `script`). + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - If you send an empty request body, the script will neither update nor + store an empty script, but InfluxDB will respond with an HTTP `200` status + code. - Use this endpoint to update the properties (`name`, `description`, and `script`) of an invokable script. + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: The script update to apply. + description: | + An object that contains the updated script properties to apply. required: true content: application/json: @@ -288,21 +330,68 @@ paths: application/json: schema: $ref: '#/components/schemas/Script' - '400': - $ref: '#/components/responses/BadRequestError' + examples: + successResponse: + value: + id: 09afa3b220fe4000 + orgID: bea7ea952287f70d + name: getLastPoint + script: 'from(bucket: newBucket) |> range(start: -7d) |> limit(n:1)' + description: get last point from new bucket + language: flux + createdAt: '2022-07-17T23:49:45.731237Z' + updatedAt: '2022-07-19T22:27:23.185436Z' '401': $ref: '#/components/responses/AuthorizationError' + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + notFound: + summary: | + The requested script wasn't found. + value: + code: not found + message: script "09afa3b220fe400" not found '500': $ref: '#/components/responses/InternalServerError' default: - description: Unexpected error + description: Internal server error $ref: '#/components/responses/ServerError' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'PATCH' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" + --header "Content-Type: application/json" + --data '{ + "description": "get last point from new bucket", + "script": "from(bucket: updatedBucket) |> range(start: -7d) |> limit(n:1)", "language": "flux" + }' delete: operationId: DeleteScriptsID tags: - Invokable Scripts summary: Delete a script - description: 'Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records.' + description: | + Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. + + #### Limitations + + - You can delete only one script per request. + - If the script ID you provide doesn't exist for the organization, InfluxDB + responds with an HTTP `204` status code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -314,7 +403,9 @@ paths: Deletes the specified script. responses: '204': - description: Success. The script is deleted. + description: | + Success. + The script is queued for deletion. '401': $ref: '#/components/responses/AuthorizationError' '500': @@ -322,6 +413,14 @@ paths: default: description: Unexpected error $ref: '#/components/responses/ServerError' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'DELETE' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' '/scripts/{scriptID}/invoke': post: operationId: PostScriptsIDInvoke @@ -730,12 +829,11 @@ components: ScriptUpdateRequest: type: object properties: - name: - type: string description: + description: A description of the script. type: string script: - description: script is script to be executed + description: The script to execute. type: string ScriptHTTPResponseData: description: | diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index f21a28ff..006b2a27 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -6,6 +6,10 @@ get: summary: Retrieve a script description: | Retrieves a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/). + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -22,12 +26,29 @@ get: application/json: schema: $ref: '../schemas/Script.yml' - '401': - $ref: '../../../common/responses/AuthorizationError.yml' - '500': - $ref: '../../../common/responses/InternalServerError.yml' + examples: + $ref: '../schemas/ScriptGetResponse.yml' + "401": + $ref: "../../../common/responses/AuthorizationError.yml" + "500": + $ref: "../../../common/responses/InternalServerError.yml" + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: "../../../common/schemas/Error.yml" + examples: + notFound: + summary: | + The requested script was not found. + value: { + "code":"not found", + "message":"script \"09afa3b220fe400\" not found" + } default: - description: Unexpected error. + description: Internal server error. $ref: '../../../common/responses/ServerError.yml' patch: operationId: PatchScriptsID @@ -35,11 +56,24 @@ patch: - Invokable Scripts summary: Update a script description: | - Updates a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and returns the script. + Updates an invokable script. - Use this endpoint to update the properties (`name`, `description`, and `script`) of an invokable script. + Use this endpoint to modify values for script properties (`description` and `script`). + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - If you send an empty request body, the script will neither update nor + store an empty script, but InfluxDB will respond with an HTTP `200` status + code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: The script update to apply. + description: | + An object that contains the updated script properties to apply. required: true content: application/json: @@ -61,21 +95,60 @@ patch: application/json: schema: $ref: '../schemas/Script.yml' - '400': - $ref: '../../../common/responses/BadRequestError.yml' - '401': - $ref: '../../../common/responses/AuthorizationError.yml' - '500': - $ref: '../../../common/responses/InternalServerError.yml' + examples: + $ref: '../schemas/ScriptUpdateResponse.yml' + "401": + $ref: "../../../common/responses/AuthorizationError.yml" + "500": + $ref: "../../../common/responses/InternalServerError.yml" + '404': + description: | + Not found. + content: + application/json: + schema: + $ref: "../../../common/schemas/Error.yml" + examples: + notFound: + summary: | + The requested script wasn't found. + value: { + "code": "not found", + "message": "script \"09afa3b220fe400\" not found" + } default: - description: Unexpected error + description: Internal server error $ref: '../../../common/responses/ServerError.yml' + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'PATCH' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header "Accept: application/json" + --header "Content-Type: application/json" + --data '{ + "description": "get last point from new bucket", + "script": "from(bucket: updatedBucket) |> range(start: -7d) |> limit(n:1)", "language": "flux" + }' delete: operationId: DeleteScriptsID tags: - Invokable Scripts summary: Delete a script - description: Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. + description: | + Deletes a [script](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) and all associated records. + + #### Limitations + + - You can delete only one script per request. + - If the script ID you provide doesn't exist for the organization, InfluxDB + responds with an HTTP `204` status code. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID @@ -87,12 +160,21 @@ delete: Deletes the specified script. responses: '204': - description: Success. The script is deleted. - '401': - $ref: '../../../common/responses/AuthorizationError.yml' - '500': - $ref: '../../../common/responses/InternalServerError.yml' + description: | + Success. + The script is queued for deletion. + "401": + $ref: "../../../common/responses/AuthorizationError.yml" + "500": + $ref: "../../../common/responses/InternalServerError.yml" default: description: Unexpected error $ref: '../../../common/responses/ServerError.yml' - + x-codeSamples: + - lang: Shell + label: cURL + source: | + curl -X 'DELETE' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' diff --git a/src/svc/invocable-scripts/schemas/ScriptGetResponse.yml b/src/svc/invocable-scripts/schemas/ScriptGetResponse.yml new file mode 100644 index 00000000..38c1b493 --- /dev/null +++ b/src/svc/invocable-scripts/schemas/ScriptGetResponse.yml @@ -0,0 +1,11 @@ + successResponse: + value: { + "id":"09afa3b220fe4000", + "orgID":"bea7ea952287f70d", + "name":"getLastPoint", + "script":"from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)", + "description":"getLastPoint finds the last point in a bucket", + "language":"flux", + "createdAt":"2022-07-17T23:49:45.731237Z", + "updatedAt":"2022-07-17T23:49:45.731237Z" + } diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml index 1f17c823..b6410043 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml @@ -1,9 +1,8 @@ type: object properties: - name: - type: string description: + description: A description of the script. type: string script: - description: script is script to be executed + description: The script to execute. type: string diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml new file mode 100644 index 00000000..d70a5cdb --- /dev/null +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml @@ -0,0 +1,11 @@ + successResponse: + value: { + "id":"09afa3b220fe4000", + "orgID":"bea7ea952287f70d", + "name":"getLastPoint", + "script":"from(bucket: newBucket) |> range(start: -7d) |> limit(n:1)", + "description":"get last point from new bucket", + "language":"flux", + "createdAt":"2022-07-17T23:49:45.731237Z", + "updatedAt":"2022-07-19T22:27:23.185436Z" + }