You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


 

Provides functionality to add, edit and delete content from a storage unit.

Add Content

Adds a new content record for the given key in the specified scope.

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc) to which the key content will be saved to.

The add POST/PUT request requires a JSON with the fields:

  • key: The unique identifier of the content record. Keys will be saved with a zone prefix. If the prefix is not specified, the local zone prefix will be added automatically. Because of the prefix, a key cannot contain colon (:) characters as it is used as the prefix separator.
  • version: A version to chronologically identify the transaction. If a record with key already exists with a higher version, the request will be discarded.
  • content: JSON content associated with the scope being added. Content will be saved encrypted and compressed if specified on the storage unit configuration.
  • policy: The policy to use when adding a new content record:
    • new: only adds the content if the key doesn't exist in the storage unit.
    • overwrite: if a record with key already exists, it overwrites all of it's previous content (discards other existing scopes for that key), otherwise, it adds the record.
    • merge: if a record with key already exists, it adds the scope information without affecting any other scopes for this record.
PUT transaction/add/<storage-unit-name>/<scope>
{
    "content": {"doc": {"test":"value"}},
    "policy": "merge",
    "key": "LOCAL_ZONE:B166F75594BF1B23A26A6F0074BEB88F",
    "version": 1445618448043
} 

Response

If the add operation is successful, a 200 response code and an OK message are returned.

 {"message":"OK"}
 

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

 {"message": "STORAGE_UNIT_DOESNT_EXIST"}
 

Execute

Executes a JSON transaction against the storage unit.

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc) to which the key content will be saved to. Note: scope is required if the action is add/update, for other actions it is optional.

The execute POST/PUT request requires a JSON with the fields::

  • key: The unique identifier of the content record. Keys will be saved with a zone prefix. If the prefix is not specified, the local zone prefix will be added automatically. Because of the prefix, a key cannot contain colon (:) characters as it is used as the prefix separator.
  • version: A version to chronologically identify the transaction. If a record with key already exists with a higher version, the request will be discarded.
  • content: When the action is add/update, it is JSON content to store. Content will be saved encrypted and compressed if specified on the storage unit configuration.
  • action: The transaction type to execute on the record's scope: add, update, delete. Custom transaction types can be specified in this field to trigger custom document and general events as described in here.
  • policy: The policy to use when executing the action on the content record:
    • add/update actions
      • new: only adds the content if the key doesn't exist in the storage unit.
      • overwrite: if a record with key already exists, it overwrites all of it's previous content (discards other existing scopes for that key), otherwise, it adds the record.
      • merge: if a record with key already exists, it adds the scope information without affecting any other scopes for this record.
    • delete actions:
      • silent: If the record/scope for key doesn't exist, the request completes without an error.
      • mustexist: If the record/scope for key doesn't exist, an error is reported back in the response.
    • custom actions: policy is not required in these cases.
 POST transaction/execute/<storage-unit-name>/<scope>
 {
    "content": {"doc": {"test":"value"}},
    "action": "add",
    "policy": "merge",
    "key": "LOCAL_ZONE:B166F75594BF1B23A26A6F0074BEB88F",
    "version": 1445618448043
}

Response

If the execute operation is successful, a 200 response code and an OK message are returned.

 

 {"message":"OK"}

 

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

 

 {"message": "STORAGE_UNIT_DOESNT_EXIST"}

 

Batch

Executes a list of JSON transactions against the storage unit. The batch expects a list of single line JSON strings.

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc) against which all transactions will be executed to.

The batch POST/PUT request requires a list of JSON objects separated by a new line, each with:

  • key: The unique identifier of the content record. Keys will be saved with a zone prefix. If the prefix is not specified, the local zone prefix will be added automatically. Because of the prefix, a key cannot contain colon (:) characters as it is used as the prefix separator.
  • version: A version to chronologically identify the transaction. If a record with key already exists with a higher version, the request will be discarded.
  • content: When the action is add/update, it is JSON content to store. Content will be saved encrypted and compressed if specified on the storage unit configuration.
  • action: The transaction type to execute on the record's scope: addupdate, delete. Custom transaction types can be specified in this field to trigger custom document and general events as described in here.
  • policy: The policy to use when executing the action on the content record:
    • add/update actions
      • new: only adds the content if the key doesn't exist in the storage unit.
      • overwrite: if a record with key already exists, it overwrites all of it's previous content (discards other existing scopes for that key), otherwise, it adds the record.
      • merge: if a record with key already exists, it adds the scope information without affecting any other scopes for this record.
      delete actions:
      • silent: If the record/scope for key doesn't exist, the request completes without an error.
      • mustexist: If the record/scope for key doesn't exist, an error is reported back in the response.
    • custom actions: policy is not required in these cases.

An optional report parameter can be specified to get processing statistics and error reports.

 POST transaction/batch/<storage-unit-name>/<scope>?report
{"content": {"doc": {"test":"value"}},"action": "add",  "policy": "merge", "key": "LOCAL_ZONE:B166F75594BF1B23A26A6F0074BEB88F", "version": 1445618448043}
{"content": {"doc": {"test":"value2"}}, "action": "delete", "policy": "silent", "key": "EXTERNAL_ZONE:B6F5H6J8HGBF1B23A26A6F0074BEB8E5", "version": 1445618448133}

 

