Beispiel #1
0
class BaseCitizenRequestSchema(Schema):
    name = Str(validate=BASIC_STRING_LENGTH, required=True)
    gender = Str(validate=OneOf([gender.name for gender in Gender]), required=True)
    birth_date = Date(format=DATE_FORMAT, required=True)
    town = Str(validate=BASIC_STRING_LENGTH, required=True)
    street = Str(validate=BASIC_STRING_LENGTH, required=True)
    building = Str(validate=BASIC_STRING_LENGTH, required=True)
    apartment = Int(validate=POSITIVE_VALUE, required=True)
    relatives = List(Int(validate=POSITIVE_VALUE), required=True)

    @validates("birth_date")
    def validate_birth_date(self, value: date) -> None:
        """
        Валидация на то, что дата рождения не может быть датой из будущего.

        :param value: дата для валидации
        """
        if value > date.today():
            raise ValidationError("Birth date can not be in future")

    @validates("relatives")
    def validate_relatives_unique(self, value: list) -> None:
        """
        Валидация на уникальной id-шников родственников.

        :param value: список id-шников родственников
        """
        if len(value) != len(set(value)):
            raise ValidationError("Relatives must be unique")
Beispiel #2
0
class eBPF_Program_Instance_Schema(Base_Schema):
    """Represents an eBPF program instance installed in an execution environment."""

    doc = eBPF_Program_Instance_Document
    id = Str(required=True,
             example='packet-capture@apache',
             description=
             'Id of the eBPF program installed in an execution environment.')
    ebpf_program_catalog_id = Str(
        required=True,
        readonly=False,
        example='packet-capture',
        description='Id of the agent in the catalog.',
        validate=In.apply(eBPF_Program_Catalog_Document.get_ids),
        error_messages=In.error_messages)
    exec_env_id = Str(
        required=True,
        readonly=True,
        example='apache',
        description=
        "Id of the execution environment where the eBPF program instance is installed",
        validate=In.apply(Exec_Env_Document.get_ids),
        error_messages=In.error_messages)
    parameters = Nested(
        eBPF_Program_Instance_Parameter_Schema,
        many=True,
        unknown='INCLUDE',
        description='List of eBPF program instance parameters.',
        validate=Unique_List.apply('id'),
        error_messages=Unique_List.error_messages)
    description = Str(
        example='Collect system metrics from Apache HTTP Web Server.',
        description=
        'Short description of the agent installed in the execution environment.'
    )
Beispiel #3
0
class Exception_Response_Schema(Schema):
    reason = Str(required=True, example='Connection timeout',
                 description='Exception reason.')
    filename = Str(required=True, example='lib/connection.py',
                   description='Filename where the exception is raised.')
    line = Integer(required=True, example=80,
                   description='Line where the exception is raised.')
Beispiel #4
0
class QuestionSchema(Schema):
    nodeId = str()
    slug = str()
    language = str()
    addedOn = DateTime()
    type = Str()
    options = List(Str())
Beispiel #5
0
class TimeseriesValidator(Schema):
    agg = Str(default='week', validate=OneOf({'day', 'week', 'month', 'quarter', 'year'}))
    dataset_name = Pointset(default=None)
    dataset_name__in = Commalist(Pointset(), default=lambda: list())
    location_geom__within = Geometry(default=None)
    obs_date__ge = DateTime(default=lambda: datetime.now() - timedelta(days=90))
    obs_date__le = DateTime(default=lambda: datetime.now())
    data_type = Str(default='json', validate=OneOf({'csv', 'json'}))

    @post_load
    def defaults(self, data):
        for name, field in self.fields.items():
            if name not in data:
                if callable(field.default):
                    data[name] = field.default()
                else:
                    data[name] = field.default
        return data

    @pre_dump
    def defaults(self, data):
        for name, field in self.fields.items():
            if name not in data:
                if callable(field.default):
                    data[name] = field.default()
                else:
                    data[name] = field.default
        return data
