Metadata-Version: 2.1
Name: aicsapi-tool-python
Version: 0.2.5
Summary: Toolkit for Python backend template
Home-page: https://github.com/slSeanWU/aicsapi-tool-python/
Author: Sean (Shih-Lun) Wu
Author-email: summer7sean@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
Requires-Dist: applicationinsights (==0.11.9)
Requires-Dist: adal (==1.0.2)
Requires-Dist: python-dotenv (==0.10.3)
Requires-Dist: azure-keyvault (==1.1.0)
Requires-Dist: pyOpenSSL (==19.0.0)

# aicsapi-tool-python
## Description
A package to help Python API template in:  
 * Logging to Azure Application Insights 
 * Fetching secret from Azure Key Vault 
 * Generating self-signed certificate and upload it to Azure Key Vault
 * Caching credential token to save login time

## Installation
This package has been published to PyPI, so you can use  
`pip install aicsapi-tool-python`

## Note
When calling methods in `keyvault_utils` or `keyvault_certgen`, be sure to have the following environment variables set:  
~~~
KEY_VAULT_URL 
KEY_VAULT_SECRET_NAME 
KEY_VAULT_CERT_NAME
~~~

## Example: Generate Self-signed Certification and Upload to Azure KV
  * Ensure required env. variables are loaded, create `.kvvars` under current working directory
~~~
KEY_VAULT_URL="https://[your keyvault name].vault.azure.net"  
KEY_VAULT_CERT_NAME="certificate name"  
~~~

 * Run the following code snippet with  
`python certgen.py [your ASUS account name] [filename of generated key & cert]`
```python
# certgen.py

from aicsapi_tool_python.keyvault_certgen import generate_v3cert, upload_v3cert_to_kv
import sys, time

asus_account = sys.argv[1]
cert_name = sys.argv[2]

generate_v3cert( asus_account, cert_name )
time.sleep(1)     # Gives time to write files to disk
upload_v3cert_to_kv( cert_name + '.pfx' )
```


