:py:mod:`kms` ============= .. py:module:: kms .. autoapi-nested-parse:: This library implements various methods for working with the Google KMS APIs. Installation ------------ .. code-block:: console $ pip install --upgrade gcloud-aio-kms Usage ----- We're still working on more complete documentation, but roughly you can do: .. code-block:: python from gcloud.aio.kms import KMS from gcloud.aio.kms import decode from gcloud.aio.kms import encode kms = KMS('my-kms-project', 'my-keyring', 'my-key-name') # encrypt plaintext = b'the-best-animal-is-the-aardvark' ciphertext = await kms.encrypt(encode(plaintext)) # decrypt assert decode(await kms.decrypt(ciphertext)) == plaintext # close the HTTP session # Note that other options include: # * providing your own session: `KMS(.., session=session)` # * using a context manager: `async with KMS(..) as kms:` await kms.close() Emulators --------- For testing purposes, you may want to use ``gcloud-aio-kms`` along with a local emulator. Setting the ``$KMS_EMULATOR_HOST`` environment variable to the address of your emulator should be enough to do the trick. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 kms/index.rst utils/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: kms.KMS Functions ~~~~~~~~~ .. autoapisummary:: kms.decode kms.encode Attributes ~~~~~~~~~~ .. autoapisummary:: kms.SCOPES kms.__version__ .. py:class:: KMS(keyproject, keyring, keyname, service_file = None, location = 'global', session = None, token = None, api_root = None) .. py:attribute:: _api_root :type: str .. py:attribute:: _api_is_dev :type: bool .. py:method:: headers() :async: .. py:method:: decrypt(ciphertext, session = None) :async: .. py:method:: encrypt(plaintext, session = None) :async: .. py:method:: close() :async: .. py:method:: __aenter__() :async: .. py:method:: __aexit__(*args) :async: .. py:data:: SCOPES :value: ['https://www.googleapis.com/auth/cloudkms'] .. py:function:: decode(payload) https://en.wikipedia.org/wiki/Base64#URL_applications modified Base64 for URL variants exist, where the + and / characters of standard Base64 are respectively replaced by - and _ Does not make any assumptions about encoding -- if you're encoding a bytes payload then `foo == decode(encode(foo))`, but if `foo` is a string you'll need to `.decode()` manually according to your expected encoding scheme. .. py:function:: encode(payload) https://en.wikipedia.org/wiki/Base64#URL_applications modified Base64 for URL variants exist, where the + and / characters of standard Base64 are respectively replaced by - and _ .. py:data:: __version__