List user-defined type names (UDTs)
Gets the names of the user-defined types (UDTs) in a keyspace.
|
Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart. |
Result
-
Python
-
TypeScript
-
Go
-
Java
-
C#
-
curl
Returns the names of the user-defined types as an unordered list of strings.
Returns a promise that resolves to the names of the user-defined types names as an unordered list of strings.
|
The Go client is in preview. For more information, see astra-db-go. |
Returns the names of the user-defined types as an unordered slice of strings.
Returns the names of the user-defined types as an unordered list of strings.
Returns the names of the user-defined types as an unordered list of strings.
Returns the names of the user-defined types as an unordered list of strings in the status.types field of the response.
Example response:
{
"status": {
"types": [
"address",
"social_media"
]
}
}
Parameters
-
Python
-
TypeScript
-
Go
-
Java
-
C#
-
curl
Use the list_type_names method, which belongs to the astrapy.Database class.
Method signature
list_type_names(
*,
keyspace: str,
table_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> list[str]
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The keyspace to inspect. Default: The database’s working keyspace. |
|
|
A timeout, in milliseconds, for the underlying HTTP request.
If not provided, the |
Use the listTypes method, which belongs to the Db class.
Method signature
async listTypes(
options?: {
nameOnly: true,
keyspace?: string,
timeout?: number | TimeoutDescriptor,
},
): string[]
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
The options for this operation.
See Properties of |
| Name | Type | Summary |
|---|---|---|
|
|
Optional.
Must be |
|
|
Optional. The keyspace to inspect. Default: The database’s working keyspace. |
|
|
Optional. A timeout to impose on the underlying API request. |
|
The Go client is in preview. For more information, see astra-db-go. |
Use the ListTypeNames method, which belongs to the Db type.
Method signature
func (d *Db) ListTypeNames(
ctx context.Context,
opts ...options.ListTypesOption
) ([]string, error)
| Name | Type | Summary |
|---|---|---|
|
|
The context for the operation. |
|
Optional.
A builder to generate options for this operation.
See Methods of the |
| Method | Summary |
|---|---|
|
Optional. The keyspace to inspect. Default: The database’s working keyspace. |
|
Optional. General API options for this operation, including the timeout. |
Use the listTypeNames method, which belongs to the com.datastax.astra.client.databases.Database class.
Method signature
List<String> listTypeNames()
List<String> listTypes(ListTypesOptions options)
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The options for this operation, including the keyspace and timeouts. |
Use the ListTypeNamesAsync method, which belongs to the Database class.
You can also use ListTypeNames, which is the synchronous version of the method.
Method signature
public Task<IEnumerable<string>> ListTypeNamesAsync(
ListTypeNamesOptions options = null
);
| Name | Type | Summary |
|---|---|---|
|
Optional. General API options for this operation, including the keyspace and timeout. For more information and examples, see Customize API interaction. |
Use the listTypes command.
Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"listTypes": {
"options": {
"explain": false
}
}
}'
| Name | Type | Summary |
|---|---|---|
|
|
Must be |
Examples
The following examples demonstrate how to list names of the user-defined types in a keyspace.
-
Python
-
TypeScript
-
Go
-
Java
-
C#
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT", token="APPLICATION_TOKEN"
)
# List type names
result = database.list_type_names()
print(result)
import { DataAPIClient } from "@datastax/astra-db-ts";
// Get a database
const client = new DataAPIClient();
const database = client.db("API_ENDPOINT", {
token: "APPLICATION_TOKEN",
});
// List type names
(async function () {
const result = await database.listTypes({ nameOnly: true });
console.log(result);
})();
|
The Go client is in preview. For more information, see astra-db-go. |
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()
// Get a database
client := astra.NewClient()
database := client.Database(
"API_ENDPOINT",
options.API().SetToken("APPLICATION_TOKEN"),
)
// List type names
names, err := database.ListTypeNames(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(names)
}
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import java.util.List;
public class Example {
public static void main(String[] args) {
// Get a database
Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");
// List type names
List<String> result = database.listTypeNames();
System.out.println(result);
}
}
using System.Text.Json;
using DataStax.AstraDB.DataApi;
namespace Examples;
public class Program
{
static async Task Main()
{
// Get an existing table
var client = new DataAPIClient();
var database = client.GetDatabase(
"API_ENDPOINT",
"APPLICATION_TOKEN"
);
// List type names
var names = await database.ListTypeNamesAsync();
Console.WriteLine(JsonSerializer.Serialize(names));
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"listTypes": {
"options": {
"explain": false
}
}
}'
Client reference
-
Python
-
TypeScript
-
Go
-
Java
-
C#
-
curl
For more information, see the client reference.
For more information, see the client reference.
|
The Go client is in preview. For more information, see astra-db-go. |
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.