Delete Entity
This section provides developers with information on how to delete an entity. Documentation for the REST protocol, as well as samples for Java, PHP, and cURL, are provided below.
REST
The REST noun (and associated message content) for deleting an entity is as follows:
- Relative Noun: AuthenticatedSession/$sessionID/Entity/$entityID. This is the relative path of the URL that should appear after the OTIS server application name. Below is an example of deleting the john.doe entity:
AuthenticatedSession/78BD660E0E5F673378BD660E0E5F6733/Entity/john.doe
- HTTP Method: DELETE.
- Request/Response message details: none. See the Entity Delete Request documentation for expected response codes.
- Description: Deletes the entity in the authenticated session.
Java
The following is example Java code that demonstrates how to create an entity:
//remove an entity
//This removes the "example" entity.
example = session.getEntity("example");
example.remove();
To view the complete Java sample code for Attribute/Entity nouns, see the [..././../Sample/Java/EntityAttribute Entity/Attribute Java Sample Code] page.
The OTIS client Java library may be downloaded from the OTIS download page.
PHP
The following is example PHP code that demonstrates how to delete an entity:
//Delete the example
$deleteData = deleteRequest($sessionURL, $sessionSecret, "Entity/example");
//Make sure there are no errors. (200 Status)
echo "\n\n\n\n" . $deleteData;
function deleteRequest($URL, $secret, $URI){
$deleteHeader =
"DELETE $URL/$URI HTTP/1.1\n".
"Host: wag.bandit-project.org\n".
(($secret) ? ("SessionSecret: " . $secret . "\n") : "") .
"Connection: Close\n\n";
$socket = fsockopen("wag.bandit-project.org", 80);
fputs($socket, $deleteHeader);
$content = "";
while(!feof($socket)) $content .= fgets($socket, 2048);
return $content;
}
To view the complete PHP sample code for Attribute/Entity nouns, see the Entity/Attribute PHP Sample Code page.
cURL
The following command deletes the "oldUser" entity:
if [ -e secret.hdr ] ; then secret=`cat secret.hdr` ; else secret="nosecret: none" ; fi
curl -b cookies.txt -H "${secret}" -X DELETE https://wag.bandit-project.org/otis/Entity/oldUser
See the Entity Delete Request documentation for further details.