From 47108d84bfdfe44b7702567c0627a815a6ab5e80 Mon Sep 17 00:00:00 2001 From: Rahul Bhardwaj Date: Tue, 20 Aug 2024 22:09:03 +0530 Subject: [PATCH] Update OpenAPI docs to include opensearch index crud changes (#903) Co-authored-by: Rahul Bhardwaj --- specification/DigitalOcean-public.v2.yaml | 10 ++++- .../databases_delete_opensearch_index.yml | 44 +++++++++++++++++++ .../databases_list_opensearch_indexes.yml | 42 ++++++++++++++++++ .../databases_delete_opensearch_index.yml | 6 +++ .../databases_list_opensearch_indexes.yml | 6 +++ .../go/databases_delete_opensearch_index.yml | 19 ++++++++ .../go/databases_list_opensearch_indexes.yml | 17 +++++++ .../databases/models/opensearch_index.yml | 25 +++++++++++ .../models/opensearch_index_base.yml | 28 ++++++++++++ .../resources/databases/parameters.yml | 11 ++++- .../responses/opensearch_indexes.yml | 35 +++++++++++++++ 11 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 specification/resources/databases/databases_delete_opensearch_index.yml create mode 100644 specification/resources/databases/databases_list_opensearch_indexes.yml create mode 100644 specification/resources/databases/examples/curl/databases_delete_opensearch_index.yml create mode 100644 specification/resources/databases/examples/curl/databases_list_opensearch_indexes.yml create mode 100644 specification/resources/databases/examples/go/databases_delete_opensearch_index.yml create mode 100644 specification/resources/databases/examples/go/databases_list_opensearch_indexes.yml create mode 100644 specification/resources/databases/models/opensearch_index.yml create mode 100644 specification/resources/databases/models/opensearch_index_base.yml create mode 100644 specification/resources/databases/responses/opensearch_indexes.yml diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index 55f73fc5..d886e4d0 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -861,7 +861,15 @@ paths: $ref: 'resources/databases/databases_get_cluster_metrics_credentials.yml' put: $ref: 'resources/databases/databases_update_cluster_metrics_credentials.yml' - + + /v2/databases/{database_cluster_uuid}/indexes: + get: + $ref: 'resources/databases/databases_list_opensearch_indexes.yml' + + /v2/databases/{database_cluster_uuid}/indexes/{index_name}: + delete: + $ref: 'resources/databases/databases_delete_opensearch_index.yml' + /v2/domains: get: $ref: 'resources/domains/domains_list.yml' diff --git a/specification/resources/databases/databases_delete_opensearch_index.yml b/specification/resources/databases/databases_delete_opensearch_index.yml new file mode 100644 index 00000000..974d1338 --- /dev/null +++ b/specification/resources/databases/databases_delete_opensearch_index.yml @@ -0,0 +1,44 @@ +operationId: databases_delete_opensearch_index + +summary: Delete Index for OpenSearch Cluster + +description: | + To delete a single index within OpenSearch cluster, send a DELETE request + to `/v2/databases/$DATABASE_ID/indexes/$INDEX_NAME`. + + A status of 204 will be given. This indicates that the request was + processed successfully, but that no response body is needed. + +tags: + - Databases + +parameters: + - $ref: 'parameters.yml#/database_cluster_uuid' + - $ref: 'parameters.yml#/opensearch_index_name' + +responses: + '204': + $ref: '../../shared/responses/no_content.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '404': + $ref: '../../shared/responses/not_found.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/databases_delete_opensearch_index.yml' + - $ref: 'examples/go/databases_delete_opensearch_index.yml' + +security: + - bearer_auth: + - 'database:delete' diff --git a/specification/resources/databases/databases_list_opensearch_indexes.yml b/specification/resources/databases/databases_list_opensearch_indexes.yml new file mode 100644 index 00000000..8f3100d4 --- /dev/null +++ b/specification/resources/databases/databases_list_opensearch_indexes.yml @@ -0,0 +1,42 @@ +operationId: databases_list_opeasearch_indexes + +summary: List Indexes for a OpenSearch Cluster + +description: | + To list all of a OpenSearch cluster's indexes, send a GET request to + `/v2/databases/$DATABASE_ID/indexes`. + + The result will be a JSON object with a `indexes` key. + +tags: + - Databases + +parameters: + - $ref: 'parameters.yml#/database_cluster_uuid' + +responses: + '200': + $ref: 'responses/opensearch_indexes.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '404': + $ref: '../../shared/responses/not_found.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/databases_list_opensearch_indexes.yml' + - $ref: 'examples/go/databases_list_opensearch_indexes.yml' + +security: + - bearer_auth: + - 'database:read' diff --git a/specification/resources/databases/examples/curl/databases_delete_opensearch_index.yml b/specification/resources/databases/examples/curl/databases_delete_opensearch_index.yml new file mode 100644 index 00000000..afc09f8a --- /dev/null +++ b/specification/resources/databases/examples/curl/databases_delete_opensearch_index.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X DELETE \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/indexes/sample-index" \ No newline at end of file diff --git a/specification/resources/databases/examples/curl/databases_list_opensearch_indexes.yml b/specification/resources/databases/examples/curl/databases_list_opensearch_indexes.yml new file mode 100644 index 00000000..9e217ccb --- /dev/null +++ b/specification/resources/databases/examples/curl/databases_list_opensearch_indexes.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/indexes" diff --git a/specification/resources/databases/examples/go/databases_delete_opensearch_index.yml b/specification/resources/databases/examples/go/databases_delete_opensearch_index.yml new file mode 100644 index 00000000..89fc39b8 --- /dev/null +++ b/specification/resources/databases/examples/go/databases_delete_opensearch_index.yml @@ -0,0 +1,19 @@ +lang: Go +source: |- + import ( + "context" + "os" + + "github.com/digitalocean/godo" + ) + + func main() { + token := os.Getenv("DIGITALOCEAN_TOKEN") + + client := godo.NewFromToken(token) + ctx := context.TODO() + + indexName := "sampe-index" + + _, err := client.Databases.DeleteIndex(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", indexName) + } diff --git a/specification/resources/databases/examples/go/databases_list_opensearch_indexes.yml b/specification/resources/databases/examples/go/databases_list_opensearch_indexes.yml new file mode 100644 index 00000000..759df5d0 --- /dev/null +++ b/specification/resources/databases/examples/go/databases_list_opensearch_indexes.yml @@ -0,0 +1,17 @@ +lang: Go +source: |- + import ( + "context" + "os" + + "github.com/digitalocean/godo" + ) + + func main() { + token := os.Getenv("DIGITALOCEAN_TOKEN") + + client := godo.NewFromToken(token) + ctx := context.TODO() + + replicas, _, err := client.Databases.ListIndexes(ctx, "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", nil) + } diff --git a/specification/resources/databases/models/opensearch_index.yml b/specification/resources/databases/models/opensearch_index.yml new file mode 100644 index 00000000..3e6111dc --- /dev/null +++ b/specification/resources/databases/models/opensearch_index.yml @@ -0,0 +1,25 @@ +type: object + +allOf: +- $ref: './opensearch_index_base.yml' +- properties: + status: + type: string + enum: + - unknown + - open + - close + - none + example: open + description: The status of the OpenSearch index. + + health: + type: string + enum: + - unknown + - green + - yellow + - red + - red* + example: green + description: The health of the OpenSearch index. diff --git a/specification/resources/databases/models/opensearch_index_base.yml b/specification/resources/databases/models/opensearch_index_base.yml new file mode 100644 index 00000000..451fc10f --- /dev/null +++ b/specification/resources/databases/models/opensearch_index_base.yml @@ -0,0 +1,28 @@ +type: object + +properties: + index_name: + type: string + description: The name of the opensearch index. + example: events + + number_of_shards: + type: integer + example: 2 + description: The number of shards for the index. + + number_of_replicas: + type: integer + example: 3 + description: The number of replicas for the index. + + size: + type: integer + example: 208 + description: The size of the index. + + created_time: + type: string + format: date-time + example: "2021-01-01T00:00:00Z" + description: The date and time the index was created. diff --git a/specification/resources/databases/parameters.yml b/specification/resources/databases/parameters.yml index f0ffe5ad..0847980c 100644 --- a/specification/resources/databases/parameters.yml +++ b/specification/resources/databases/parameters.yml @@ -71,6 +71,15 @@ kafka_topic_name: schema: type: string +opensearch_index_name: + in: path + name: index_name + description: The name of the OpenSearch index. + required: true + example: logs-* + schema: + type: string + logsink_id: in: path name: logsink_id @@ -78,4 +87,4 @@ logsink_id: required: true example: 50484ec3-19d6-4cd3-b56f-3b0381c289a6 schema: - type: string \ No newline at end of file + type: string diff --git a/specification/resources/databases/responses/opensearch_indexes.yml b/specification/resources/databases/responses/opensearch_indexes.yml new file mode 100644 index 00000000..cc7606e0 --- /dev/null +++ b/specification/resources/databases/responses/opensearch_indexes.yml @@ -0,0 +1,35 @@ +description: A JSON object with a key of `indexes`. + +headers: + ratelimit-limit: + $ref: "../../../shared/headers.yml#/ratelimit-limit" + ratelimit-remaining: + $ref: "../../../shared/headers.yml#/ratelimit-remaining" + ratelimit-reset: + $ref: "../../../shared/headers.yml#/ratelimit-reset" + +content: + application/json: + schema: + properties: + indexes: + type: array + items: + $ref: "../models/opensearch_index.yml" + + example: + indexes: + - index_name: sample-data + number_of_shards: 2 + number_of_replicas: 3 + size: 208 + created_time: "2021-01-01T00:00:00Z" + status: open + health: green + - index_name: logs-* + number_of_shards: 2 + number_of_replicas: 3 + size: 208 + created_time: "2021-01-01T00:00:00Z" + status: open + health: green