Exemplo n.º 1
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database


nssensor = api.namespace('sensors', description='sensors related operations')


sensor_model_post = nssensor.model(
    'Sensor Model Post',
    {
        'name': fields.String,
        'serial_number': fields.String,
        'brand': fields.String,
        'model': fields.String,
        'description': fields.String,
        'type': fields.String(required=True),
        'specifications': fields.Raw,
    })


sensor_model = nssensor.inherit(
    'Sensor Model',
    sensor_model_post,
    {
        'id': fields.Integer
    })

Exemplo n.º 2
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from .datasource import datasource_model
from .posdatasource import posdatasource_model

nssession = api.namespace('sessions',
                          description='sessions related operations')

session_model_post = nssession.model(
    'Session Model Post', {
        'name': fields.String,
        'platform': fields.Integer(required=True),
        'start_time': fields.DateTime(dt_format='iso8601', default=None),
        'end_time': fields.DateTime(dt_format='iso8601', default=None),
        'project': fields.Integer(required=True),
    })

session_model = nssession.inherit('Session Model', session_model_post, {
    'id': fields.Integer,
})


@nssession.route('/', endpoint='sessions')
class AllSessions(Resource):
    @nssession.marshal_with(session_model)
    def get(self):
        '''Get all sessions'''
        return Database.query_asjson("select * from li3ds.session")
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database

nstft = api.namespace('transfotrees',
                      description='transformation trees related operations')

transfotree_model_post = nstft.model(
    'Transformation tree Model Post', {
        'name': fields.String,
        'isdefault': fields.Boolean,
        'sensor_connections': fields.Boolean,
        'owner': fields.String,
        'transfos': fields.List(fields.Integer),
    })

transfotree_model = nstft.inherit('Transformation tree Model',
                                  transfotree_model_post,
                                  {'id': fields.Integer})


@nstft.route('/', endpoint='transfotrees')
class TransfoTree(Resource):
    @nstft.marshal_with(transfotree_model)
    def get(self):
        '''List all transformation trees'''
        return Database.query_asjson("select * from li3ds.transfo_tree")

    @api.secure
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database

nstf = api.namespace('transfos', description='transformations related operations')


transfo_model_post = nstf.model(
    'Transformation Model Post',
    {
        'source': fields.Integer,
        'target': fields.Integer,
        'transfo_type': fields.Integer,
        'description': fields.String,
        'parameters': fields.Raw,
        'tdate': fields.DateTime(dt_format='iso8601'),
        'validity_start': fields.DateTime(dt_format='iso8601'),
        'validity_end': fields.DateTime(dt_format='iso8601'),
    })

transfo_model = nstf.inherit(
    'Transformation Model',
    transfo_model_post,
    {
        'id': fields.Integer
    })


