# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.3.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if getattr(globals().get("__spec__"), "parent", None) or globals().get("__package__") or "." in __name__:
    from . import _plugin
else:
    import _plugin

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import weakref

from . import conf
from . import common
from . import exception
from . import logger
class Version(object):
    r"""Plugin version"""

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr
    major = property(_plugin.Version_major_get, _plugin.Version_major_set)
    minor = property(_plugin.Version_minor_get, _plugin.Version_minor_set)
    micro = property(_plugin.Version_micro_get, _plugin.Version_micro_set)

    def __init__(self, major, minor, micro):
        _plugin.Version_swiginit(self, _plugin.new_Version(major, minor, micro))
    __swig_destroy__ = _plugin.delete_Version

# Register Version in _plugin:
_plugin.Version_swigregister(Version)
class IPlugin(object):
    r"""A base class for implementing LIBDNF5 plugins that introduce additional logic into the library using hooks."""

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self, data):
        if self.__class__ == IPlugin:
            _self = None
        else:
            _self = self
        _plugin.IPlugin_swiginit(self, _plugin.new_IPlugin(_self, data))
    __swig_destroy__ = _plugin.delete_IPlugin

    def get_api_version(self):
        r"""Returns the version of the API supported by the plugin. It can be called at any time."""
        return _plugin.IPlugin_get_api_version(self)

    def get_name(self):
        r"""Returns the name of the plugin. It can be called at any time."""
        return _plugin.IPlugin_get_name(self)

    def get_version(self):
        r"""Gets the plugin version. It can be called at any time."""
        return _plugin.IPlugin_get_version(self)

    def get_attributes(self):
        r"""
        :rtype: string
        :return: A nullptr terminated array of attributes supported by the plugin.
        """
        return _plugin.IPlugin_get_attributes(self)

    def get_attribute(self, name):
        r"""
        Gets the value of the attribute from the plugin. Returns nullptr if the attribute does not exist.
        It can be called at any time.
        """
        return _plugin.IPlugin_get_attribute(self, name)

    def load_plugins(self):
        r"""
        The plugin can load additional plugins. E.g. C++ plugin for loading Python plugins.
        Called before init.
        """
        return _plugin.IPlugin_load_plugins(self)

    def init(self):
        r"""
        Plugin initialization.
        Called before hooks.
        """
        return _plugin.IPlugin_init(self)

    def pre_base_setup(self):
        r"""
        The pre_base_setup hook.
        It is called at the beginning of the `Base::setup` method (after the `init` hook).
        """
        return _plugin.IPlugin_pre_base_setup(self)

    def post_base_setup(self):
        r"""
        The post_base_setup hook.
        It is called at the end of the `Base::setup` method.
        """
        return _plugin.IPlugin_post_base_setup(self)

    def repos_configured(self):
        r"""
        The repos_configured hook.
        It is called in `Base::notify_repos_configured` method.
        """
        return _plugin.IPlugin_repos_configured(self)

    def repos_loaded(self):
        r"""
        The repos_loaded hook.
        It is called at the end of the `RepoSack::load_repos` method (in Impl).
        """
        return _plugin.IPlugin_repos_loaded(self)

    def pre_add_cmdline_packages(self, paths):
        r"""
        The pre_add_cmdline_packages hook.
        It is called at the beginning of the `RepoSack::add_cmdline_packages` method.
        :type paths: std::vector< std::string,std::allocator< std::string > >
        :param paths: Vector of paths (local files or URLs) to package files to be inserted into cmdline repo.
        """
        return _plugin.IPlugin_pre_add_cmdline_packages(self, paths)

    def post_add_cmdline_packages(self):
        r"""
        The post_add_cmdline_packages hook.
        It is called at the end of the `RepoSack::add_cmdline_packages` method.
        """
        return _plugin.IPlugin_post_add_cmdline_packages(self)

    def pre_transaction(self, transaction):
        r"""
        The pre_transaction hook.
        It is called just before the actual transaction starts.
        :type transaction: libdnf5::base::Transaction
        :param transaction: Contains the transaction that will be started.
        """
        return _plugin.IPlugin_pre_transaction(self, transaction)

    def post_transaction(self, transaction):
        r"""
        The post_transaction hook.
        It is called after transactions.
        :type transaction: libdnf5::base::Transaction
        :param transaction: Contains the completed transaction.
        """
        return _plugin.IPlugin_post_transaction(self, transaction)

    def finish(self):
        r"""Finish the plugin and release all resources obtained by the init method and in hooks."""
        return _plugin.IPlugin_finish(self)

    def get_base(self):
        return _plugin.IPlugin_get_base(self)
    def __disown__(self):
        self.this.disown()
        _plugin.disown_IPlugin(self)
        return weakref.proxy(self)

# Register IPlugin in _plugin:
_plugin.IPlugin_swigregister(IPlugin)
class IPlugin2_1(IPlugin):
    r"""Extended plugin interface with additional hooks introduced in version 2.1 of the plugin API."""

    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined - class is abstract")
    __repr__ = _swig_repr
    __swig_destroy__ = _plugin.delete_IPlugin2_1

    def goal_resolved(self, transaction):
        r"""
        The goal resolved hook.
        It is called right after the goal is resolved.
        :type transaction: libdnf5::base::Transaction
        :param transaction: Contains the transaction that was resolved.
        """
        return _plugin.IPlugin2_1_goal_resolved(self, transaction)

# Register IPlugin2_1 in _plugin:
_plugin.IPlugin2_1_swigregister(IPlugin2_1)
class PluginInfo(object):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr
    __swig_destroy__ = _plugin.delete_PluginInfo

    def __init__(self, *args):
        _plugin.PluginInfo_swiginit(self, _plugin.new_PluginInfo(*args))

    def get_name(self):
        r"""
        :rtype: string
        :return: the real name of the plugin or derived from the configuration file if the plugin is not loaded
        """
        return _plugin.PluginInfo_get_name(self)

    def is_loaded(self):
        r"""
        :rtype: boolean
        :return: true if the plugin is loaded
        """
        return _plugin.PluginInfo_is_loaded(self)

    def get_api_version(self):
        r"""
        :rtype: :py:class:`PluginAPIVersion`
        :return: the version of the API supported by the plugin, or zeros if the plugin is not loaded
        """
        return _plugin.PluginInfo_get_api_version(self)

    def get_real_name(self):
        r"""
        :rtype: string
        :return: the real plugin name (returned from plugin) or nullptr if the plugin is not loaded
        """
        return _plugin.PluginInfo_get_real_name(self)

    def get_version(self):
        r"""
        :rtype: :py:class:`Version`
        :return: the version of the plugin, or zeros if the plugin is not loaded
        """
        return _plugin.PluginInfo_get_version(self)

    def get_attributes(self):
        r"""
        :rtype: string
        :return: a nullptr terminated array of attributes supported by the plugin or nullptr if the plugin is not loaded
        """
        return _plugin.PluginInfo_get_attributes(self)

    def get_attribute(self, name):
        r"""
        Gets the value of the attribute from the plugin.
        Returns nullptr if the attribute does not exist or plugin is not loaded.
        :rtype: string
        :return: the value of the `name` attribute or nullptr
        """
        return _plugin.PluginInfo_get_attribute(self, name)

# Register PluginInfo in _plugin:
_plugin.PluginInfo_swigregister(PluginInfo)

