Delete
Delete removes an attribute, one instance of it, or a whole entity, with DELETE /entities/{id}/attrs/{attrId} or DELETE /entities/{id}. It answers 204, or 404 ResourceNotFound when there is nothing to delete.
The first request deletes the attribute speed, and the second deletes the entity:
- http
- curl
- rust
- python
DELETE /ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:A4567/attrs/speed
DELETE /ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:A4567
curl -i -X DELETE http://localhost:1056/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:A4567/attrs/speed
curl -i -X DELETE http://localhost:1056/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:A4567
let speed: AttributeName = "speed".parse()?;
let outcome = client.entities().delete_attribute(&id, &speed).send().await?;
let outcome = client.entities().delete(&id).send().await?;
response = requests.delete(f"{ENTITY}/attrs/speed")
assert response.status_code == 204
response = requests.delete(ENTITY)
assert response.status_code == 204
Each answers 204, or 404 ResourceNotFound when there is nothing to delete. Without a query parameter, an attribute delete removes only its default instance. Two parameters change that.
?datasetId=deletes one instance of the attribute.?deleteAll=truedeletes every instance.
Sending both is refused because they contradict each other. deleteAll removes every instance, and datasetId names one. In Rust the two are one choice, InstanceSelection::Dataset(&uri) or InstanceSelection::All, passed to .instances(...), so asking for both can't be written.
What gets refused
404ResourceNotFoundwhen the entity, or the attribute, doesn't exist.400BadRequestDatawhendatasetIdanddeleteAll=trueare sent together.
To remove members inside a value, use merge with the NGSI-LD Null on each one.