# Path: src/stratis_cli/_errors.py
# class StratisCliEngineError(StratisCliRuntimeError):
#     """
#     Raised if there was a failure due to an error in stratisd's engine.
#     """
# 
#     def __init__(self, rc, message):
#         """
#         Initializer.
# 
#         :param rc int: the error code returned by the engine
#         :param str message: whatever message accompanied the error code
#         """
#         # pylint: disable=super-init-not-called
#         self.error_code = rc
#         self.message = message
# 
#     def __str__(self):
#         return "%s: %s" % (STRATISD_ERROR_TO_NAME(self.error_code), self.message)
# 
# class StratisCliNoChangeError(StratisCliPartialChangeError):
#     """
#     Raised if a request made of stratisd must result in no change since the
#     post-condition of the request is already entirely satisfied. This is
#     a special case of StratisCliPartialChangeError, where the change requested
#     is so simple that it can only succeed or fail.
#     """
# 
#     def __init__(self, command, resource):
#         """
#         Initializer.
# 
#         :param str command: the executed command
#         :param str resource: the target resource
#         """
#         StratisCliPartialChangeError.__init__(
#             self, command, frozenset(), frozenset([resource])
#         )
# 
# Path: src/stratis_cli/_stratisd_constants.py
# CLEVIS_KEY_TANG_TRUST_URL = "stratis:tang:trust_url"
# 
# CLEVIS_KEY_THP = "thp"
# 
# CLEVIS_KEY_URL = "url"
# 
# CLEVIS_PIN_TANG = "tang"
# 
# CLEVIS_PIN_TPM2 = "tpm2"
# 
# class EncryptionMethod(Enum):
#     """
#     Encryption method, used as argument to unlock.
#     """
# 
#     KEYRING = "keyring"
#     CLEVIS = "clevis"
# 
#     def __str__(self):
#         return self.value
# 
# class StratisdErrors(IntEnum):
#     """
#     Stratisd Errors
#     """
# 
#     OK = 0
#     ERROR = 1
# 
# Path: src/stratis_cli/_actions/_connection.py
# def get_object(object_path):
#     """
#     Get an object from an object path.
# 
#     :param str object_path: an object path with a valid format
#     :returns: the proxy object corresponding to the object path
#     :rtype: ProxyObject
#     """
#     return Bus.get_bus().get_object(SERVICE, object_path, introspect=False)
# 
# Path: src/stratis_cli/_actions/_constants.py
# TOP_OBJECT = "/org/storage/stratis3"


import json
from .._errors import StratisCliEngineError, StratisCliNoChangeError
from .._stratisd_constants import (
    CLEVIS_KEY_TANG_TRUST_URL,
    CLEVIS_KEY_THP,
    CLEVIS_KEY_URL,
    CLEVIS_PIN_TANG,
    CLEVIS_PIN_TPM2,
    EncryptionMethod,
    StratisdErrors,
)
from ._connection import get_object
from ._constants import TOP_OBJECT
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools

    @staticmethod
    def unbind(namespace):
        """
        Unbind all devices in an encrypted pool.

        :raises StratisCliNoChangeError:
        :raises StratisCliEngineError:
        """
        # pylint: disable=import-outside-toplevel

        proxy = get_object(TOP_OBJECT)
        managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
        pool_name = namespace.pool_name
        (pool_object_path, _) = next(
            pools(props={"Name": pool_name})
            .require_unique_match(True)
            .search(managed_objects)
        )

        unbind_method = (
            Pool.Methods.UnbindClevis
            if namespace.method == str(EncryptionMethod.CLEVIS)
            else Pool.Methods.UnbindKeyring
        )

        (changed, return_code, return_msg) = unbind_method(
            get_object(pool_object_path), {}
        )


# Path: src/stratis_cli/_errors.py
# class StratisCliEngineError(StratisCliRuntimeError):
#     """
#     Raised if there was a failure due to an error in stratisd's engine.
#     """
# 
#     def __init__(self, rc, message):
#         """
#         Initializer.
# 
#         :param rc int: the error code returned by the engine
#         :param str message: whatever message accompanied the error code
#         """
#         # pylint: disable=super-init-not-called
#         self.error_code = rc
#         self.message = message
# 
#     def __str__(self):
#         return "%s: %s" % (STRATISD_ERROR_TO_NAME(self.error_code), self.message)
# 
# class StratisCliNoChangeError(StratisCliPartialChangeError):
#     """
#     Raised if a request made of stratisd must result in no change since the
#     post-condition of the request is already entirely satisfied. This is
#     a special case of StratisCliPartialChangeError, where the change requested
#     is so simple that it can only succeed or fail.
#     """
# 
#     def __init__(self, command, resource):
#         """
#         Initializer.
# 
#         :param str command: the executed command
#         :param str resource: the target resource
#         """
#         StratisCliPartialChangeError.__init__(
#             self, command, frozenset(), frozenset([resource])
#         )
# 
# Path: src/stratis_cli/_stratisd_constants.py
# CLEVIS_KEY_TANG_TRUST_URL = "stratis:tang:trust_url"
# 
# CLEVIS_KEY_THP = "thp"
# 
# CLEVIS_KEY_URL = "url"
# 
# CLEVIS_PIN_TANG = "tang"
# 
# CLEVIS_PIN_TPM2 = "tpm2"
# 
# class EncryptionMethod(Enum):
#     """
#     Encryption method, used as argument to unlock.
#     """
# 
#     KEYRING = "keyring"
#     CLEVIS = "clevis"
# 
#     def __str__(self):
#         return self.value
# 
# class StratisdErrors(IntEnum):
#     """
#     Stratisd Errors
#     """
# 
#     OK = 0
#     ERROR = 1
# 
# Path: src/stratis_cli/_actions/_connection.py
# def get_object(object_path):
#     """
#     Get an object from an object path.
# 
#     :param str object_path: an object path with a valid format
#     :returns: the proxy object corresponding to the object path
#     :rtype: ProxyObject
#     """
#     return Bus.get_bus().get_object(SERVICE, object_path, introspect=False)
# 
# Path: src/stratis_cli/_actions/_constants.py
# TOP_OBJECT = "/org/storage/stratis3"


# Path: src/stratis_cli/_actions/_bind.py
import json
from .._errors import StratisCliEngineError, StratisCliNoChangeError
from .._stratisd_constants import (
    CLEVIS_KEY_TANG_TRUST_URL,
    CLEVIS_KEY_THP,
    CLEVIS_KEY_URL,
    CLEVIS_PIN_TANG,
    CLEVIS_PIN_TPM2,
    EncryptionMethod,
    StratisdErrors,
)
from ._connection import get_object
from ._constants import TOP_OBJECT
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools
        from ._data import ObjectManager, Pool, pools


    @staticmethod
    def unbind(namespace):
        """
        Unbind all devices in an encrypted pool.

        :raises StratisCliNoChangeError:
        :raises StratisCliEngineError:
        """
        # pylint: disable=import-outside-toplevel

        proxy = get_object(TOP_OBJECT)
        managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
        pool_name = namespace.pool_name
        (pool_object_path, _) = next(
            pools(props={"Name": pool_name})
            .require_unique_match(True)
            .search(managed_objects)
        )

        unbind_method = (
            Pool.Methods.UnbindClevis
            if namespace.method == str(EncryptionMethod.CLEVIS)
            else Pool.Methods.UnbindKeyring
        )

        (changed, return_code, return_msg) = unbind_method(
            get_object(pool_object_path), {}
        )


        if return_code != StratisdErrors.OK: