digitalocean / doctl

The official command line interface for the DigitalOcean API.
https://docs.digitalocean.com/reference/doctl/
Apache License 2.0
3.26k stars 397 forks source link

Databases: Add OpenSearch index CRUD support #1571

Closed bhardwajRahul closed 2 months ago

bhardwajRahul commented 2 months ago

This PR aims at adding support for OpenSearch index CRUD in DOCTL.

Command Details

The subcommands under `doctl databases indexes` enable the management of indexes for opensearch clusters

Usage:
  doctl databases indexes [command]

Available Commands:
  delete      Deletes a opensearch index by index name
  list        Retrieve a list of topics for a given kafka database

Flags:
  -h, --help   help for indexes

Global Flags:
  -t, --access-token string   API V2 access token
  -u, --api-url string        Override default API endpoint
  -c, --config string         Specify a custom config file (default "/home/user/.config/doctl/config.yaml")
      --context string        Specify a custom authentication context name
      --http-retry-max int    Set maximum number of retries for requests that fail with a 429 or 500-level error (default 5)
      --interactive           Enable interactive behavior. Defaults to true if the terminal supports it (default true)
  -o, --output string         Desired output format [text|json] (default "text")
      --trace                 Show a log of network activity while performing a command
  -v, --verbose               Enable verbose output

Command to List OpenSearch Indexes

This command lists the following details for each index in an opensearch cluster:

    - The Name of the index.
    - The Status of the index.
    - The Health of the index.
    - The Number of Shards in the index.
    - The Number of Replicas in the index.
    - The Number of Documents in the index.
    - The Size of the index.

Usage:
  doctl databases indexes list <database-uuid> [flags]

Aliases:
  list, ls

Flags:
      --format Index Name   Columns for output in a comma-separated list. Possible values: Index Name, `Status`, `Health`, `Size`, `Docs`, `Create At`, `Number of Shards`, `Number of Replica`.
  -h, --help                help for list
      --no-header           Return raw data with no headers

Global Flags:
  -t, --access-token string   API V2 access token
  -u, --api-url string        Override default API endpoint
  -c, --config string         Specify a custom config file (default "/home/user/.config/doctl/config.yaml")
      --context string        Specify a custom authentication context name
      --http-retry-max int    Set maximum number of retries for requests that fail with a 429 or 500-level error (default 5)
      --interactive           Enable interactive behavior. Defaults to true if the terminal supports it (default true)
  -o, --output string         Desired output format [text|json] (default "text")
      --trace                 Show a log of network activity while performing a command
  -v, --verbose               Enable verbose output

Command Usage

doctl -t $token databases indexes list 70c35b01-6f6d-40e6-92ec-2b1f3cdfd61a

Ouput

Index Name                      Status    Health    Size      Docs    Create At               Number of Shards    Number of Replica
index-test-tiger-2024-08-21     open      green     10694     1       2024-08-21T14:11:07Z    1                   0
index-test-tiger-2024-08-22     open      green     10694     1       2024-08-22T14:11:04Z    1                   0
index-test-tiger-2024-08-24     open      green     10710     1       2024-08-24T14:11:11Z    1                   0
index-test-tiger-2024-08-25     open      green     10710     1       2024-08-25T14:11:10Z    1                   0
index-test-tiger-2024-08-26     open      green     10710     1       2024-08-26T14:11:05Z    1                   0

Command to Delete OpenSearch Index

Deletes an opensearch index by index name

Usage:
  doctl databases indexes delete <database-uuid> <index-name> [flags]

Aliases:
  delete, rm

Flags:
  -f, --force   Deletes the opensearch index without a confirmation prompt
  -h, --help    help for delete

Global Flags:
  -t, --access-token string   API V2 access token
  -u, --api-url string        Override default API endpoint
  -c, --config string         Specify a custom config file (default "/home/user/.config/doctl/config.yaml")
      --context string        Specify a custom authentication context name
      --http-retry-max int    Set maximum number of retries for requests that fail with a 429 or 500-level error (default 5)
      --interactive           Enable interactive behavior. Defaults to true if the terminal supports it (default true)
  -o, --output string         Desired output format [text|json] (default "text")
      --trace                 Show a log of network activity while performing a command
  -v, --verbose               Enable verbose output

Command Usage

doctl -t $token databases indexes delete 70c35b01-6f6d-40e6-92ec-2b1f3sdsa61a test_index

danaelhe commented 2 months ago

Looks great! Could you please create some integration tests as well? https://github.com/digitalocean/doctl/tree/main/integration