Managing Data Stores

The Get Data Stores API
Using the Get Data Stores API, you can view the list of data stores in a system.
METHOD GET
URI
https://<NLB DNS:9090>/historian-rest-api/v1/datastores?dataStoreMask=
SAMPLE QUERY PARAM GET URL
https://<NLB DNS:9090>/historian-rest-api/v1/datastores?dataStoreMask=*
SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null,

    "Data": [

        {

            "Description": "The System Data Store.",

            "Id": "D3C23639-81CD-40F7-9CB0-37484FC5190D",

            "IsDefault": false,

            "IsSystem": true,

            "Name": "System",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "System Storage",

            "StorageType": 0,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/System"

                }

            ]

        },

        {

            "Description": "The Scada Buffer Data Store.",

            "Id": "39B39D42-DC7A-4048-9BA8-E4BAB4644B0C",

            "IsDefault": false,

            "IsSystem": false,

            "Name": "ScadaBuffer",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 1,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/ScadaBuffer"

                }

            ]

        },

        {

            "Description": "The DHS System Data Store.",

            "Id": "56C1DFE9-D0BF-427F-B5D8-B127E38B5C11",

            "IsDefault": false,

            "IsSystem": false,

            "Name": "DHSSystem",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 0,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/DHSSystem"

                }

            ]

        },

        {

            "Description": "The User Data Store.",

            "Id": "33BA016D-B005-4702-96DB-42CF7238C8FF",

            "IsDefault": true,

            "IsSystem": false,

            "Name": "User",

            "NumberOfTags": 5,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 0,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/User"

                }

            ]

        }

    ]

}

   }

}
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -H "Authorization: Bearer <TOKEN>” 
https://<NLB DNS:9090>/historian-rest-api/v1/datastores?dataStoreMask=*
Table 1. Query Parameters
Parameter Description Required? Values
dataStoreMask The value of the data store mask. No String
Table 2. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.
The Get Data Stores of Storage API
Using the Get Data Stores of Storage API, you can view the list of data stores in a location.
METHOD GET
URI
https://<NLB DNS:9090>/historian-rest-api/v1/storage/datastores?storageName=
SAMPLE QUERY PARAM GET URL
https://<NLB DNS:9090>/historian-resr-api/v1/storage/datastores?storageName=xx
SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null,

    "Data": [

        {

            "Description": "The Scada Buffer Data Store.",

            "Id": "39B39D42-DC7A-4048-9BA8-E4BAB4644B0C",

            "IsDefault": false,

            "IsSystem": false,

            "Name": "ScadaBuffer",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 1,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/ScadaBuffer"

                }

            ]

        },

        {

            "Description": "The DHS System Data Store.",

            "Id": "56C1DFE9-D0BF-427F-B5D8-B127E38B5C11",

            "IsDefault": false,

            "IsSystem": false,

            "Name": "DHSSystem",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 0,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/DHSSystem"

                }

            ]

        },

        {

            "Description": "The User Data Store.",

            "Id": "33BA016D-B005-4702-96DB-42CF7238C8FF",

            "IsDefault": true,

            "IsSystem": false,

            "Name": "User",

            "NumberOfTags": 5,

            "State": 2,

            "DHSStorageName": "xyz",

            "StorageType": 0,

            "Links": [

                {

                    "Rel": "self",

                    "Href": "/datastore/User"

                }

            ]

        }

    ]

}
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -H "Authorization: Bearer <TOKEN>” 
https://<NLB DNS:9090>/historian-rest-api/v1/storage/datastores?storageName=xx
Table 3. Query Parameters
Parameter Description Required? Values
storageName The name of the location whose data stores you want to view. Yes String
Table 4. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.
The Add Datastore API
Using the Add Datastore API, you can create a data store in a Historian server.
Note: This API is applicable only to an Enterprise Historian.
METHOD POST
URI
https://<NLB DNS:9090>/historian-rest-api/v1/datastoretostorage
SAMPLE PATH PARAM GET URI
https://<NLB DNS:9090>/historian-rest-api/v1/datastoretostorage

Payload

