Data storage API endpoint

Table of contents

  1. Fields
  2. List view
  3. Add
  4. Detail
  5. Change
  6. Delete

Fields

FieldDescription
idUUID identificator formatted as a string
namestring [required] [max length: 100]
locationstring describing the location of the data storage
descriptionstring [max length: 500]
is_publicboolean
data_organizationJSON dictionary describing data organization
data_protocolsJSON dictionary describing data access protocols

List view

  • Allowed portals: public, private
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/personal_attributes/datastorage
  • Data: None
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.load('datastorage')

Response example

{'datastorages': [
    {
        'id': '<id>',
        'name': 'Test dataset',
        'location': '/data/test',
        'description': '',
        'is_public': False,
        'data_organization': [],
        'data_protocols': []
    },
    {
        'id': '<id>',
        'name': 'Project data repository',
        'location': '/data/project',
        'description': '',
        'is_public': False,
        'data_organization': [
                {
                    "elements": "Sessions"
                },
                {
                    "elements": "Subjects"
                }
            ],
        'data_protocols': [
                {
                    "protocol": "Dropbox (Cloud solution)",
                    "path": "data/myproject",
                    "is_public": true
                },
                {
                    "protocol": "Local harddrive",
                    "path": "/home/myuser/data/myproject",
                    "is_public": false
                }
            ]
    }
]}

Public list responses also include a meta object (pagination/filter metadata).

Add

  • Allowed portals: private
  • Request method: POST
  • URL: https://www.brainstem.org/api/private/personal_attributes/datastorage
  • Data: JSON dictionary containing at least the required fields.
  • Responses: 201 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.save("datastorage",  data=
    {
        'name': "MyNewRepo",
        'location': '/data/newrepo',
        'data_organization': [
                {
                    "elements": "Sessions"
                },
                {
                    "elements": "Subjects"
                }
            ],
        'data_protocols': [
                {
                    "protocol": "Dropbox (Cloud solution)",
                    "path": "data/myproject",
                    "is_public": True
                },
                {
                    "protocol": "Local harddrive",
                    "path": "/home/myuser/data/myproject",
                    "is_public": False
                }
            ]
    }
)

Response example

{'datastorage': {
    'id': '<id>',
    'name': 'MyNewRepo',
    'location': '/data/newrepo',
    'description': '',
    'is_public': False,
    'data_organization': [
                {
                    "elements": "Sessions"
                },
                {
                    "elements": "Subjects"
                }
            ],
    'data_protocols': [
                {
                    "protocol": "Dropbox (Cloud solution)",
                    "path": "data/myproject",
                    "is_public": true
                },
                {
                    "protocol": "Local harddrive",
                    "path": "/home/myuser/data/myproject",
                    "is_public": false
                }
            ]}
}

Detail

  • Allowed portals: public, private
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/personal_attributes/datastorage/<id>/
  • Data: None
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.load('datastorage', id='<id>')

Response example

{'datastorage': {
    'id': '<id>',
    'name': 'MyNewRepo',
    'location': '/data/newrepo',
    'description': '',
    'is_public': False,
    'data_organization': [
                {
                    "elements": "Sessions"
                },
                {
                    "elements": "Subjects"
                }
            ],
    'data_protocols': [
                {
                    "protocol": "Dropbox (Cloud solution)",
                    "path": "data/myproject",
                    "is_public": true
                },
                {
                    "protocol": "Local harddrive",
                    "path": "/home/myuser/data/myproject",
                    "is_public": false
                }
            ]}
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/personal_attributes/datastorage/<id>/
  • Data: dictionary containing the fields to be updated
  • Responses: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.save("datastorage", id="<id>", data={"description": "new text"})

Response example

{'datastorage': {
    'id': '<id>',
    'name': 'MyNewRepo',
    'location': '/data/newrepo',
    'description': 'new text',
    'is_public': False,
    'data_organization': [
                {
                    "elements": "Sessions"
                },
                {
                    "elements": "Subjects"
                }
            ],
    'data_protocols': [
                {
                    "protocol": "Dropbox (Cloud solution)",
                    "path": "data/myproject",
                    "is_public": true
                },
                {
                    "protocol": "Local harddrive",
                    "path": "/home/myuser/data/myproject",
                    "is_public": false
                }
            ]}
}

Delete

  • Allowed portals: private
  • Request method: DELETE
  • URL: https://www.brainstem.org/api/private/personal_attributes/datastorage/<id>/
  • Data: None
  • Responses: 204 OK; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.delete("datastorage", id="<id>")