class BillingInfo(db.Model): """ SQLAlchemy class representing storage server billing information, i.e. the retrieval of a record by a data owner """ __tablename__ = 'billing_information' id = db.Column(db.Integer, nullable=False, primary_key=True) # Auto client_id = db.Column(db.Integer, db.ForeignKey("client.id"), nullable=False) client = db.relationship("Client", uselist=False, foreign_keys=[client_id]) provider_id = db.Column(db.Integer, db.ForeignKey("owner.id"), nullable=False) provider = db.relationship("Owner", uselist=False, foreign_keys=[provider_id]) count = db.Column(db.Integer, nullable=False) # Num. of retr. items transaction_id = db.Column(db.Integer, db.ForeignKey("record_retrieval_accesses.id"), nullable=False) # ID of transaction transaction = db.relationship("RecordRetrieval", uselist=False, foreign_keys=[transaction_id]) timestamp = db.Column(db.DateTime, default=datetime.now(), nullable=False)
class Owner(User, db.Model): """Data Providers.""" tokens = db.relationship("Token", uselist=True, backref='provider', lazy=False)
class Client(User, db.Model): """Client-type end-users.""" tokens = db.relationship("Token", uselist=True, backref='client', lazy=False)
class PSIAccess(db.Model): """ SQLAlchemy class representing one access to the PSI API """ __tablename__ = 'psi_accesses' id = db.Column(db.Integer, nullable=False, primary_key=True) # Auto client_id = db.Column(db.Integer, db.ForeignKey("client.id"), nullable=False) client = db.relationship("Client", uselist=False, foreign_keys=[client_id]) timestamp = db.Column(db.DateTime, default=datetime.now(), nullable=False)
class HashKeyRetrieval(db.Model): """ SQLAlchemy class storing all hash key retrieval operations. """ __tablename__ = 'hash_key_retrievals' id = db.Column(db.Integer, nullable=False, primary_key=True) # Auto client_id = db.Column(db.Integer, db.ForeignKey("client.id")) client = db.relationship("Client", uselist=False, foreign_keys=[client_id]) provider_id = db.Column(db.Integer, db.ForeignKey("owner.id")) provider = db.relationship("Owner", uselist=False, foreign_keys=[provider_id]) timestamp = db.Column(db.DateTime, default=datetime.now(), nullable=False)
class KeyRetrieval(db.Model): """ SQLAlchemy class representing one key retrieval operation on the key server only """ __tablename__ = 'key_retrievals' id = db.Column(db.Integer, nullable=False, primary_key=True) # Auto client_id = db.Column(db.Integer, db.ForeignKey("client.id")) client = db.relationship("Client", uselist=False, foreign_keys=[client_id]) provider_id = db.Column(db.Integer, db.ForeignKey("owner.id")) provider = db.relationship("Owner", uselist=False, foreign_keys=[provider_id]) retrieved_keys = db.Column(db.Integer, nullable=False) timestamp = db.Column(db.DateTime, default=datetime.now(), nullable=False)
class RecordRetrieval(db.Model): """ SQLAlchemy class representing one data retrieval operation on the storage server only """ __tablename__ = 'record_retrieval_accesses' id = db.Column(db.Integer, nullable=False, primary_key=True) # Auto client_id = db.Column(db.Integer, db.ForeignKey("client.id"), nullable=False) client = db.relationship("Client", uselist=False, foreign_keys=[client_id]) enc_keys_by_hash = db.Column(db.Integer, nullable=False) # Number of encryption keys for all requested hashes enc_keys_by_records = db.Column(db.Integer, nullable=False) # Number of encryption keys fo all returned records timestamp = db.Column(db.DateTime, default=datetime.now(), nullable=False)