Skip to content

Add new notification categories SECURITY and TOPOLOGY #975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`
:data:`None` will apply the server's default setting.

.. Note::
If configured, the server or all servers of the cluster need to support notifications filtering.
If configured, the server or all servers of the cluster need to support notifications filtering
(server version 5.7 and newer).
Otherwise, the driver will raise a :exc:`.ConfigurationError` as soon as it encounters a server that does not.

:Type: :data:`None`, :class:`.NotificationMinimumSeverity`, or :class:`str`
Expand All @@ -652,7 +653,8 @@ Notifications are available via :attr:`.ResultSummary.notifications` and :attr:`
:data:`None` will apply the server's default setting.

.. Note::
If configured, the server or all servers of the cluster need to support notifications filtering.
If configured, the server or all servers of the cluster need to support notifications filtering
(server version 5.7 and newer).
Otherwise, the driver will raise a :exc:`.ConfigurationError` as soon as it encounters a server that does not.

:Type: :data:`None`, :term:`iterable` of :class:`.NotificationDisabledCategory` and/or :class:`str`
Expand Down Expand Up @@ -1778,15 +1780,15 @@ BookmarkManager
Constants, Enums, Helpers
*************************

.. autoclass:: neo4j.NotificationMinimumSeverity
.. autoclass:: neo4j.NotificationMinimumSeverity()
:show-inheritance:
:members:

.. autoclass:: neo4j.NotificationDisabledCategory
.. autoclass:: neo4j.NotificationDisabledCategory()
:show-inheritance:
:members:

.. autoclass:: neo4j.RoutingControl
.. autoclass:: neo4j.RoutingControl()
:show-inheritance:
:members:

Expand Down
24 changes: 16 additions & 8 deletions src/neo4j/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NotificationMinimumSeverity(str, Enum):
"""Filter notifications returned by the server by minimum severity.

Inherits from :class:`str` and :class:`Enum`. Every driver API accepting a
:class:`.NotificationFilter` value will also accept a string::
:class:`.NotificationMinimumSeverity` value will also accept a string::

>>> NotificationMinimumSeverity.OFF == "OFF"
True
Expand Down Expand Up @@ -128,23 +128,20 @@ class NotificationDisabledCategory(str, Enum):
"""Filter notifications returned by the server by category.

Inherits from :class:`str` and :class:`Enum`. Every driver API accepting a
:class:`.NotificationFilter` value will also accept a string::
:class:`.NotificationDisabledCategory` value will also accept a string::

>>> NotificationDisabledCategory.HINT == "HINT"
True
>>> NotificationDisabledCategory.UNRECOGNIZED == "UNRECOGNIZED"
True
>>> NotificationDisabledCategory.UNSUPPORTED == "UNSUPPORTED"
True
>>> NotificationDisabledCategory.PERFORMANCE == "PERFORMANCE"
True
>>> NotificationDisabledCategory.DEPRECATION == "DEPRECATION"
True
>>> NotificationDisabledCategory.GENERIC == "GENERIC"
True

.. versionadded:: 5.7

.. versionchanged:: 5.14
Added categories :attr:`.SECURITY` and :attr:`.TOPOLOGY`.

.. seealso::
driver config :ref:`driver-notifications-disabled-categories-ref`,
session config :ref:`session-notifications-disabled-categories-ref`
Expand All @@ -156,6 +153,10 @@ class NotificationDisabledCategory(str, Enum):
PERFORMANCE = "PERFORMANCE"
DEPRECATION = "DEPRECATION"
GENERIC = "GENERIC"
#: Requires server version 5.14 or newer.
SECURITY = "SECURITY"
#: Requires server version 5.14 or newer.
TOPOLOGY = "TOPOLOGY"


if t.TYPE_CHECKING:
Expand All @@ -168,6 +169,8 @@ class NotificationDisabledCategory(str, Enum):
"PERFORMANCE",
"DEPRECATION",
"GENERIC",
"SECURITY",
"TOPOLOGY",
],
]
__all__.append("T_NotificationDisabledCategory")
Expand All @@ -188,6 +191,9 @@ class NotificationCategory(str, Enum):

.. versionadded:: 5.7

.. versionchanged:: 5.14
Added categories :attr:`.SECURITY` and :attr:`.TOPOLOGY`.

.. seealso:: :attr:`SummaryNotification.category`
"""

Expand All @@ -197,6 +203,8 @@ class NotificationCategory(str, Enum):
PERFORMANCE = "PERFORMANCE"
DEPRECATION = "DEPRECATION"
GENERIC = "GENERIC"
SECURITY = "SECURITY"
TOPOLOGY = "TOPOLOGY"
#: Used when the server provides a Category which the driver is unaware of.
#: This can happen when connecting to a server newer than the driver or
#: before notification categories were introduced.
Expand Down
2 changes: 2 additions & 0 deletions src/neo4j/_work/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def contains_system_updates(self) -> bool:
"PERFORMANCE": NotificationCategory.PERFORMANCE,
"DEPRECATION": NotificationCategory.DEPRECATION,
"GENERIC": NotificationCategory.GENERIC,
"SECURITY": NotificationCategory.SECURITY,
"TOPOLOGY": NotificationCategory.TOPOLOGY,
}


Expand Down