123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- # Copyright (c) "Neo4j"
- # Neo4j Sweden AB [https://neo4j.com]
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # https://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- from __future__ import annotations
- import typing as t
- from enum import Enum
- if t.TYPE_CHECKING:
- import typing_extensions as te
- __all__ = [
- "NotificationCategory",
- "NotificationClassification",
- "NotificationDisabledCategory",
- "NotificationDisabledClassification",
- "NotificationMinimumSeverity",
- "NotificationSeverity",
- "RoutingControl",
- "TelemetryAPI",
- ]
- class NotificationMinimumSeverity(str, Enum):
- """
- Filter notifications returned by the server by minimum severity.
- For GQL-aware servers, notifications are a subset of GqlStatusObjects.
- See also :attr:`.GqlStatusObject.is_notification`.
- Inherits from :class:`str` and :class:`enum.Enum`.
- Every driver API accepting a :class:`.NotificationMinimumSeverity` value
- will also accept a string::
- >>> NotificationMinimumSeverity.OFF == "OFF"
- True
- >>> NotificationMinimumSeverity.WARNING == "WARNING"
- True
- >>> NotificationMinimumSeverity.INFORMATION == "INFORMATION"
- True
- .. seealso::
- driver config :ref:`driver-notifications-min-severity-ref`,
- session config :ref:`session-notifications-min-severity-ref`
- .. versionadded:: 5.7
- """
- OFF = "OFF"
- WARNING = "WARNING"
- INFORMATION = "INFORMATION"
- if t.TYPE_CHECKING:
- T_NotificationMinimumSeverity = t.Union[
- NotificationMinimumSeverity,
- te.Literal[
- "OFF",
- "WARNING",
- "INFORMATION",
- ],
- ]
- __all__.append("T_NotificationMinimumSeverity")
- class NotificationSeverity(str, Enum):
- """
- Server-side notification severity.
- Inherits from :class:`str` and :class:`enum.Enum`.
- Hence, can also be compared to its string value::
- >>> NotificationSeverity.WARNING == "WARNING"
- True
- >>> NotificationSeverity.INFORMATION == "INFORMATION"
- True
- >>> NotificationSeverity.UNKNOWN == "UNKNOWN"
- True
- Example::
- import logging
- from neo4j import NotificationSeverity
- log = logging.getLogger(__name__)
- ...
- summary = session.run("RETURN 1").consume()
- for notification in summary.summary_notifications:
- severity = notification.severity_level
- if severity == NotificationSeverity.WARNING:
- # or severity == "WARNING"
- log.warning("%r", notification)
- elif severity == NotificationSeverity.INFORMATION:
- # or severity == "INFORMATION"
- log.info("%r", notification)
- else:
- # assert severity == NotificationSeverity.UNKNOWN
- # or severity == "UNKNOWN"
- log.debug("%r", notification)
- .. seealso:: :attr:`.SummaryNotification.severity_level`
- .. versionadded:: 5.7
- """
- WARNING = "WARNING"
- INFORMATION = "INFORMATION"
- #: Used when the server provides a Severity which the driver is unaware of.
- #: This can happen when connecting to a server newer than the driver.
- UNKNOWN = "UNKNOWN"
- class NotificationDisabledCategory(str, Enum):
- """
- Filter notifications returned by the server by category.
- For GQL-aware servers, notifications are a subset of GqlStatusObjects.
- See also :attr:`.GqlStatusObject.is_notification`.
- Inherits from :class:`str` and :class:`enum.Enum`.
- Every driver API accepting a :class:`.NotificationDisabledCategory` value
- will also accept a string::
- >>> NotificationDisabledCategory.UNRECOGNIZED == "UNRECOGNIZED"
- True
- >>> NotificationDisabledCategory.PERFORMANCE == "PERFORMANCE"
- True
- >>> NotificationDisabledCategory.DEPRECATION == "DEPRECATION"
- True
- .. seealso::
- driver config :ref:`driver-notifications-disabled-categories-ref`,
- session config :ref:`session-notifications-disabled-categories-ref`
- .. versionadded:: 5.7
- .. versionchanged:: 5.14
- Added categories :attr:`.SECURITY` and :attr:`.TOPOLOGY`.
- .. versionchanged:: 5.24
- Added category :attr:`.SCHEMA`.
- """
- HINT = "HINT"
- UNRECOGNIZED = "UNRECOGNIZED"
- UNSUPPORTED = "UNSUPPORTED"
- PERFORMANCE = "PERFORMANCE"
- DEPRECATION = "DEPRECATION"
- GENERIC = "GENERIC"
- SECURITY = "SECURITY"
- #: Requires server version 5.13 or newer.
- TOPOLOGY = "TOPOLOGY"
- #: Requires server version 5.17 or newer.
- SCHEMA = "SCHEMA"
- class NotificationDisabledClassification(str, Enum):
- """
- Identical to :class:`.NotificationDisabledCategory`.
- This alternative is provided for a consistent naming with
- :attr:`.GqlStatusObject.classification`.
- **This is a preview**.
- It might be changed without following the deprecation policy.
- See also
- https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
- .. seealso::
- driver config
- :ref:`driver-notifications-disabled-classifications-ref`,
- session config
- :ref:`session-notifications-disabled-classifications-ref`
- .. versionadded:: 5.22
- .. versionchanged:: 5.24
- Added classification :attr:`.SCHEMA`.
- """
- HINT = "HINT"
- UNRECOGNIZED = "UNRECOGNIZED"
- UNSUPPORTED = "UNSUPPORTED"
- PERFORMANCE = "PERFORMANCE"
- DEPRECATION = "DEPRECATION"
- GENERIC = "GENERIC"
- SECURITY = "SECURITY"
- #: Requires server version 5.13 or newer.
- TOPOLOGY = "TOPOLOGY"
- #: Requires server version 5.17 or newer.
- SCHEMA = "SCHEMA"
- if t.TYPE_CHECKING:
- T_NotificationDisabledCategory = t.Union[
- NotificationDisabledCategory,
- NotificationDisabledClassification,
- te.Literal[
- "HINT",
- "UNRECOGNIZED",
- "UNSUPPORTED",
- "PERFORMANCE",
- "DEPRECATION",
- "GENERIC",
- "SECURITY",
- "TOPOLOGY",
- "SCHEMA",
- ],
- ]
- __all__.append("T_NotificationDisabledCategory")
- class NotificationCategory(str, Enum):
- """
- Server-side notification category.
- Inherits from :class:`str` and :class:`enum.Enum`.
- Hence, can also be compared to its string value::
- >>> NotificationCategory.DEPRECATION == "DEPRECATION"
- True
- >>> NotificationCategory.GENERIC == "GENERIC"
- True
- >>> NotificationCategory.UNKNOWN == "UNKNOWN"
- True
- .. seealso:: :attr:`.SummaryNotification.category`
- .. versionadded:: 5.7
- .. versionchanged:: 5.14
- Added categories :attr:`.SECURITY` and :attr:`.TOPOLOGY`.
- .. versionchanged:: 5.24
- Added category :attr:`.SCHEMA`.
- """
- HINT = "HINT"
- UNRECOGNIZED = "UNRECOGNIZED"
- UNSUPPORTED = "UNSUPPORTED"
- PERFORMANCE = "PERFORMANCE"
- DEPRECATION = "DEPRECATION"
- GENERIC = "GENERIC"
- SECURITY = "SECURITY"
- TOPOLOGY = "TOPOLOGY"
- SCHEMA = "SCHEMA"
- #: 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.
- UNKNOWN = "UNKNOWN"
- class NotificationClassification(str, Enum):
- """
- Identical to :class:`.NotificationCategory`.
- This alternative is provided for a consistent naming with
- :attr:`.GqlStatusObject.classification`.
- **This is a preview**.
- It might be changed without following the deprecation policy.
- See also
- https://github.com/neo4j/neo4j-python-driver/wiki/preview-features
- .. seealso:: :attr:`.GqlStatusObject.classification`
- .. versionadded:: 5.22
- .. versionchanged:: 5.24
- Added classification :attr:`.SCHEMA`.
- """
- HINT = "HINT"
- UNRECOGNIZED = "UNRECOGNIZED"
- UNSUPPORTED = "UNSUPPORTED"
- PERFORMANCE = "PERFORMANCE"
- DEPRECATION = "DEPRECATION"
- GENERIC = "GENERIC"
- SECURITY = "SECURITY"
- TOPOLOGY = "TOPOLOGY"
- SCHEMA = "SCHEMA"
- #: 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.
- UNKNOWN = "UNKNOWN"
- class RoutingControl(str, Enum):
- """
- Selection which cluster members to route a query connect to.
- Inherits from :class:`str` and :class:`enum.Enum`.
- Every driver API accepting a :class:`.RoutingControl` value will also
- accept a string::
- >>> RoutingControl.READ == "r"
- True
- >>> RoutingControl.WRITE == "w"
- True
- .. seealso::
- :meth:`.AsyncDriver.execute_query`, :meth:`.Driver.execute_query`
- .. versionadded:: 5.5
- .. versionchanged:: 5.8
- * Renamed ``READERS`` to ``READ`` and ``WRITERS`` to ``WRITE``.
- * Stabilized from experimental.
- """
- READ = "r"
- WRITE = "w"
- class TelemetryAPI(int, Enum):
- TX_FUNC = 0
- TX = 1
- AUTO_COMMIT = 2
- DRIVER = 3
- if t.TYPE_CHECKING:
- T_RoutingControl = t.Union[
- RoutingControl,
- te.Literal["r", "w"],
- ]
- __all__.append("T_RoutingControl")
|