Beispiel #6
0
class Data_Schema(Base_Schema):
    """Represents the stored data."""

    doc = Data_Document
    id = Str(required=True,
             example='BXrHRn5RPU55Qh9JwMZn',
             description='Id of the data.')
    agent_instance_id = Str(
        readonly=True,
        example='filebeat@apache',
        description=
        "Id of the agent instance in the execution environment that collected the data",
        validate=In.apply(Agent_Instance_Document.get_ids),
        error_messages=In.error_messages)
    ebpf_program_instance_id = Str(
        readonly=True,
        example='packet-capture@apache',
        description=
        """Id of the eBPF program instance in the execution environment
                                                  that collected the data""",
        validate=In.apply(eBPF_Program_Instance_Document.get_ids),
        error_messages=In.error_messages)
    timestamp_event = Date_Time(
        format=FORMAT,
        readonly=True,
        example='2019/02/14 15:23:30',
        description='Timestamp of the event related to the collected data')
    timestamp_agent = Date_Time(
        format=FORMAT,
        readonly=True,
        example='2019/02/14 15:23:30',
        description='Timestamp when the agent instance collected the data')
Beispiel #7
0
class ForecastSettingsSchema(Schema):
    id = Str()
    user_id = Str(required=True, error_messages={'required': _MSG309})
    address = Str(required=True, error_messages={'required': _MSG309})
    period = Nested(PeriodSchema, required=True)
    days = Nested(DaySchema, required=True)
    notification = Str(required=True, error_messages={'required': _MSG309})
class ClienteUnidadeConsumidoraSchema(Schema):
    codClienteUnidadeConsumidora = Int()
    codCliente = Int()
    numeroUC = Str(required=True,
                   error_messages={'required': MSG_FIELD_REQUIRED})
    endereco = Str()
    numero = Str()
    codCidade = Int()
    bairro = Str()
    consumoMedioMensal = Float()
    taxaDisponibilidade = Float()
    classe = EnumField(ClassesEnum, by_value=True)
    fase = EnumField(FasesEnum, by_value=True)
    seq = Int()

    def getClasse(self, obj):
        print(obj.classe.value)
        return obj.classe.value

    def getFase(self, obj):
        print(obj.fase.value)
        return obj.fase.value

    @post_load
    def make_clienteUnidadeConsumidora(self, data, **kwargs):
        return ClienteUnidadeConsumidora(**data)
Beispiel #9
0
class PaymentSchemeGet(PaymentScheme):
    description = Str()
    switch_package_name = Str()
    lrn_package_name = Str()
    user_email = Str()

    class Meta:
        model = model.Payment
        fields = ('payment_uuid', 'type', 'paid_time', 'user_uuid',
                  'license_lrn_uuid', 'license_switch_uuid', 'amount_lrn',
                  'amount_switch', 'amount_total', 'switch_uuid',
                  'description', 'lrn_package_name', 'switch_package_name',
                  'user_email')
        search_fields = ('payment_uuid', 'type', 'period', 'user_uuid',
                         'license_lrn_uuid', 'license_switch_uuid',
                         'switch_uuid', 'description', 'lrn_package_name',
                         'switch_package_name', 'user_email')
        query_fields = (
            'amount_lrn_gt',
            'amount_lrn_lt',
            'amount_switch_gt',
            'amount_switch_lt',
            'amount_total_gt',
            'amount_total_lt',
            'paid_time_gt',
            'paid_time_lt',
        )
