Grasp Labs AS - Stoa Package
Overview
The Stoa package, developed by Grasp Labs AS, is a core component of our communication and data exchange system. The Stoa class offers essential functionalities for fetching, signing, authenticating, and ordering messages. These operations are fundamental for ensuring the integrity, authenticity, and proper sequencing of messages within our system.
Installation
You can install the Stoa package via pip:
pip install ds-stoa
Usage
Below are examples demonstrating how to utilize the Stoa class to handle message operations:
Initialization
Initialize the Stoa class with required parameters:
from stoa import Stoa
stoa = Stoa(
authentication="oauth2",
product_group_name="group1",
product_name="product1",
workspace="apps",
owner_id="owner123",
client_id="your_client_id",
client_secret="your_client_secret",
)
Authentication
Authenticate using the specified method:
stoa.authenticate()
assert stoa.is_authenticated():
Ordering
Create simple orders to be pre-signed.
order_ids = stoa.order()
print(f"Ordered IDs: {order_ids}")
Signing
Sign order to ensure their integrity and authenticity:
signatures = stoa.sign()
print(f"Signatures: {signatures}")
Fetch
Fetch method automatically handles the order and sign.
- Authenticate
- Order
- Sign
- Fetch
One can decide output format (default pd.Dataframe).
# Fetch as JSON
fetched_data_json = stoa.fetch(format="json")
print(f"Fetched Data (JSON): {fetched_data_json}")
# Fetch as DataFrame
fetched_data_df = stoa.fetch(format="dataframe")
print(f"Fetched Data (DataFrame):\n{fetched_data_df}")
Class Details
Stoa Class
The Stoa class provides methods for handling messages within our system, including operations for fetching, signing, authenticating, and ordering messages.
Constructor
def __init__(
self,
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: Optional[str] = None,
password: Optional[str] = None,
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
) -> None
Parameters:
- authentication (str): The authentication method to use ("rest" or "oauth2").
- product_group_name (str): The name of the product group.
- product_name (str): The name of the product.
- workspace (str): The workspace where the product is located ("apps" or "cart").
- owner_id (str): The ID of the product owner.
- version (str): The version of the product (default: "1.0").
- offset (int): The offset for pagination (default: 0).
- limit (int): The limit for pagination (default: 20).
- ascending (bool): Whether to sort in ascending order (default: False).
- email (Optional[str]): The email for REST authentication (default: None).
- password (Optional[str]): The password for REST authentication (default: None).
- client_id (Optional[str]): The client ID for OAuth2 authentication (default: None).
- client_secret (Optional[str]): The client secret for OAuth2 authentication (default: None).
Methods
- authenticate() -> None: Authenticates a message to verify its origin.
- is_authenticated() -> bool: Checks if a message is authenticated.
- order() -> List[str]: Orders messages based on predefined rules.
- sign() -> Dict: Signs messages to ensure their integrity and authenticity.
- fetch(format: Literal["json", "dataframe"]) -> Union[List[Dict], pd.DataFrame]: Fetches messages in the specified form
License
This package is licensed under the MIT License.
Contact
For further information or assistance, please contact Grasp Labs AS support at hello@grasplabs.com.
Metadata
Release files for ds-stoa 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ds_stoa-0.2.1.tar.gz | 18.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ds_stoa-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.9 kB
Release files / ds_stoa-0.2.1.tar.gz
| Download URL | ds_stoa-0.2.1.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f19bc54c513c5690f20232b49a9370b4cb77e0c5691163135473c361d5e48179
|
|
BLAKE2b-256 checksum How to use checksums |
e4db11db344f2b140cb9419a96c480366a836de7f49e7693295f5b16ce8ff300
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / ds_stoa-0.2.1-py3-none-any.whl
| Download URL | ds_stoa-0.2.1-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb81d5301f2544535e0e4a11c31288b646d0be2b015beb72a0094a847e105a8a
|
|
BLAKE2b-256 checksum How to use checksums |
99d449414805dc558136921901296dee7e36bd94d3a1a74d0689a7ace1e1a4cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|