Skip to main content

A python package for GraspDP Stoa. Simple and easy way to interact with GraspDP datalake.

Project description

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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ds_stoa-0.1.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ds_stoa-0.1.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file ds_stoa-0.1.0.tar.gz.

File metadata

  • Download URL: ds_stoa-0.1.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for ds_stoa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c73f6e4ad1c7ea2173c655226e267a114c2246e764ac18931ef8289acef4fad2
MD5 d4a49c946cb5134c5d35df4105867fac
BLAKE2b-256 3a975a09375a4584e19ecedbe97dcc4dc0355e114f0229832b151ea40e0b67fc

See more details on using hashes here.

File details

Details for the file ds_stoa-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ds_stoa-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for ds_stoa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 feeada72b58f5f018b69c0a1e6da1f3a60f8da02f5e02b32d60efc163f67f7f5
MD5 f66fa51d5e50f3f2b40a2ba30dd0ccfd
BLAKE2b-256 81baf95e76e3e0b7901839431306018456ac9a157df9c768f78c84042fe4c9f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page