Ejemplo n.º 1
0
from flask_restplus import fields
from app.api.restplus import api

event = api.model(
    'Event', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a event'),
        'name':
        fields.String(required=True, description='Event name'),
        'location':
        fields.String(required=True, description='Event location'),
        'start_time':
        fields.DateTime(required=True, description='Event start time'),
        'end_time':
        fields.DateTime(required=True, description='Event end time'),
        'email':
        fields.String(required=True, description='Event contact'),
    })

user = api.model(
    'Event User', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a user'),
        'email':
        fields.String(required=True, description='Email address'),
    })

signup = api.model(
    'Event sign-up', {
Ejemplo n.º 2
0
from flask_restplus import fields
from app.api.restplus import api

logvisit_location = api.model('Visitor\'s last location', {
    'visitor_id': fields.String(readOnly=True, description='a visitor ID (an 8 byte binary string)'),
    'site_id': fields.String(readOnly=True, description='the ID of the website it was tracked for'),
    'location_ip': fields.String(readOnly=True, description='the IP address of the computer that the visit was made from. Can be anonymized'),
    'location_browser_lang': fields.String(readOnly=True, description='a string describing the language used in the visitor\'s browser'),
    'location_country': fields.String(readOnly=True, description='a two character string describing the country the visitor was located in while visiting the site.'),
    'location_region': fields.String(readOnly=True, description='a two character string describing the region of the country the visitor was in.'),
    'location_city': fields.String(readOnly=True, description='a string naming the city the visitor was in while visiting the site.'),
    'location_latitude': fields.Float(readOnly=True, description='the latitude of the visitor while he/she visited the site.'),
    'location_longitude': fields.Float(readOnly=True, description='the longitude of the visitor while he/she visited the site.'),
    'visit_last_action_time': fields.String(readOnly=True, description='time, when visitor\'s last visited the site.'),
})

pagination = api.model('A page of results', {
    'page': fields.Integer(description='Number of this page of results'),
    'pages': fields.Integer(description='Total number of pages of results'),
    'per_page': fields.Integer(description='Number of items per page of results'),
    'total': fields.Integer(description='Total number of results'),
})

page_of_logvisit = api.inherit('Page of Visitors details', pagination, {
    'items': fields.List(fields.Nested(logvisit_location))
})
Ejemplo n.º 3
0
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist

from app.api.restplus import api
from app.models import Application

log = logging.getLogger(__name__)

ns = api.namespace('applications', description='Application')

application = api.model(
    'application', {
        'id':
        fields.Integer(readOnly=True,
                       description='The internal id of the application.'),
        'name':
        fields.String(
            required=True,
            description=
            'The name of the appication represented by the logical id (LID) prefix.'
        )
    })


@ns.route('/')
class ApplicationsList(Resource):
    @api.marshal_list_with(application)
    @api.doc(model=application)
    def get(self):
        """
        Return a list with all applications.
        :return: list_of_applications
Ejemplo n.º 4
0
from flask_restplus import fields
from app.api.restplus import api

credentials = api.model(
    'signup_credentials', {
        'sellerName': fields.String(required=True),
        'password': fields.String(required=True),
        'email': fields.String(required=True),
        'phoneNumber': fields.String(required=True),
        'storeName': fields.String(required=True),
        'address': fields.String(required=True)
    })

login = api.model(
    'login', {
        'phoneNumber': fields.String(readOnly=True),
        'password': fields.String(readOnly=True)
    })

update_seller = api.model(
    'update_seller', {
        'sellerName': fields.String(required=True),
        'password': fields.String(required=True),
        'email': fields.String(required=True),
        'phoneNumber': fields.String(required=True),
        'storeName': fields.String(required=True),
        'address': fields.String(required=True)
    })

new_seller = api.model(
    'new_user', {
Ejemplo n.º 5
0
from flask_restplus import fields
from app.api.restplus import api

blog_post = api.model('Blog post', {
    'id': fields.Integer(readOnly=True, description='The unique identifier of a blog post'),
    'title': fields.String(required=True, description='Article title'),
    'body': fields.String(required=True, description='Article content'),
    'pub_date': fields.DateTime,
    'category_id': fields.Integer(attribute='category.id'),
    'category': fields.String(attribute='category.id'),
})

pagination = api.model('A page of results', {
    'page': fields.Integer(description='Number of this page of results'),
    'pages': fields.Integer(description='Total number of pages of results'),
    'per_page': fields.Integer(description='Number of items per page of results'),
    'total': fields.Integer(description='Total number of results'),
})

page_of_blog_posts = api.inherit('Page of blog posts', pagination, {
    'items': fields.List(fields.Nested(blog_post))
})

category = api.model('Blog category', {
    'id': fields.Integer(readOnly=True, description='The unique identifier of a blog category'),
    'name': fields.String(required=True, description='Category name'),
})

category_with_posts = api.inherit('Blog category with posts', category, {
    'posts': fields.List(fields.Nested(blog_post))
})
Ejemplo n.º 6
0
from flask_restplus import fields
from app.api.restplus import api

order_credentials = api.model('order_credentials', {
    'paymentMode': fields.String(required=True),
    'cartId': fields.List(fields.Integer,required=True),
    'customerId': fields.Integer(required=True),
})

get_orders = api.model('get_orders', {
    'customerId': fields.Integer(required=True)
})
query_request = api.model(
    'Query request', {
        'ids1':
        fields.String(
            required=False,
            example="5111,6996,57697,6815,889,7112,2176,1019,5888,5706",
            description="""A comma delimited list of Entrez gene ids to select.

**Default**: all genes.
"""),
        'ids2':
        fields.String(
            description="""Entrez gene ids to select.

If not given, the query selects any gene related to a gene in ids 1.
If given, the query only selects relations that contain a gene in ids1 and a gene in ids2.

**Default**: all genes.
""",
            required=False,
            example='5111,6996,57697,6815,889,7112,2176,1019,5888,5706'),
        'columns':
        fields.String(
            description="""A comma delimited list of column names to return.

Gene ids are always returned and do not need to be specified. If a column is not present, then an error is returned.

Available columns are provided by `/api/metadata/tables/{table_name}/columns`.

**Default**: all columns.
""",
            required=False,
            example=
            'TCGA_GBM_Correlation,TCGA_GBM_Pvalue,GTEx_Brain_Correlation,GTEx_Brain_Pvalue'
        ),
        'restriction_lt':
        fields.String(description="""
A list of pairs of values `column name,value` with which to restrict the results of the query to rows where the value of the column is less than the given value.
""",
                      example='TCGA_GBM_Pvalue,1.3, GTEx_Brain_Pvalue,1.3'),
        'restriction_gt':
        fields.String(
            description="""
A list of pairs of values `column name,value` with which to restrict the results of the query to rows where the value of the column is greater than the given value.
""",
            required=False,
            example='TCGA_GBM_Correlation,.2, GTEx_Brain_Correlation,.2'),
        'restriction_bool':
        fields.String(description="""
A list of pairs of values `column name,value` with which to restrict the results of the query to rows where the value of the column is True or False.
""",
                      required=False,
                      example='BioGRID_Interaction,True'),
        'restriction_join':
        fields.String(description="""
The type of join made on restrictions.

**Default**: intersect
""",
                      required=False,
                      example='intersect',
                      enum=['intersect', 'union']),
        'limit':
        fields.Integer(description="""
The maximum number of rows to return.

**Default**: 10000
""",
                       required=False,
                       example=10000),
        'table':
        fields.String(description="""
The table to select from.

Available tables are provided by  `/api/metadata/tables`.

**Default**: %s
""" % settings.BIGQUERY_DEFAULT_TABLE,
                      example=settings.BIGQUERY_DEFAULT_TABLE)
    })
Ejemplo n.º 8
0
from flask import Response
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist

from app.api.restplus import api
from app.models import Device

log = logging.getLogger(__name__)

ns = api.namespace('devices', description='Device')

device = api.model('device', {
    'id': fields.Integer(readOnly=True, description='The internal id of the application.'),
    'family': fields.String(required=True, description='The family (e.g.: iOS, Android, Windowss, etc...) of the device.'),
    'brand': fields.String(required=True, description='The brand of the device.'),
    'model': fields.String(required=True, description='The model of the device.'),
    'type': fields.String(required=True, description='The type of the device.'),
    'is_touch_capable': fields.Boolean(required=True, description='Indicates if the device is touch capable.')
})

@ns.route('/')
class DevicesList(Resource):

    @api.marshal_list_with(device)
    def get(self):
        """
        Return a list with all devices.
        :return: list_of_devices
        """
        devices = Device.nodes
        list_of_devices = list(devices)
Ejemplo n.º 9
0
from flask_restplus import fields
from app.api.restplus import api

cart_credentials = api.model(
    'cart_credentials', {
        'customerId': fields.Integer(required=True),
        'itemId': fields.Integer(required=True),
        'quantity': fields.Integer(required=True)
    })

return_cart = api.model('return_cart', {
    'customerId': fields.Integer(required=True),
})
Ejemplo n.º 10
0
from flask_restplus import fields
from app.api.restplus import api

message = api.model("Message",
                    {
                        "user_id": fields.Integer(readOnly=True, description='The user identifier'),
                        "msg_id": fields.Integer(readOnly=True, description='The message unique identifier'),
                        "message": fields.String(required=True, description='The message itself')
                    })
Ejemplo n.º 11
0
from flask_restplus import fields
from app.api.restplus import api

item_credentials = api.model('item_credentials', {
    'name': fields.String(required=True),
    'price': fields.Float(required=True),
    'sellerId': fields.Integer(required=True),
    'itemImage': fields.String(required=True),
    'description' : fields.String(required=True)
})
Ejemplo n.º 12
0
from app.api.restplus import api
from app.models import Environment

log = logging.getLogger(__name__)

ns = api.namespace('environments', description='Environment')

environment = api.model(
    'environment', {
        'id':
        fields.Integer(readOnly=True,
                       description='The internal id of the application.'),
        'server':
        fields.String(
            required=True,
            description='The server where the environment is deployed.'),
        'type':
        fields.String(
            required=True,
            description=
            'The type of the environment (e.g.: OP, ST, MT, or DEMO).')
    })


@ns.route('/')
class EnvironmentsList(Resource):
    @api.marshal_list_with(environment)
    def get(self):
        """
        Return a list with all environemnts.
Ejemplo n.º 13
0
from flask import Response
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist

from app.api.restplus import api
from app.models import Tenant

log = logging.getLogger(__name__)

ns = api.namespace('tenants', description='Tenant')

tenant = api.model(
    'tenant', {
        'id':
        fields.Integer(readOnly=True,
                       description='The internal id of the tenant.'),
        'tenant_id':
        fields.String(required=True, description='The tenant id.'),
    })


@ns.route('/')
class TenantsList(Resource):
    @api.marshal_list_with(tenant)
    def get(self):
        """
        Return a list with all tenants.
        :return: list_of_tenants
        """
        tenants = Tenant.nodes
        list_of_tenants = list(tenants)
Ejemplo n.º 14
0
from flask_restplus import fields
from app.api.restplus import api

add_deals = api.model('add_deals', {
    'itemId': fields.Integer(required=True),
    'description': fields.String(required=True),
    'discount': fields.Float(required=True)
})

get_deals = api.model('get_deals', {
    'itemId': fields.Integer(required=True)
})
Ejemplo n.º 15
0
from flask_restplus import fields
from app.api.restplus import api

vat_return = api.model(
    'VAT return', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a blog post'),
    })

vat_obligation = api.model(
    'VAT obligation', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a blog post'),
    })