{

"dataStoreName": "abc",

"storageName": "storage1",

"description": "test",

"isDefault": true

}
SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null

}
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -i -H "Content-Type: application/json"
-H "Authorization: Bearer <TOKEN>” -d “{ \”dataStoreName \”:\”name\”,\" storageName \": \"sname\",\"description 
\":\" des\",\" isDefault \":false}” 
-X POST https://<NLB DNS:9090>/historian-rest-api/v1/datastoretostorage
Table 5. Query Parameters
Parameter Description Required? Values
Payload Contains the details of the data store in the JSON format. Yes Multiple
Table 6. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.
The Delete Data Store API
Using the Delete Data Store API, you can delete a data store.
METHOD DELETE
URI
https://<NLB DNS:9090>/historian-rest-api/v1/datastore
SAMPLE URI
https://<NLB DNS:9090>/historian-rest-api/v1/datastore

Payload

{

"dataStoreName": "testdatastore"

}
SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null

}
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -i -H "Content-Type: application/json"
-H "Authorization: Bearer <TOKEN>” -d “{ \”dataStoreName \”:\”name\”}” -X DELETE
https://<NLB DNS:9090>/historian-rest-api/v1/datastore
Table 7. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.
The Data Store Update API
Using the Data Store Update API, you can modify a data store.
METHOD PUT
URI
https://<NLB DNS:9090>/historian-rest-api/v1/dataStore/<data store name>
SAMPLE URI
https://<NLB DNS:9090>/historian-rest-api/v1/dataStore/mirror1DS1
Payload

{

            "Description": "testing",

            "IsDefault": true,

            "IsSystem": false,

            "Name": "mirror1DS1",

            "NumberOfTags": 0,

            "State": 2,

            "DHSStorageName": "mirror1",

            "StorageType": 0,

        }
SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null

}
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -i -H "Content-Type: application/json"
-H "Authorization: Bearer <TOKEN>” -d “{ \” Description\”:\”des\”,\"IsDefault \": true,
\” IsSystem \”:false, \” Name\”:\” mirror1DS1\”,\”NumberOfTags \”:0,\”State\”:2,
\”DHSStorageName\”:\”mirror1\”,\”StorageType \”:0,\}” -X PUT https://<NLB DNS:9090>/historian-rest-api/v1/dataStore/mirror1DS1
Table 8. Query Parameters
Parameter Description Required? Values
Payload Contains the values of the attributes of the data store that you want to change. Yes Multiple
Table 9. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.
The Default Data Store Update API
Using the Default Data Store Update API, you can change the default data store.
METHOD PUT
URI
https://<NLB DNS:9090>/historian-rest-api/v1/storage/<location name>
SAMPLE URI
https://<NLB DNS:9090>/historian-rest-api/v1/storage/NPI212611749M1

Payload

{

            "StorageName": "NPI212611749M1",

            "StorageType": 0,

            "NumberOfDataStores": 5,

            "NumberOfArchivers": 1,

            "DataStores": [

                "User",

                "testDS1",

                "ScadaBuffer",

                "testDS2",

                "DHSSystem"

            ],

            "Id": "9CD06AFB-1566-4CE6-99D4-B2F65857F33A",

            "IsDefault": true,

            "LastModifiedUser": null,

            "LastModifiedTime": "1970-01-01T00:00:00.000Z",

            "ArchiverServices": [                

             "DataArchiver_NPI212611749M1", "DataArchiver_distamchine1"

            ]

        }

SAMPLE RESPONSE
{

    "ErrorCode": 0,

    "ErrorMessage": null,

   }
SAMPLE cURL COMMAND
curl -i -H "Accept: application/json" -i -H "Content-Type: application/json"
-H "Authorization: Bearer <TOKEN>” -d “{ \”StorageName\”:\”name\”,\"StorageType\": 0,
\”NumberOfDataStores\”:5,\” NumberOfArchivers\”:1,

\”IsDefault\”:true,\”ArchiverServices\”: [\"DataArchiver_NPI212611749M1\", 
\"DataArchiver_distamchine1"\"]}” -X PUT 
https://<NLB DNS:9090>/historian-rest-api/v1/storage/NPI212611749M1
Table 10. Query Parameters
Parameter Description Required? Values
Payload Contains the values of the attributes of the default data store that you want to change. Yes Multiple
Table 11. Response Parameters
Parameter Data Type Required? Description
ErrorCode Integer Yes For example, ErrorCode = 0 implies the operation was successful.
ErrorMessage String Yes For example, NULL.