Beispiel #10
0
class LicenseLrnScheme(BaseModelScheme):
    user_email = Str(validate=[validate.Length(max=128)])
    cps = Int()
    type = Int()
    ip = Str(required=True,
             allow_none=False,
             validate=[validate.Length(max=16),
                       validate.Regexp(IP_REGEXP)])
    lrn_port = Int()
    dip_count = Int()
    amount = Int()
    license_lrn_uuid = Str(validate=[validate.Length(max=36)])
    package_lrn_uuid = Str(validate=[
        validate.Length(max=36),
        lambda value: _valid('PackageLrn', 'package_lrn_uuid', value)
    ])
    user_uuid = Str(validate=[validate.Length(max=36)])
    start_time = DateTime()
    end_time = DateTime()
    duration = Choice()
    ordered_amount = Int()
    cost = Float()
    package = Nested('PackageLrnScheme', many=False)
    enabled = Bool()

    class Meta:
        model = model.LicenseLrn
        fields = ('package_lrn_uuid', 'ip', 'start_time', 'duration')
Beispiel #11
0
class UserScheme(BaseModelScheme):
    user_id = Str()

    email = Email(required=True,
                  allow_none=False,
                  validate=[
                      validate.Email(error='Incorrect email address'),
                      lambda value: _valid_unique('User', 'email', value)
                  ])
    password = Str(validate=[validate.Length(max=72)])
    is_admin = Bool()
    last_login = DateTime()
    is_active = Bool()
    created_on = DateTime()
    phone = Str(required=True,
                allow_none=False,
                validate=[
                    validate.Regexp(PHONE_REGEXP),
                    lambda value: _valid_unique('User', 'phone', value)
                ])

    logo_file_uuid = FileSchemeField(model.FileModel,
                                     'User',
                                     'logo',
                                     required=False)
    logo = Nested('FileModelScheme', many=False)

    class Meta:
        model = model.User
        fields = ('email', 'passwd', 'is_admin', 'is_active', 'logo_file_uuid')
Beispiel #12
0
class UserSchema(Schema):
    cpf = Str(
        required=True, error_messages={'required': MSG_FIELD_REQUIRED}
    )
    password = Str(
        required=True, error_messages={'required': MSG_FIELD_REQUIRED}
    )
Beispiel #13
0
class OrganizerSchema(Schema):
    """
    Schema for action organizer info
    """
    class Meta:
        unknown = EXCLUDE

    club_id = Integer(data_key="organizerClub")
    email = Str(data_key="contactMail")
    phone = List(Str(), data_key="contactPhone")
    web = Str(data_key="contactWeb")

    @pre_load
    def load_phone(self, in_data, **kwargs):
        if "contactPhone" not in in_data:
            return in_data
        if "," not in in_data["contactPhone"]:
            in_data["contactPhone"] = (in_data["contactPhone"])
        elif "," in in_data["contactPhone"]:
            in_data["contactPhone"] = [phone.strip() for phone in in_data["contactPhone"].split(",")]
        return in_data

    @post_load
    def make_action(self, data, **kwargs):
        return DeClass(_name="Organizer", _resp=("email", "web"), **data)
class XMLTagSchema(Schema):
    name = Str(data_key='$')
    lang = Str(data_key='@lang', validate=validate.OneOf(choices=['en', 'pl']))

    class Meta:
        fields = ('name', 'lang')
        unknown = EXCLUDE
Beispiel #15
0
class Computer(Device):
    __doc__ = m.Computer.__doc__
    components = NestedOn(
        'Component',
        many=True,
        dump_only=True,
        collection_class=OrderedSet,
        description='The components that are inside this computer.')
    chassis = EnumField(enums.ComputerChassis,
                        required=True,
                        description=m.Computer.chassis.comment)
    ram_size = Integer(dump_only=True,
                       data_key='ramSize',
                       description=m.Computer.ram_size.__doc__)
    data_storage_size = Integer(
        dump_only=True,
        data_key='dataStorageSize',
        description=m.Computer.data_storage_size.__doc__)
    processor_model = Str(dump_only=True,
                          data_key='processorModel',
                          description=m.Computer.processor_model.__doc__)
    graphic_card_model = Str(dump_only=True,
                             data_key='graphicCardModel',
                             description=m.Computer.graphic_card_model.__doc__)
    network_speeds = List(Integer(dump_only=True),
                          dump_only=True,
                          data_key='networkSpeeds',
                          description=m.Computer.network_speeds.__doc__)
    privacy = NestedOn('Event',
                       many=True,
                       dump_only=True,
                       collection_class=set,
                       description=m.Computer.privacy.__doc__)
