-
Notifications
You must be signed in to change notification settings - Fork 6
REST API
Uploading data does not require authentication, but to query data, you have to submit a username and password.
In PowerShell, you can store the cedentials in a variable (e.g. "$cred")
$cred = Get-Credential
of if you want to send the password directly from script:
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "DEMO",(ConvertTo-SecureString "password" -AsPlainText -Force)
Upload a new or existing object where {Id} is the identifier of the object.
http://{URL}/upload/{Id}
Return value is the hash of the uploaded Object.
PowerShell example ($id is the Identifier and $con is the JSON string):
Invoke-RestMethod -Uri "http://localhost:5000/upload/$($id)" -Method Post -Body $con -ContentType "application/json; charset=utf-8"
Upload a new or existing object where {Id} is the identifier of the object.
Note: XML will be converted into JSON.
http://{URL}/uploadxml/{Id}
Return value is the hash of the uploaded Object.
Resolves the Blockchain with all hashed values and returns the full object in JSON Format.
http://{URL}/full?id={Id}[&index={revision}] -Credential $cred
http://{URL}/full?{lookupId}={LookupValue}[&index={revision}] -Credential $cred
Example:
http://server/full?name=NUC1&index=1 -Credential $cred
http://{URL}/diff?id={Id}[&index={revision}]|[&lindex={left revision}&rindex={right revision}] -Credential $cred
http://{URL}/diff?{lookupId}={LookupValue}[&index={revision}][&mode=0¦1] -Credential $cred
Diff Modes: Mode 0 returns the full object; Mode 1 returns in jsondiffpatch format
Example:
http://server/diff?name=NUC1&index=1 -Credential $cred
http://{URL}/diffvis?id={Id}[&index={revision}]|[&lindex={left revision}&rindex={right revision}] -Credential $cred
http://{URL}/diffvis?{lookupId}={LookupValue}[&index={revision}]|[&lindex={left revision}&rindex={right revision}] -Credential $cred
Example:
http://server/diffvis?name=NUC1 -Credential $cred
Get all Objects from the latest block in the chain. Use a JSONPath to filter the result.
http://{URL}/query?[JSONPath,..][&$select={KeyName,..}][&$exclude={KeyName,..}][&$where={filter}] -Credential $cred
Example:
http://{URL}/query?OS&$select=%23Name,_date&$exclude=$..MUILanguages&$where=OS.BuildNumber==17134 -Credential $cred
New: JSONPath ending with '[]' will convert result to an array: Example:
http://{URL}/query?LogicalDisk[]
will convert LogicalDisk result into an array.
Get all Objects from all blocks in the chain. Use a JSONPath to filter the result.
http://{URL}/queryall?[JSONPath,..][&$select={KeyName,..}][&$exclude={KeyName,..}] -Credential $cred
Example:
http://{URL}/queryall?OS.Caption,OS.Version&$select=%23Name,_date -Credential $cred
Note: Query all blocks may take a long time to process.
http://{URL}/search?{free text}&$select=%23Name -Credential $cred
Get all index,timestamp and hashid for a specific device.
http://{URL}/history?id={Id}[&index={revision}] -Credential $cred
http://{URL}/history?{lookupId}={LookupValue} -Credential $cred
Get all Objects that have changed within a specifc timespan (default 24h).
Changetyp: 0 = new; 1 = update; -1 = all
The Timespan Format is separated by '-'. e.g "1-05-00-00" = 1day 5Hours
http://localhost:5000/changes?[age={timespan}][&changetype=-1|0|1] -Credential $cred
Example:
Get only new Objects created within the last 5h
http://localhost:5000/changes?age=5-00-00&changetype=0 -Credential $cred
PowerShell to get all modified objects from the last 10 hours
(Invoke-WebRequest -Uri "http://localhost:5000/changes?age=10-0-0&changetype=1" -Credential $cred).Content | ConvertFrom-Json
Eports all blocks of all blockchains and upload to another JainDB. This is required if something does change on the blockchain logic or if you want to change the hash algorythm etc.
http://{URL}/export?url={URL encoded target URL}[&remove={Jpath;Jpath}] -Credential $cred
To remove objects during export, the "remove" option can be used to specify a JPath of an Object or Attribute.
Convert an XML Object into JSON and return the JSON without uploading to the blockchain.
http://{URL}/xml2json
This function is for testing/validation only. It compares the data stored in the blockchain with the cached full data and returns "true" if the hash is the same or "false" if they are different.
http://{URL}/validate?id={Id} -Credential $cred