vat_liability = api.model(
    'VAT liability', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a blog post'),
    })

organisation = api.model(
    'Organisation', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of an Organisation'),
        'code':
        fields.String(required=True, description='Organisation code'),
Ejemplo n.º 16
0
products = api.model(
    'products',
    {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of an order'),
        # 'order_id': CustomField.OrderID(required=True, description='Product order ID', min_length=5, max_length=5),
        'order_id':
        CustomField.OrderID(description='Product order id'),
        'product_group':
        fields.String(required=True,
                      description='Product group',
                      example='product_group'),
        'product':
        fields.String(
            required=True, description='Product name', example='prod1'),
        'args':
        CustomField.Json(required=True,
                         description='Product arguments in JSON format',
                         example={"foo": "bar"}),
        'request_origin':
        fields.String(
            required=True, description='Request Origin', example='127.0.0.1'),
        'request_callback':
        fields.Url(required=True,
                   description='Request callback url',
                   example='http://origin.com/callback_uri'),
        'created_at':
        fields.DateTime(readOnly=True, description='Product creation date'),
        'updated_at':
        fields.DateTime(readOnly=True, description='product last update date'),
    })
Ejemplo n.º 17
0
#from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist
from werkzeug.exceptions import BadRequest
from quart import Response


from app.api.restplus import api
from app.models import User

log = logging.getLogger(__name__)

ns = api.namespace('users', description='Users')

user = api.model('user', {
    'id': fields.Integer(readOnly=True, description='The internal id of of a user'),
    'user_id': fields.String(required=True, description='The user unique identifier')}
)

@ns.route('/')
@api.response(404, 'Users not found.')
class UsersList(Resource):

    @api.marshal_list_with(user)
    def get(self):
        """
        Returns a list of all users
        :return: list_of_users
        """
        try:
            users = User.nodes
            list_of_users = list(users)
Ejemplo n.º 18
0
from neomodel.core import DoesNotExist

from app.api.restplus import api
from app.models import ApplicationInstance

log = logging.getLogger(__name__)

ns = api.namespace('applications_instances',
                   description='Applications Instances')

application_instance = api.model(
    'applications_instances', {
        'id':
        fields.Integer(readOnly=True,
                       description='The internal id of the application.'),
        'application_id':
        fields.String(
            required=True,
            description=
            'The id of the appication instance represented by the logical id (LID).'
        )
    })


@ns.route('/')
class ApplicationsInstanceList(Resource):
    @api.marshal_list_with(application_instance)
    @api.doc(model=application_instance)
    def get(self):
        """
        Return a list with all applications.
        :return: list_of_applications
Ejemplo n.º 19
0
from flask import Response
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist

from app.api.restplus import api
from app.models import OS

log = logging.getLogger(__name__)

ns = api.namespace('os', description='OS')

os = api.model(
    'os', {
        'id':
        fields.Integer(readOnly=True,
                       description='The internal id of of an OS.'),
        'family':
        fields.String(required=True, description='The family of the OS.'),
        'version':
        fields.String(required=True, description='The version of the OS.')
    })


# TODO - Define endpoints that return sessions that started, ended and timedout in a date/time range, used a given ip address
@ns.route('/')
class SessionsList(Resource):
    @api.marshal_list_with(os)
    def get(self):
        """
        Return a list with all OSs
        :return: list_of_os
        """
Ejemplo n.º 20
0
from flask_restplus import fields
from app.api.restplus import api

entry = api.model(
    'entry', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of an entry'),
        'title':
        fields.String(required=True, description='title'),
        'body':
        fields.String(required=True, description='content')
    })

pagination = api.model(
    'A page of results', {
        'page':
        fields.Integer(description='Number of this page of results'),
        'pages':
        fields.Integer(description='Total number of pages of results'),
        'per_page':
        fields.Integer(description='Number of items per page of results'),
        'total':
        fields.Integer(description='Total number of results'),
    })

page_of_entries = api.inherit('Page of blog entries', pagination,
                              {'items': fields.List(fields.Nested(entry))})
Ejemplo n.º 21
0
from flask import Response
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist

from app.api.restplus import api, base_reponse
from app.models import Session

log = logging.getLogger(__name__)

ns = api.namespace('sessions', description='Sessions')

session = api.model('session',  {
    'id': fields.Integer(readOnly=True, description='The internal id of of a session.'),
    'session_id': fields.String(required=True, description='The session id.'),
    'ip_address': fields.String(required=True, description='A list of IP addresses '
                                                           'used during the session.'),
    'start': fields.DateTime(required=True, description='The date and time when the session '
                                                        'started.'),
    'end': fields.DateTime(required=True, description='The date and time when the session ended.'),
    'timeout': fields.DateTime(required=True, description='The date and time when the session timedout.')
})

# TODO - Define endpoints that return sessions that started, ended and timedout in a date/time range, used a given ip address
@ns.route('/')
class SessionsList(Resource):

    @api.marshal_list_with(session)
    def get(self):
        """
        Return a list with all sessions
        :return: list_of_sessions
        """
Ejemplo n.º 22
0
from flask import Response
from flask_restplus import Resource, fields
from neomodel.core import DoesNotExist
from neomodel import MultipleNodesReturned


from app.api.restplus import api
from app.models import Browser

log = logging.getLogger(__name__)

ns = api.namespace('browsers', description='Browsers')

browser = api.model('browser', {
    'id': fields.Integer(readOnly=True, description='The internal id of the browser.'),
    'type': fields.String(required=True, description='The type of the browser.'),
    'version': fields.String(required=True, description='The version of the browser.')
})

@ns.route('/')
class BrowserList(Resource):

    @api.marshal_list_with(browser)
    def get(self):
        """
        Returns a list with all browsers
        :return: list_of_browsers
        """
        try:
            browsers = Browser.nodes
            list__of_browsers = list(browsers)
Ejemplo n.º 23
0
from flask_restplus import fields, Model, marshal_with
from app.api.restplus import api

# partners - get
get_partners_inner = api.model('Partner\'s List', {
    'id': fields.String(readOnly=True,description='partner\'s ID'),
    'name': fields.String(readOnly=True, description='partner\'s name'),
    'description': fields.String(readOnly=True,description='short description of partner'),
    'type': fields.String(readOnly=True,description='partner\'s type (enum)'),
})

get_partners_serializer = api.model('Get Partners', {
    'partners': fields.Nested(get_partners_inner, description='list of found partner\'s'),
})


# partners - post
post_partners_serializer = api.model('Post Partner', {
    'success': fields.Boolean(readOnly=True,description='Boolean representing the success of post api call'),
})

# partner - put
put_partners_serializer = api.model('Put Partner',{
    'success': fields.Boolean(readOnly=True, description='Boolean representing the success of post api call'),
})


# partner - get
get_partner_crm = api.model('Get Partner\'s CRM', {
    'id': fields.Integer,
    'name': fields.String,
Ejemplo n.º 24
0
Contains endpoints for API
"""
import time
import datetime
import requests
from flask import request
from flask_restplus import Resource, fields
from werkzeug.exceptions import BadRequest
from app.api.restplus import api
from app.api.io_logic import get_sites_from_io, update_sites_in_io

ns_sites = api.namespace('sites', description='Operations with sites')
ns_monitoring = api.namespace('monitoring',
                              description='Monitoring operations')

site = api.model('Site',
                 {'url': fields.String(required=True, description='URL')})

site_update = api.model(
    'Site to update', {
        'url': fields.String(required=True, description='URL'),
        'new_url': fields.String(required=True, description='URL'),
    })

site_status = api.model(
    'Site to monitor', {
        'url': fields.String(required=True, description='URL'),
        'last_status': fields.String(description='Last known status'),
        'last_checked': fields.DateTime(description='Last update'),
    })

Ejemplo n.º 25
0
from flask_restplus import fields
from app.api.restplus import api

signup_credentials = api.model(
    'customer_credentials', {
        'userName': fields.String(required=True),
        'password': fields.String(required=True),
        'email': fields.String(required=True),
        'phoneNumber': fields.String(required=True),
        'shipping': fields.String(),
        'billing': fields.String()
    })

login = api.model(
    'login', {
        'phoneNumber': fields.String(readOnly=True),
        'password': fields.String(readOnly=True)
    })

update_customer = api.model(
    'update_user', {
        'id': fields.Integer,
        'userName': fields.String(),
        'password': fields.String(),
        'email': fields.String(),
        'phoneNumber': fields.String(),
        'shipping': fields.String(),
        'billing': fields.String()
    })

new_user = api.model(