Find a database (Go)
Gets information about a database.
|
You need an application token with permission to create and configure databases, such as the Organization Administrator role. For more information, see Get endpoint and token. |
Result
Returns a FullAstraDatabaseInfo struct that contains information about the requested database, including the database ID, name, keyspaces, and status.
Signature
Use the DatabaseInfo method, which belongs to the AstraAdmin type.
func (a *AstraAdmin) DatabaseInfo(
ctx context.Context,
databaseID string,
opts ...options.DatabaseInfoOption
) (*FullAstraDatabaseInfo, error)
Parameters
| Name | Type | Summary |
|---|---|---|
|
|
The context for the operation. |
|
|
The ID of the target database. |
|
Optional.
A builder to generate options for this operation.
See Methods of the |
| Method | Summary |
|---|---|
|
Optional. General API options for this operation, including the timeout. |
Examples
The following examples demonstrate how to find a database.
package main
import (
"context"
"fmt"
"log"
"github.com/datastax/astra-db-go/v2/astra"
"github.com/datastax/astra-db-go/v2/astra/options"
)
func main() {
ctx := context.Background()
client := astra.NewClient(
options.API().SetToken("APPLICATION_TOKEN"),
)
admin, err := client.Admin()
if err != nil {
log.Fatal(err)
}
databaseInfo, err := admin.DatabaseInfo(ctx, "DATABASE_ID")
if err != nil {
log.Fatal(err)
}
fmt.Println(databaseInfo)
}
Errors
For a full list of Data API error codes and their corresponding messages, see Data API errors and error codes.
For more information about how the client handles underlying Data API errors, see Go client error handling.
Client reference
For more information, see the client reference.