class RolesSchema(ModelSchema): rid = base_fields.Integer() title = base_fields.String() resources = base_fields.String() class Meta: pass
class PagerJSONParameters(JSONParameters): search = base_fields.String(required=False, default='') sort = base_fields.String(required=False, default='') order = base_fields.String(required=True, default='asc') offset = base_fields.Integer(required=True, default=0) limit = base_fields.Integer(required=True, default=10) lang = base_fields.String(required=False, default='')
class AddDatasetParameters(PostFormParameters, schemas.DatasetSchema): """ New data creation parameters. """ license_name = base_fields.String('license_name', required=True) publisher_name = base_fields.String('publisher_name') organization_name = base_fields.String('organization_name') keywords = base_fields.List(base_fields.String, required=False) class Meta(schemas.DatasetSchema.Meta): fields = schemas.DatasetSchema.Meta.fields + ( 'license_name', 'organization_name', 'publisher_name', ) @validates('temporal') def validate_temporal_field(self): # TODO: support field validation pass @validates('spatial') def validate_spatial_field(self): # TODO: support field validation pass
class CategoryFieldSchema(ModelSchema): """ Category Field schema """ title = base_fields.String() field = base_fields.String() class Meta: pass
class AttachmentsCKeditorUploadSchema(ModelSchema): uploaded = base_fields.Integer() fileName = base_fields.String() url = base_fields.String() error = base_fields.Nested(CKeditorUploadErrorSchema) class Meta: pass
class AddCommentParameters(parameters.PostFormParameters, schemas.CommentSchema): target_id = base_fields.String(required=False) target_type = base_fields.String(required=False) user_id = base_fields.String(required=False) class Meta(schemas.CommentSchema.Meta): fields = schemas.CommentSchema.Meta.fields
class UpdateStoryParameters(PostFormParameters, schemas.StorySchema): """ Story updating parameters. """ title = base_fields.String(required=False) web = base_fields.String(required=False) class Meta(schemas.StorySchema.Meta): fields = schemas.StorySchema.Meta.fields
class UpdateSourceParameters(PostFormParameters, schemas.SourceSchema): """ Update a source """ title = base_fields.String(required=False) url = base_fields.String(required=False) class Meta(schemas.SourceSchema.Meta): fields = schemas.SourceSchema.Meta.fields
class UpdateLicenseParameters(PostFormParameters, schemas.LicenseSchema): """ Update a license """ name = base_fields.String(required=False) url = base_fields.String(required=False) class Meta(schemas.LicenseSchema.Meta): fields = schemas.LicenseSchema.Meta.fields
class RolesDetailSchema(ModelSchema): uid = base_fields.Integer() rids = base_fields.List(base_fields.Integer()) rids_str = base_fields.String() resources_ids = base_fields.List(base_fields.Integer()) resources_ids_str = base_fields.String() titles = base_fields.String() roles = base_fields.Nested(RolesSchema, many=True) class Meta: pass
class F14Schema(Schema): response = base_fields.Dict() interest_rate = base_fields.Float() lifetime = base_fields.Integer() ##Information from selected area nuts0 = base_fields.String() nuts3 = base_fields.String() population = base_fields.Integer() #user input building_energy_demand = base_fields.Float() building_heat_load = base_fields.Float()
class CreateUserParameters(Parameters): """ Helper parameters to create user. """ name = base_fields.String( description="the users name" ) email = base_fields.Email( description="the users email" ) password = base_fields.String( description="the users password" )
class RelatedJiraParameters(PaginationParameters): """ Find Related JIRA parameters. """ jira_id = base_fields.String(description="Jira ID", required=False) jira_query = base_fields.String( description="Find similar Jira's for Jira Query", required=False) model_name = base_fields.String(description="Trained Model Name", required=False) num_of_related_jira_return = base_fields.String( description="Return No. of Related JIRA ", required=False, default="10")
class AddUserParameters(schemas.BaseUserSchema): """ New user creation (sign up) parameters. """ username = base_fields.String(description="Example: root", required=True) email = base_fields.Email(description="Example: [email protected]", required=True) password = base_fields.String(description="No rules yet", required=True) class Meta(schemas.BaseUserSchema.Meta): fields = schemas.BaseUserSchema.Meta.fields + ( 'email', 'password', )
class CreateReviewParameters(Parameters): description = base_fields.String(description="the users review") rating = base_fields.Integer( description="the users rating of a ride", validate=validate.Range(min=1, max=5, error="Invalid rating. Must be between 1-5"))
class GeocodeParameters(Parameters): """ Helper Parameters class to reuse geocoding. """ search = base_fields.String( description="the type of query we want to search", ) filters = base_fields.Raw() coordinates = base_fields.List( cls_or_instance=base_fields.List( cls_or_instance=base_fields.Float() ), allow_none=True, ) latitude = base_fields.Float( allow_none=True, description="the latitude to search in", validate=validate.Range(min=-90.0, max=90.0, error="Invalid latitude parameters. Must be between -90 and 90.") ) longitude = base_fields.Float( allow_none=True, description="the latitude to search in", validate=validate.Range(min=-180.0, max=180.0, error="Invalid longitude parameters. Must be between -180 and 180.") ) radius = base_fields.Float( description="the radius to search in", missing=5, validate=validate.Range(min=0) )
class ListUserParameters(PaginationParameters): """ New user creation (sign up) parameters. """ search = base_fields.String(description='Example: [email protected]', required=False)
class AdminUserInitializedParameters(Parameters): """ New user creation (sign up) parameters. """ email = base_fields.Email(description='Example: [email protected]', required=True) password = base_fields.String(description='No rules yet', required=True)
class DefaultHTTPErrorSchema(Schema): errors = base_fields.Dict() data = base_fields.Dict() message = base_fields.String() def __init__(self, **kwargs): super(DefaultHTTPErrorSchema, self).__init__(**kwargs)
class IrisFigureSchema(ModelSchema): """ IRIS pager schema """ figure_name = base_fields.String() class Meta: pass
class UpdatePublisherParameters(PostFormParameters, schemas.PublisherSchema): """ Update a publisher """ name = base_fields.String(required=False) class Meta(schemas.PublisherSchema.Meta): fields = schemas.PublisherSchema.Meta.fields
class UpdateOrganizationParameters(PostFormParameters, schemas.OrganizationSchema): """ Update a organization """ name = base_fields.String(required=False) class Meta(schemas.OrganizationSchema.Meta): fields = schemas.OrganizationSchema.Meta.fields
class IrisClassifyPredictParameters(Parameters): sepal_length_logic = base_fields.Float(required=False) sepal_width_logic = base_fields.Float(required=False) petal_length_logic = base_fields.Float(required=False) petal_width_logic = base_fields.Float(required=False) logic_select = base_fields.String(required=False)
class CreateUserParameters(Parameters, schemas.BaseUserSchema): """ New user creation (sign up) parameters. """ email = base_fields.Email(description='Example: [email protected]', required=True) password = base_fields.String(description='No rules yet', required=True) recaptcha_key = base_fields.String( description= ('See `/<prefix>/auth/recaptcha` for details. It is required for everybody, except admins' ), required=False, ) class Meta(schemas.BaseUserSchema.Meta): fields = schemas.BaseUserSchema.Meta.fields + ( 'email', 'password', 'recaptcha_key', ) @validates_schema def validate_captcha(self, data): """ " Check reCAPTCHA if necessary. NOTE: we remove 'recaptcha_key' from data once checked because we don't need it in the resource """ recaptcha_key = data.pop('recaptcha_key', None) captcha_is_valid = False if not recaptcha_key: no_captcha_permission = permissions.AdminRolePermission() if no_captcha_permission.check(): captcha_is_valid = True elif recaptcha_key == current_app.config.get('RECAPTCHA_BYPASS', None): captcha_is_valid = True if not captcha_is_valid: abort(code=HTTPStatus.FORBIDDEN, message='CAPTCHA key is incorrect.')
class CreateReviewParameters(Parameters): ride_id = base_fields.Integer(description="the ride our user is reviewing", validate=validate.Range(min=0, error="Invalid ride id")) user_id = base_fields.Integer(description="the user id who is reviewing", validate=validate.Range(min=0, error="Invalid user id")) description = base_fields.String(description="the users review") rating = base_fields.Integer( description="the users rating of a ride", validate=validate.Range(min=1, max=5, error="Invalid rating. Must be between 1-5") )
class LoginParameters(Parameters): """ Helper parameters to login user. """ email = base_fields.Email( description="the users email" ) password = base_fields.String( description="the users password" )
class IrisPredictSchema(ModelSchema): """ IRIS pager schema """ linear_result = base_fields.Float() classify_result = base_fields.String() metric = base_fields.Float() class Meta: pass
class AddUserParameters(PostFormParameters, schemas.BaseUserSchema): """ New user creation (sign up) parameters. """ username = base_fields.String(description="Example: root", required=True) email = base_fields.Email(description="Example: [email protected]", required=True) password = base_fields.String(description="No rules yet", required=True) recaptcha_key = base_fields.String( description=( "See `/users/signup_form` for details. It is required for everybody, except admins" ), required=False ) class Meta(schemas.BaseUserSchema.Meta): fields = schemas.BaseUserSchema.Meta.fields + ( 'email', 'password', 'recaptcha_key', ) @validates_schema def validate_captcha(self, data): """" Check reCAPTCHA if necessary. NOTE: we remove 'recaptcha_key' from data once checked because we don't need it in the resource """ recaptcha_key = data.pop('recaptcha_key', None) captcha_is_valid = False if not recaptcha_key: no_captcha_permission = permissions.AdminRolePermission() if no_captcha_permission.check(): captcha_is_valid = True # NOTE: This hardcoded CAPTCHA key is just for demo purposes. elif recaptcha_key == 'secret_key': captcha_is_valid = True if not captcha_is_valid: abort(code=HTTPStatus.FORBIDDEN, message="CAPTCHA key is incorrect.")
class GetAssetParameters(Parameters): asset_id = fields.String(description="A public key representing the asset") @validates('asset_id') def validate_id(self, asset_id): """ Validate the format of the asset id. must be a public key :param str asset_id: the id to be validated :raises: ValidationError """ validate_public_key(asset_id)
class FilteringParameters(Parameters): """ Helper Parameters class to reuse filtering. """ operator = base_fields.String( allow_none=True ) ride_type = base_fields.List( cls_or_instance=base_fields.String(), allow_none=True ) min_height_in_cm = base_fields.Integer( allow_none=True, validate=validate.Range(min=0) ) admission_price = base_fields.Integer( allow_none=True, validate=validate.Range(min=0) )