Skip to main content

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)

Release files for uugai-python-kerberos-vault 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uugai-python-kerberos-vault 1.2.0
File Size Uploaded
uugai_python_kerberos_vault-1.2.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uugai-python-kerberos-vault 1.2.0
File Interpreter ABI Platform
uugai_python_kerberos_vault-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / uugai_python_kerberos_vault-1.2.0.tar.gz

Download URL uugai_python_kerberos_vault-1.2.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cb8ed713ab5ae89f7d13b03963760da0924770caff34ecd28e6897eb98b2bfd4
BLAKE2b-256 checksum
How to use checksums
875b6a4c15715a2c44cc2e64a2f0b79eafb4a066fac8fb42e165c091e1ee84bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Release files / uugai_python_kerberos_vault-1.2.0-py3-none-any.whl

Download URL uugai_python_kerberos_vault-1.2.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49cfc9b0571f868e40742f20c1becfeba37a69bb6eadf28da0603dfdcc26b69e
BLAKE2b-256 checksum
How to use checksums
d45dafee1fd24432a8b4d6742ea67a3c00790d76a421a14494e297c1900b0357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page