Beispiel #16
0
class UserSchema(Schema):
    full_name = Str(required=True,
                    error_messages={'required': 'Campo obrigatório'})
    email = Email(required=True,
                  error_messages={'required': 'Campo obrigatório'})
    cpf_cnpj = Str()
    active = Boolean()
Beispiel #17
0
class CredSchema(Schema):
    cred = Dict()
    ssh = Nested(SshSchema)
    key_name = Str()
    security_groups = List(Str())
    create_with = Dict()
    provider = ProviderSchema()
Beispiel #18
0
class Exec_Env_Schema(Base_Schema):
    """Represents an execution environment."""

    doc = Exec_Env_Document
    id = Str(required=True,
             example='apache',
             description='Id of the execution environment.')
    hostname = Str(required=True,
                   example='192.168.1.2',
                   description='Hostname of the execution environment.')
    type_id = Str(required=True,
                  example='vm',
                  description='Id of the execution environment type.',
                  validate=In.apply(Exec_Env_Type_Document.get_ids),
                  error_messages=In.error_messages)
    lcp = Nested(LCP_Schema,
                 readonly=True,
                 unknown='INCLUDE',
                 description='Data related to the LCP.')
    description = Str(
        example='Apache HTTP Web Server.',
        description='Short description of the execution environment,')
    enabled = Boolean(
        required=True,
        default=True,
        example='Yes',
        description='Indicate if the execution environment is enabled or not')
Beispiel #19
0
class CursoModel(Schema):
    id = Integer(primary_key=True, default=PK_DEFAULT_VALUE)
    nome = Str(required=True, default='')
    sala = Str()
    horario = Str()
    foto = Str()
    professor = Nested(ProfessorModel)
Beispiel #20
0
class UserSchema(Schema):
    id = Str()
    full_name = Str(required=True,
                    error_messages={'required': MSG_FIELD_REQUIRED})
    email = Email(required=True,
                  error_messages={'required': MSG_FIELD_REQUIRED})
    active = Boolean()
Beispiel #21
0
class UserRegistrationSchema(Schema):
    full_name = Str(required=True,
                    error_messages={'required': MSG_FIELD_REQUIRED})
    email = Email(required=True,
                  error_messages={'required': MSG_FIELD_REQUIRED})
    password = Str(required=True,
                   error_messages={'required': MSG_FIELD_REQUIRED})
class FileSchema(Schema):
    """Schema for records v1 in JSON."""
    class Meta:
        """Meta class to reject unknown fields."""

        unknown = EXCLUDE

    key = SanitizedUnicode(dump_only=True)
    created = Str(dump_only=True)
    updated = Str(dump_only=True)

    status = GenMethod('dump_status')

    metadata = Dict(dump_only=True)

    checksum = Str(dump_only=True, attribute='file.checksum')
    storage_class = Str(dump_only=True, attribute='file.storage_class')
    mimetype = Str(dump_only=True, attribute='file.mimetype')
    size = Number(attribute='file.size')
    version_id = UUID(attribute='file.version_id')
    file_id = UUID(attribute='file.file_id')
    bucket_id = UUID(attribute='file.bucket_id')

    links = Links()

    def dump_status(self, obj):
        """Dump file status."""
        return 'completed' if obj.file else 'pending'
Beispiel #23
0
class PipelineParameters(Schema):
    input_nwb_file = Str(description="input nwb file", required=True)
    stimulus_ontology_file = Str(description="stimulus ontology JSON",
                                 required=False)
    qc_criteria = Nested(QcCriteria, required=False)
    manual_sweep_states = Nested(ManualSweepState, required=False, many=True)
    ipfx_version = Str(description="version of ipfx package")
