angelos.lib.storage.portfolio_mixin¶
Mixin for enforcing portfolio policy’s before importing.
-
class
angelos.lib.storage.portfolio_mixin.
PortfolioMixin
¶ Bases:
object
Mixin that lets a storage deal with a portfolio repository.
-
PATH_PORTFOLIOS
= (PurePosixPath('/portfolios'),)¶
-
add_portfolio
(portfolio: angelos.lib.policy.portfolio.Portfolio) → Tuple[bool, Set[Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope]], Set[Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope]]]¶ Add a new portfolio of documents into the vault.
All policies are being applied, if documents are invalid exceptions are thrown. The owner documents are excluded.
Return whether portfolio was added True/False and two empty sets.
- Parameters
portfolio_temp (Portfolio) – Portfolio to be imported.
Tuple[bool –
Tuple of bool and two Set of documents.
[0] boolean indicating success or failure. [2] set with rejected documents [3] set of removed documents
Set[DocumentT] –
Tuple of bool and two Set of documents.
[0] boolean indicating success or failure. [2] set with rejected documents [3] set of removed documents
Set[DocumentT]] –
Tuple of bool and two Set of documents.
[0] boolean indicating success or failure. [2] set with rejected documents [3] set of removed documents
-
delete_portfolio
(eid: uuid.UUID) → bool¶ Delete an existing portfolio, except the owner.
- Parameters
eid (uuid.UUID) – The portfolio entity ID.
- Returns (bool):
True upon success.
-
docs_to_portfolio
(documents: Set[Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope]]) → Tuple[Set[Union[angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked]], List[Any]]¶ Import a bunch of statements to several portfolios.
This method applies policys except revoked.
- Parameters
documents (Set[StatementT]) – Set of statement documents.
- Returns
[0] Set of rejected statements. [1] List of results from asyncio gather.
- Return type
Tuple[Set[StatementT], List[Any]]
-
import_portfolio
(portfolio: angelos.lib.policy.portfolio.Portfolio) → bool¶ Save a portfolio for the first time.
This method expects policy’s to already be applied.
- Parameters
portfolio (Portfolio) – Portfolio to be imported.
- Returns
Success or failure.
- Return type
bool
-
list_portfolios
() → Set[Tuple[str, uuid.UUID]]¶ Load a list of all portfolios.
- Returns (List[Tuple[str, uuid.UUID]]):
List of tuples with portfolio path and ID.
-
load_portfolio
(eid: uuid.UUID, config: Tuple[str]) → angelos.lib.policy.portfolio.Portfolio¶ Load portfolio based on uuid.
- Parameters
eid (uuid.UUID) – Entity ID for portfolio to load.
config (Tuple[str]) – Which portfolio configuration to use.
- Returns
Loaded portfolio object.
- Return type
-
portfolio_exists_not
(path: pathlib.PurePosixPath, eid: uuid.UUID)¶ Check that portfolio exists.
-
portfolio_files
(path: pathlib.PurePosixPath, owner: Optional[uuid.UUID] = None)¶ Glob a list of all files in a portfolio.
-
portfolio_path
(eid: uuid.UUID) → pathlib.PurePosixPath¶ Generate portfolio path for a particular entity id.
-
reload_portfolio
(portfolio: angelos.lib.policy.portfolio.PrivatePortfolio, config: Tuple[str]) → bool¶ Synchronize portfolio from storage.
- Parameters
portfolio (PrivatePortfolio) – Portfolio to synchronize or complement.
config (Tuple[str]) – Which portfolio configuration to use.
- Returns
Success or failure.
- Return type
bool
-
save_portfolio
(portfolio: angelos.lib.policy.portfolio.PrivatePortfolio) → bool¶ Save a changed portfolio.
This methods simply sorts all the documents from a portfolio into issued and owned documents. The owned documents are thrown away while the issued documents are compared to the list of existing document. Existing documents are updated, while the new files are created.
This method expects policies to be applied.
-
update_portfolio
(portfolio: angelos.lib.policy.portfolio.Portfolio) → Tuple[bool, Set[Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope]], Set[Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope]]]¶ Update a portfolio in storage with documents.
This method applies policys while doing document comparison.
- Parameters
portfolio_temp (Portfolio) – Portfolio to update storage with.
- Returns
Tuple of bool and two Set of documents.
[0] boolean indicating success or failure. [2] set with rejected documents [3] set of removed documents
- Return type
Tuple[bool, Set[DocumentT], Set[DocumentT]]
-
write_file
(filename: pathlib.PurePosixPath, doc: Union[angelos.document.entities.Person, angelos.document.entities.Ministry, angelos.document.entities.Church, angelos.document.entities.PrivateKeys, angelos.document.entities.Keys, angelos.document.profiles.PersonProfile, angelos.document.profiles.MinistryProfile, angelos.document.profiles.ChurchProfile, angelos.document.domain.Domain, angelos.document.domain.Node, angelos.document.domain.Network, angelos.document.statements.Verified, angelos.document.statements.Trusted, angelos.document.statements.Revoked, angelos.document.messages.Note, angelos.document.messages.Instant, angelos.document.messages.Mail, angelos.document.messages.Share, angelos.document.messages.Report, angelos.document.envelope.Envelope])¶ Write a document to the current archive.
-