How to use the hvac.api.system_backend.system_backend_mixin.SystemBackendMixin function in hvac

To help you get started, we’ve selected a few hvac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hvac / hvac / hvac / api / system_backend / audit.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Support for "Audit"-related System Backend Methods."""
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Audit(SystemBackendMixin):

    def list_enabled_audit_devices(self):
        """List enabled audit devices.

        It does not list all available audit devices.
        This endpoint requires sudo capability in addition to any path-specific capabilities.

        Supported methods:
            GET: /sys/audit. Produces: 200 application/json

        :return: JSON response of the request.
        :rtype: dict
        """
        list_audit_devices_response = self._adapter.get('/v1/sys/audit').json()
        return list_audit_devices_response
github hvac / hvac / hvac / api / system_backend / policy.py View on Github external
import json

from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Policy(SystemBackendMixin):

    def list_policies(self):
        """List all configured policies.

        Supported methods:
            GET: /sys/policy. Produces: 200 application/json

        :return: The JSON response of the request.
        :rtype: dict
        """
        api_path = '/v1/sys/policy'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
github hvac / hvac / hvac / api / system_backend / seal.py View on Github external
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Seal(SystemBackendMixin):

    def is_sealed(self):
        """Determine if  Vault is sealed.

        :return: True if Vault is seal, False otherwise.
        :rtype: bool
        """
        seal_status = self.read_seal_status()
        return seal_status['sealed']

    def read_seal_status(self):
        """Read the seal status of the Vault.

        This is an unauthenticated endpoint.

        Supported methods:
github hvac / hvac / hvac / api / system_backend / key.py View on Github external
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin
from hvac.exceptions import ParamValidationError


class Key(SystemBackendMixin):

    def read_root_generation_progress(self):
        """Read the configuration and process of the current root generation attempt.

        Supported methods:
            GET: /sys/generate-root/attempt. Produces: 200 application/json

        :return: The JSON response of the request.
        :rtype: dict
        """
        api_path = '/v1/sys/generate-root/attempt'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
github hvac / hvac / hvac / api / system_backend / lease.py View on Github external
from hvac import utils
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Lease(SystemBackendMixin):

    def read_lease(self, lease_id):
        """Retrieve lease metadata.

        Supported methods:
            PUT: /sys/leases/lookup. Produces: 200 application/json

        :param lease_id: the ID of the lease to lookup.
        :type lease_id: str | unicode
        :return: Parsed JSON response from the leases PUT request
        :rtype: dict.
        """
        params = {
            'lease_id': lease_id
        }
        api_path = '/v1/sys/leases/lookup'
github hvac / hvac / hvac / api / system_backend / leader.py View on Github external
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Leader(SystemBackendMixin):

    def read_leader_status(self):
        """Read the high availability status and current leader instance of Vault.

        Supported methods:
            GET: /sys/leader. Produces: 200 application/json

        :return: The JSON response of the request.
        :rtype: dict
        """
        api_path = '/v1/sys/leader'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
github hvac / hvac / hvac / api / system_backend / auth.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Support for "Auth"-related System Backend Methods."""
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin
from hvac.utils import validate_list_of_strings_param, list_to_comma_delimited
from hvac import exceptions


class Auth(SystemBackendMixin):

    def list_auth_methods(self):
        """List all enabled auth methods.

        Supported methods:
            GET: /sys/auth. Produces: 200 application/json

        :return: The JSON response of the request.
        :rtype: dict
        """
        api_path = '/v1/sys/auth'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
github hvac / hvac / hvac / api / system_backend / namespace.py View on Github external
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Namespace(SystemBackendMixin):

    def create_namespace(self, path):
        """Create a namespace at the given path.

        Supported methods:
            POST: /sys/namespaces/{path}. Produces: 200 application/json

        :return: The response of the request.
        :rtype: requests.Response
        """
        api_path = '/v1/sys/namespaces/{path}'.format(path=path)
        response = self._adapter.post(
            url=api_path,
        )
        return response
github hvac / hvac / hvac / api / system_backend / health.py View on Github external
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Support for "Health"-related System Backend Methods."""
from hvac import exceptions
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Health(SystemBackendMixin):
    """.

    Reference: https://www.vaultproject.io/api/system/index.html
    """

    def read_health_status(self, standby_ok=False, active_code=200, standby_code=429, dr_secondary_code=472,
                           performance_standby_code=473, sealed_code=503, uninit_code=501, method='HEAD'):
        """Read the health status of Vault.

        This matches the semantics of a Consul HTTP health check and provides a simple way to monitor the health of a
        Vault instance.


        :param standby_ok: Specifies if being a standby should still return the active status code instead of the
            standby status code. This is useful when Vault is behind a non-configurable load balance that just wants a
            200-level response.
github hvac / hvac / hvac / api / system_backend / mount.py View on Github external
from hvac.api.system_backend.system_backend_mixin import SystemBackendMixin


class Mount(SystemBackendMixin):

    def list_mounted_secrets_engines(self):
        """Lists all the mounted secrets engines.

        Supported methods:
            POST: /sys/mounts. Produces: 200 application/json

        :return: JSON response of the request.
        :rtype: dict
        """
        response = self._adapter.get('/v1/sys/mounts')
        return response.json()

    def retrieve_mount_option(self, mount_point, option_name, default_value=None):
        secrets_engine_path = '{mount_point}/'.format(mount_point=mount_point)
        secrets_engines_list = self.list_mounted_secrets_engines()['data']