Skip to content

Commit

Permalink
Update OpenAPI docs to include opensearch index crud changes (#903)
Browse files Browse the repository at this point in the history
Co-authored-by: Rahul Bhardwaj <rahulbhardwaj@digitalocean.com>
  • Loading branch information
bhardwajRahul and Rahul Bhardwaj authored Aug 20, 2024
1 parent 12a6416 commit 47108d8
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 2 deletions.
10 changes: 9 additions & 1 deletion specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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)
}
25 changes: 25 additions & 0 deletions specification/resources/databases/models/opensearch_index.yml
Original file line number Diff line number Diff line change
@@ -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.
28 changes: 28 additions & 0 deletions specification/resources/databases/models/opensearch_index_base.yml
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 10 additions & 1 deletion specification/resources/databases/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,20 @@ 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
description: A unique identifier for a logsink of a database cluster
required: true
example: 50484ec3-19d6-4cd3-b56f-3b0381c289a6
schema:
type: string
type: string
35 changes: 35 additions & 0 deletions specification/resources/databases/responses/opensearch_indexes.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 47108d8

Please sign in to comment.