MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / ServerApi

Class ServerApi

pymongo/server_api.py:101–158  ·  view source on GitHub ↗

MongoDB Stable API.

Source from the content-addressed store, hash-verified

99
100
101class ServerApi:
102 """MongoDB Stable API."""
103
104 def __init__(
105 self, version: str, strict: Optional[bool] = None, deprecation_errors: Optional[bool] = None
106 ):
107 """Options to configure MongoDB Stable API.
108
109 :param version: The API version string. Must be one of the values in
110 :class:`ServerApiVersion`.
111 :param strict: Set to ``True`` to enable API strict mode.
112 Defaults to ``None`` which means "use the server's default".
113 :param deprecation_errors: Set to ``True`` to enable
114 deprecation errors. Defaults to ``None`` which means "use the
115 server's default".
116
117 .. versionadded:: 3.12
118 """
119 if version != ServerApiVersion.V1:
120 raise ValueError(f"Unknown ServerApi version: {version}")
121 if strict is not None and not isinstance(strict, bool):
122 raise TypeError(
123 "Wrong type for ServerApi strict, value must be an instance "
124 f"of bool, not {type(strict)}"
125 )
126 if deprecation_errors is not None and not isinstance(deprecation_errors, bool):
127 raise TypeError(
128 "Wrong type for ServerApi deprecation_errors, value must be "
129 f"an instance of bool, not {type(deprecation_errors)}"
130 )
131 self._version = version
132 self._strict = strict
133 self._deprecation_errors = deprecation_errors
134
135 @property
136 def version(self) -> str:
137 """The API version setting.
138
139 This value is sent to the server in the "apiVersion" field.
140 """
141 return self._version
142
143 @property
144 def strict(self) -> Optional[bool]:
145 """The API strict mode setting.
146
147 When set, this value is sent to the server in the "apiStrict" field.
148 """
149 return self._strict
150
151 @property
152 def deprecation_errors(self) -> Optional[bool]:
153 """The API deprecation errors setting.
154
155 When set, this value is sent to the server in the
156 "apiDeprecationErrors" field.
157 """
158 return self._deprecation_errors

Callers 15

test_command_optionsMethod · 0.90
test_versioned_apiMethod · 0.90
__init__Method · 0.90
_create_entityMethod · 0.90
sigstop_sigcont.pyFile · 0.90

Calls

no outgoing calls