Granica Python SDK
Project description
Granica SDK
This SDK provides an authentication solution for programatically interacting with Granica. It wraps the boto3 interface so project wide integration is as easy as refactoring import boto3
to import granica as boto3
.
The package affects the signing and routing protocol of the boto3 S3 client, therefore any non S3 clients created through this SDK will be un-affected by the wrapper.
Prerequisites
The minimum supported version of Python is version 3.
Installation
python3 -m pip install granica-sdk
Configuration
For the client to work it must have knowledge of Granica's service discovery url. These are parameterized by the region of Granica's deployment. A preferred availability zone ID can also be provided for AZ-aware routing.
Configure the Granica custom domain:
Declare the ENV variable: GRANICA_CUSTOM_DOMAIN
, which constructs Granica URL and hostname based on default naming, and AWS region.
export GRANICA_CUSTOM_DOMAIN="example.com"
There are two ways to expose Granica's region/preferred availability zone to the SDK:
- If running on an EC2 instance the SDK will by default use that instance's region and zone ID
- With the ENV variables:
AWS_REGION
andAWS_ZONE_ID
.
export AWS_REGION='<region>'
export AWS_ZONE_ID='<az-id>'
Debugging
Import the default logger and set its level to DEBUG
logging.getLogger().setLevel(logging.DEBUG)
Example S3 GetObject
import granica as boto3
s3_client = boto3.client('s3')
response = s3_client.get_object(Bucket='MyBucket', Key='MyKey.csv')
obj = response['Body'].read()
Tests
Basic integration tests are provided for the modified Session/Client interfaces. They must be run in an environment with a properly configured Granica deployment accessible.
python3 tests/tests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for granica_sdk-2.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020c4eb88e441c6d057ae840aa30bab923ab1374c0454884842f659ba1c4e646 |
|
MD5 | c9c4a5b429c12da25abdb668c5e5a1d5 |
|
BLAKE2b-256 | 599b5f610cbf0cec18533f414c164b1c059ccbd764ceb5b89fce707745f4bbe1 |