Response

If the batch operation is successful, a 200 response code and an OK message are returned if no transactions failed. A COMPLETED_WITH_ERRORS message if one or more transactions failed.

{"message":"OK"}

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

{"message": "STORAGE_UNIT_DOESNT_EXIST"}

If the report parameter is specified, a 200 response code is returned with the list of processed keys and a status for each key, as well as a general report. An OK message value if no errors occurred or COMPLETED_WITH_ERRORS with one or more transactions failed.

{
    "entry":[
        {"key":"B6F5H6J8HGBF1B23A26A6F0074BEB8E5","success":true},
        {"key":"B166F75594BF1B23A26A6F0074BEB88F","success":true}
    ],
    "processed":2,
    "errors":0,
    "message":"OK"
}

Delete

Deletes a scope for a key in the specified storage unit.

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc.) to delete from the record. If scope = $record, the whole record will be deleted.

The delete POST/DELETE request requires a JSON with the fields::

  • key: The unique identifier of the content record.
  • version: A version to identify the record. If a record with key already exists with a higher version, the request will be ignored.
  • policy: The policy to use when deleting a scope of the record:
  • silent (default): If the record/scope doesn't exist, the request completes without an error.
  • mustexist: If the record/scope doesn't exist, an error is reported back in the response.
 POST transaction/delete/<storage-unit-name>/<optional:scope>
{
    "policy": "silent", //delete: silent, mustexist
    "key": "B6F5H6J8HGBF1B23A26A6F0074BEB8E5",
    "version": 1445618448133
}

 

Response

If the delete operation is successful, a 200 response code and an OK message are returned.

 

 {"message":"OK"}

 

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

 

 {"message": "STORAGE_UNIT_DOESNT_EXIST"}

 

If the scope doesn't exist and the delete policy was MUSTEXIST, a 400 response code with a DELETED_SCOPE_DOESNT_EXIST message is returned.

 

 {"message": "DELETED_SCOPE_DOESNT_EXIST"}

 

Delete All

Deletes the provided scope for all content records of the storage unit. If the scope is the global $record scope or it is not provided, all content records are deleted.

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc.) to delete from the record. If scope = $record, the whole record will be deleted.

The delete all POST/DELETE request requires a JSON with the fields::

  • version: A version to identify the records. If a record already exists with a higher version, the delete action for that record will not be executed.
 POST transaction/deleteAll/<storage-unit-name>/<optional:scope>
{
  "version": 1445618448133
}

 

Response

If the delete all operation is successful, a 200 response code and an OK message are returned.

 

 {"message":"OK"}

 

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

 

 {"message": "STORAGE_UNIT_DOESNT_EXIST"}

 

If the scope doesn't exist and the delete policy was MUSTEXIST, a 400 response code with a DELETED_SCOPE_DOESNT_EXIST message is returned.

 

 {"message": "DELETED_SCOPE_DOESNT_EXIST"}

 

Delete If

Deletes a content record scope based on a comparison criteria (X field is equal, greater than, lesser than or not equal to a value).

Request

The URL is composed by the Storage Unit and the scope (I.e. connectorocrindex, etc.) to delete from the record. If scope = $record, the whole record will be deleted.

The delete if POST/DELETE request requires a JSON with the fields::

  • version: A version to identify the record's transactions. If a record already exists with a higher version, the delete action for that record will not be executed.
  • policy: The policy to use when deleting the scope of the records:
  • silent (default): If the record/scope doesn't exist, the request completes without an error.
  • mustexist: If the record/scope doesn't exist, an error is reported back in the response for the record.
  • xpath: An xpath in the scope's JSON object for the field to evaluate.
  • test: The comparison operation to perform on the value of the field found by the xpath.
  • value: The value to compare against the value of the field found by the xpath.
 POST transaction/deleteIf/<storage-unit-name>/<optional:scope>
{
  "version": 1445618448133,
  "policy": "silent",
  "test": "EQ", 
  "xpath": "/url", 
  "value": "E:\\LSA\\Foundations_of_Statistical_Natural_Language_Processing.pdf"
}

 

Response

Returns a 200 response code with the statusId to be used by the DeleteIfStatus API call.

 

 {"statusId": "storageUnit"}

 

If the storage unit doesn't exist, a 400 response code with a STORAGE_UNIT_DOESNT_EXIST message is returned.

 

 {"message": "STORAGE_UNIT_DOESNT_EXIST"}

 

Delete If Status

Returns the current status of the delete if processing execution for the storage unit.

Request

The delete if status GET/POST request will return a JSON with the current status of the deleteif processing if it has been executed.

 GET transaction/deleteIfStatus/<storage-unit-name>

Response

A 200 response code is received and the current status with the number of deleted items and/or errors.

 

 {"message":{"status":"complete","deleteCount":1}}

 


  • No labels