// WARNING: Please don't edit this file. It was generated by Python/WinRT v3.1.0

#include "py.Windows.Management.h"

namespace py::cpp::Windows::Management
{
    // ----- MdmAlert class --------------------

    static PyObject* _new_MdmAlert(PyTypeObject* type, PyObject* args, PyObject* kwds) noexcept
    {
        if (kwds)
        {
            py::set_invalid_kwd_args_error();
            return nullptr;
        }

        auto arg_count = PyTuple_GET_SIZE(args);
        if (arg_count == 0)
        {
            try
            {
                winrt::Windows::Management::MdmAlert instance{};
                return py::wrap(instance, type);
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static void _dealloc_MdmAlert(py::wrapper::Windows::Management::MdmAlert* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* MdmAlert_get_Type(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Type");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Type();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Type(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Type");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            {
                auto _gil = release_gil();
                self->obj.Type(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Target(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Target");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Target();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Target(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Target");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            {
                auto _gil = release_gil();
                self->obj.Target(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Source(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Source");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Source();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Source(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Source");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            {
                auto _gil = release_gil();
                self->obj.Source(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Mark(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Mark");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Mark();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Mark(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Mark");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Management::MdmAlertMark>(arg);

            {
                auto _gil = release_gil();
                self->obj.Mark(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Format(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Format");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Format();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Format(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Format");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::Windows::Management::MdmAlertDataType>(arg);

            {
                auto _gil = release_gil();
                self->obj.Format(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Data(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Data");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Data();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static int MdmAlert_put_Data(py::wrapper::Windows::Management::MdmAlert* self, PyObject* arg, void* /*unused*/) noexcept
    {
        if (!arg)
        {
            PyErr_SetString(PyExc_AttributeError, "can't delete attribute");
            return -1;
        }

        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Data");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return -1;
            }

            auto param0 = py::convert_to<winrt::hstring>(arg);

            {
                auto _gil = release_gil();
                self->obj.Data(param0);
            }

            return 0;
        }
        catch (...)
        {
            py::to_PyErr();
            return -1;
        }
    }

    static PyObject* MdmAlert_get_Status(py::wrapper::Windows::Management::MdmAlert* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmAlert", L"Status");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Status();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_MdmAlert(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Management::MdmAlert>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_MdmAlert(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Management::MdmAlert>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_MdmAlert[] = {
        { "_assign_array_", _assign_array_MdmAlert, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_MdmAlert), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_MdmAlert[] = {
        { "type", reinterpret_cast<getter>(MdmAlert_get_Type), reinterpret_cast<setter>(MdmAlert_put_Type), nullptr, nullptr },
        { "target", reinterpret_cast<getter>(MdmAlert_get_Target), reinterpret_cast<setter>(MdmAlert_put_Target), nullptr, nullptr },
        { "source", reinterpret_cast<getter>(MdmAlert_get_Source), reinterpret_cast<setter>(MdmAlert_put_Source), nullptr, nullptr },
        { "mark", reinterpret_cast<getter>(MdmAlert_get_Mark), reinterpret_cast<setter>(MdmAlert_put_Mark), nullptr, nullptr },
        { "format", reinterpret_cast<getter>(MdmAlert_get_Format), reinterpret_cast<setter>(MdmAlert_put_Format), nullptr, nullptr },
        { "data", reinterpret_cast<getter>(MdmAlert_get_Data), reinterpret_cast<setter>(MdmAlert_put_Data), nullptr, nullptr },
        { "status", reinterpret_cast<getter>(MdmAlert_get_Status), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_MdmAlert[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_MdmAlert) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_MdmAlert) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_MdmAlert) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_MdmAlert) },
        { }};

    static PyType_Spec type_spec_MdmAlert = {
        "winrt._winrt_windows_management.MdmAlert",
        sizeof(py::wrapper::Windows::Management::MdmAlert),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_MdmAlert};

    // ----- MdmSession class --------------------

    static PyObject* _new_MdmSession(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Management::MdmSession>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Management::MdmSession>::type_name);
        return nullptr;
    }

    static void _dealloc_MdmSession(py::wrapper::Windows::Management::MdmSession* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* MdmSession_AttachAsync(py::wrapper::Windows::Management::MdmSession* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSession", L"AttachAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.AttachAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSession_Delete(py::wrapper::Windows::Management::MdmSession* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSession", L"Delete", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                {
                    auto _gil = release_gil();
                    self->obj.Delete();
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSession_StartAsync(py::wrapper::Windows::Management::MdmSession* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSession", L"StartAsync", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.StartAsync();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSession_StartWithAlertsAsync(py::wrapper::Windows::Management::MdmSession* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSession", L"StartAsync", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::Windows::Foundation::Collections::IIterable<winrt::Windows::Management::MdmAlert>>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.StartAsync(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSession_get_Alerts(py::wrapper::Windows::Management::MdmSession* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmSession", L"Alerts");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Alerts();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* MdmSession_get_ExtendedError(py::wrapper::Windows::Management::MdmSession* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmSession", L"ExtendedError");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.ExtendedError();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* MdmSession_get_Id(py::wrapper::Windows::Management::MdmSession* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmSession", L"Id");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.Id();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* MdmSession_get_State(py::wrapper::Windows::Management::MdmSession* self, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmSession", L"State");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return self->obj.State();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyObject* _assign_array_MdmSession(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        auto array = std::make_unique<py::ComArray<winrt::Windows::Management::MdmSession>>();
        if (!py::cpp::_winrt::Array_Assign(arg, std::move(array)))
        {
            return nullptr;
        }
        Py_RETURN_NONE;
    }

    static PyObject* _from_MdmSession(PyObject* /*unused*/, PyObject* arg) noexcept
    {
        try
        {
            auto return_value = py::convert_to<winrt::Windows::Foundation::IInspectable>(arg);
            return py::convert(return_value.as<winrt::Windows::Management::MdmSession>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_MdmSession[] = {
        { "attach_async", reinterpret_cast<PyCFunction>(MdmSession_AttachAsync), METH_VARARGS, nullptr },
        { "delete", reinterpret_cast<PyCFunction>(MdmSession_Delete), METH_VARARGS, nullptr },
        { "start_async", reinterpret_cast<PyCFunction>(MdmSession_StartAsync), METH_VARARGS, nullptr },
        { "start_with_alerts_async", reinterpret_cast<PyCFunction>(MdmSession_StartWithAlertsAsync), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_MdmSession, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_MdmSession), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_MdmSession[] = {
        { "alerts", reinterpret_cast<getter>(MdmSession_get_Alerts), nullptr, nullptr, nullptr },
        { "extended_error", reinterpret_cast<getter>(MdmSession_get_ExtendedError), nullptr, nullptr, nullptr },
        { "id", reinterpret_cast<getter>(MdmSession_get_Id), nullptr, nullptr, nullptr },
        { "state", reinterpret_cast<getter>(MdmSession_get_State), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_MdmSession[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_MdmSession) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_MdmSession) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_MdmSession) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_MdmSession) },
        { }};

    static PyType_Spec type_spec_MdmSession = {
        "winrt._winrt_windows_management.MdmSession",
        sizeof(py::wrapper::Windows::Management::MdmSession),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_MdmSession};

    // ----- MdmSessionManager class --------------------

    static PyObject* _new_MdmSessionManager(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::Management::MdmSessionManager>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::Management::MdmSessionManager>::type_name);
        return nullptr;
    }

    static PyObject* MdmSessionManager_DeleteSessionById(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSessionManager", L"DeleteSessionById", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                {
                    auto _gil = release_gil();
                    winrt::Windows::Management::MdmSessionManager::DeleteSessionById(param0);
                }

                Py_RETURN_NONE;
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSessionManager_GetSessionById(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 1)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSessionManager", L"GetSessionById", 1);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(1);
                    return nullptr;
                }

                auto param0 = py::convert_to<winrt::hstring>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Management::MdmSessionManager::GetSessionById(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSessionManager_TryCreateSession(PyObject* /*unused*/, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 0)
        {
            try
            {
                static std::optional<bool> is_overload_present{};

                if (!is_overload_present.has_value())
                {
                    is_overload_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(L"Windows.Management.MdmSessionManager", L"TryCreateSession", 0);
                }

                if (!is_overload_present.value())
                {
                    py::set_arg_count_version_error(0);
                    return nullptr;
                }

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::Management::MdmSessionManager::TryCreateSession();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmSessionManager_get_SessionIds(PyObject* /*unused*/, void* /*unused*/) noexcept
    {
        try
        {
            static std::optional<bool> is_property_present{};

            if (!is_property_present.has_value())
            {
                is_property_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsPropertyPresent(L"Windows.Management.MdmSessionManager", L"SessionIds");
            }

            if (!is_property_present.value())
            {
                PyErr_SetString(PyExc_AttributeError, "property is not available in this version of Windows");
                return nullptr;
            }

            return py::convert([&]()
            {
                auto _gil = release_gil();
                return winrt::Windows::Management::MdmSessionManager::SessionIds();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_MdmSessionManager[] = {
        { }};

    static PyGetSetDef _getset_MdmSessionManager[] = {
        { }};

    static PyType_Slot _type_slots_MdmSessionManager[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_MdmSessionManager) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_MdmSessionManager) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_MdmSessionManager) },
        { }};

    static PyType_Spec type_spec_MdmSessionManager = {
        "winrt._winrt_windows_management.MdmSessionManager",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_MdmSessionManager};

    static PyGetSetDef getset_MdmSessionManager_Static[] = {
        { "session_ids", reinterpret_cast<getter>(MdmSessionManager_get_SessionIds), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_MdmSessionManager_Static[] = {
        { "delete_session_by_id", reinterpret_cast<PyCFunction>(MdmSessionManager_DeleteSessionById), METH_VARARGS, nullptr },
        { "get_session_by_id", reinterpret_cast<PyCFunction>(MdmSessionManager_GetSessionById), METH_VARARGS, nullptr },
        { "try_create_session", reinterpret_cast<PyCFunction>(MdmSessionManager_TryCreateSession), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_MdmSessionManager_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_MdmSessionManager_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_MdmSessionManager_Static) },
        { }
    };

    static PyType_Spec type_spec_MdmSessionManager_Static = {
        "winrt._winrt_windows_management.MdmSessionManager_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_MdmSessionManager_Static};

    // ----- Windows.Management Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.Management");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_management",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::Management

PyMODINIT_FUNC PyInit__winrt_windows_management(void) noexcept
{
    using namespace py::cpp::Windows::Management;

    if (py::import_winrt_runtime() == -1)
    {
        return nullptr;
    }

    py::pyobj_handle module{PyModule_Create(&module_def)};

    if (!module)
    {
        return nullptr;
    }

    auto inspectable_meta_type = py::get_inspectable_meta_type();
    if (!inspectable_meta_type)
    {
        return nullptr;
    }

    auto object_type = py::get_object_type();
    if (!object_type)
    {
        return nullptr;
    }

    py::pyobj_handle object_bases{PyTuple_Pack(1, object_type)};

    if (!object_bases)
    {
        return nullptr;
    }

    py::pytype_handle MdmAlert_type{py::register_python_type(module.get(), &type_spec_MdmAlert, object_bases.get(), inspectable_meta_type)};
    if (!MdmAlert_type)
    {
        return nullptr;
    }

    py::pytype_handle MdmSession_type{py::register_python_type(module.get(), &type_spec_MdmSession, object_bases.get(), inspectable_meta_type)};
    if (!MdmSession_type)
    {
        return nullptr;
    }

    py::pyobj_handle MdmSessionManager_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!MdmSessionManager_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_MdmSessionManager_Static{PyType_FromSpecWithBases(&type_spec_MdmSessionManager_Static, MdmSessionManager_Static_bases.get())};
    if (!type_MdmSessionManager_Static)
    {
        return nullptr;
    }

    py::pytype_handle MdmSessionManager_type{py::register_python_type(module.get(), &type_spec_MdmSessionManager, object_bases.get(), reinterpret_cast<PyTypeObject*>(type_MdmSessionManager_Static.get()))};
    if (!MdmSessionManager_type)
    {
        return nullptr;
    }


    return module.detach();
}
