NOTE: Trivore ID Documentation has moved to https://trivoreid.com

The content on this site IS OUT OF DATE!

This space has been archived!

Please go ahead to the new site!

Data Storage Service (python)

Wrapper for the '/datastorage' API. Each datastorage can contain data with the custom fields.

List of all options:

  • Get all
  • Create/get one/update/delete data storage
  • Get and update data from datastorage

Data storage management

from trivoreid.utils.criteria import Filter
from trivoreid.models.datastorage import DataStorage

ds_to_create = DataStorage()
ds_to_create.name = 'test name'
ds_to_create.description = 'example'

datastorage = api.datastorage_service.create(ds_to_create)
print('\nCreated dada storage fields : {}\nData : {}\n'.format(datastorage.serialize(), ds_created.data))

datastorage.description = 'modified'
datastorage.data = {
'testData' : 1,
'testData2' : 'test value'
}

ds_updated = api.datastorage_service.update(datastorage)
data = api.datastorage_service.get_data(ds_updated.id)
print('\nModified dada storage fields : {}\nData : {}\n'.format(ds_updated.serialize(), data))

data_filter = Filter().and_filters(
Filter(Filter.LESS_THAN, 'testData', 2),
Filter(Filter.CONTAINS, 'testData2', 'test')
)
datastorage_filter = Filter(Filter.CONTAINS, 'description', 'modified')

ds = api.datastorage_service.(dsfilter=datastorage_filter,datafilter=data_filter).resources

api.datastorage_service.delete(ds[0].id)
 Output
INFO:root:Successfully created datastorage with id exampleId

Created dada storage fields : 
{'id': 'exampleId',
 'description': 'example',
 'owner_id': 'exampleOwnerId',
 'name': 'test name',
 'readAccess': ['exampleOwnerId'],
 'writeAccess': ['exampleOwnerId'],
 'adminAccess': ['exampleOwnerId'],
 'size': None}

Data :

INFO:root:Successfully modified datastorage with id exampleId
INFO:root:Successfully updated the data in the datastorage

{'id': 'exampleId',
 'description': 'modified',
 'owner_id': 'exampleOwnerId',
 'name': 'test name',
 'readAccess': ['exampleOwnerId'],
 'writeAccess': ['exampleOwnerId'],
 'adminAccess': ['exampleOwnerId'],
 'size': None}

Data:{'testData': 1, 'testData2': 'test value'}

INFO:root:Found 1 datastorages

INFO:root:Deleted datastorage with id exampleId

Data Storage Service Models

/wiki/spaces/TISpubdoc/pages/20515247

NOTE: Trivore ID Documentation has moved to https://trivoreid.com

The content on this site IS OUT OF DATE!

This space has been archived!