Utility to download or upload data from/to .Stat Suite using ADFS authentication to connect to it
Project description
DotStat_IO:
A generic python package which could be integrated with other end-user applications and Gitlab runner to perform basic io with .Stat Suite. Its role is to mask the complexities of authentication to connect to .Stat Suite. The user needs to provide a set of parameters and the package exposes a couple of methods which will download or upload data from/to .Stat Suite.
This package contains three modules:
- ADFSAuthentication module
- KeycloakAuthentication module
- Download_upload module
In ADFSAuthentication module, four methods are available:
1. To initialise the module for interactive use:
from dotstat_io.authentication import AdfsAuthentication
with AdfsAuthentication.interactive(
client_id=client_id,
sdmx_resource_id=sdmx_resource_id,
scopes=scopes,
authority_url=authority_url,
redirect_port=redirect_port) as Interactive_obj:
access_token = Interactive_obj.get_token()
client_id:
The Application (client) ID that the ADFS assigned to your appsdmx_resource_id:
The ID of the application to be accessed such as .Stat Suitescopes:
Scopes requested to access a protected API (a resource defined by sdmx_resource_id)authority_url:
URL that identifies a token authorityredirect_port:
The port of the address to return to upon receiving a response from the authority
2. To initialise the module for non-interactive use using a secret:
from dotstat_io.authentication import AdfsAuthentication
with AdfsAuthentication.nointeractive_with_secret(
client_id=client_id,
sdmx_resource_id=sdmx_resource_id,
scopes=scopes,
authority_url=authority_url,
client_secret=client_secret) as Nointeractive_with_secret_obj:
access_token = Nointeractive_with_secret_obj.get_token()
client_id:
The Application (client) ID that the ADFS assigned to your appsdmx_resource_id:
The ID of the application to be accessed such as .Stat Suitescopes:
Scopes requested to access a protected API (a resource defined by sdmx_resource_id)authority_url:
URL that identifies a token authorityclient_secret:
The application secret that you created during app registration in ADFS
3. To initialise the module for non-interactive use using windows client authentication:
from dotstat_io.authentication import AdfsAuthentication
with AdfsAuthentication.nointeractive_with_adfs(
client_id=client_id,
sdmx_resource_id=sdmx_resource_id,
token_url=token_url) as Nointeractive_with_adfs_obj:
access_token = Nointeractive_with_adfs_obj.get_token()
client_id:
The Application (client) ID that the ADFS assigned to your appsdmx_resource_id:
The ID of the application to be accessed such as .Stat Suitetoken_url:
URL of the authentication service
4. To get a token after initialisation of "AdfsAuthentication" object as shown above:
access_token = [Authentication Object Name].get_token()
In KeycloakAuthentication module, two methods are available:
1. To initialise the module for Keycloak authentication:
from dotstat_io.authentication import KeycloakAuthentication
with KeycloakAuthentication.nointeractive_with_secret(
user=user,
password=password,
token_url=token_url,
proxy=proxy) as Nointeractive_with_keycloak_obj:
access_token = Nointeractive_with_keycloak_obj.get_token()
user:
User name for .Stat Suite authenticationpassword:
User name's passwordtoken_url:
URL of the authentication serviceproxy:
URL of the SSL certificates
2. To get a token after initialisation of "KeycloakAuthentication" object as shown above:
access_token = [Authentication Object Name].get_token()
In Download_upload module, four methods are available:
1. To download a file from .Stat Suite:
from dotstat_io.download_upload import Download_upload
with Download_upload(adfsAuthentication_obj, access_token) as Download_upload_obj:
Returned_Message = Download_upload_obj.download_file(
dotstat_url, content_format, Path(file_path))
dotstat_url:
URL of data to be downloaded from .Stat Suitecontent_format:
Format of the downloaded contentfile_path:
The full path where the file will downloaded
2. To download streamed content from .Stat Suite:
from dotstat_io.download_upload import Download_upload
with Download_upload(adfsAuthentication_obj, access_token) as Download_upload_obj:
Returned_Message = Download_upload_obj.download_stream(
dotstat_url, content_format)
dotstat_url:
URL of data to be downloaded from .Stat Suitecontent_format:
Format of the downloaded content
3. To upload a data file to .Stat Suite:
from dotstat_io.download_upload import Download_upload
with Download_upload(adfsAuthentication_obj, access_token) as Download_upload_obj:
Returned_Message = Download_upload_obj.upload_file(
transfer_url, Path(file_path), space, validationType, use_filepath)
transfer_url:
URL of the transfer servicefile_path:
The full path of the SDMX-CSV file, which will be uploaded to .Stat Suitespace:
Data space where the file will be uploadedvalidationType:
The type of validation to use during upload. Possible values: Basic Validation (0), Advanced Validation (1)use_filepath:
Use a file path of a shared folder accessible by the .Stat Suite data upload engine (for unlimited file sizes)
4. To upload a structure to .Stat Suite:
from dotstat_io.download_upload import Download_upload
with Download_upload(adfsAuthentication_obj, access_token) as Download_upload_obj:
Returned_Message = Download_upload_obj.upload_structure(
transfer_url, Path(file_path))
transfer_url:
URL of the transfer servicefile_path:
The full path of the SDMX-ML file, which will be uploaded to .Stat Suite
For more information about how to use this package, all test cases can be accessed from this link
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
dotstat_io-0.2.0.tar.gz
(7.0 kB
view hashes)
Built Distribution
Close
Hashes for dotstat_io-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd8a997448c267d5224ff2cb983c0e422a23f3b3be2c1ef7a4175d975ecd366 |
|
MD5 | 2fa65fc6d2d479a786a3d76f00dc6996 |
|
BLAKE2b-256 | 99ed61cd5f16e4d868f9b2a29abb6b08b0a5de198dc6513403a021e482189342 |