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

#include "py.Windows.Management.Workplace.h"

namespace py::cpp::Windows::Management::Workplace
{
    // ----- MdmPolicy class --------------------

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

    static PyObject* MdmPolicy_GetMessagingSyncPolicy(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.Workplace.MdmPolicy", L"GetMessagingSyncPolicy", 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::Workplace::MdmPolicy::GetMessagingSyncPolicy();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmPolicy_IsBrowserAllowed(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.Workplace.MdmPolicy", L"IsBrowserAllowed", 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::Workplace::MdmPolicy::IsBrowserAllowed();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmPolicy_IsCameraAllowed(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.Workplace.MdmPolicy", L"IsCameraAllowed", 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::Workplace::MdmPolicy::IsCameraAllowed();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmPolicy_IsMicrosoftAccountAllowed(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.Workplace.MdmPolicy", L"IsMicrosoftAccountAllowed", 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::Workplace::MdmPolicy::IsMicrosoftAccountAllowed();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* MdmPolicy_IsStoreAllowed(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.Workplace.MdmPolicy", L"IsStoreAllowed", 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::Workplace::MdmPolicy::IsStoreAllowed();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyMethodDef _methods_MdmPolicy[] = {
        { }};

    static PyGetSetDef _getset_MdmPolicy[] = {
        { }};

    static PyType_Slot _type_slots_MdmPolicy[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_MdmPolicy) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_MdmPolicy) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_MdmPolicy) },
        { }};

    static PyType_Spec type_spec_MdmPolicy = {
        "winrt._winrt_windows_management_workplace.MdmPolicy",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_MdmPolicy};

    static PyGetSetDef getset_MdmPolicy_Static[] = {
        { }};

    static PyMethodDef methods_MdmPolicy_Static[] = {
        { "get_messaging_sync_policy", reinterpret_cast<PyCFunction>(MdmPolicy_GetMessagingSyncPolicy), METH_VARARGS, nullptr },
        { "is_browser_allowed", reinterpret_cast<PyCFunction>(MdmPolicy_IsBrowserAllowed), METH_VARARGS, nullptr },
        { "is_camera_allowed", reinterpret_cast<PyCFunction>(MdmPolicy_IsCameraAllowed), METH_VARARGS, nullptr },
        { "is_microsoft_account_allowed", reinterpret_cast<PyCFunction>(MdmPolicy_IsMicrosoftAccountAllowed), METH_VARARGS, nullptr },
        { "is_store_allowed", reinterpret_cast<PyCFunction>(MdmPolicy_IsStoreAllowed), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_MdmPolicy_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_MdmPolicy_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_MdmPolicy_Static) },
        { }
    };

    static PyType_Spec type_spec_MdmPolicy_Static = {
        "winrt._winrt_windows_management_workplace.MdmPolicy_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_MdmPolicy_Static};

    // ----- WorkplaceSettings class --------------------

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

    static PyObject* WorkplaceSettings_get_IsMicrosoftAccountOptional(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.Workplace.WorkplaceSettings", L"IsMicrosoftAccountOptional");
            }

            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::Workplace::WorkplaceSettings::IsMicrosoftAccountOptional();
            }());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_WorkplaceSettings[] = {
        { }};

    static PyGetSetDef _getset_WorkplaceSettings[] = {
        { }};

    static PyType_Slot _type_slots_WorkplaceSettings[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_WorkplaceSettings) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_WorkplaceSettings) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_WorkplaceSettings) },
        { }};

    static PyType_Spec type_spec_WorkplaceSettings = {
        "winrt._winrt_windows_management_workplace.WorkplaceSettings",
        0,
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_WorkplaceSettings};

    static PyGetSetDef getset_WorkplaceSettings_Static[] = {
        { "is_microsoft_account_optional", reinterpret_cast<getter>(WorkplaceSettings_get_IsMicrosoftAccountOptional), nullptr, nullptr, nullptr },
        { }};

    static PyMethodDef methods_WorkplaceSettings_Static[] = {
        { }};

    static PyType_Slot type_slots_WorkplaceSettings_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_WorkplaceSettings_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_WorkplaceSettings_Static) },
        { }
    };

    static PyType_Spec type_spec_WorkplaceSettings_Static = {
        "winrt._winrt_windows_management_workplace.WorkplaceSettings_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_WorkplaceSettings_Static};

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

    PyDoc_STRVAR(module_doc, "Windows.Management.Workplace");

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

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

    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::pyobj_handle MdmPolicy_Static_bases{PyTuple_Pack(1, reinterpret_cast<PyObject*>(inspectable_meta_type))};
    if (!MdmPolicy_Static_bases)
    {
        return nullptr;
    }

    py::pyobj_handle type_MdmPolicy_Static{PyType_FromSpecWithBases(&type_spec_MdmPolicy_Static, MdmPolicy_Static_bases.get())};
    if (!type_MdmPolicy_Static)
    {
        return nullptr;
    }

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

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

    py::pyobj_handle type_WorkplaceSettings_Static{PyType_FromSpecWithBases(&type_spec_WorkplaceSettings_Static, WorkplaceSettings_Static_bases.get())};
    if (!type_WorkplaceSettings_Static)
    {
        return nullptr;
    }

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


    return module.detach();
}
