Kerberos Vault Python library for interacting with the Kerberos Vault.
Project description
Python Kerberos Vault
Python Kerberos Vault is a package that provides seamless integration between Python applications and the Kerberos Vault. It simplifies the process of receiving messages or videos from the Kerberos Vault.
Installation
To get started with Python Kerberos Vault, simply install the package using pip and follow the provided documentation for configuration and usage instructions: pip install uugai_python_kerberos_vault
To import the KerberosVault
class into your Python file, use the following import statement:
from uugai_python_kerberos_vault import KerberosVault
Message object architecture
The message architecture should match this architecture:
{'source': 'your_storage_provider',
'payload': {'key': 'file_name', 'additional_info: '...'},
'data': {storage_uri: 'kerberos_vault_uri' , storage_access_key: 'access_key' , storage_secret: 'secret_key'}
}
Features
KerberosVault
has a couple of useful features such as:
Initialization
Simply initialize the Kerberos Vault connection using your storage_uri, storage_access_key and storage_secret_key.
integrator = KerberosVault(storage_uri, storage_access_key, storage_secret_key)
Retrieve media
The retrieve_media function is a method of the KerberosVault
class. It fetches associated data from storage and performs actions based on the provided parameters. It returns the response from the request.get method.
Parameters:
message
(str): The message to be processed.media_type
(str): The type of message to be processed (image, video). Default is an empty string.media_savepath
(str): The path where the media file is to be saved. Default is an empty string.
The function first updates the storage-related information if available in the message payload. Then, it creates headers for accessing the storage service using the create_headers method of the class. Make sure the message's architecture matches the above mentioned architecture!
-
media_type == 'image': To be implemented
-
media_type == 'video': It reconstructs a video file from the received requested data and saves it to the specified media_savepath.
resp = retrieve_media(message, media_type, media_savepath)
-
media_type not provided or supported: No actions are taken on the response object. solely the response is returned.
Update storage information
The update_storage_information
function in the KerberosVault
class is responsible for updating the storage information used for connecting to the Kerberos Vault. It takes a single dictionary with the key-value pairs of the following parameters.
storage_uri
(str): The URI of the storage where the Kerberos Vault is located.storage_access_key
(str): The access key for the storage.storage_secret_key
(str): The secret key for the storage.
it could look something like this:
data = {'storage_uri': 'kerberos_vault_uri',
'storage_access_key': 'username',
'storage_secret_key': 'password'}
update_storage_info(data)
Create headers
The create_headers()
function in the KerberosVault
class is responsible for creating the headers required for authentication with the Kerberos Vault API. It takes the following parameters:
file_name
(str): The name of the file to request.storage_provider
(str): The name of the storage provider.
The function returns a dictionary containing the headers to be used in the API request.
Example usage
The code snippet provided demonstrates the usage of the KerberosVault library in Python. It showcases how to initialize a connection and retrieve a media object from the Kerberos Vault.
from uugai_python_dynamic_queue.MessageBrokers import RabbitMQ
from uugai_python_kerberos_vault.KerberosVault import KerberosVault
# Initialize a message broker using the python_queue_reader package
rabbitmq = RabbitMQ(queue_name='queue_name_example',
target_queue_name = '',
exchange='',
host='host_name_example',
username='username',
password='password')
# Initialize Kerberos Vault
kerberos_vault = KerberosVault('vault_api', 'access_key', 'secret_key')
# Receive messages from the queue
message = rabbitmq.receive_message()
media_type = 'video'
media_savepath = 'data/video.mp4'
# Retrieve media from the Kerberos Vault
resp = kerberos_vault.retrieve_media(message, media_type, media_savepath)
print("media of type", media_type, "saved to location: ", media_savepath)
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
File details
Details for the file uugai_python_kerberos_vault-1.1.0.tar.gz
.
File metadata
- Download URL: uugai_python_kerberos_vault-1.1.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d55b238e99dc9fb1583394a57bc3de4291226618ab9137989c403aa546454c6 |
|
MD5 | 596511efc4b07e9d372ffd95f4cd31a7 |
|
BLAKE2b-256 | 3788a0bcdf72b45ca80b490ef91ffc1f23768b2c38145f8b9b0cebdda6c0bcc2 |
File details
Details for the file uugai_python_kerberos_vault-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: uugai_python_kerberos_vault-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ec22a3aebb187af7e486ee94cb5c362b3e56ca56a8c677ddcc7efd70502a582 |
|
MD5 | 027ec2d0903b8c583d1d1458429a8924 |
|
BLAKE2b-256 | 00abc5b1482a03532d6865408b0f07f42166937ba0d1106efad477a7a41d63eb |