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

#include "py.Windows.System.Diagnostics.DevicePortal.h"

namespace py::cpp::Windows::System::Diagnostics::DevicePortal
{
    // ----- DevicePortalConnection class --------------------

    static PyObject* _new_DevicePortalConnection(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection>::type_name);
        return nullptr;
    }

    static void _dealloc_DevicePortalConnection(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DevicePortalConnection_GetForAppServiceConnection(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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetForAppServiceConnection", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::ApplicationModel::AppService::AppServiceConnection>(args, 0);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection::GetForAppServiceConnection(param0);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DevicePortalConnection_GetServerMessageWebSocketForRequest(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* 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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetServerMessageWebSocketForRequest", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Web::Http::HttpRequestMessage>(args, 0);

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

    static PyObject* DevicePortalConnection_GetServerMessageWebSocketForRequest2(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 3)
        {
            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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetServerMessageWebSocketForRequest", 3);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Web::Http::HttpRequestMessage>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Networking::Sockets::SocketMessageType>(args, 1);
                auto param2 = py::convert_to<winrt::hstring>(args, 2);

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

    static PyObject* DevicePortalConnection_GetServerMessageWebSocketForRequest3(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 6)
        {
            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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetServerMessageWebSocketForRequest", 6);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Web::Http::HttpRequestMessage>(args, 0);
                auto param1 = py::convert_to<winrt::Windows::Networking::Sockets::SocketMessageType>(args, 1);
                auto param2 = py::convert_to<winrt::hstring>(args, 2);
                auto param3 = py::convert_to<uint32_t>(args, 3);
                auto param4 = py::convert_to<uint32_t>(args, 4);
                auto param5 = py::convert_to<winrt::Windows::Networking::Sockets::MessageWebSocketReceiveMode>(args, 5);

                return py::convert([&]()
                {
                    auto _gil = release_gil();
                    return self->obj.GetServerMessageWebSocketForRequest(param0, param1, param2, param3, param4, param5);
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DevicePortalConnection_GetServerStreamWebSocketForRequest(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* 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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetServerStreamWebSocketForRequest", 1);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Web::Http::HttpRequestMessage>(args, 0);

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

    static PyObject* DevicePortalConnection_GetServerStreamWebSocketForRequest2(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* args) noexcept
    {
        auto arg_count = PyTuple_GET_SIZE(args);

        if (arg_count == 4)
        {
            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.System.Diagnostics.DevicePortal.DevicePortalConnection", L"GetServerStreamWebSocketForRequest", 4);
                }

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

                auto param0 = py::convert_to<winrt::Windows::Web::Http::HttpRequestMessage>(args, 0);
                auto param1 = py::convert_to<winrt::hstring>(args, 1);
                auto param2 = py::convert_to<uint32_t>(args, 2);
                auto param3 = py::convert_to<bool>(args, 3);

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

    static PyObject* DevicePortalConnection_add_Closed(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Diagnostics.DevicePortal.DevicePortalConnection", L"Closed");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection, winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs>>(arg);

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

    static PyObject* DevicePortalConnection_remove_Closed(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Diagnostics.DevicePortal.DevicePortalConnection", L"Closed");
            }

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

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

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

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

    static PyObject* DevicePortalConnection_add_RequestReceived(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Diagnostics.DevicePortal.DevicePortalConnection", L"RequestReceived");
            }

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

            auto param0 = py::convert_to<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection, winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs>>(arg);

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

    static PyObject* DevicePortalConnection_remove_RequestReceived(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection* self, PyObject* arg) noexcept
    {
        try
        {
            static std::optional<bool> is_event_present{};

            if (!is_event_present.has_value())
            {
                is_event_present = winrt::Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.System.Diagnostics.DevicePortal.DevicePortalConnection", L"RequestReceived");
            }

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

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

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

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

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

    static PyObject* _from_DevicePortalConnection(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::System::Diagnostics::DevicePortal::DevicePortalConnection>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DevicePortalConnection[] = {
        { "get_server_message_web_socket_for_request", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetServerMessageWebSocketForRequest), METH_VARARGS, nullptr },
        { "get_server_message_web_socket_for_request2", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetServerMessageWebSocketForRequest2), METH_VARARGS, nullptr },
        { "get_server_message_web_socket_for_request3", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetServerMessageWebSocketForRequest3), METH_VARARGS, nullptr },
        { "get_server_stream_web_socket_for_request", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetServerStreamWebSocketForRequest), METH_VARARGS, nullptr },
        { "get_server_stream_web_socket_for_request2", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetServerStreamWebSocketForRequest2), METH_VARARGS, nullptr },
        { "add_closed", reinterpret_cast<PyCFunction>(DevicePortalConnection_add_Closed), METH_O, nullptr },
        { "remove_closed", reinterpret_cast<PyCFunction>(DevicePortalConnection_remove_Closed), METH_O, nullptr },
        { "add_request_received", reinterpret_cast<PyCFunction>(DevicePortalConnection_add_RequestReceived), METH_O, nullptr },
        { "remove_request_received", reinterpret_cast<PyCFunction>(DevicePortalConnection_remove_RequestReceived), METH_O, nullptr },
        { "_assign_array_", _assign_array_DevicePortalConnection, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DevicePortalConnection), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DevicePortalConnection[] = {
        { }};

    static PyType_Slot _type_slots_DevicePortalConnection[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DevicePortalConnection) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DevicePortalConnection) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DevicePortalConnection) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DevicePortalConnection) },
        { }};

    static PyType_Spec type_spec_DevicePortalConnection = {
        "winrt._winrt_windows_system_diagnostics_deviceportal.DevicePortalConnection",
        sizeof(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnection),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DevicePortalConnection};

    static PyGetSetDef getset_DevicePortalConnection_Static[] = {
        { }};

    static PyMethodDef methods_DevicePortalConnection_Static[] = {
        { "get_for_app_service_connection", reinterpret_cast<PyCFunction>(DevicePortalConnection_GetForAppServiceConnection), METH_VARARGS, nullptr },
        { }};

    static PyType_Slot type_slots_DevicePortalConnection_Static[] = 
    {
        { Py_tp_base, reinterpret_cast<void*>(&PyType_Type) },
        { Py_tp_getset, reinterpret_cast<void*>(getset_DevicePortalConnection_Static) },
        { Py_tp_methods, reinterpret_cast<void*>(methods_DevicePortalConnection_Static) },
        { }
    };

    static PyType_Spec type_spec_DevicePortalConnection_Static = {
        "winrt._winrt_windows_system_diagnostics_deviceportal.DevicePortalConnection_Static",
        static_cast<int>(PyType_Type.tp_basicsize),
        static_cast<int>(PyType_Type.tp_itemsize),
        Py_TPFLAGS_DEFAULT,
        type_slots_DevicePortalConnection_Static};

    // ----- DevicePortalConnectionClosedEventArgs class --------------------

    static PyObject* _new_DevicePortalConnectionClosedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_DevicePortalConnectionClosedEventArgs(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DevicePortalConnectionClosedEventArgs_get_Reason(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionClosedEventArgs", L"Reason");
            }

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

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

    static PyObject* _from_DevicePortalConnectionClosedEventArgs(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::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DevicePortalConnectionClosedEventArgs[] = {
        { "_assign_array_", _assign_array_DevicePortalConnectionClosedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DevicePortalConnectionClosedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DevicePortalConnectionClosedEventArgs[] = {
        { "reason", reinterpret_cast<getter>(DevicePortalConnectionClosedEventArgs_get_Reason), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DevicePortalConnectionClosedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DevicePortalConnectionClosedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DevicePortalConnectionClosedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DevicePortalConnectionClosedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DevicePortalConnectionClosedEventArgs) },
        { }};

    static PyType_Spec type_spec_DevicePortalConnectionClosedEventArgs = {
        "winrt._winrt_windows_system_diagnostics_deviceportal.DevicePortalConnectionClosedEventArgs",
        sizeof(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionClosedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DevicePortalConnectionClosedEventArgs};

    // ----- DevicePortalConnectionRequestReceivedEventArgs class --------------------

    static PyObject* _new_DevicePortalConnectionRequestReceivedEventArgs(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/) noexcept
    {
        static_assert(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs>::type_name);
        py::set_invalid_activation_error(py::py_type<winrt::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs>::type_name);
        return nullptr;
    }

    static void _dealloc_DevicePortalConnectionRequestReceivedEventArgs(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* self) noexcept
    {
        auto tp = Py_TYPE(self);
        std::destroy_at(&self->obj);
        tp->tp_free(self);
        Py_DECREF(tp);
    }

    static PyObject* DevicePortalConnectionRequestReceivedEventArgs_GetDeferral(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionRequestReceivedEventArgs", L"GetDeferral", 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.GetDeferral();
                }());
            }
            catch (...)
            {
                py::to_PyErr();
                return nullptr;
            }
        }
        else
        {
            py::set_invalid_arg_count_error(arg_count);
            return nullptr;
        }
    }

    static PyObject* DevicePortalConnectionRequestReceivedEventArgs_get_RequestMessage(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionRequestReceivedEventArgs", L"RequestMessage");
            }

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

    static PyObject* DevicePortalConnectionRequestReceivedEventArgs_get_ResponseMessage(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionRequestReceivedEventArgs", L"ResponseMessage");
            }

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

    static PyObject* DevicePortalConnectionRequestReceivedEventArgs_get_IsWebSocketUpgradeRequest(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionRequestReceivedEventArgs", L"IsWebSocketUpgradeRequest");
            }

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

    static PyObject* DevicePortalConnectionRequestReceivedEventArgs_get_WebSocketProtocolsRequested(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs* 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.System.Diagnostics.DevicePortal.DevicePortalConnectionRequestReceivedEventArgs", L"WebSocketProtocolsRequested");
            }

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

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

    static PyObject* _from_DevicePortalConnectionRequestReceivedEventArgs(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::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs>());
        }
        catch (...)
        {
            py::to_PyErr();
            return nullptr;
        }
    }

    static PyMethodDef _methods_DevicePortalConnectionRequestReceivedEventArgs[] = {
        { "get_deferral", reinterpret_cast<PyCFunction>(DevicePortalConnectionRequestReceivedEventArgs_GetDeferral), METH_VARARGS, nullptr },
        { "_assign_array_", _assign_array_DevicePortalConnectionRequestReceivedEventArgs, METH_O | METH_STATIC, nullptr },
        { "_from", reinterpret_cast<PyCFunction>(_from_DevicePortalConnectionRequestReceivedEventArgs), METH_O | METH_STATIC, nullptr },
        { }};

    static PyGetSetDef _getset_DevicePortalConnectionRequestReceivedEventArgs[] = {
        { "request_message", reinterpret_cast<getter>(DevicePortalConnectionRequestReceivedEventArgs_get_RequestMessage), nullptr, nullptr, nullptr },
        { "response_message", reinterpret_cast<getter>(DevicePortalConnectionRequestReceivedEventArgs_get_ResponseMessage), nullptr, nullptr, nullptr },
        { "is_web_socket_upgrade_request", reinterpret_cast<getter>(DevicePortalConnectionRequestReceivedEventArgs_get_IsWebSocketUpgradeRequest), nullptr, nullptr, nullptr },
        { "web_socket_protocols_requested", reinterpret_cast<getter>(DevicePortalConnectionRequestReceivedEventArgs_get_WebSocketProtocolsRequested), nullptr, nullptr, nullptr },
        { }};

    static PyType_Slot _type_slots_DevicePortalConnectionRequestReceivedEventArgs[] = {
        { Py_tp_new, reinterpret_cast<void*>(_new_DevicePortalConnectionRequestReceivedEventArgs) },
        { Py_tp_dealloc, reinterpret_cast<void*>(_dealloc_DevicePortalConnectionRequestReceivedEventArgs) },
        { Py_tp_methods, reinterpret_cast<void*>(_methods_DevicePortalConnectionRequestReceivedEventArgs) },
        { Py_tp_getset, reinterpret_cast<void*>(_getset_DevicePortalConnectionRequestReceivedEventArgs) },
        { }};

    static PyType_Spec type_spec_DevicePortalConnectionRequestReceivedEventArgs = {
        "winrt._winrt_windows_system_diagnostics_deviceportal.DevicePortalConnectionRequestReceivedEventArgs",
        sizeof(py::wrapper::Windows::System::Diagnostics::DevicePortal::DevicePortalConnectionRequestReceivedEventArgs),
        0,
        Py_TPFLAGS_DEFAULT,
        _type_slots_DevicePortalConnectionRequestReceivedEventArgs};

    // ----- Windows.System.Diagnostics.DevicePortal Initialization --------------------

    PyDoc_STRVAR(module_doc, "Windows.System.Diagnostics.DevicePortal");

    static PyModuleDef module_def = {
        PyModuleDef_HEAD_INIT,
        "_winrt_windows_system_diagnostics_deviceportal",
        module_doc,
        0,
        nullptr,
        nullptr,
        nullptr,
        nullptr,
        nullptr};
} // py::cpp::Windows::System::Diagnostics::DevicePortal

PyMODINIT_FUNC PyInit__winrt_windows_system_diagnostics_deviceportal(void) noexcept
{
    using namespace py::cpp::Windows::System::Diagnostics::DevicePortal;

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

    py::pyobj_handle type_DevicePortalConnection_Static{PyType_FromSpecWithBases(&type_spec_DevicePortalConnection_Static, DevicePortalConnection_Static_bases.get())};
    if (!type_DevicePortalConnection_Static)
    {
        return nullptr;
    }

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

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

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


    return module.detach();
}
