def __init__(self, app, server):
# NetServer
self.server = server
# Set the version
self.version = 1.0
# Initialise the API
self.api = Api(app, prefix='/api/v' + str(self.version))
# Setup routing
self.resources = {
# System endpoint
'/system': RestSystem,
# Device endpoints
'/device/<int:deveui>': RestDevice,
'/devices': RestDevices,
# Application endpoints
'/app/<int:appeui>': RestApplication,
'/apps': RestApplications,
# Gateway endpoints
'/gateway/<host>': RestGateway,
'/gateways': RestGateways,
# Application interface endpoints
'/interface/<appinterface_id>': RestAppInterface,
'/interfaces': RestAppInterfaces,
# Application property endpoints
'/property/<int:appeui>': RestAppProperty,
'/propertys': RestAppPropertys
}
kwargs = {'restapi': self, 'server': self.server}
for path,klass in self.resources.iteritems():
self.api.add_resource(klass, path, resource_class_kwargs=kwargs)
评论列表
文章目录