Alter a user-defined type (UDT) (HTTP)
|
For details about additional languages, see: |
Adds and renames fields in a user-defined type (UDT).
This command can’t rename the user-defined type itself or drop fields from the user-defined type. Instead, you must drop the user-defined type and then re-create the user-defined type with the desired name and fields.
|
Ready to write code? See the examples for this method to get started. |
Result
Adds and renames fields in a user-defined type.
If the command succeeds, the response indicates the success.
Example response:
{
"status": {
"ok": 1
}
}
Signature
Use the alterType command.
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"alterType": {
"name": STRING,
"rename": {
"fields": {
OLD_FIELD_NAME: NEW_FIELD_NAME,
OLD_FIELD_NAME: NEW_FIELD_NAME
}
},
"add": {
"fields": {
FIELD_NAME: FIELD_TYPE,
FIELD_NAME: FIELD_TYPE
}
},
}
}'
Parameters
| Name | Type | Summary |
|---|---|---|
|
|
The name of the user-defined type to alter. |
|
|
A JSON object that describes the fields to rename. Each key is an existing field name and each value is the new name for the field. See the examples for usage. |
|
|
Examples
The following examples demonstrate how to alter a user-defined type.
Rename fields
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"alterType": {
"name": "member",
"rename": {
"fields": {
"name": "first_name",
"is_active": "is_member"
}
}
}
}'
Add fields
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"alterType": {
"name": "member",
"add": {
"fields": {
"email": "text",
"credits": "int"
}
}
}
}'
Rename and add fields
You may rename and add fields in the same call. However, if one alteration fails, all subsequent operations are aborted.
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"alterType": {
"name": "member",
"rename": {
"fields": {
"name": "first_name",
"is_active": "is_member"
}
},
"add": {
"fields": {
"email": "text",
"credits": "int"
}
}
}
}'