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

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.2.1.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.2.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ds_stoa-0.2.1.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.2.1.tar.gz
Algorithm Hash digest
SHA256 f19bc54c513c5690f20232b49a9370b4cb77e0c5691163135473c361d5e48179
MD5 494f2f76f898be70a180d99b7d019c3b
BLAKE2b-256 e4db11db344f2b140cb9419a96c480366a836de7f49e7693295f5b16ce8ff300

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ds_stoa-0.2.1-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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb81d5301f2544535e0e4a11c31288b646d0be2b015beb72a0094a847e105a8a
MD5 f8a8faa0690cc6f4b42a40cdb637b7b8
BLAKE2b-256 99d449414805dc558136921901296dee7e36bd94d3a1a74d0689a7ace1e1a4cd

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