Beispiel #24
0
class PreQuestionSchema(Schema):
    nodeId = Str()
    slug = Str()
    langauge = Str()
    text = Str()
    randomize = Bool()
    addedOn = DateTime()
Beispiel #25
0
class Agent_Catalog_Schema(Base_Schema):
    """Represents an agent in the catalog."""

    doc = Agent_Catalog_Document
    id = Str(required=True,
             example='filebeat',
             description='Id of the agent in the catalog.')
    actions = Nested(Agent_Catalog_Action_Schema,
                     unknown='INCLUDE',
                     many=True,
                     description='Action properties.',
                     validate=Unique_List.apply('id'),
                     error_messages=Unique_List.error_messages)
    parameters = Nested(Agent_Catalog_Parameter_Schema,
                        unknown='INCLUDE',
                        many=True,
                        description='Parameter properties.',
                        validate=Unique_List.apply('id'),
                        error_messages=Unique_List.error_messages)
    resources = Nested(Agent_Catalog_Resource_Schema,
                       unknown='INCLUDE',
                       many=True,
                       description='Resource properties.',
                       validate=Unique_List.apply('id'),
                       error_messages=Unique_List.error_messages)
    description = Str(
        example='Collect system metrics from execution environments.',
        description='Short description of the agent.')
Beispiel #26
0
class Config_Resource_Response_Schema(Config_Response_Schema):
    """Resource part in a single item of the config response."""
    path = Str(required=True, example='filebeat.yml', description='File path')
    """Resource part in a single item of the config response."""
    content = Str(required=True,
                  example='<config><period>10s</period></config>',
                  description='File content')
Beispiel #27
0
class Pipeline_Schema(Base_Schema):
    """Represents the stored pipelines."""

    doc = Pipeline_Document
    id = Str(required=True,
             example='BXrHRn5RPU55Qh9JwMZn',
             description='Id of the pipeline.')
    updated_at = Date_Time(
        description=
        'Date of last update of the pipeline in Unix timestamp format.',
        format='timestamp',
        example=1617278285)
    created_at = Date_Time(
        required=True,
        readonly=True,
        example=1617278285,
        format='timestamp',
        description='Date of creation of the pipeline in Unix timestamp format.'
    )
    name = Str(description='Used by the UI to create a new pipeline.',
               example='test pipeline guard-vdpi ud')
    status = Str(required=True,
                 description='Pipeline status.',
                 example='started')
    user = Str(
        description='User/Entity owner/manager/responsible of the pipeline.',
        example='Minds & Sparks')
class ResellerRegisterSchema(Schema):
    name = Str(required=True, error_messages=SCHEMA_MESSAGE_REQUIRED)
    last_name = Str(required=True, error_messages=SCHEMA_MESSAGE_REQUIRED)
    cpf = Str(required=True,
              validate=Length(max=11),
              error_messages=SCHEMA_MESSAGE_REQUIRED)
    email = Email(required=True, error_messages=SCHEMA_MESSAGE_REQUIRED)
    password = Str(required=True, error_messages=SCHEMA_MESSAGE_REQUIRED)
Beispiel #29
0
class FeaturesExtractionParameters(Schema):
    input_nwb_file = Str(description="input nwb file", required=True)
    stimulus_ontology_file = Str(description="stimulus ontology JSON",
                                 required=False)
    output_nwb_file = Str(description="output nwb file", required=True)
    qc_fig_dir = Str(description="output qc figure directory", required=False)
    sweep_features = Nested(SweepParameters, many=True)
    cell_features = Nested(CellParameters, required=True)
Beispiel #30
0
class CommonDataSet(Schema):
    id = Str(required=True)
    filename = Str(required=True,
                   error_messages={"required": Messages.FIELD_REQUIRED.value})
    path = Str(required=True,
               error_messages={"required": Messages.FIELD_REQUIRED.value})
    status = Str(required=True,
                 error_messages={"required": Messages.FIELD_REQUIRED.value})