You use "filter" properties to select labels and "new" properties to change values. If you omit a "new" property, such as "newGroup", the action does not change that property. You can also deprecate or permanently delete labels.
- This action cannot be undone.
- The response to this action includes a list of labels that were successfully changed by this action.
- Each object in the list contains the original value of the label before it was changed or deleted.
- An application can use "alterLabel" to return each label to its original values.
- If you do not configure the filter properties properly, the action may change more labels than you want.
- Tip Use the same filter in "listLabels" to verify the filter returns the labels you expect.
- FairCom recommends you deprecate a label rather than permanently deleting it.
- To deprecate a label, set its "deprecate" property to true.
- When you permanently delete a label, records referencing the deleted label's "id" property will fail to join the label. This will cause referential integrity problems if records reference the label.
- Tip Permanently delete a label only when no records reference it.
- If a label doesn't exist when the server attempts to delete it, the server considers the action a success because the label does not exist. It does not return an error. The server only returns an error when it fails to permanently delete an existing label.
- If the server cannot process all the requested labels as requested, it returns an error, aborts the transaction, and rolls back all labels back to their previous state. Thus, this action runs in an atomic, all-or-nothing transaction.
How to modify many labels at once
The "changeLabels" action modifies labels that match its filter criteria. It uses properties to define the filter.
The "idFilter" property filters all labels matching the specified "id" values. The action returns an error if you include other filter properties.
The remaining filter properties work together to filter labels. Each is optional and does not filter labels when omitted or set to null. The filter combines them using a logical AND operation.
- "groupFilter" includes labels that match one group in the specified list.
- "partialGroupFilter" includes labels that match the specified partial group names.
- "nameFilter" includes labels that match the specified label names.
- "partialNameFilter" includes labels that match a partial label name.
- "deprecatedFilter" includes labels that are deprecated or not.
- "enumFilter" includes labels that have the specified enum values.
- "sequenceFilter" includes labels that have the specified sequence values.
Note The "groupFilter" and "partialGroupFilter" properties are mutually exclusive, and the "nameFilter" and "partialNameFilter" properties are mutually exclusive.
Request examples
Maximal changing label property values
This example changes labels that match the filters. The filter properties select labels, and the new data properties change values.
{
"api": "admin",
"action": "changeLabels",
"params": {
"partialGroupFilter": "product/color/",
"nameFilter": [
"my label 1",
"myLabel2",
"myLabel3"
],
"deprecatedFilter": false,
"enumFilter": [ 0,"1" ],
"sequenceFilter": [ 1, 3.2, "4.4" ],
"newGroup": "product/color/",
"newValue": 99,
"newEnum": 1,
"newSequence": 4.4,
"newDeprecated": false,
"newDescription": "My new label description.",
"newMetadata": {"myKey": "myValue"},
"includeDescription": true,
"includeMetadata": true
},
"authToken": "",
"apiVersion": "1.0",
"requestId": "00000027",
"debug": "none"
}Maximal deleting labels
This example deletes all labels that match the filter properties.
Note When "permanentlyDeleteLabels" is true, this action permanently deletes the labels matching your filter requirements. When deleting labels, the server ignores the following properties: "newGroup", "newName", "newValue", "newEnum", "newSequence", "newDeprecated", "newDescription", and "newMetadata".
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"idFilter": [ 1, "2" ],
"partialGroupFilter": "product/color/",
"nameFilter": [ "my label 1", "myLabel2" ],
"deprecatedFilter": false,
"enumFilter": [ 0, "1" ],
"sequenceFilter": [ 3.2, "4.4" ]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete labels matching specified "id" values
This example permanently deletes two labels with "id" values 1 and 2. You can embed an "id" value in a string.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"idFilter": [ 1, "2" ]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete all labels that match the partial group filter
This example uses a partial group filter to find one or more matching groups. It then deletes all labels in those groups.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"partialGroupFilter": "product/"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete specific labels in a specific group hierarchy
This example uses a partial group filter to find one or more matching groups. It then deletes all labels in those groups that exactly match the two specified label names. Different groups may have labels with the same name.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"partialGroupFilter": "product/",
"nameFilter": [ "my label 1", "myLabel2" ]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete all deprecated labels
This example deletes all deprecated labels.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"deprecatedFilter": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete all labels that match specific group names
This example uses a group filter to delete all labels with the matching groups.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"groupFilter": [ "myGroup1", "myGroup2", "" ]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete labels in specific groups that match a partial name filter
This example uses a group filter to delete all labels with the matching groups.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"groupFilter": [ "myGroup1", "myGroup2" ],
"partialNameFilter": "myNa"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Permanently delete labels that match the partial name filter
This example uses a partial name filter to delete labels with matching names. The labels may be part of any group.
{
"api": "admin",
"action": "changeLabels",
"params": {
"permanentlyDeleteLabels": true,
"partialNameFilter": "myNa"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Response examples
Maximal changed labels
{
"result": {
"changedLabels": [
{
"id": 1,
"group": "mylabelGroupName",
"name": "mylabelName",
"value": 99,
"enum": 0,
"sequence": "3.14",
"deprecated": false,
"description": "My label description.",
"metadata": { "my": "metadata" }
},
{
"id": 2,
"group": "anotherlabelGroupName",
"name": "anotherlabelName",
"value": 99,
"enum": 0,
"sequence": null,
"deprecated": false,
"description": null,
"metadata": null
}
]
},
"authToken": "authToken",
"debugInfo": {},
"errorCode": 0,
"errorMessage": ""
}Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
idFilter |
The The
|
Optional with default of []
|
array of integers | Each array item is an integer from 0 to 2147483647
|
partialGroupFilter |
The
|
Optional with default of ""
|
string | 1 to 64 bytes |
nameFilter |
The
|
Optional with default of []
|
array of strings | Each array item is a label string from 1 to 64 bytes |
deprecatedFilter |
The
|
Optional with default of false
|
Boolean |
|
enumFilter |
The
|
Optional with default of []
|
array of smallints | Each array item is an integer from -32768 to 32767
|
sequenceFilter |
The |
Optional with default of []
|
array of doubles | Each array item is a floating-point or integer number. |
newGroup |
The |
Optional with default of null
|
string | 1 to 64 bytes |
newValue |
The |
Optional with default of null
|
JSON | 0 to 65,500 bytes |
newEnum |
The |
Optional with default of null
|
smallint |
-32768 to 32767
|
newSequence |
The |
Optional with default of null
|
double | Any floating point or integer number. |
newDeprecated |
The |
Optional with default of null
|
Boolean |
|
newDescription |
The |
Optional with default of ""
|
string | 1 to 65,500 bytes |
newMetadata |
The |
Optional with default of {}
|
JSON | 0 to 65,500 bytes |
includeDescription |
The |
Optional with default of |
Boolean |
|
includeMetadata |
The |
Optional with default of |
Boolean |
|
Response properties ("result")
| Property | Description | Type | Limits (inclusive) |
|---|---|---|---|
changedLabels |
The "changedLabels": [
{
"id": 4,
"group": "myLabelGroupName",
"name": "myLabelName",
"value": 99,
"enum": 0,
"sequence": 1.2,
"deprecated": false,
"description": "My label description.",
"metadata": {}
}
] |
array of objects | An object for each changed label. |
id |
The |
integer |
|
group |
The The If the When you assign a group name to a label, the server automatically checks whether the group name exists in the list of groups returned by the "listLabelGroups" action. If the group name does not exist, the server adds it to the list. When you rename a group assigned to a label, the server automatically adds a new group name to the list and removes the previous group name if no other label uses it.
|
string | 1 to 64 bytes |
name |
The The The
|
string | 1 to 64 bytes |
value |
The
In Key-Value actions, the |
JSON | 0 to 65,500 bytes |
enum |
The
|
smallint |
-32768 to 32767
|
sequence |
The |
float | Any floating point or integer number. |
deprecated |
The |
Boolean |
|
description |
The Markdown is a good language for formatting description text. You must ensure the text is compatible with a JSON string. For example, you must escape a double quote character using the backslash character:
In the Thing API, It defaults to
|
string | 1 to 65,500 bytes |
metadata |
The |
JSON | 0 to 65,500 bytes |