As a tool builder I want to be able to change labels of an item so that work in my tool can be saved back to Wikidata.
PATCH /entities/items/{item_id}/labels
The request contains a json body with a mandatory `patch` key containing a JSON Patch document plus optional metadata: `tags`, `bot`, `comment`.
Response of a successful request:
* 200 HTTP response
* response body containing the updated labels data, using the similar structure as `GET /entities/items/{item_id}/labels`.
* Should also include ETag and Last-Modified headers of the latest revision ID of the relevant item.
"Autocomments":
* should mimic the `wbeditentity` behavior when editing labels/descriptions/aliases:
* If the change results in changing labels in not more than 50 languages: `/* wbeditentity-update-languages-short:0||LANGS */`
* If the change results in changing labels in 51 or more languages: `/* wbeditentity-update-languages:0||LANG_COUNT */`
* where `LANGS` is a comma separated list of language codes of relevant languages (e.g. `en, de, es, fr, fi, it`). `LANG_COUNT` is a number of languages with changed labels
* the boundary number of 50 languages is defined in `ChangedLanguagesCounter::SHORTENED_SUMMARY_MAX_EDIT` constant (not configurable)
Error cases considered:
<table>
<tr>
<th>error type</th>
<th> HTTP Response code</th>
<th>Response content</th>
</tr>
<tr>
<td>item with the given ID does not exist</td>
<td>404</td>
<td>
`"code": "item-not-found",`
`"message": "Could not find an item with the ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>ID provided is not a valid item ID</td>
<td>400</td>
<td>
` "code": "invalid-item-id",`
`"message": "Not a valid item ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>Invalid JSON patch (general error)</td>
<td>400</td>
<td>
`"code": "invalid-patch"`
`"message": "The provided patch is invalid"`
</td>
</tr>
<tr>
<td>incorrect JSON patch operation</td>
<td>400</td>
<td>
`"code": "invalid-patch-operation"`
`"message": "Incorrect JSON patch operation: '<op>'"`
`"context": { "operation": <operation_object> }`
</td>
</tr>
<tr>
<td>
invalid field type in JSON patch
(either of `op`, `path`, `from` is not a string)
</td>
<td>400</td>
<td>
`"code": "invalid-patch-field-type"`
`"message": "The value of '<field>' must be of type string"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>
missing mandatory field in JSON patch
(`op`, `path`, `value`, also `from` on copy/move patches)
</td>
<td>400</td>
<td>
`"code": "missing-json-patch-field"`
`"message": "Missing '<field>' in JSON patch"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>_target of JSON Patch not found on the object</td>
<td>409</td>
<td>
`"code": "patch-_target-not-found",`
`"message": "_target '<_target>' not found on the resource",`
`"context": {`
` "operation": <operation_object>,`
` "field": <path>`
`}`
</td>
</tr>
<tr>
<td>JSON Patch test operation failed</td>
<td>409</td>
<td>
`"code": "patch-test-failed",`
`"message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'",`
`"context": {`
` "operation": <operation_object>,`
` "actual-value": <actual>`
`}`
</td>
</tr>
<tr>
<td>After changes an invalid language code is used</td>
<td>422</td>
<td>
`"code": "patched-labels-invalid-language-code"`
`"message": "Not a valid language code '{language_code}' in changed labels"`
`"context": {`
` "language": <language_code>`
`}`
</td>
</tr>
<tr>
<td>After changes a label is invalid (empty, too long)</td>
<td>422</td>
<td>
`"code": "patched-label-empty"/"patched-label-too-long"`
`"message": "Changed label for '{lang_code}' cannot be empty" / "Changed label for '{lang_code}' must not be more than '{limit}' characters long"`
`"context": {`
` "language": <language_code>`
` "label": <label>` (too long label case only)
` "limit": <limit>` (too long label case only)
`}`
</td>
</tr>
<tr>
<td>After changes the item has the exact same label and description in a given language</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-same-value"`
`"message": "Label and description for language code {language} can not have the same value.`
`"context": {`
` "language": <language>`
`}`
</td>
</tr>
<tr>
<td>After changes the item has the same label and description in a given language as an existing item</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-duplicate"`
`"message": "Item {dupe_id} already has label "{label}" associated with language code {language}, using the same description text."`
`"context": {`
` "language": <language>`
` "label": <label>`
` "description": <description>`
` "matching-item-id": <dupe_item_id>`
`}`
</td></tr>
</table>
Note:
* leading and trailing whitespace in changed labels to be trimmed "silently" (i.e. accept the label with leading/trailing whitespace but remove it before saving)
* we allow all patch operations (including "move", "copy", etc) even if they likely are not useful
* Handling content-type: accept both `application/json` and `application/json-patch+json`, assume json patch input format - anything else yields a 415 http status code
* Conditional HTTP headers are to be handled as in other PATCH endpoints
**Examples**:
Add a label in French and Bavarian:
```
{
{ "op": "add", "path": "/fr", "value": "pomme de terre" },
{ "op": "add", "path": "/bar", "value": "Erdapfel" }
}
```
Remove the German label
```
{
{ "op": "remove", "path": "/de" }
}
```
Replace English label if it is "tater":
```
{
{ "op": "test", "path": "/en", "value": "tater" },
{ "op": "replace", "path": "/en", "value": "potato" }
}
```
As a tool builder I want to be able to change labels of an item so that work in my tool can be saved back to Wikidata.
PATCH /entities/items/{item_id}/labels
The request contains a json body with a mandatory `patch` key containing a JSON Patch document plus optional metadata: `tags`, `bot`, `comment`.
Response of a successful request:
* 200 HTTP response
* response body containing the updated labels data, using the similar structure as `GET /entities/items/{item_id}/labels`.
* Should also include ETag and Last-Modified headers of the latest revision ID of the relevant item.
"Autocomments":
* should mimic the `wbeditentity` behavior when editing labels/descriptions/aliases:
* If the change results in changing labels in not more than 50 languages: `/* wbeditentity-update-languages-short:0||LANGS */`
* If the change results in changing labels in 51 or more languages: `/* wbeditentity-update-languages:0||LANG_COUNT */`
* where `LANGS` is a comma separated list of language codes of relevant languages (e.g. `en, de, es, fr, fi, it`). `LANG_COUNT` is a number of languages with changed labels
* the boundary number of 50 languages is defined in `ChangedLanguagesCounter::SHORTENED_SUMMARY_MAX_EDIT` constant (not configurable)
Error cases considered:
<table>
<tr>
<th>error type</th>
<th> HTTP Response code</th>
<th>Response content</th>
</tr>
<tr>
<td>item with the given ID does not exist</td>
<td>404</td>
<td>
`"code": "item-not-found",`
`"message": "Could not find an item with the ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>ID provided is not a valid item ID</td>
<td>400</td>
<td>
` "code": "invalid-item-id",`
`"message": "Not a valid item ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>Item with the provided ID has been redirected to another item</td>
<td>409</td>
<td>
`"code": "redirected-item"`
`"message": "Item {item_id} has been merged into {other_id}." `
`"context": {"redirect-_target-id": <other_id> }`
</td>
</tr>
<tr>
<td>Invalid JSON patch (general error)</td>
<td>400</td>
<td>
`"code": "invalid-patch"`
`"message": "The provided patch is invalid"`
</td>
</tr>
<tr>
<td>incorrect JSON patch operation</td>
<td>400</td>
<td>
`"code": "invalid-patch-operation"`
`"message": "Incorrect JSON patch operation: '<op>'"`
`"context": { "operation": <operation_object> }`
</td>
</tr>
<tr>
<td>
invalid field type in JSON patch
(either of `op`, `path`, `from` is not a string)
</td>
<td>400</td>
<td>
`"code": "invalid-patch-field-type"`
`"message": "The value of '<field>' must be of type string"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>
missing mandatory field in JSON patch
(`op`, `path`, `value`, also `from` on copy/move patches)
</td>
<td>400</td>
<td>
`"code": "missing-json-patch-field"`
`"message": "Missing '<field>' in JSON patch"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>_target of JSON Patch not found on the object</td>
<td>409</td>
<td>
`"code": "patch-_target-not-found",`
`"message": "_target '<_target>' not found on the resource",`
`"context": {`
` "operation": <operation_object>,`
` "field": <path>`
`}`
</td>
</tr>
<tr>
<td>JSON Patch test operation failed</td>
<td>409</td>
<td>
`"code": "patch-test-failed",`
`"message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'",`
`"context": {`
` "operation": <operation_object>,`
` "actual-value": <actual>`
`}`
</td>
</tr>
<tr>
<td>After changes an invalid language code is used</td>
<td>422</td>
<td>
`"code": "patched-labels-invalid-language-code"`
`"message": "Not a valid language code '{language_code}' in changed labels"`
`"context": {`
` "language": <language_code>`
`}`
</td>
</tr>
<tr>
<td>After changes a label is invalid (empty, too long)</td>
<td>422</td>
<td>
`"code": "patched-label-empty"/"patched-label-too-long"`
`"message": "Changed label for '{lang_code}' cannot be empty" / "Changed label for '{lang_code}' must not be more than '{limit}' characters long"`
`"context": {`
` "language": <language_code>`
` "label": <label>` (too long label case only)
` "limit": <limit>` (too long label case only)
`}`
</td>
</tr>
<tr>
<td>After changes the item has the exact same label and description in a given language</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-same-value"`
`"message": "Label and description for language code {language} can not have the same value.`
`"context": {`
` "language": <language>`
`}`
</td>
</tr>
<tr>
<td>After changes the item has the same label and description in a given language as an existing item</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-duplicate"`
`"message": "Item {dupe_id} already has label "{label}" associated with language code {language}, using the same description text."`
`"context": {`
` "language": <language>`
` "label": <label>`
` "description": <description>`
` "matching-item-id": <dupe_item_id>`
`}`
</td></tr>
</table>
Note:
* leading and trailing whitespace in changed labels to be trimmed "silently" (i.e. accept the label with leading/trailing whitespace but remove it before saving)
* we allow all patch operations (including "move", "copy", etc) even if they likely are not useful
* Handling content-type: accept both `application/json` and `application/json-patch+json`, assume json patch input format - anything else yields a 415 http status code
* Conditional HTTP headers are to be handled as in other PATCH endpoints
**Examples**:
Add a label in French and Bavarian:
```
{
{ "op": "add", "path": "/fr", "value": "pomme de terre" },
{ "op": "add", "path": "/bar", "value": "Erdapfel" }
}
```
Remove the German label
```
{
{ "op": "remove", "path": "/de" }
}
```
Replace English label if it is "tater":
```
{
{ "op": "test", "path": "/en", "value": "tater" },
{ "op": "replace", "path": "/en", "value": "potato" }
}
```
As a tool builder I want to be able to change labels of an item so that work in my tool can be saved back to Wikidata.
PATCH /entities/items/{item_id}/labels
The request contains a json body with a mandatory `patch` key containing a JSON Patch document plus optional metadata: `tags`, `bot`, `comment`.
Response of a successful request:
* 200 HTTP response
* response body containing the updated labels data, using the similar structure as `GET /entities/items/{item_id}/labels`.
* Should also include ETag and Last-Modified headers of the latest revision ID of the relevant item.
"Autocomments":
* should mimic the `wbeditentity` behavior when editing labels/descriptions/aliases:
* If the change results in changing labels in not more than 50 languages: `/* wbeditentity-update-languages-short:0||LANGS */`
* If the change results in changing labels in 51 or more languages: `/* wbeditentity-update-languages:0||LANG_COUNT */`
* where `LANGS` is a comma separated list of language codes of relevant languages (e.g. `en, de, es, fr, fi, it`). `LANG_COUNT` is a number of languages with changed labels
* the boundary number of 50 languages is defined in `ChangedLanguagesCounter::SHORTENED_SUMMARY_MAX_EDIT` constant (not configurable)
Error cases considered:
<table>
<tr>
<th>error type</th>
<th> HTTP Response code</th>
<th>Response content</th>
</tr>
<tr>
<td>item with the given ID does not exist</td>
<td>404</td>
<td>
`"code": "item-not-found",`
`"message": "Could not find an item with the ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>ID provided is not a valid item ID</td>
<td>400</td>
<td>
` "code": "invalid-item-id",`
`"message": "Not a valid item ID: '{item_id}'"`
</td>
</tr>
<tr>
<td>Item with the provided ID has been redirected to another item</td>
<td>409</td>
<td>
`"code": "redirected-item"`
`"message": "Item {item_id} has been merged into {other_id}." `
`"context": {"redirect-_target-id": <other_id> }`
</td>
</tr>
<tr>
<td>Invalid JSON patch (general error)</td>
<td>400</td>
<td>
`"code": "invalid-patch"`
`"message": "The provided patch is invalid"`
</td>
</tr>
<tr>
<td>incorrect JSON patch operation</td>
<td>400</td>
<td>
`"code": "invalid-patch-operation"`
`"message": "Incorrect JSON patch operation: '<op>'"`
`"context": { "operation": <operation_object> }`
</td>
</tr>
<tr>
<td>
invalid field type in JSON patch
(either of `op`, `path`, `from` is not a string)
</td>
<td>400</td>
<td>
`"code": "invalid-patch-field-type"`
`"message": "The value of '<field>' must be of type string"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>
missing mandatory field in JSON patch
(`op`, `path`, `value`, also `from` on copy/move patches)
</td>
<td>400</td>
<td>
`"code": "missing-json-patch-field"`
`"message": "Missing '<field>' in JSON patch"`
`"context": { "operation": <operation_object>, "field": <field> }`
</td>
</tr>
<tr>
<td>_target of JSON Patch not found on the object</td>
<td>409</td>
<td>
`"code": "patch-_target-not-found",`
`"message": "_target '<_target>' not found on the resource",`
`"context": {`
` "operation": <operation_object>,`
` "field": <path>`
`}`
</td>
</tr>
<tr>
<td>JSON Patch test operation failed</td>
<td>409</td>
<td>
`"code": "patch-test-failed",`
`"message": "Test operation in the provided patch failed. At path '{path}' expected '{expected}', actual: '{actual}'",`
`"context": {`
` "operation": <operation_object>,`
` "actual-value": <actual>`
`}`
</td>
</tr>
<tr>
<td>After changes an invalid language code is used</td>
<td>422</td>
<td>
`"code": "patched-labels-invalid-language-code"`
`"message": "Not a valid language code '{language_code}' in changed labels"`
`"context": {`
` "language": <language_code>`
`}`
</td>
</tr>
<tr>
<td>After changes a label is invalid (empty, too long)</td>
<td>422</td>
<td>
`"code": "patched-label-empty"/"patched-label-too-long"`
`"message": "Changed label for '{lang_code}' cannot be empty" / "Changed label for '{lang_code}' must not be more than '{limit}' characters long"`
`"context": {`
` "language": <language_code>`
` "label": <label>` (too long label case only)
` "limit": <limit>` (too long label case only)
`}`
</td>
</tr>
<tr>
<td>After changes the item has the exact same label and description in a given language</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-same-value"`
`"message": "Label and description for language code {language} can not have the same value.`
`"context": {`
` "language": <language>`
`}`
</td>
</tr>
<tr>
<td>After changes the item has the same label and description in a given language as an existing item</td>
<td>422</td>
<td>
`"code": "patched-item-label-description-duplicate"`
`"message": "Item {dupe_id} already has label "{label}" associated with language code {language}, using the same description text."`
`"context": {`
` "language": <language>`
` "label": <label>`
` "description": <description>`
` "matching-item-id": <dupe_item_id>`
`}`
</td></tr>
</table>
Note:
* leading and trailing whitespace in changed labels to be trimmed "silently" (i.e. accept the label with leading/trailing whitespace but remove it before saving)
* we allow all patch operations (including "move", "copy", etc) even if they likely are not useful
* Handling content-type: accept both `application/json` and `application/json-patch+json`, assume json patch input format - anything else yields a 415 http status code
* Conditional HTTP headers are to be handled as in other PATCH endpoints
**Examples**:
Add a label in French and Bavarian:
```
{
{ "op": "add", "path": "/fr", "value": "pomme de terre" },
{ "op": "add", "path": "/bar", "value": "Erdapfel" }
}
```
Remove the German label
```
{
{ "op": "remove", "path": "/de" }
}
```
Replace English label if it is "tater":
```
{
{ "op": "test", "path": "/en", "value": "tater" },
{ "op": "replace", "path": "/en", "value": "potato" }
}
```