Kubernetes Service Binding Library for Python Applications
Project description
pyservicebinding
Kubernetes Service Binding Library for Python Applications
This is a Python module to retrieve bindings from a file-system created through an implementation of Service Binding Specification for Kubernetes.
You can install this package using pip:
pip install pyservicebinding
The ServiceBinding
object can be instantiated like this:
from pyservicebinding import binding
try:
sb = binding.ServiceBinding()
except binding.ServiceBindingRootMissingError as msg:
# log the error message and retry/exit
print("SERVICE_BINDING_ROOT env var not set")
To get bindings for a specific type
, say postgres
:
bindings_list = sb.bindings("postgres")
To get bindings for a specific type
, say mysql
, and provider
, say mariadb
:
bindings_list = sb.bindings("mysql", "mariadb")
To get all bindings irrespective of the type
and provider
:
bindings_list = sb.all_bindings()
This is the complete API of the module:
class ServiceBindingRootMissingError(Exception):
pass
class ServiceBinding:
def __init__(self):
"""
- raise ServiceBindingRootMissingError if SERVICE_BINDING_ROOT env var not set
"""
def all_bindings(self) -> list[dict[str, str]]:
"""Get all bindings as a list of dictionaries
- return empty list if no bindings found
"""
def bindings(self, _type: str, provider: typing.Optional[str] = None) -> list[dict[str, str]]:
"""Get filtered bindings as a list of dictionaries
- return empty dictionary if no binding found
- filter the result with the given _type input
- if provider input is given, filter bindings using the given type and provider
"""
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
Built Distribution
File details
Details for the file pyservicebinding-0.2.3.tar.gz
.
File metadata
- Download URL: pyservicebinding-0.2.3.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4279d63a3c3fb2b739a4a9ab74cb399472e271b99c71b2954866478e91dcab7 |
|
MD5 | 5d702a000af39a13ca267eafb3bf693a |
|
BLAKE2b-256 | b5b5d7edc7d078e865de7f3b5906d35a58ae42c6bc6693310029284a41c0e82a |
File details
Details for the file pyservicebinding-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: pyservicebinding-0.2.3-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 650a2e16d2a1d9d5b81a87aa3b0a3944a0f58494aaaa2d87bce6a1457b37eb83 |
|
MD5 | 25bcd2605066ffa93d9b0fc1adcb36d9 |
|
BLAKE2b-256 | 8d00eada160ac103a1861bdadbea25da66b83402f4582d78160cdb61e6b0eddd |