ds_stoa.sign._sign

Module for pre-signing URLs for fetching data from GraspDP datalake.

This module provides a function to generate pre-signed URLs for securely accessing data stored in the GraspDP datalake. It uses an authentication token and request parameters to request a pre-signed URL from the Stoa service, which can then be used to fetch data without further authentication.

The sign function supports different environments (development and production) by selecting the appropriate URL to request the pre-signed URL from.

Dependencies: - requests: For making HTTP requests to the Stoa service. - os: For reading environment variables to determine the running environment. - utils.exceptions: For enriching exceptions with more context. - utils.logger: For logging information and errors.

Example Usage:

from ds_stoa.sign import sign

# Authentication token and parameters for the request
token = "your_auth_token"
params = {"key": "12345"}

# Generate a pre-signed URL
pre_signed_url = sign(token=token, params=params)
print(pre_signed_url)

Attributes

LOGGER

BUILDING_MODE

Functions

enrich_http_exception(→ None)

Enriches an HTTP exception with additional context without re-raising it.

sign(→ str)

Generate a pre-signed URL for accessing data in the

Module Contents

ds_stoa.sign._sign.enrich_http_exception(exc: requests.exceptions.HTTPError) None

Enriches an HTTP exception with additional context without re-raising it.

Parameters:

exc – Exception

Returns:

None

ds_stoa.sign._sign.LOGGER
ds_stoa.sign._sign.BUILDING_MODE
ds_stoa.sign._sign.sign(token: str, params: Dict) str

Generate a pre-signed URL for accessing data in the GraspDP datalake.

Parameters:
  • token – Authentication token required for generating the pre-signed URL.

  • params – Parameters for the request, typically including identifiers for the data to be accessed.

Returns:

A string containing the pre-signed URL.

Raises:

ValueError – If the pre-signed URL is not found.

Example::
>>> sign(token=token, params=params)
"https://fmdp.io/stoa-dev/sign/12345"