logger = logging.getLogger(__name__) base_blueprint = Blueprint("base_model_view", __name__) api = Api( app=base_blueprint, title="Gordo Base Model View API Docs", version=__version__, description="Documentation for the Gordo ML Server", default_label="Gordo Endpoints", ) # POST type declarations API_MODEL_INPUT_POST = api.model("Prediction - Multiple Samples", {"X": fields.List(fields.List(fields.Float))}) API_MODEL_OUTPUT_POST = api.model( "Prediction - Output from POST", {"output": fields.List(fields.List(fields.Float))}) _tags = { fields.String: fields.Float } # tags of single prediction record {'tag-name': tag-value} _single_prediction_record = { "start": fields.DateTime, "end": fields.DateTime, "tags": fields.Nested(_tags), "total_abnormality": fields.Float, } class BaseModelView(Resource):
fields.Boolean( readOnly=True, description= 'Weather the image is the first one of the annotation process.'), 'isLast': fields.Boolean( readOnly=True, description= 'Weather the image is the last one of the annotation process.'), 'isLast': fields.Boolean( readOnly=True, description= 'Weather the image is the last one of the annotation process.'), 'labelIds': fields.List(fields.Integer(readOnly=True, description='Label id.'), description='All label ids which belongs to this image.'), 'isJunk': fields.Boolean( readOnly=True, description='Indicates if the image was marked as Junk.'), }) bbox_data = api.model( 'BBox Data', { 'x': fields.Float(readOnly=True, description='Relative and centered value of x.'), 'y': fields.Float(readOnly=True, description='Relative and centered value of y.'), 'w':
from app.nris.models.inspected_location_type import InspectedLocationType from app.nris.models.document import DOCUMENT_RESPONSE_MODEL from app.nris.models.location import LOCATION_RESPONSE_MODEL from app.nris.models.order_advisory_detail import ADVISORY_DETAILS_RESPONSE_MODEL from app.nris.models.order_request_detail import REQUEST_DETAILS_RESPONSE_MODEL from app.nris.models.order_stop_detail import STOP_DETAILS_RESPONSE_MODEL from app.nris.models.order_warning_detail import WARNING_DETAILS_RESPONSE_MODEL INSPECTED_LOCATION_RESPONSE_MODEL = api.model( 'inspected_location', { 'inspected_location_type': fields.String, 'location': fields.Nested(LOCATION_RESPONSE_MODEL), 'documents': fields.List(fields.Nested(DOCUMENT_RESPONSE_MODEL)), 'advisory_details': fields.List(fields.Nested(ADVISORY_DETAILS_RESPONSE_MODEL)), 'request_details': fields.List(fields.Nested(REQUEST_DETAILS_RESPONSE_MODEL)), 'stop_details': fields.List(fields.Nested(STOP_DETAILS_RESPONSE_MODEL)), 'warning_details': fields.List(fields.Nested(WARNING_DETAILS_RESPONSE_MODEL)), }) class InspectedLocation(Base): __tablename__ = "inspected_location" inspected_location_id = db.Column(db.Integer, primary_key=True) inspection_id = db.Column(db.Integer,
'mobile_number': fields.String(required=False, description='Mobile Number'), 'gender': fields.String(required=False, description='Gender'), 'cust_no': fields.String(required=True, description='Customer Number'), 'country_of_birth': fields.String(required=False, description='Country of Birth'), 'country_of_residence': fields.String(required=False, description='Country of ' 'Residence'), 'customer_segment': fields.String(required=False, description='Customer Segment'), 'addresses': fields.List(cls_or_instance=fields.Nested(address_model), required=False, description='Address') }) parser = ns.parser() parser.add_argument("cust_no", type=str, required=True, help='cust_no', location='form') @ns.route("/customer") class Customer(Resource): @ns.expect(customer_model, validate=True) def post(self, **kwargs):
'current_index': fields.Integer(), 'keyspace': fields.Integer(), 'hc_keyspace': fields.Integer(), 'progress': fields.Float(required=False) }) hash_model = api.model( 'Hash', { 'hashText': fields.String(), 'password': fields.String(), 'time_cracked': fields.DateTime() }) page_of_packages_model = api.inherit( 'Page of packages', pagination, {'items': fields.List(fields.Nested(package_short_model))}) page_of_jobs_model = api.inherit( 'Page of jobs', pagination, {'items': fields.List(fields.Nested(job_model))}) verifyHash_model = api.model( 'Verified hash', { 'hash': fields.String(required=True, description='Hash ktory sa overoval'), 'result': fields.String(required=True, description='Ak ma hash spravny format tak OK'), 'isInCache': fields.Boolean() })
@api.route('/endpoints') class Endpoints(Resource): def get(self): """ List our endpoints. """ endpoints = sorted(rule.rule for rule in api.app.url_map.iter_rules()) return {"Available endpoints": endpoints} group_fields = api.model("group", { "group_name": fields.String, "num_of_agents": fields.Integer, "color": fields.String, "group_actions": fields.List(fields.String), }) # env_width/height must be >0 when adding agents create_model_spec = api.model("model_specification", { "model_name": fields.String("Enter model name."), "env_width": fields.Integer("Enter environment width."), "env_height": fields.Integer("Enter environment height."), "groups": fields.List(fields.Nested(group_fields)), }) @api.route('/model_creator') class ModelCreator(Resource): def get(self): """
"""Path to model directory.""" _MODEL: keras.Model = None """Keras model.""" app = Flask(__name__) probe_ns = Namespace('probe', description="Health checks.") model_ns = Namespace('model', description="Model namespace.") model_input = model_ns.model( 'Input', { 'instances': fields.List( fields.List(fields.Float), required=True, description="Model input instances. Tensor of shape (N, 13)", example=json.loads( Path(_ACCELEROMETER_DATA_PATH, 'examples/example_instance.json').read_text()), ), 'signature': fields.String(required=True, default="serving_default", description="Signature to be returned my model.", example="serving_default") }) model_ns.add_model('model_input', model_input) @probe_ns.route('/liveness') class Liveness(Resource):
# Request Parsers users_parser = reqparse.RequestParser() # users_parser.add_argument('username', type=str, help='Username is required', required=True) users_parser.add_argument('username', type=str, help='Username is required') # Models for swagger registration_model = api.model( 'User registration', { 'username': fields.String(required=True), 'email': fields.String(required=True), 'password': fields.String(required=True), 'is_refugee': fields.Boolean }) user_login_model = api.model( 'User login model', { 'username': fields.String(required=True), 'password': fields.String(required=True), 'remember_me': fields.Boolean }) profile_model = api.model( 'User profile', { 'full_name': fields.String, 'email': fields.String, 'password': fields.String, 'description': fields.String, 'address': fields.String, 'phone_number': fields.String, 'tags': fields.List(fields.Integer, description='List containing tags Id') })
), } details_model = { 'app_id': fields.String( title='App ID', description='App package name', example='com.android.chrome', readOnly=True, ), 'category': fields.List( fields.String( title='Category', description='App category on Play Store', example='COMMUNICATION', readOnly=True, ), ), 'content_rating': fields.List( fields.String( title='Content rating', description='App content rating assigned on Play Store', example='Everyone', readOnly=True, ), ), 'description': fields.String( title='Description', description='App description on Play Store',
celerytask.arl_task.delay(options=options) ret_data = { "domain": ",".join(add_domain_list), "scope_id": scope_id, "domain_in_scope": ",".join(domain_in_scope_list) } if len(add_domain_list) == 0: return utils.build_ret(ErrorMsg.DomainNotFoundNotInScope, ret_data) return utils.build_ret(ErrorMsg.Success, ret_data) delete_domain_fields = ns.model( 'deleteAssetDomain', {'_id': fields.List(fields.String(required=True, description="数据_id"))}) @ns.route('/delete/') class DeleteARLAssetDomain(ARLResource): @auth @ns.expect(delete_domain_fields) def post(self): """ 删除资产组中的域名 """ args = self.parse_args(delete_domain_fields) id_list = args.pop('_id', "") for _id in id_list: query = {'_id': ObjectId(_id)} utils.conn_db('asset_domain').delete_one(query)
def getTypeModel(flaskRestPlusAPI, typeName): if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/ARAutoInv/V1:ARAutoInvEBOTypeV1': return flaskRestPlusAPI.model( 'ARAutoInvEBOTypeV1', { #Element ORG_ID has a type that is not catered for (xsd:decimal) 0 'BATCH_SOURCE_NAME': fields.String(default='', description=''), 'Lookups': fields.Nested( flaskRestPlusAPI.model( 'InlineLookupsType', { 'INTERFACE_LINE': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/ARAutoInv/V1:ATTTYPEV1' )), 'REF_LINE': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/ARAutoInv/V1:ATTTYPEV1' )), 'HDR': fields.Nested( getTypeModel( flaskRestPlusAPI, 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/ARAutoInv/V1:ATTTYPEV1' )), })), 'ORIG_SYS_BATCH_NAME': fields.String(default='', description=''), 'LINES_TBL': fields.Nested( flaskRestPlusAPI.model( 'InlineLINES_TBLType', { 'Line': fields.List( fields.Nested( flaskRestPlusAPI.model( 'InlineLineType', { #Element INTERFACE_LINE_CONTEXT has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT1 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT2 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT3 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT4 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT5 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT6 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT7 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT8 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT9 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT10 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT11 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT12 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT13 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT14 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT15 has a type that is not catered for () 0 #Element SET_OF_BOOKS_ID has a type that is not catered for (xsd:decimal) 0 #Element LINE_TYPE has a type that is not catered for () 0 #Element DESC has a type that is not catered for () 0 #Element CURRENCY_CODE has a type that is not catered for () 0 #Element AMOUNT has a type that is not catered for (xsd:decimal) 0 #Element CUST_TRX_TYPE_NAME has a type that is not catered for () 0 #Element TERM_NAME has a type that is not catered for () 0 #Element ORIG_SYS_BILL_CUST_ID has a type that is not catered for (xsd:decimal) 0 #Element ORIG_SYS_BILL_ADDRESS_ID has a type that is not catered for (xsd:decimal) 0 #Element ORIG_SYS_BILL_CONTACT_ID has a type that is not catered for (xsd:decimal) 0 #Element CONVERSION_TYPE has a type that is not catered for () 0 #Element CONVERSION_DATE has a type that is not catered for (xsd:dateTime) 0 #Element CONVERSION_RATE has a type that is not catered for (xsd:decimal) 0 #Element TRX_DATE has a type that is not catered for (xsd:dateTime) 0 #Element GL_DATE has a type that is not catered for (xsd:dateTime) 0 #Element TRX_NUM has a type that is not catered for () 0 #Element QTY has a type that is not catered for (xsd:decimal) 0 #Element QTY_ORDERED has a type that is not catered for (xsd:decimal) 0 #Element UNIT_SELLING_PRICE has a type that is not catered for (xsd:decimal) 0 #Element UNIT_STANDARD_PRICE has a type that is not catered for (xsd:decimal) 0 #Element PRINTING_OPTION has a type that is not catered for () 0 #Element REASON_CODE has a type that is not catered for () 0 #Element TAX_CODE has a type that is not catered for () 0 #Element PRIMARY_SALESREP_NUM has a type that is not catered for () 0 #Element PURCHASE_ORDER has a type that is not catered for () 0 #Element REF_LINE_CONTEXT has a type that is not catered for () 0 #Element REF_LINE_ATT1 has a type that is not catered for () 0 #Element REF_LINE_ATT2 has a type that is not catered for () 0 #Element REF_LINE_ATT3 has a type that is not catered for () 0 #Element REF_LINE_ATT4 has a type that is not catered for () 0 #Element REF_LINE_ATT5 has a type that is not catered for () 0 #Element REF_LINE_ATT6 has a type that is not catered for () 0 #Element REF_LINE_ATT7 has a type that is not catered for () 0 #Element REF_LINE_ATT8 has a type that is not catered for () 0 #Element REF_LINE_ATT9 has a type that is not catered for () 0 #Element REF_LINE_ATT10 has a type that is not catered for () 0 #Element REF_LINE_ATT11 has a type that is not catered for () 0 #Element REF_LINE_ATT12 has a type that is not catered for () 0 #Element REF_LINE_ATT13 has a type that is not catered for () 0 #Element REF_LINE_ATT14 has a type that is not catered for () 0 #Element REF_LINE_ATT15 has a type that is not catered for () 0 #Element ATT_CAT has a type that is not catered for () 0 #Element ATT1 has a type that is not catered for () 0 #Element ATT2 has a type that is not catered for () 0 #Element ATT3 has a type that is not catered for () 0 #Element ATT4 has a type that is not catered for () 0 #Element ATT5 has a type that is not catered for () 0 #Element ATT6 has a type that is not catered for () 0 #Element ATT7 has a type that is not catered for () 0 #Element ATT8 has a type that is not catered for () 0 #Element ATT9 has a type that is not catered for () 0 #Element ATT10 has a type that is not catered for () 0 #Element ATT11 has a type that is not catered for () 0 #Element ATT12 has a type that is not catered for () 0 #Element ATT13 has a type that is not catered for () 0 #Element ATT14 has a type that is not catered for () 0 #Element ATT15 has a type that is not catered for () 0 #Element HDR_ATT_CAT has a type that is not catered for () 0 #Element HDR_ATT1 has a type that is not catered for () 0 #Element HDR_ATT2 has a type that is not catered for () 0 #Element HDR_ATT3 has a type that is not catered for () 0 #Element HDR_ATT4 has a type that is not catered for () 0 #Element HDR_ATT5 has a type that is not catered for () 0 #Element HDR_ATT6 has a type that is not catered for () 0 #Element HDR_ATT7 has a type that is not catered for () 0 #Element HDR_ATT8 has a type that is not catered for () 0 #Element HDR_ATT9 has a type that is not catered for () 0 #Element HDR_ATT10 has a type that is not catered for () 0 #Element HDR_ATT11 has a type that is not catered for () 0 #Element HDR_ATT12 has a type that is not catered for () 0 #Element HDR_ATT13 has a type that is not catered for () 0 #Element HDR_ATT14 has a type that is not catered for () 0 #Element HDR_ATT15 has a type that is not catered for () 0 #Element COMMENTS has a type that is not catered for () 0 #Element INTERNAL_NOTES has a type that is not catered for () 0 #Element UOM_NAME has a type that is not catered for () 0 #Element CREDIT_METHOD_FOR_INSTALLMENTS has a type that is not catered for () 0 #Element INTERFACE_LINE_ID has a type that is not catered for (xsd:decimal) 0 #Element INTERFACE_STATUS has a type that is not catered for () 0 #Element CUST_TRX_ID has a type that is not catered for (xsd:decimal) 0 }))), })), 'DIST_TBL': fields.Nested( flaskRestPlusAPI.model( 'InlineDIST_TBLType', { 'Dist': fields.List( fields.Nested( flaskRestPlusAPI.model( 'InlineDistType', { #Element INTERFACE_LINE_CONTEXT has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT1 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT2 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT3 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT4 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT5 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT6 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT7 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT8 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT9 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT10 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT11 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT12 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT13 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT14 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT15 has a type that is not catered for () 0 #Element ACCOUNT_CLASS has a type that is not catered for () 0 #Element AMOUNT has a type that is not catered for (xsd:decimal) 0 #Element PERCENT has a type that is not catered for (xsd:decimal) 0 #Element COMMENTS has a type that is not catered for () 0 #Element SEG1 has a type that is not catered for () 0 #Element SEG2 has a type that is not catered for () 0 #Element SEG3 has a type that is not catered for () 0 #Element SEG4 has a type that is not catered for () 0 #Element SEG5 has a type that is not catered for () 0 #Element SEG6 has a type that is not catered for () 0 #Element SEG7 has a type that is not catered for () 0 #Element SEG8 has a type that is not catered for () 0 #Element SEG9 has a type that is not catered for () 0 #Element SEG10 has a type that is not catered for () 0 #Element SEG11 has a type that is not catered for () 0 #Element SEG12 has a type that is not catered for () 0 #Element SEG13 has a type that is not catered for () 0 #Element SEG14 has a type that is not catered for () 0 #Element SEG15 has a type that is not catered for () 0 #Element SEG16 has a type that is not catered for () 0 #Element SEG17 has a type that is not catered for () 0 #Element SEG18 has a type that is not catered for () 0 #Element SEG19 has a type that is not catered for () 0 #Element SEG20 has a type that is not catered for () 0 #Element SEG21 has a type that is not catered for () 0 #Element SEG22 has a type that is not catered for () 0 #Element SEG23 has a type that is not catered for () 0 #Element SEG24 has a type that is not catered for () 0 #Element SEG25 has a type that is not catered for () 0 #Element SEG26 has a type that is not catered for () 0 #Element SEG27 has a type that is not catered for () 0 #Element SEG28 has a type that is not catered for () 0 #Element SEG29 has a type that is not catered for () 0 #Element SEG30 has a type that is not catered for () 0 }))), })), 'CREDITS_TBL': fields.Nested( flaskRestPlusAPI.model( 'InlineCREDITS_TBLType', { 'Credit': fields.List( fields.Nested( flaskRestPlusAPI.model( 'InlineCreditType', { #Element INTERFACE_LINE_CONTEXT has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT1 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT2 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT3 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT4 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT5 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT6 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT7 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT8 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT9 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT10 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT11 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT12 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT13 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT14 has a type that is not catered for () 0 #Element INTERFACE_LINE_ATT15 has a type that is not catered for () 0 #Element SALESREP_NUM has a type that is not catered for () 0 #Element SALES_CREDIT_TYPE_NAME has a type that is not catered for () 0 #Element SALES_CREDIT_AMOUNT_SPLIT has a type that is not catered for (xsd:decimal) 0 #Element SALES_CREDIT_PERCENT_SPLIT has a type that is not catered for (xsd:decimal) 0 }))), })), 'Response': fields.Nested( flaskRestPlusAPI.model( 'InlineResponseType', { #Element BATCHFAIL has a type that is not catered for (xsd:decimal) 0 'BATCHFAILMSG': fields.String(default='', description=''), #Element AI_REQUEST_ID has a type that is not catered for (xsd:decimal) 0 #Element Loaded_CREDITS_RECCNT has a type that is not catered for (xsd:decimal) 0 #Element Loaded_CREDITS_SUMAMNT has a type that is not catered for (xsd:decimal) 0 })), 'ERRORS_RSP_TBL': fields.Nested( flaskRestPlusAPI.model( 'InlineERRORS_RSP_TBLType', { 'ErrorRsp': fields.List( fields.Nested( flaskRestPlusAPI.model( 'InlineErrorRspType', { #Element INTERFACE_LINE_ID has a type that is not catered for (xsd:decimal) 0 #Element MSG_TEXT has a type that is not catered for () 0 #Element INVALID_VALUE has a type that is not catered for () 0 }))), })), 'CHECKSUM': fields.Nested( flaskRestPlusAPI.model( 'InlineCHECKSUMType', { #Element LINES_RECCNT has a type that is not catered for (xsd:decimal) 0 #Element CREDITS_RECCNT has a type that is not catered for (xsd:decimal) 0 #Element DISTRIB_RECCNT has a type that is not catered for (xsd:decimal) 0 #Element LINES_SUMAMNT has a type that is not catered for (xsd:decimal) 0 #Element CREDITS_SUMAMNTSP has a type that is not catered for (xsd:decimal) 0 #Element DISTRIB_SUMAMNT has a type that is not catered for (xsd:decimal) 0 #Element ERRORS_RECCNT has a type that is not catered for (xsd:decimal) 0 #Element LINES_ERRCNT has a type that is not catered for (xsd:decimal) 0 })), }) if typeName == 'http://ic.ac.uk/AIAMetaData/AIAComponents/EnterpriseObjectLibrary/Core/IC_EBO/ARAutoInv/V1:ATTTYPEV1': return flaskRestPlusAPI.model( 'ATTTYPEV1', { #Element ATT1 has a type that is not catered for () 0 #Element ATT2 has a type that is not catered for () 0 #Element ATT3 has a type that is not catered for () 0 #Element ATT4 has a type that is not catered for () 0 #Element ATT5 has a type that is not catered for () 0 #Element ATT6 has a type that is not catered for () 0 #Element ATT7 has a type that is not catered for () 0 #Element ATT8 has a type that is not catered for () 0 #Element ATT9 has a type that is not catered for () 0 #Element ATT10 has a type that is not catered for () 0 #Element ATT11 has a type that is not catered for () 0 #Element ATT12 has a type that is not catered for () 0 #Element ATT13 has a type that is not catered for () 0 #Element ATT14 has a type that is not catered for () 0 #Element ATT15 has a type that is not catered for () 0 }) raise Exception('Searching for unknown type')
# PATH_REGEX = r'(^[a-zA-Z]:\\[\\\S|*\S]?.*$)|(^(/[^/ ]*)+/?$)' PROJECT_PATH_MODEL = api.model( 'Project Path', { 'path': fields.String(description='Path of Project'), 'scenario': fields.String(description='Path of Project') }) PROJECT_MODEL = api.inherit( 'Project', PROJECT_PATH_MODEL, { 'name': fields.String(description='Name of Project'), 'scenario': fields.String(description='Name of Current Scenario'), 'scenarios': fields.List(fields.String, description='Name of Current Scenario') }) @api.route('/') class Project(Resource): @api.marshal_with(PROJECT_MODEL) def get(self): config = cea.config.Configuration() name = os.path.basename(config.project) return { 'name': name, 'path': config.project, 'scenario': config.scenario_name, 'scenarios': config.get_parameter('general:scenario-name')._choices }
fields.String(description="Lesson's room"), 'start': fields.String(description="Time represented in yyyy-mm-dd HH:MM:ss"), 'teacher': fields.String( description= "Teacher entire name.\nSometimes names have class groups attached to them.\nIt is up to you to format such info" ), }, description="An unordered list of lessons.") response_model = ns.model( 'TimetableResponse', { 'result': fields.Boolean(default=False, title="Result"), 'message': fields.String(default='No message', title="Error message"), 'timetable': fields.List(fields.Nested(timetable_model)) }) @ns.route('/get', methods=["GET"]) @ns.route('/get/<timestamp>', methods=["GET"]) @ns.header('X-API-KEY', 'TOKEN AUTH', required=True) @ns.doc(security='Token Auth', params={'timestamp': 'Timestamp for a day'}) class TimetableGet(Resource): @ns.marshal_with(response_model) def get(self, timestamp=None): token = request.headers.get('X-API-KEY') message, code = check_token(token).explain() if code is not 200: return message, code timetable, status = get_timetable(token, timestamp)
'DocumentTemplateFieldModel', { "id": fields.String, "label": fields.String, "type": fields.String, "placeholder": fields.String, "required": fields.Boolean(default=False), "context-value": fields.String, "read-only": fields.Boolean(default=False), }) DOCUMENT_TEMPLATE_MODEL = api.model( 'DocumentTemplateModel', { 'document_template_code': fields.String, 'form_spec': fields.List(fields.Nested(DOCUMENT_TEMPLATE_FIELD_MODE, skip_none=True)) }) class DateTime(fields.Raw): def format(self, value): return value.strftime("%Y-%m-%d %H:%M") if value else None class Date(fields.Raw): def format(self, value): return value.strftime("%Y-%m-%d") if value else None NOW_APPLICATION_EQUIPMENT = api.model( 'NOWEquipment', {
from flask_restplus import Resource, fields from src.models import School from src.routes import namespace, api from src import dbi school_model = api.model( 'School', { 'name': fields.String(), 'slug': fields.String(), 'domains': fields.List(fields.String()) }) schools_model = api.model('Schools', { 'schools': fields.List(fields.Nested(school_model)), }) @namespace.route('/schools') class GetSchools(Resource): """Fetch all non-destroyed Schools""" @namespace.doc('get_schools') @namespace.marshal_with(schools_model) def get(self): schools = dbi.find_all(School, {'is_demo': False}) school_data = [{ 'name': s.name, 'slug': s.slug, 'domains': s.domains } for s in schools] return {'schools': school_data}
"ScanOutputModel", { "target": fields.String(required=True), "uuid": fields.String(required=True, attribute=lambda scan: scan["uuid"].hex), "error_reason": fields.String(required=True), "comment": fields.String(required=True), "source_ip": fields.String(required=True), "created_at": fields.DateTime(required=True), "updated_at": fields.DateTime(required=True), "scheduled": fields.Boolean(required=True), "processed": fields.Boolean(required=True), "start_at": fields.DateTime(required=True), "end_at": fields.DateTime(required=True), "started_at": fields.DateTime(required=True), "ended_at": fields.DateTime(required=True), "results": fields.List(fields.Nested(ScanResultModel), required=True), }, ) @api.route("/<string:scan_uuid>/") @api.doc(security="API Token") @api.response(200, "Success") @api.response(401, "Invalid Token") @api.response(404, "Not Found") class ScanItem(Resource): ScanPatchInputModel = api.model("ScanPatchInput", {"comment": fields.String(required=True)}) @api.marshal_with(ScanOutputModel) @Authorizer.token_required
pagination = users_ns.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'), }) user = users_ns.model( 'User', { 'id': fields.String(required=False, description='The user identifier'), 'username': fields.String(required=True, description='The username'), 'email': fields.String(required=True, description='The email'), }) page_of_users = users_ns.inherit('Page of users', pagination, {'users': fields.List(fields.Nested(user))}) @users_ns.route("/") class UserList(Resource): @users_ns.doc('list_users') @users_ns.marshal_list_with(user) def get(self): return get_all_user()
user_list = api.model( 'user_list', { 'username': fields.String(required=True, description='Username of the user'), 'email': fields.String(required=True, description='Email of the user'), 'access': fields.String(required=True, description='User has access to application'), 'activated': fields.String(required=True, description='User is activated'), 'id': fields.Integer(required=True, description='The unique identifier of the user'), }) user_items = api.inherit('List of user items', {'items': fields.List(fields.Nested(user_list))}) privilege_list = api.model( 'privilege_list', { 'privilege': fields.String(required=True, description='The list of privileges'), 'id': fields.Integer(required=True, description='The unique identifier of the privilege'), }) privilege_items = api.inherit( 'List of privilege items', {'items': fields.List(fields.Nested(privilege_list))})
task_model = api.model( 'ToDOList', { 'Task_Name': fields.String(required=True, readOnly=True, description='The task unique identifier.'), 'Dead_Line': fields.Date(required=True, description='The dead line for the task.', validate=True), 'Description': fields.String(required=False, description='The Summary for the task.'), 'Tags': fields.List(fields.String, required=False, description='The dead line for the task.') }) @api.route('/tasklist', endpoint='Tasks List') class ToDOList(Resource): def get(self): data = [] cursor = mongo.db.todos.find({}, {"_id": 0}) for todos in cursor: data.append(todos) return jsonify({"response": data}) @ns.doc( params={'Task Model': 'All the neccesary Information for the Task.'})
# See the License for the specific language governing permissions and # limitations under the License. # from core.model import ModelWrapper from maxfw.core import MAX_API, PredictAPI from flask_restplus import fields from werkzeug.datastructures import FileStorage from config import DEFAULT_MODEL, MODELS predict_response = MAX_API.model( 'ModelPredictResponse', { 'status': fields.String(required=True, description='Response status message'), 'predictions': fields.List(fields.List(fields.Float), description='Predicted values for weather features') }) # Set up parser for input data (http://flask-restplus.readthedocs.io/en/stable/parsing.html) input_parser = MAX_API.parser() input_parser.add_argument( 'file', type=FileStorage, location='files', required=True, help= 'Input data to use for prediction, in the form of a numpy array txt file') input_parser.add_argument('model', type=str, default=DEFAULT_MODEL, choices=MODELS,
from models import db, User, Stock import models from validator import validate, username_validator stocksApi = Namespace('stocks', description="Stock operations") # ----------------------------------- Response Model Registration ------------------------------------------------------ stock_model = stocksApi.model('stock', { 'server_error': fields.String(default = "no"), 'company_name': fields.String }) stock_list_model = stocksApi.model('stocks', { 'server_error': fields.String(default = "no"), 'stocks': fields.List(fields.Nested(stock_model)) }) # ----------- @stocksApi.route('/') class stocks(Resource): def get(self): try: #get stocks return db.session.query.filter_by(email='*****@*****.**'), 200 except Exception as e: return {'message': str(e)}, 500
fields.Nested( existing_testgen_config_input, allow_null=True, required=False, description='TestgenConfigInput associated with this workflow'), 'vulnerabilityConfigurationInput': fields.Nested( existing_vulnconfig_input, allow_null=True, required=False, description= 'VulnerabilityConfigurationInput associated with this workflow'), 'reportJobs': fields.List( fields.Nested( existing_report_job, allow_null=True, required=False, description='ReportJob associated with this workflow')) }) @ns.route('') class WorkflowListApi(Resource): # by declaring which swagger model we use to marshal data, # flask will automagically convert any returned data to be # limited to that shape. This means that can effectively be # hidden by not including them in the definition @ns.marshal_list_with(existing_workflow) def get(self): """ fetch all the current workflows
}) 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_artists = api.inherit('Page of artists', pagination, {'items': fields.List(fields.Nested(artist))}) genre = api.model( 'Genre', { 'id': fields.Integer(readOnly=True, description='The unique identifier of a genre'), 'name': fields.String(required=True, description='Genre name'), }) genres_with_artists = api.inherit( 'Genres with artists', genre, {'artists': fields.List(fields.Nested(artist))}) song = api.model(
from flask import request from flask_restplus import Namespace, Resource, fields from word_count_service.exception_handling import exception_wrapper from word_count_service.word_stats.word_stats_service import word_count_service from word_count_service.word_stats.word_stats_transformer import words_stats_transformer from flask_jwt_extended import jwt_required word_stats_ns = Namespace('wordsStats', description='words stats') word_count_requests = word_stats_ns.model('Words Stats Requerst', { 'url': fields.String(required=True, description='The url to fetch'), 'desired_words': fields.List(fields.String,required=True, description='The word fetch stats on'), }) word_stats_item = word_stats_ns.model('Words Stats Requests Items', { 'word': fields.String(required=True, description='The word'), 'frequency': fields.Integer(description='The word fetch stats on'), }) word_stats = word_stats_ns.model('Words Count Requests', { 'id': fields.Integer(required=True, description='db id'), 'url': fields.String(description='the url'), 'results': fields.List(fields.Nested(word_stats_item),description='The word fetch stats on'), }) @word_stats_ns.route('/') class WordsCountApi(Resource): @exception_wrapper @word_stats_ns.doc('fetch words frequencies by url') @jwt_required @word_stats_ns.expect(word_count_requests)
import logging from flask import request from flask_restplus import Resource, Namespace, fields from model_buyer.services.model_buyer_service import ModelBuyerService api = Namespace('predictions', description='Predictions related operations') prediction = api.model( name='Prediction ', model={ 'id': fields.String(required=True, description='The prediction identifier'), 'values': fields.List(fields.Raw, required=True, description='The prediction values'), 'mse': fields.Integer(required=True, description='The MSE'), # 'model': fields.Nested(model, required=True, description='The model'), }) prediction_request = api.model(name='Prediction ', model={ 'id': fields.String( required=True, description='The prediction identifier') }) model_buyer = ModelBuyerService()
from flask_restplus import fields from task_lectures.lectures import api schemaLecture = api.model('Lectures', {'data': fields.List(fields.String)})
captureItem = capture.model( 'captureItems', { 'id': fields.String, "frameNumber": fields.Integer, 'url': fields.String, 'noSubtitleUrl': fields.String, 'timeStamp': fields.Integer, 'subtitle': fields.String }) captureResult = capture.model( 'CaptureResult', { 'id': fields.String, 'title': fields.String, 'thumbnailUrl': fields.String, 'captureItems': fields.List(fields.Nested(captureItem)), }) @capture.route('') class GetImages(Resource): parser = capture.parser() parser.add_argument('url', required=True, help='url cannot be null or empty', type=str) parser.add_argument('language', required=False, type=str, default="en") parser.add_argument('numberToCapture', required=False, type=int) parser.add_argument('startTimeStamp', required=False, type=int) parser.add_argument('endTimeStamp', required=False, type=int)
model={ 'id': fields.Integer(), 'name': fields.String(), 'description': fields.String(), 'is_active': fields.Boolean(), 'created_at': fields.DateTime(), 'updated_at': fields.DateTime(), 'user_created': fields.String() }) category_list_model = ns.model(name='CategoryListModel', model={ 'total': fields.Integer(), 'results': fields.List(fields.Nested(category_model)) }) @ns.route('/list/') class CategoryList(Resource): @ns.marshal_with(category_list_model) @ns.doc( params={ '_page': 'page number', '_limit': 'size in page', 'q': 'key search by name', '_sort': 'Sort field', '_order': 'Sort type', 'is_active': 'Filter status' })
api = Namespace('indicators', description='Indicator related operations') indicator = api.model( 'Indicator', { 'id': fields.String(required=True, description='The indicator id'), 'indicator': fields.String(required=True, description='The indicator'), 'itype': fields.String(enum=itypes), 'confidence': fields.Float(min=0, max=10), 'provider': fields.String(required=True), 'groups': fields.List(fields.String), 'tlp': fields.String(enum=['white', 'green', 'amber', 'red']), 'reported_at': fields.DateTime, 'last_at': fields.DateTime(required=True), 'first_at': fields.DateTime, 'probability': fields.Float(min=0, max=100), 'portlist': fields.String, 'protocol': fields.String, 'expire_at':
from mongoengine import DoesNotExist from .cache import cache from .queries import get_citing_publications, get_occurrences_count from .queries import get_publications, get_cited_publications from .models import author_fields, article_fields, book_fields from .primary_sources import primary_source_fields from .parsers import req_parser logger = logging.getLogger(__name__) api = Namespace('authors', description='Authors related operations') api.models[author_fields.name] = author_fields publication_list = api.model( 'AuthoredPublications', { 'articles': fields.List(fields.Nested(article_fields)), 'books': fields.List(fields.Nested(book_fields)), }) citing_publication_list = api.clone('CitingPublications', publication_list) cited_publication_list = api.clone( 'CitedPublications', publication_list, {'primary_sources': fields.List(fields.Nested(primary_source_fields))}) author_data = api.model( 'AuthorData', { 'author': fields.Nested(author_fields, required=True), 'publications': fields.Nested(publication_list, required=False),