class SchemaField(MessageValidator): schema = ( (NAME, NonEmptyStringField()), (VERSION, NonEmptyStringField()), (ORIGIN, NonEmptyStringField(optional=True)), )
class ClientDiscloOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(DISCLO)), (DATA, NonEmptyStringField()), (NONCE, NonEmptyStringField()), (TARGET_NYM, IdentifierField(optional=True)), )
class ClientClaimDefGetOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(GET_CLAIM_DEF)), (REF, NonNegativeNumberField()), (ORIGIN, NonEmptyStringField()), (SIGNATURE_TYPE, NonEmptyStringField()), )
class ClientAttribOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(ATTRIB)), (TARGET_NYM, IdentifierField(optional=True)), (RAW, JsonField(optional=True)), (ENC, NonEmptyStringField(optional=True)), (HASH, NonEmptyStringField(optional=True)), ) def _validate_message(self, msg): fields_n = sum(1 for f in (RAW, ENC, HASH) if f in msg) if fields_n == 0: self._raise_missed_fields(RAW, ENC, HASH) if fields_n > 1: self._raise_invalid_message( "only one field from {}, {}, {} is expected".format( RAW, ENC, HASH))
class ClientPoolUpgradeOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(POOL_UPGRADE)), (ACTION, NonEmptyStringField()), # TODO check actual value set (VERSION, NonEmptyStringField()), # TODO replace actual checks (idr, datetime) (SCHEDULE, MapField(NonEmptyStringField(), NonEmptyStringField(), optional=True)), (SHA256, NonEmptyStringField()), (TIMEOUT, NonNegativeNumberField(optional=True)), (JUSTIFICATION, NonEmptyStringField(optional=True, nullable=True)), (NAME, NonEmptyStringField(optional=True)), )
class ClientGetAttribOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(GET_ATTR)), (TARGET_NYM, IdentifierField(optional=True)), (RAW, NonEmptyStringField()), )
class ClientSchemaOperation(MessageValidator): schema = ( (TXN_TYPE, ConstantField(SCHEMA)), (DATA, NonEmptyStringField()), )