Skip to main content

Kubernetes Service Binding Library for Python Applications

Project description

pyservicebinding

PyPI - Downloads Release Supported Python Versions CI

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

pyservicebinding-0.2.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyservicebinding-0.2.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pyservicebinding-0.2.1.tar.gz.

File metadata

  • Download URL: pyservicebinding-0.2.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for pyservicebinding-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f978cd714d8eedd2de1f8af2f03435507c162601898af820c88afa176571f418
MD5 1d7b858af36e63a918b75da77e1f2021
BLAKE2b-256 d062c1db3114936cb2da5aaeb238751e5b02aad0ba164a250f6e653884e75cae

See more details on using hashes here.

File details

Details for the file pyservicebinding-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyservicebinding-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6

File hashes

Hashes for pyservicebinding-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 738cf13c6ac2f71ae9ae343e5f615b71b4f4694ad21821363391e32323fa104b
MD5 5df608b0644e2c68c52122bc41e41b00
BLAKE2b-256 7844b88d18ad74b76425cfec65d1a77c93b5c20920634880ec8ba4265cf9b839

See more details on using hashes here.

Supported by

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