ds_stoa.manager

Manager module for the Stoa class.

This module serves as the manager for the Stoa class, facilitating the management of messages within our system. The Stoa class provides methods for fetching, signing, authenticating, and ordering messages, which are crucial for secure and efficient communication and data exchange.

Usage Examples:

  1. Creating an instance of the Stoa class with REST authentication:

    from ds_stoa.manager.client import StoaClient
    
    stoa = StoaClient(
        authentication="rest",
        product_group_name="exampleGroup",
        product_name="exampleProduct",
        workspace="apps",
        owner_id="owner123",
        email="user@example.com",
        password="securepassword"
    )
    
    stoa.authenticate()
    assert stoa.is_authenticated()
    
  2. Creating an instance of the Stoa class with OAuth2 authentication:

    from ds_stoa.manager.client import StoaClient
    
    stoa = StoaClient(
        authentication="oauth2",
        product_group_name="exampleGroup",
        product_name="exampleProduct",
        workspace="cart",
        owner_id="owner456",
        client_id="client_id_example",
        client_secret="client_secret_example"
    )
    
    stoa.authenticate()
    assert stoa.is_authenticated()
    
  3. Order, Sign & Fetch:

    stoa = StoaClient(**params)
    order_ids = stoa.order()
    signatures = stoa.sign()
    dataframe = stoa.fetch()
    

Note: Replace the placeholder values (e.g., “user@example.com”, “securepassword”, “client_id_example”, etc.) with your actual data when implementing these examples.

Submodules

Classes

StoaClient

The Stoa class provides methods for handling messages within our system.

Package Contents

class ds_stoa.manager.StoaClient(authentication: Literal['rest', 'oauth2'], product_group_name: str, product_name: str, workspace: Literal['apps', 'cart'], owner_id: str, version: str = '1.0', offset: int = 0, limit: int = 20, ascending: bool = False, email: str | None = None, password: str | None = None, client_id: str | None = None, client_secret: str | None = None)

The Stoa class provides methods for handling messages within our system. These methods include operations for fetching, signing, authenticating, and ordering messages.

property token: str

Token getter that retrieves the current access token.

Returns:

The access token.

Raises:

ValueError – If the access token is missing.

property order_ids: List[str]

Order IDs getter that retrieves the current list of order IDs.

Returns:

List of order IDs.

Raises:

ValueError – If no order IDs are found.

property signatures: Dict

Signatures getter that retrieves the current dictionary of signatures.

Returns:

Dictionary of signatures.

Raises:

ValueError – If no signatures are found.

authenticate() None

Authenticates a message to verify its origin. This method is used to check if a message came from a trusted source before it is processed by the system.

Returns:

The access token for the authenticated request.

Return type:

str

Raises:

NotImplementedError – If the authentication method is invalid.

example::
>>> stoa = StoaClient(**params)
>>> stoa.authenticate()
>>> assert stoa.token
is_authenticated() bool

Checks if a message is authenticated. This method is used to verify that a message has been authenticated before it is processed by the system.

Returns:

True if the message is authenticated, False otherwise.

Return type:

bool

example::
>>> stoa = StoaClient(**params)
>>> stoa.authenticate()
>>> assert stoa.is_authenticated()
order() List[str]

Orders a message based on predefined rules. This method is used to sort or arrange messages according to certain criteria before they are processed by the system.

Returns:

Ordered keys.

Return type:

List

Raises:

ValueError – If the workspace is invalid.

example::
>>> stoa = StoaClient(**params)
>>> stoa.order()
>>> assert stoa.order_ids
sign() Dict

Signs a message to ensure its integrity and authenticity. This method is used to add a layer of security to our messages, making sure they are not tampered with during transit.

Returns:

The pre-signed URLs for the messages.

Return type:

Dict

Raises:

ValueError – If the order IDs are missing.

example::
>>> stoa = StoaClient(**params)
>>> stoa.order()
>>> stoa.sign()
>>> assert stoa.signatures
fetch(format: Literal['json', 'dataframe']) List[Dict] | pandas.DataFrame

Fetches a message from a predefined source. This method is responsible for retrieving messages that are to be processed by the system.

Parameters:

format – The format in which to return the fetched data.

Returns:

The fetched data in the specified format.

Return type:

List[Dict]

Raises:

ValueError – If the format is invalid.

example::
>>> stoa = StoaClient(**params)
>>> stoa.fetch(format="json")