List user-defined types (UDTs)
Gets information about 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
-
Java
-
C#
-
curl
Returns an unordered list of ListTypeDescriptor objects that describe each user-defined type in the keyspace.
Returns a promise that resolves to an unordered list of TypeDescriptor objects that describe each user-defined type in the keyspace.
Returns an unordered list of TableUserDefinedTypeDescriptor objects that describe each user-defined type in the keyspace.
Returns an unordered list of UserDefinedTypeInfo objects that describe each user-defined type in the keyspace.
The status.types field in the response describes each user-defined type.
Example response:
{
"status": {
"types": [
{
"type": "userDefined",
"udtName": "address",
"definition": {
"fields": {
"city": {
"type": "text"
},
"country": {
"type": "text"
}
}
},
"apiSupport": {
"createTable": true,
"insert": true,
"read": true,
"filter": false,
"cqlDefinition": "demo.address"
}
}
]
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
C#
-
curl
Use the list_types method, which belongs to the astrapy.Database class.
Method signature
list_types(
*,
keyspace: str,
table_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> list[ListTypeDescriptor]
| 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?: false,
keyspace?: string,
timeout?: number | TimeoutDescriptor,
},
): TypeDescriptor[]
| 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. |
Use the listTypes method, which belongs to the com.datastax.astra.client.databases.Database class.
Method signature
List<TableUserDefinedTypeDescriptor> listTypes()
List<TableUserDefinedTypeDescriptor> listTypes(ListTypesOptions options)
| Name | Type | Summary |
|---|---|---|
|
|
Optional. The options for this operation, including the keyspace and timeouts. |
Use the ListTypesAsync method, which belongs to the Database class.
You can also use ListTypes, which is the synchronous version of the method.
Method signature
public Task<List<UserDefinedTypeInfo>> ListTypesAsync(
ListTypesOptions 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": true
}
}
}'
| Name | Type | Summary |
|---|---|---|
|
|
Must be |
Examples
The following examples demonstrate how to get metadata about user-defined types in a keyspace.
-
Python
-
TypeScript
-
Java
-
C#
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT", token="APPLICATION_TOKEN"
)
# List type metadata
result = database.list_types()
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 metadata
(async function () {
const result = await database.listTypes({ nameOnly: false });
console.log(result);
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.definition.types.TableUserDefinedTypeDescriptor;
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 metadata
List<TableUserDefinedTypeDescriptor> result = database.listTypes();
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 types
var types = await database.ListTypesAsync();
Console.WriteLine(JsonSerializer.Serialize(types));
}
}
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": true
}
}
}'
Client reference
-
Python
-
TypeScript
-
Java
-
C#
-
curl
For more information, see the client reference.
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.