transfotype_model_post = nstf.model(
Exemplo n.º 5
0
# -*- coding: utf-8 -*-
from flask_restplus import fields
from psycopg2.extras import Json

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds import fields as li3ds_fields

nstf = api.namespace('transfos', description='transformations related operations')


transfo_model_post = nstf.model(
    'Transformation Model Post',
    {
        'name': fields.String,
        'source': fields.Integer,
        'target': fields.Integer,
        'transfo_type': fields.Integer,
        'description': fields.String,
        'parameters': fields.List(fields.Raw),
        'parameters_column': fields.String,
        'tdate': li3ds_fields.DateTime(dt_format='iso8601'),
        'validity_start': li3ds_fields.DateTime(dt_format='iso8601'),
        'validity_end': li3ds_fields.DateTime(dt_format='iso8601'),
    })

transfo_model = nstf.inherit(
    'Transformation Model',
    transfo_model_post,
    {
        'id': fields.Integer
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
from flask import request
from flask_restplus import fields
from psycopg2.extensions import AsIs

from api_li3ds.app import api, Resource
from api_li3ds.database import Database

nsitowns = api.namespace('itowns', description='itowns facilities')

image_model = nsitowns.model('Image', {
    'id': fields.Integer,
    'filename': fields.String,
    'exif': fields.Raw
})


@nsitowns.route('/v1/sessions/<int:session_id>/images')
class Images(Resource):
    @nsitowns.response(404, 'Session not found')
    def get(self, session_id):
        '''List all images in a given session with their location'''
        # get project name
        res = Database.query(
            """
            select p.id, p.name from li3ds.project p
            join li3ds.session s on s.project = p.id
            where s.id = %s
            """, (session_id, ))

        if not res:
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds import fields as li3ds_fields

nsrf = api.namespace('referentials', description='referentials related operations')

referential_model_post = nsrf.model(
    'Referential Model Post',
    {
        'name': fields.String,
        'description': fields.String,
        'srid': fields.Integer,
        'sensor': fields.Integer,
    })

referential_model = nsrf.inherit(
    'Referential Model',
    referential_model_post,
    {
        'id': fields.Integer
    })


transfo_model = nsrf.model(
    'Transfo Model',
    {
        'id': fields.Integer,
        'source': fields.Integer,
Exemplo n.º 8
0
# -*- coding: utf-8 -*-
from flask import make_response
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds import dot
from api_li3ds import fields as li3ds_fields

from .sensor import sensor_model

nspfm = api.namespace('platforms', description='platforms related operations')

platform_model_post = nspfm.model(
    'Platform Model Post',
    {
        'name': fields.String,
        'description': fields.String,
        'start_time': li3ds_fields.DateTime(dt_format='iso8601', default=None),
        'end_time': li3ds_fields.DateTime(dt_format='iso8601', default=None),
    })

platform_model = nspfm.inherit(
    'Platform Model',
    platform_model_post,
    {
        'id': fields.Integer
    })

platform_config_post = nspfm.model(
    'Platform Config Post',
Exemplo n.º 9
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database


nsds = api.namespace('datasources', description='datasources related operations')

datasource_model_post = nsds.model('Datasource Model Post', {
    'uri': fields.String,
    'referential': fields.Integer(required=True),
    'session': fields.Integer(required=True)
})


datasource_model = nsds.inherit('Datasource Model', datasource_model_post, {
    'id': fields.Integer,
})

processing_model_post = nsds.model('Processing Model Post', {
    'launched': fields.DateTime(dt_format='iso8601', default=None),
    'tool': fields.String(required=True),
    'description': fields.String,
    'source': fields.Integer(required=True),
})

processing_model = nsds.inherit('Processing Model', processing_model_post, {
    'id': fields.Integer,
    'target': fields.Integer(required=True)
})
Exemplo n.º 10
0
# -*- coding: utf-8 -*-
from flask_restplus import fields
from psycopg2 import sql

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds.exc import abort


nsfpc = api.namespace(
    'foreignpc',
    description='foreign objects used for pointcloud data')


foreignpc_table_model = nsfpc.model(
    'foreign table creation',
    {
        'table': fields.String(required=True),
        'server': fields.String(required=True),
        'options': fields.Raw(),
        'srid': fields.Integer(required=True, default=0)
    })


foreignpc_server_model = nsfpc.model(
    'foreign server creation',
    {
        'name': fields.String(description='name for the foreign server'),
        'options': fields.Raw(description='foreign server creation options'),
        'driver': fields.String(required=True)
    })
Exemplo n.º 11
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database

nsrf = api.namespace('referentials', description='referentials related operations')

referential_model_post = nsrf.model(
    'Referential Model Post',
    {
        'name': fields.String,
        'description': fields.String,
        'srid': fields.Integer,
        'root': fields.Boolean,
        'sensor': fields.Integer,
    })

referential_model = nsrf.inherit(
    'Referential Model',
    referential_model_post,
    {
        'id': fields.Integer
    })


transfo_model = nsrf.model(
    'Transfo Model',
    {
        'id': fields.Integer,
        'source': fields.Integer,
Exemplo n.º 12
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.database import Database
from api_li3ds.app import api, Resource, defaultpayload
from .session import session_model


nsproject = api.namespace('projects', description='projects related operations')


class GeometryInput(fields.String):
    __schema_format__ = 'geometry_string'
    __schema_example__ = 'srid=4326;polygon((1 1, 2 2, 3 3, 1 1))'


class GeometryOutput(fields.String):
    __schema_format__ = 'geometry_wkb'
    __schema_example__ = '01030000...'


project_model_post = nsproject.model('Project Model Post', {
    'name': fields.String,
    'extent': GeometryInput(default=None),
    'timezone': fields.String(default="Europe/Paris")
})

project_model = nsproject.inherit('Project Model', project_model_post, {
    'id': fields.Integer(description='the unique project identifier'),
    'extent': GeometryOutput
})
Exemplo n.º 13
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds import fields as li3ds_fields
from .datasource import datasource_model

nssession = api.namespace('sessions', description='sessions related operations')

session_model_post = nssession.model('Session Model Post', {
    'name': fields.String,
    'platform': fields.Integer(required=True),
    'start_time': li3ds_fields.DateTime(dt_format='iso8601', default=None),
    'end_time': li3ds_fields.DateTime(dt_format='iso8601', default=None),
    'project': fields.Integer(required=True),
})


session_model = nssession.inherit('Session Model', session_model_post, {
    'id': fields.Integer,
})


@nssession.route('/', endpoint='sessions')
class AllSessions(Resource):

    @nssession.marshal_with(session_model)
    def get(self):
        '''Get all sessions'''
        return Database.query_asjson("select * from li3ds.session")
Exemplo n.º 14
0
# -*- coding: utf-8 -*-
from flask import make_response
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database
from api_li3ds import dot

nstft = api.namespace('transfotrees', description='transformation trees related operations')

transfotree_model_post = nstft.model(
    'Transformation tree Model Post',
    {
        'name': fields.String,
        'owner': fields.String,
        'transfos': fields.List(fields.Integer),
    })

transfotree_model = nstft.inherit(
    'Transformation tree Model',
    transfotree_model_post,
    {
        'id': fields.Integer
    })


@nstft.route('/', endpoint='transfotrees')
class TransfoTree(Resource):

    @nstft.marshal_with(transfotree_model)
    def get(self):
Exemplo n.º 15
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database


nspds = api.namespace('posdatasources', description='positional datasources related operations')

posdatasource_model_post = nspds.model('Posdatasource Model Post', {
    'uri': fields.String,
    'referential': fields.Integer(required=True),
    'version': fields.Integer,
    'session': fields.Integer(required=True)
})


posdatasource_model = nspds.inherit('Posdatasource Model', posdatasource_model_post, {
    'id': fields.Integer,
})

posprocessing_model_post = nspds.model('PosProcessing Model Post', {
    'launched': fields.DateTime(dt_format='iso8601', default=None),
    'tool': fields.String(required=True),
    'description': fields.String,
    'source': fields.Integer(required=True),
})

posprocessing_model = nspds.inherit('PosProcessing Model', posprocessing_model_post, {
    'id': fields.Integer,
    'target': fields.Integer(required=True)
Exemplo n.º 16
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.app import api, Resource, defaultpayload
from api_li3ds.database import Database

nssensor = api.namespace('sensors', description='sensors related operations')

sensor_model_post = nssensor.model(
    'Sensor Model Post', {
        'serial_number': fields.String,
        'short_name': fields.String,
        'brand': fields.String,
        'model': fields.String,
        'description': fields.String,
        'type': fields.String(required=True),
        'specifications': fields.Raw,
    })

sensor_model = nssensor.inherit('Sensor Model', sensor_model_post,
                                {'id': fields.Integer})


@nssensor.route('/', endpoint='sensors')
class Sensors(Resource):
    @nssensor.marshal_with(sensor_model)
    def get(self):
        '''List sensors'''
        return Database.query_asjson("select * from li3ds.sensor")

    @api.secure
Exemplo n.º 17
0
# -*- coding: utf-8 -*-
from flask_restplus import fields

from api_li3ds.database import Database
from api_li3ds.app import api, Resource, defaultpayload
from .session import session_model


nsproject = api.namespace('projects', description='projects related operations')


class GeometryInput(fields.String):
    __schema_format__ = 'geometry_string'
    __schema_example__ = 'srid=4326;polygon((1 1, 2 2, 3 3, 1 1))'


class GeometryOutput(fields.String):
    __schema_format__ = 'geometry_wkb'
    __schema_example__ = '01030000...'


project_model_post = nsproject.model('Project Model Post', {
    'name': fields.String,
    'extent': GeometryInput(default=None),
    'timezone': fields.String(default="Europe/Paris")
})

project_model = nsproject.inherit('Project Model', project_model_post, {
    'id': fields.Integer(description='the unique project identifier'),
    'extent': GeometryOutput
})