From 59b5848704a62f82e9c5b26c133115d8c0060487 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 13:27:45 -0700 Subject: [PATCH 01/11] feat: delete and getID --- .../paths/scripts_scriptID.yml | 61 ++++++++++++++++--- .../schemas/ScriptIDResponse.yml | 11 ++++ 2 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 src/svc/invocable-scripts/schemas/ScriptIDResponse.yml diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index dc5d372e6..8f7c83f74 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -4,23 +4,48 @@ get: - Data I/O endpoints - Invokable Scripts summary: Retrieve a script - description: Uses script ID to retrieve details of an invokable script. + description: | + Retrieve a script by its ID. + + #### Related Guides + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only return a script with this ID. responses: '200': - description: The requested script object. + description: | + Success. + The response body contains the requested script object. content: application/json: schema: $ref: '../schemas/Script.yml' + examples: + $ref: "../schemas/ScriptIDResponse.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 @@ -58,17 +83,39 @@ delete: tags: - Invokable Scripts summary: Delete a script - description: Deletes a script and all associated records. + description: | + Deletes a script and all associated records. + + #### Limitations + + - Only one script can be deleted per request. + - `scriptIDs` that do not exist return 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 schema: type: string required: true - description: The ID of the script to delete. + description: | + Script ID. + Only deletes scripts with this ID. responses: '204': - description: The script is deleted. + description: | + No content. + The script is deleted. 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/SCRIPTID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' diff --git a/src/svc/invocable-scripts/schemas/ScriptIDResponse.yml b/src/svc/invocable-scripts/schemas/ScriptIDResponse.yml new file mode 100644 index 000000000..38c1b493d --- /dev/null +++ b/src/svc/invocable-scripts/schemas/ScriptIDResponse.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" + } From 2758b811ec6648636245bd05d6df7eb26ad6ad3b Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 14:57:27 -0700 Subject: [PATCH 02/11] contracts --- contracts/invocable-scripts.yml | 103 ++++++++++++++++-- contracts/ref/cloud.yml | 103 ++++++++++++++++-- contracts/svc/invocable-scripts.yml | 103 ++++++++++++++++-- .../paths/scripts_scriptID.yml | 33 +++++- .../schemas/ScriptUpdateRequest.yml | 4 +- .../schemas/ScriptUpdateResponse.yml | 2 + 6 files changed, 305 insertions(+), 43 deletions(-) create mode 100644 src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 0ba7f04d2..409f90055 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -75,23 +75,57 @@ paths: - Data I/O endpoints - Invokable Scripts summary: Retrieve a script - description: Uses script ID to retrieve details of an invokable script. + description: | + Retrieve an invokable script by its ID. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only return a script with this ID. responses: '200': - description: The requested script object. + description: | + Success. + The response body contains the requested script object. content: 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' + '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 default: - description: Unexpected error + description: Internal server error. $ref: '#/components/responses/ServerError' patch: operationId: PatchScriptsID @@ -99,9 +133,23 @@ paths: - Invokable Scripts summary: Update a script description: | - Updates properties (`name`, `description`, and `script`) of an invokable script. + Updates an invokable script. + + Use this endpoint to update the properties (`name`, `description`, and `script`) + of an invokable script. + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - Sending an empty response body returns a 200 + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: Script update to apply + description: | + An object that contains updated task properties to apply. required: true content: application/json: @@ -113,14 +161,21 @@ paths: schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only returns scripts with this ID. responses: '200': - description: The updated script. + description: | + Success. + The response body contains the updated script. content: application/json: schema: $ref: '#/components/schemas/Script' + examples: + successResponse: + value: null default: description: Unexpected error $ref: '#/components/responses/ServerError' @@ -129,20 +184,42 @@ paths: tags: - Invokable Scripts summary: Delete a script - description: Deletes a script and all associated records. + description: | + Deletes an invokable script and all associated records. + + #### Limitations + + - Only one script can be deleted per request. + - `scriptIDs` that do not exist return 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 schema: type: string required: true - description: The ID of the script to delete. + description: | + Script ID. + Only deletes scripts with this ID. responses: '204': - description: The script is deleted. + description: | + No content. + The script is deleted. 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/SCRIPTID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' '/scripts/{scriptID}/invoke': post: operationId: PostScriptsIDInvoke @@ -275,11 +352,13 @@ components: type: object properties: name: + description: Script name. The name must be unique within the organization. type: string description: + description: Script 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: The data sent in the response body when a script is invoked by an HTTP request. User defined and dynamic. diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index af3ebf6a3..d0e851cac 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -4074,11 +4074,13 @@ components: ScriptUpdateRequest: properties: description: + description: Script description. A description of the script. type: string name: + description: Script name. The name must be unique within the organization. type: string script: - description: script is script to be executed + description: The script to execute. type: string type: object Scripts: @@ -10707,10 +10709,22 @@ paths: - Invokable Scripts /api/v2/scripts/{scriptID}: delete: - description: Deletes a script and all associated records. + description: | + Deletes an invokable script and all associated records. + + #### Limitations + + - Only one script can be deleted per request. + - `scriptIDs` that do not exist return 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: The ID of the script to delete. + - description: | + Script ID. + Only deletes scripts with this ID. in: path name: scriptID required: true @@ -10718,18 +10732,35 @@ paths: type: string responses: "204": - description: The script is deleted. + description: | + No content. + The script is deleted. default: $ref: '#/components/responses/ServerError' description: Unexpected error summary: Delete a script tags: - Invokable Scripts + x-codeSamples: + - label: cURL + lang: Shell + source: | + curl -X 'DELETE' \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPTID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' get: - description: Uses script ID to retrieve details of an invokable script. + description: | + Retrieve an invokable script by its ID. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) operationId: GetScriptsID parameters: - - description: The script ID. + - description: | + Script ID. + Only return a script with this ID. in: path name: scriptID required: true @@ -10739,22 +10770,64 @@ 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: The requested script object. + description: | + Success. + The response body contains the requested script object. + "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. 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 properties (`name`, `description`, and `script`) of an invokable script. + Updates an invokable script. + + Use this endpoint to update the properties (`name`, `description`, and `script`) + of an invokable script. + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - Sending an empty response body returns a 200 + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) operationId: PatchScriptsID parameters: - - description: The script ID. + - description: | + Script ID. + Only returns scripts with this ID. in: path name: scriptID required: true @@ -10765,15 +10838,21 @@ paths: application/json: schema: $ref: '#/components/schemas/ScriptUpdateRequest' - description: Script update to apply + description: | + An object that contains updated task properties to apply. required: true responses: "200": content: application/json: + examples: + successResponse: + value: null schema: $ref: '#/components/schemas/Script' - description: The updated script. + description: | + Success. + The response body contains the updated script. default: $ref: '#/components/responses/ServerError' description: Unexpected error diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index 280fb50d7..4fb3db7ca 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -75,23 +75,57 @@ paths: - Data I/O endpoints - Invokable Scripts summary: Retrieve a script - description: Uses script ID to retrieve details of an invokable script. + description: | + Retrieve an invokable script by its ID. + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path name: scriptID schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only return a script with this ID. responses: '200': - description: The requested script object. + description: | + Success. + The response body contains the requested script object. content: 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' + '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 default: - description: Unexpected error + description: Internal server error. $ref: '#/components/responses/ServerError' patch: operationId: PatchScriptsID @@ -99,9 +133,23 @@ paths: - Invokable Scripts summary: Update a script description: | - Updates properties (`name`, `description`, and `script`) of an invokable script. + Updates an invokable script. + + Use this endpoint to update the properties (`name`, `description`, and `script`) + of an invokable script. + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - Sending an empty response body returns a 200 + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: Script update to apply + description: | + An object that contains updated task properties to apply. required: true content: application/json: @@ -113,14 +161,21 @@ paths: schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only returns scripts with this ID. responses: '200': - description: The updated script. + description: | + Success. + The response body contains the updated script. content: application/json: schema: $ref: '#/components/schemas/Script' + examples: + successResponse: + value: null default: description: Unexpected error $ref: '#/components/responses/ServerError' @@ -129,20 +184,42 @@ paths: tags: - Invokable Scripts summary: Delete a script - description: Deletes a script and all associated records. + description: | + Deletes an invokable script and all associated records. + + #### Limitations + + - Only one script can be deleted per request. + - `scriptIDs` that do not exist return 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 schema: type: string required: true - description: The ID of the script to delete. + description: | + Script ID. + Only deletes scripts with this ID. responses: '204': - description: The script is deleted. + description: | + No content. + The script is deleted. 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/SCRIPTID" \ + --header "Authorization: Token INFLUX_TOKEN" \ + --header 'Accept: application/json' '/scripts/{scriptID}/invoke': post: operationId: PostScriptsIDInvoke @@ -275,11 +352,13 @@ components: type: object properties: name: + description: Script name. The name must be unique within the organization. type: string description: + description: Script 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: The data sent in the response body when a script is invoked by an HTTP request. User defined and dynamic. diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 8f7c83f74..f97835dd2 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -5,9 +5,10 @@ get: - Invokable Scripts summary: Retrieve a script description: | - Retrieve a script by its ID. + Retrieve an invokable script by its ID. #### Related Guides + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) parameters: - in: path @@ -53,9 +54,23 @@ patch: - Invokable Scripts summary: Update a script description: | - Updates properties (`name`, `description`, and `script`) of an invokable script. + Updates an invokable script. + + Use this endpoint to update the properties (`name`, `description`, and `script`) + of an invokable script. + + To update a script, pass an object that contains the updated key-value pairs. + + #### Limitations + + - Sending an empty response body returns a 200 + + #### Related Guides + + - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: - description: Script update to apply + description: | + An object that contains updated task properties to apply. required: true content: application/json: @@ -67,14 +82,20 @@ patch: schema: type: string required: true - description: The script ID. + description: | + Script ID. + Only returns scripts with this ID. responses: '200': - description: The updated script. + description: | + Success. + The response body contains the updated script. content: application/json: schema: $ref: '../schemas/Script.yml' + examples: + $ref: "../schemas/ScriptUpdateResponse.yml" default: description: Unexpected error $ref: '../../../common/responses/ServerError.yml' @@ -84,7 +105,7 @@ delete: - Invokable Scripts summary: Delete a script description: | - Deletes a script and all associated records. + Deletes an invokable script and all associated records. #### Limitations diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml index 1f17c8233..3955e5de2 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml @@ -1,9 +1,11 @@ type: object properties: name: + description: Script name. The name must be unique within the organization. type: string description: + description: Script 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 000000000..68ee7d06e --- /dev/null +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml @@ -0,0 +1,2 @@ + successResponse: + value: \ No newline at end of file From ac8a608f2407dba16903ec4b26a6588f42edb9b1 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 15:46:33 -0700 Subject: [PATCH 03/11] feat: patch --- contracts/invocable-scripts.yml | 76 ++++++++++++++++--- contracts/ref/cloud.yml | 76 ++++++++++++++++--- contracts/svc/invocable-scripts.yml | 76 ++++++++++++++++--- .../paths/scripts_scriptID.yml | 42 ++++++++-- .../schemas/ScriptResponse.yml | 23 ++++++ .../schemas/ScriptUpdateRequest.yml | 3 - .../schemas/ScriptUpdateResponse.yml | 11 ++- 7 files changed, 263 insertions(+), 44 deletions(-) create mode 100644 src/svc/invocable-scripts/schemas/ScriptResponse.yml diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 409f90055..17d9ff21d 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -98,7 +98,29 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Script' + properties: + id: + readOnly: true + type: string + name: + type: string + description: + type: string + orgID: + type: string + script: + description: script to be executed + type: string + language: + $ref: '#/components/schemas/ScriptLanguage' + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true examples: successResponse: value: @@ -135,21 +157,21 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`name`, `description`, and `script`) + Use this endpoint to update the properties (`description`, and `script`) of an invokable script. To update a script, pass an object that contains the updated key-value pairs. #### Limitations - - Sending an empty response body returns a 200 + - Sending an empty request body returns an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains updated task properties to apply. + An object that contains the updated task properties to apply. required: true content: application/json: @@ -172,13 +194,48 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Script' + $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' examples: successResponse: - value: null + 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' + '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 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: @@ -217,7 +274,7 @@ paths: label: cURL source: | curl -X 'DELETE' \ - "https://cloud2.influxdata.com/api/v2/scripts/SCRIPTID" \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ --header "Authorization: Token INFLUX_TOKEN" \ --header 'Accept: application/json' '/scripts/{scriptID}/invoke': @@ -351,9 +408,6 @@ components: ScriptUpdateRequest: type: object properties: - name: - description: Script name. The name must be unique within the organization. - type: string description: description: Script description. A description of the script. type: string diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index d0e851cac..ce7ea9557 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -4076,9 +4076,6 @@ components: description: description: Script description. A description of the script. type: string - name: - description: Script name. The name must be unique within the organization. - type: string script: description: The script to execute. type: string @@ -10746,7 +10743,7 @@ paths: lang: Shell source: | curl -X 'DELETE' \ - "https://cloud2.influxdata.com/api/v2/scripts/SCRIPTID" \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ --header "Authorization: Token INFLUX_TOKEN" \ --header 'Accept: application/json' get: @@ -10782,7 +10779,29 @@ paths: script: 'from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)' updatedAt: "2022-07-17T23:49:45.731237Z" schema: - $ref: '#/components/schemas/Script' + properties: + createdAt: + format: date-time + readOnly: true + type: string + description: + type: string + id: + readOnly: true + type: string + language: + $ref: '#/components/schemas/ScriptLanguage' + name: + type: string + orgID: + type: string + script: + description: script to be executed + type: string + updatedAt: + format: date-time + readOnly: true + type: string description: | Success. The response body contains the requested script object. @@ -10811,14 +10830,14 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`name`, `description`, and `script`) + Use this endpoint to update the properties (`description`, and `script`) of an invokable script. To update a script, pass an object that contains the updated key-value pairs. #### Limitations - - Sending an empty response body returns a 200 + - Sending an empty request body returns an HTTP `200` status code. #### Related Guides @@ -10839,7 +10858,7 @@ paths: schema: $ref: '#/components/schemas/ScriptUpdateRequest' description: | - An object that contains updated task properties to apply. + An object that contains the updated task properties to apply. required: true responses: "200": @@ -10847,18 +10866,53 @@ paths: application/json: examples: successResponse: - value: null + 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' + $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' description: | Success. The response body contains the updated script. + "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. 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: Invokes a script and substitutes `params` keys referenced in the diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index 4fb3db7ca..49d1cec71 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -98,7 +98,29 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Script' + properties: + id: + readOnly: true + type: string + name: + type: string + description: + type: string + orgID: + type: string + script: + description: script to be executed + type: string + language: + $ref: '#/components/schemas/ScriptLanguage' + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true examples: successResponse: value: @@ -135,21 +157,21 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`name`, `description`, and `script`) + Use this endpoint to update the properties (`description`, and `script`) of an invokable script. To update a script, pass an object that contains the updated key-value pairs. #### Limitations - - Sending an empty response body returns a 200 + - Sending an empty request body returns an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains updated task properties to apply. + An object that contains the updated task properties to apply. required: true content: application/json: @@ -172,13 +194,48 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/Script' + $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' examples: successResponse: - value: null + 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' + '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 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: @@ -217,7 +274,7 @@ paths: label: cURL source: | curl -X 'DELETE' \ - "https://cloud2.influxdata.com/api/v2/scripts/SCRIPTID" \ + "https://cloud2.influxdata.com/api/v2/scripts/SCRIPT_ID" \ --header "Authorization: Token INFLUX_TOKEN" \ --header 'Accept: application/json' '/scripts/{scriptID}/invoke': @@ -351,9 +408,6 @@ components: ScriptUpdateRequest: type: object properties: - name: - description: Script name. The name must be unique within the organization. - type: string description: description: Script description. A description of the script. type: string diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index f97835dd2..a4e0172be 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -27,7 +27,7 @@ get: content: application/json: schema: - $ref: '../schemas/Script.yml' + $ref: '../schemas/ScriptResponse.yml' examples: $ref: "../schemas/ScriptIDResponse.yml" '404': @@ -56,21 +56,21 @@ patch: description: | Updates an invokable script. - Use this endpoint to update the properties (`name`, `description`, and `script`) + Use this endpoint to update the properties (`description`, and `script`) of an invokable script. To update a script, pass an object that contains the updated key-value pairs. #### Limitations - - Sending an empty response body returns a 200 + - Sending an empty request body returns an HTTP `200` status code. #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains updated task properties to apply. + An object that contains the updated task properties to apply. required: true content: application/json: @@ -93,12 +93,40 @@ patch: content: application/json: schema: - $ref: '../schemas/Script.yml' + $ref: '../schemas/ScriptResponse.yml' examples: $ref: "../schemas/ScriptUpdateResponse.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' + 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: @@ -137,6 +165,6 @@ delete: label: cURL source: | curl -X 'DELETE' \ - "https://cloud2.influxdata.com/api/v2/scripts/SCRIPTID" \ + "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/ScriptResponse.yml b/src/svc/invocable-scripts/schemas/ScriptResponse.yml new file mode 100644 index 000000000..1980cc507 --- /dev/null +++ b/src/svc/invocable-scripts/schemas/ScriptResponse.yml @@ -0,0 +1,23 @@ +properties: + id: + readOnly: true + type: string + name: + type: string + description: + type: string + orgID: + type: string + script: + description: script to be executed + type: string + language: + $ref: './ScriptLanguage.yml' + createdAt: + type: string + format: date-time + readOnly: true + updatedAt: + type: string + format: date-time + readOnly: true \ No newline at end of file diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml index 3955e5de2..af01e0ef9 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml @@ -1,8 +1,5 @@ type: object properties: - name: - description: Script name. The name must be unique within the organization. - type: string description: description: Script description. A description of the script. type: string diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml index 68ee7d06e..c57936eca 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml @@ -1,2 +1,11 @@ successResponse: - value: \ No newline at end of file + 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" + } From e81705b5d553bc1c3756fbe758c06edc666615cd Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 15:48:07 -0700 Subject: [PATCH 04/11] linting --- src/svc/invocable-scripts/paths/scripts_scriptID.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index a4e0172be..880e5957c 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -58,13 +58,13 @@ patch: Use this endpoint to update the properties (`description`, and `script`) of an invokable script. - + To update a script, pass an object that contains the updated key-value pairs. - + #### Limitations - + - Sending an empty request body returns an HTTP `200` status code. - + #### Related Guides - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) From 1b35d845e2a34710d10d94f36adc025111fe3d04 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 15:50:25 -0700 Subject: [PATCH 05/11] lint --- src/svc/invocable-scripts/schemas/ScriptResponse.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svc/invocable-scripts/schemas/ScriptResponse.yml b/src/svc/invocable-scripts/schemas/ScriptResponse.yml index 1980cc507..d93dc4713 100644 --- a/src/svc/invocable-scripts/schemas/ScriptResponse.yml +++ b/src/svc/invocable-scripts/schemas/ScriptResponse.yml @@ -20,4 +20,4 @@ properties: updatedAt: type: string format: date-time - readOnly: true \ No newline at end of file + readOnly: true From 6689332b7ac8daa326bff1a2099a3f76316e6e89 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 19 Jul 2022 16:37:00 -0700 Subject: [PATCH 06/11] feat: finished draft --- contracts/invocable-scripts.yml | 26 ++----------------- contracts/ref/cloud.yml | 26 ++----------------- contracts/svc/invocable-scripts.yml | 26 ++----------------- .../paths/scripts_scriptID.yml | 8 +++--- ...ptIDResponse.yml => ScriptGetResponse.yml} | 0 .../schemas/ScriptResponse.yml | 23 ---------------- .../schemas/ScriptUpdateResponse.yml | 2 +- 7 files changed, 11 insertions(+), 100 deletions(-) rename src/svc/invocable-scripts/schemas/{ScriptIDResponse.yml => ScriptGetResponse.yml} (100%) delete mode 100644 src/svc/invocable-scripts/schemas/ScriptResponse.yml diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 17d9ff21d..867b588b6 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -98,29 +98,7 @@ paths: content: application/json: schema: - properties: - id: - readOnly: true - type: string - name: - type: string - description: - type: string - orgID: - type: string - script: - description: script to be executed - type: string - language: - $ref: '#/components/schemas/ScriptLanguage' - createdAt: - type: string - format: date-time - readOnly: true - updatedAt: - type: string - format: date-time - readOnly: true + $ref: '#/components/schemas/Script' examples: successResponse: value: @@ -194,7 +172,7 @@ paths: content: application/json: schema: - $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' + $ref: '#/components/schemas/Script' examples: successResponse: value: diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index ce7ea9557..7591f6c6a 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -10779,29 +10779,7 @@ paths: script: 'from(bucket: my-bucket) |> range(start: -7d) |> limit(n:1)' updatedAt: "2022-07-17T23:49:45.731237Z" schema: - properties: - createdAt: - format: date-time - readOnly: true - type: string - description: - type: string - id: - readOnly: true - type: string - language: - $ref: '#/components/schemas/ScriptLanguage' - name: - type: string - orgID: - type: string - script: - description: script to be executed - type: string - updatedAt: - format: date-time - readOnly: true - type: string + $ref: '#/components/schemas/Script' description: | Success. The response body contains the requested script object. @@ -10876,7 +10854,7 @@ paths: script: 'from(bucket: newBucket) |> range(start: -7d) |> limit(n:1)' updatedAt: "2022-07-19T22:27:23.185436Z" schema: - $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' + $ref: '#/components/schemas/Script' description: | Success. The response body contains the updated script. diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index 49d1cec71..a8ab7ffbc 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -98,29 +98,7 @@ paths: content: application/json: schema: - properties: - id: - readOnly: true - type: string - name: - type: string - description: - type: string - orgID: - type: string - script: - description: script to be executed - type: string - language: - $ref: '#/components/schemas/ScriptLanguage' - createdAt: - type: string - format: date-time - readOnly: true - updatedAt: - type: string - format: date-time - readOnly: true + $ref: '#/components/schemas/Script' examples: successResponse: value: @@ -194,7 +172,7 @@ paths: content: application/json: schema: - $ref: '#/paths/~1scripts~1%7BscriptID%7D/get/responses/200/content/application~1json/schema' + $ref: '#/components/schemas/Script' examples: successResponse: value: diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 880e5957c..72eab54c4 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -27,9 +27,9 @@ get: content: application/json: schema: - $ref: '../schemas/ScriptResponse.yml' + $ref: '../schemas/Script.yml' examples: - $ref: "../schemas/ScriptIDResponse.yml" + $ref: '../schemas/ScriptGetResponse.yml' '404': description: | Not found. @@ -93,9 +93,9 @@ patch: content: application/json: schema: - $ref: '../schemas/ScriptResponse.yml' + $ref: '../schemas/Script.yml' examples: - $ref: "../schemas/ScriptUpdateResponse.yml" + $ref: '../schemas/ScriptUpdateResponse.yml' '404': description: | Not found. diff --git a/src/svc/invocable-scripts/schemas/ScriptIDResponse.yml b/src/svc/invocable-scripts/schemas/ScriptGetResponse.yml similarity index 100% rename from src/svc/invocable-scripts/schemas/ScriptIDResponse.yml rename to src/svc/invocable-scripts/schemas/ScriptGetResponse.yml diff --git a/src/svc/invocable-scripts/schemas/ScriptResponse.yml b/src/svc/invocable-scripts/schemas/ScriptResponse.yml deleted file mode 100644 index d93dc4713..000000000 --- a/src/svc/invocable-scripts/schemas/ScriptResponse.yml +++ /dev/null @@ -1,23 +0,0 @@ -properties: - id: - readOnly: true - type: string - name: - type: string - description: - type: string - orgID: - type: string - script: - description: script to be executed - type: string - language: - $ref: './ScriptLanguage.yml' - createdAt: - type: string - format: date-time - readOnly: true - updatedAt: - type: string - format: date-time - readOnly: true diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml index c57936eca..d70a5cdbe 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateResponse.yml @@ -8,4 +8,4 @@ "language":"flux", "createdAt":"2022-07-17T23:49:45.731237Z", "updatedAt":"2022-07-19T22:27:23.185436Z" - } + } From a9b13b012639f54f839cdeeed2e443187df190fa Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Tue, 26 Jul 2022 14:44:19 -0700 Subject: [PATCH 07/11] fix: pr requested changes --- contracts/invocable-scripts.yml | 12 ++++++------ contracts/ref/cloud.yml | 12 ++++++------ contracts/svc/invocable-scripts.yml | 12 ++++++------ src/svc/invocable-scripts/paths/scripts_scriptID.yml | 10 +++++----- .../schemas/ScriptUpdateRequest.yml | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 867b588b6..89bc31be7 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -76,7 +76,7 @@ paths: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script by its ID. + Retrieve an invokable script. #### Related Guides @@ -89,7 +89,7 @@ paths: required: true description: | Script ID. - Only return a script with this ID. + Only returns the script with this ID. responses: '200': description: | @@ -149,7 +149,7 @@ paths: - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains the updated task properties to apply. + An object that contains the updated script properties to apply. required: true content: application/json: @@ -163,7 +163,7 @@ paths: required: true description: | Script ID. - Only returns scripts with this ID. + The ID of the script to update. responses: '200': description: | @@ -238,7 +238,7 @@ paths: required: true description: | Script ID. - Only deletes scripts with this ID. + The ID of the script to delete. responses: '204': description: | @@ -387,7 +387,7 @@ components: type: object properties: description: - description: Script description. A description of the script. + description: A description of the script. type: string script: description: The script to execute. diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index 7591f6c6a..787f14947 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -4074,7 +4074,7 @@ components: ScriptUpdateRequest: properties: description: - description: Script description. A description of the script. + description: A description of the script. type: string script: description: The script to execute. @@ -10721,7 +10721,7 @@ paths: parameters: - description: | Script ID. - Only deletes scripts with this ID. + The ID of the script to delete. in: path name: scriptID required: true @@ -10748,7 +10748,7 @@ paths: --header 'Accept: application/json' get: description: | - Retrieve an invokable script by its ID. + Retrieve an invokable script. #### Related Guides @@ -10757,7 +10757,7 @@ paths: parameters: - description: | Script ID. - Only return a script with this ID. + Only returns the script with this ID. in: path name: scriptID required: true @@ -10824,7 +10824,7 @@ paths: parameters: - description: | Script ID. - Only returns scripts with this ID. + The ID of the script to update. in: path name: scriptID required: true @@ -10836,7 +10836,7 @@ paths: schema: $ref: '#/components/schemas/ScriptUpdateRequest' description: | - An object that contains the updated task properties to apply. + An object that contains the updated script properties to apply. required: true responses: "200": diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index a8ab7ffbc..1046ccdaa 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -76,7 +76,7 @@ paths: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script by its ID. + Retrieve an invokable script. #### Related Guides @@ -89,7 +89,7 @@ paths: required: true description: | Script ID. - Only return a script with this ID. + Only returns the script with this ID. responses: '200': description: | @@ -149,7 +149,7 @@ paths: - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains the updated task properties to apply. + An object that contains the updated script properties to apply. required: true content: application/json: @@ -163,7 +163,7 @@ paths: required: true description: | Script ID. - Only returns scripts with this ID. + The ID of the script to update. responses: '200': description: | @@ -238,7 +238,7 @@ paths: required: true description: | Script ID. - Only deletes scripts with this ID. + The ID of the script to delete. responses: '204': description: | @@ -387,7 +387,7 @@ components: type: object properties: description: - description: Script description. A description of the script. + description: A description of the script. type: string script: description: The script to execute. diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 72eab54c4..7fedff4e4 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -5,7 +5,7 @@ get: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script by its ID. + Retrieve an invokable script. #### Related Guides @@ -18,7 +18,7 @@ get: required: true description: | Script ID. - Only return a script with this ID. + Only returns the script with this ID. responses: '200': description: | @@ -70,7 +70,7 @@ patch: - [Invoke custom scripts](https://docs.influxdata.com/influxdb/cloud/api-guide/api-invokable-scripts/) requestBody: description: | - An object that contains the updated task properties to apply. + An object that contains the updated script properties to apply. required: true content: application/json: @@ -84,7 +84,7 @@ patch: required: true description: | Script ID. - Only returns scripts with this ID. + The ID of the script to update. responses: '200': description: | @@ -151,7 +151,7 @@ delete: required: true description: | Script ID. - Only deletes scripts with this ID. + The ID of the script to delete. responses: '204': description: | diff --git a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml index af01e0ef9..b6410043e 100644 --- a/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml +++ b/src/svc/invocable-scripts/schemas/ScriptUpdateRequest.yml @@ -1,7 +1,7 @@ type: object properties: description: - description: Script description. A description of the script. + description: A description of the script. type: string script: description: The script to execute. From 94fc60eebb0228f20fe162e8d08da1774d984d31 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Sun, 7 Aug 2022 14:07:49 -0700 Subject: [PATCH 08/11] fix: requested PR changes --- contracts/invocable-scripts.yml | 45 +++++++++++++++++-- contracts/ref/cloud.yml | 20 +++++++-- contracts/svc/invocable-scripts.yml | 45 +++++++++++++++++-- src/svc-invocable-scripts.yml | 4 ++ .../paths/scripts_scriptID.yml | 20 +++++++-- 5 files changed, 118 insertions(+), 16 deletions(-) diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 89bc31be7..cc22a458a 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -76,7 +76,7 @@ paths: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script. + Retrieves an invokable script. #### Related Guides @@ -94,7 +94,7 @@ paths: '200': description: | Success. - The response body contains the requested script object. + The response body contains the script object. content: application/json: schema: @@ -110,6 +110,8 @@ paths: 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. @@ -124,6 +126,8 @@ paths: value: code: not found message: script "09afa3b220fe400" not found + '500': + $ref: '#/components/responses/InternalServerError' default: description: Internal server error. $ref: '#/components/responses/ServerError' @@ -184,6 +188,8 @@ paths: 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. @@ -198,6 +204,8 @@ paths: value: code: not found message: script "09afa3b220fe400" not found + '500': + $ref: '#/components/responses/InternalServerError' default: description: Internal server error $ref: '#/components/responses/ServerError' @@ -242,8 +250,12 @@ paths: responses: '204': description: | - No content. - The script is deleted. + Success. + The script is queued for deletion. + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' default: description: Unexpected error $ref: '#/components/responses/ServerError' @@ -292,6 +304,31 @@ components: application/json: schema: $ref: '#/components/schemas/Error' + AuthorizationError: + description: | + Unauthorized. The error may indicate one of the following: + + * The `Authorization: Token` header is missing or malformed. + * The API token value is missing from the header. + * The token does not have sufficient permissions to write to this organization and bucket. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + tokenNotAuthorized: + summary: Token is not authorized to access a resource + value: + code: unauthorized + message: unauthorized access + InternalServerError: + description: | + Internal server error. + The server encountered an unexpected situation. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' schemas: Error: properties: diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index 787f14947..379b3626e 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -10730,8 +10730,12 @@ paths: responses: "204": description: | - No content. - The script is deleted. + Success. + The script is queued for deletion. + "401": + $ref: '#/components/responses/AuthorizationError' + "500": + $ref: '#/components/responses/InternalServerError' default: $ref: '#/components/responses/ServerError' description: Unexpected error @@ -10748,7 +10752,7 @@ paths: --header 'Accept: application/json' get: description: | - Retrieve an invokable script. + Retrieves an invokable script. #### Related Guides @@ -10782,7 +10786,9 @@ paths: $ref: '#/components/schemas/Script' description: | Success. - The response body contains the requested script object. + The response body contains the script object. + "401": + $ref: '#/components/responses/AuthorizationError' "404": content: application/json: @@ -10797,6 +10803,8 @@ paths: $ref: '#/components/schemas/Error' description: | Not found. + "500": + $ref: '#/components/responses/InternalServerError' default: $ref: '#/components/responses/ServerError' description: Internal server error. @@ -10858,6 +10866,8 @@ paths: description: | Success. The response body contains the updated script. + "401": + $ref: '#/components/responses/AuthorizationError' "404": content: application/json: @@ -10872,6 +10882,8 @@ paths: $ref: '#/components/schemas/Error' description: | Not found. + "500": + $ref: '#/components/responses/InternalServerError' default: $ref: '#/components/responses/ServerError' description: Internal server error diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index 1046ccdaa..b1fee6b31 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -76,7 +76,7 @@ paths: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script. + Retrieves an invokable script. #### Related Guides @@ -94,7 +94,7 @@ paths: '200': description: | Success. - The response body contains the requested script object. + The response body contains the script object. content: application/json: schema: @@ -110,6 +110,8 @@ paths: 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. @@ -124,6 +126,8 @@ paths: value: code: not found message: script "09afa3b220fe400" not found + '500': + $ref: '#/components/responses/InternalServerError' default: description: Internal server error. $ref: '#/components/responses/ServerError' @@ -184,6 +188,8 @@ paths: 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. @@ -198,6 +204,8 @@ paths: value: code: not found message: script "09afa3b220fe400" not found + '500': + $ref: '#/components/responses/InternalServerError' default: description: Internal server error $ref: '#/components/responses/ServerError' @@ -242,8 +250,12 @@ paths: responses: '204': description: | - No content. - The script is deleted. + Success. + The script is queued for deletion. + '401': + $ref: '#/components/responses/AuthorizationError' + '500': + $ref: '#/components/responses/InternalServerError' default: description: Unexpected error $ref: '#/components/responses/ServerError' @@ -292,6 +304,31 @@ components: application/json: schema: $ref: '#/components/schemas/Error' + AuthorizationError: + description: | + Unauthorized. The error may indicate one of the following: + + * The `Authorization: Token` header is missing or malformed. + * The API token value is missing from the header. + * The token does not have sufficient permissions to write to this organization and bucket. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + tokenNotAuthorized: + summary: Token is not authorized to access a resource + value: + code: unauthorized + message: unauthorized access + InternalServerError: + description: | + Internal server error. + The server encountered an unexpected situation. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' schemas: Error: properties: diff --git a/src/svc-invocable-scripts.yml b/src/svc-invocable-scripts.yml index 53ae90fff..a6333a2ca 100644 --- a/src/svc-invocable-scripts.yml +++ b/src/svc-invocable-scripts.yml @@ -26,6 +26,10 @@ components: responses: ServerError: $ref: './common/responses/ServerError.yml' + AuthorizationError: + $ref: './common/responses/AuthorizationError.yml' + InternalServerError: + $ref: './common/responses/InternalServerError.yml' schemas: Error: $ref: './common/schemas/Error.yml' diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 7fedff4e4..5770746cd 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -5,7 +5,7 @@ get: - Invokable Scripts summary: Retrieve a script description: | - Retrieve an invokable script. + Retrieves an invokable script. #### Related Guides @@ -23,13 +23,17 @@ get: '200': description: | Success. - The response body contains the requested script object. + The response body contains the script object. content: application/json: schema: $ref: '../schemas/Script.yml' examples: $ref: '../schemas/ScriptGetResponse.yml' + "401": + $ref: "../../../common/responses/AuthorizationError.yml" + "500": + $ref: "../../../common/responses/InternalServerError.yml" '404': description: | Not found. @@ -96,6 +100,10 @@ patch: $ref: '../schemas/Script.yml' examples: $ref: '../schemas/ScriptUpdateResponse.yml' + "401": + $ref: "../../../common/responses/AuthorizationError.yml" + "500": + $ref: "../../../common/responses/InternalServerError.yml" '404': description: | Not found. @@ -155,8 +163,12 @@ delete: responses: '204': description: | - No content. - The script is deleted. + 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' From 310fa2843c8dacd112e29d404fbd3e61d451eece Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Wed, 17 Aug 2022 17:35:56 -0700 Subject: [PATCH 09/11] fix: pr requested changes --- contracts/invocable-scripts.yml | 13 +++++++------ contracts/ref/cloud.yml | 13 +++++++------ contracts/svc/invocable-scripts.yml | 13 +++++++------ .../invocable-scripts/paths/scripts_scriptID.yml | 13 +++++++------ 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index d098cbee7..858e9b974 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -300,14 +300,14 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`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 - - Sending an empty request body returns an HTTP `200` status code. + - If you send an empty request body, InfluxDB responds with an HTTP `200` + status code. #### Related Guides @@ -361,7 +361,7 @@ paths: examples: notFound: summary: | - The requested script was not found. + The requested script wasn't found. value: code: not found message: script "09afa3b220fe400" not found @@ -393,8 +393,9 @@ paths: #### Limitations - - Only one script can be deleted per request. - - `scriptIDs` that do not exist return an HTTP `204` status code. + - You can delete only one script per request. + - If the script ID you provide doesnt exist for the organization, InfluxDB + responds with an HTTP `204` status code. #### Related Guides diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index faa9ee5b1..56113adbc 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -12195,8 +12195,9 @@ paths: #### Limitations - - Only one script can be deleted per request. - - `scriptIDs` that do not exist return an HTTP `204` status code. + - You can delete only one script per request. + - If the script ID you provide doesnt exist for the organization, InfluxDB + responds with an HTTP `204` status code. #### Related Guides @@ -12300,14 +12301,14 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`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 - - Sending an empty request body returns an HTTP `200` status code. + - If you send an empty request body, InfluxDB responds with an HTTP `200` + status code. #### Related Guides @@ -12358,7 +12359,7 @@ paths: examples: notFound: summary: | - The requested script was not found. + The requested script wasn't found. value: code: not found message: script "09afa3b220fe400" not found diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index d68a9f5b1..b54e0dd94 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -300,14 +300,14 @@ paths: description: | Updates an invokable script. - Use this endpoint to update the properties (`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 - - Sending an empty request body returns an HTTP `200` status code. + - If you send an empty request body, InfluxDB responds with an HTTP `200` + status code. #### Related Guides @@ -361,7 +361,7 @@ paths: examples: notFound: summary: | - The requested script was not found. + The requested script wasn't found. value: code: not found message: script "09afa3b220fe400" not found @@ -393,8 +393,9 @@ paths: #### Limitations - - Only one script can be deleted per request. - - `scriptIDs` that do not exist return an HTTP `204` status code. + - You can delete only one script per request. + - If the script ID you provide doesnt exist for the organization, InfluxDB + responds with an HTTP `204` status code. #### Related Guides diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 5770746cd..4f14d5deb 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -60,14 +60,14 @@ patch: description: | Updates an invokable script. - Use this endpoint to update the properties (`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 - - Sending an empty request body returns an HTTP `200` status code. + - If you send an empty request body, InfluxDB responds with an HTTP `200` + status code. #### Related Guides @@ -114,7 +114,7 @@ patch: examples: notFound: summary: | - The requested script was not found. + The requested script wasn't found. value: { "code": "not found", "message": "script \"09afa3b220fe400\" not found" @@ -145,8 +145,9 @@ delete: #### Limitations - - Only one script can be deleted per request. - - `scriptIDs` that do not exist return an HTTP `204` status code. + - You can delete only one script per request. + - If the script ID you provide doesnt exist for the organization, InfluxDB + responds with an HTTP `204` status code. #### Related Guides From 959bda4d3721a06ae20fce4aa02210520469af8e Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Mon, 22 Aug 2022 14:49:31 -0700 Subject: [PATCH 10/11] fix: requested PR changes --- contracts/invocable-scripts.yml | 6 ++---- contracts/ref/cloud.yml | 6 ++---- contracts/svc/invocable-scripts.yml | 6 ++---- src/svc/invocable-scripts/paths/scripts_scriptID.yml | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 858e9b974..987ec973c 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -249,8 +249,7 @@ paths: type: string required: true description: | - Script ID. - Only returns the script with this ID. + The ID of the script to retrieve. responses: '200': description: | @@ -394,7 +393,7 @@ paths: #### Limitations - You can delete only one script per request. - - If the script ID you provide doesnt exist for the organization, InfluxDB + - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides @@ -407,7 +406,6 @@ paths: type: string required: true description: | - Script ID. The ID of the script to delete. responses: '204': diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index 56113adbc..9b20f4311 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -12196,7 +12196,7 @@ paths: #### Limitations - You can delete only one script per request. - - If the script ID you provide doesnt exist for the organization, InfluxDB + - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides @@ -12205,7 +12205,6 @@ paths: operationId: DeleteScriptsID parameters: - description: | - Script ID. The ID of the script to delete. in: path name: scriptID @@ -12245,8 +12244,7 @@ paths: operationId: GetScriptsID parameters: - description: | - Script ID. - Only returns the script with this ID. + The ID of the script to retrieve. in: path name: scriptID required: true diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index b54e0dd94..ffe123b1a 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -249,8 +249,7 @@ paths: type: string required: true description: | - Script ID. - Only returns the script with this ID. + The ID of the script to retrieve. responses: '200': description: | @@ -394,7 +393,7 @@ paths: #### Limitations - You can delete only one script per request. - - If the script ID you provide doesnt exist for the organization, InfluxDB + - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides @@ -407,7 +406,6 @@ paths: type: string required: true description: | - Script ID. The ID of the script to delete. responses: '204': diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index 4f14d5deb..d8fff1cb1 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -17,8 +17,7 @@ get: type: string required: true description: | - Script ID. - Only returns the script with this ID. + The ID of the script to retrieve. responses: '200': description: | @@ -146,7 +145,7 @@ delete: #### Limitations - You can delete only one script per request. - - If the script ID you provide doesnt exist for the organization, InfluxDB + - If the script ID you provide doesn't exist for the organization, InfluxDB responds with an HTTP `204` status code. #### Related Guides @@ -159,7 +158,6 @@ delete: type: string required: true description: | - Script ID. The ID of the script to delete. responses: '204': From 5581a91c76c381267f92352ee130fb00048f2eb1 Mon Sep 17 00:00:00 2001 From: Sunbrye Ly Date: Mon, 29 Aug 2022 11:06:31 -0700 Subject: [PATCH 11/11] fix: pr requested changes --- contracts/invocable-scripts.yml | 7 ++++--- contracts/ref/cloud.yml | 7 ++++--- contracts/svc/invocable-scripts.yml | 7 ++++--- src/svc/invocable-scripts/paths/scripts_scriptID.yml | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/contracts/invocable-scripts.yml b/contracts/invocable-scripts.yml index 987ec973c..16d4aef52 100644 --- a/contracts/invocable-scripts.yml +++ b/contracts/invocable-scripts.yml @@ -299,14 +299,15 @@ paths: description: | Updates an invokable script. - Use this endpoint to modify values for script properties (`description`, and `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, InfluxDB responds with an HTTP `200` - status code. + - 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 diff --git a/contracts/ref/cloud.yml b/contracts/ref/cloud.yml index 9b20f4311..5794b9738 100644 --- a/contracts/ref/cloud.yml +++ b/contracts/ref/cloud.yml @@ -12299,14 +12299,15 @@ paths: description: | Updates an invokable script. - Use this endpoint to modify values for script properties (`description`, and `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, InfluxDB responds with an HTTP `200` - status code. + - 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 diff --git a/contracts/svc/invocable-scripts.yml b/contracts/svc/invocable-scripts.yml index ffe123b1a..cc6ad4ea1 100644 --- a/contracts/svc/invocable-scripts.yml +++ b/contracts/svc/invocable-scripts.yml @@ -299,14 +299,15 @@ paths: description: | Updates an invokable script. - Use this endpoint to modify values for script properties (`description`, and `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, InfluxDB responds with an HTTP `200` - status code. + - 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 diff --git a/src/svc/invocable-scripts/paths/scripts_scriptID.yml b/src/svc/invocable-scripts/paths/scripts_scriptID.yml index d8fff1cb1..6d9aae769 100644 --- a/src/svc/invocable-scripts/paths/scripts_scriptID.yml +++ b/src/svc/invocable-scripts/paths/scripts_scriptID.yml @@ -59,14 +59,15 @@ patch: description: | Updates an invokable script. - Use this endpoint to modify values for script properties (`description`, and `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, InfluxDB responds with an HTTP `200` - status code. + - 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