Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uugai_python_kerberos_vault-1.2.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file uugai_python_kerberos_vault-1.2.0.tar.gz.

File metadata

File hashes

Hashes for uugai_python_kerberos_vault-1.2.0.tar.gz
Algorithm Hash digest
SHA256 cb8ed713ab5ae89f7d13b03963760da0924770caff34ecd28e6897eb98b2bfd4
MD5 9a4d5ba4e1bea8b3154ac6338278b55f
BLAKE2b-256 875b6a4c15715a2c44cc2e64a2f0b79eafb4a066fac8fb42e165c091e1ee84bc

See more details on using hashes here.

File details

Details for the file uugai_python_kerberos_vault-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for uugai_python_kerberos_vault-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49cfc9b0571f868e40742f20c1becfeba37a69bb6eadf28da0603dfdcc26b69e
MD5 b04f256fc906aac0348485ad1b4eb218
BLAKE2b-256 d45dafee1fd24432a8b4d6742ea67a3c00790d76a421a14494e297c1900b0357

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page