Page MenuHomePhabricator

Allow wbeditentity API to both add and remove claims in a single API request
Closed, ResolvedPublic

Description

Actually, the wbeditentity API can be used to create multiple claims in a single call. It can also be used to remove multiple claims in a single call. Sadly, it seems that can't be used to both create and delete some claims in a single API request.

Actual situation

If you want to add multiple claims this is the data argument:

{ "claims": {
  "P123": [
    { claim to be added },
    { claim to be added },
  ],
  "P234": [
    { claim to be added },
  ],
  // ecc.
} }

If you want to remove multiple claims this is the data argument:

{ "claims": [
  { id: "ID claim to be removed", remove: 1 },
  { id: "ID claim to be removed", remove: 1 },
 // ecc.
] }

As you see, there is an inconsistence:

  • The first claims contains an object indexed by properties that contains an array of claims
  • The second claims contains directly an array of claims to be removed

Proposal

My suggestion is to avoid these differences. For example, allowing this format:

{ "claims": {
 "P123": [
    { claim to be added },
    { claim to be added },
  ],
  "P234": [
    { claim to be added },
  ],
  "remove": [
    { id: "ID claim to be removed", remove: 1 },
    { id: "ID claim to be removed", remove: 1 },
  ],
} }

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 5 2018, 2:01 PM
valerio.bozzolan updated the task description. (Show Details)
valerio.bozzolan updated the task description. (Show Details)
valerio.bozzolan closed this task as Resolved.Sep 5 2018, 2:28 PM
valerio.bozzolan claimed this task.
valerio.bozzolan awarded a token.
valerio.bozzolan updated the task description. (Show Details)
valerio.bozzolan rescinded a token.
valerio.bozzolan awarded a token.

Actually it's yet supported as undocumented feature.

Solved.

As a note, you can also do:

{ "claims": {
 "P123": [
    { claim to be added },
    { claim to be added },
  ],
  "P234": [
    { claim to be added },
  ],
  "ASD-ASD-ASD": [
    { id: "ID claim to be removed", remove: 1 },
    { id: "ID claim to be removed", remove: 1 },
  ],
} }