
    &gi                    Z    S r SSKJr  SSKJrJrJr   " S S5      r " S S5      rS
S jr	g	)a
  Support for MongoDB Stable API.

.. _versioned-api-ref:

MongoDB Stable API
=====================

Starting in MongoDB 5.0, applications can specify the server API version
to use when creating a :class:`~pymongo.mongo_client.MongoClient`. Doing so
ensures that the driver behaves in a manner compatible with that server API
version, regardless of the server's actual release version.

Declaring an API Version
````````````````````````

.. attention:: Stable API requires MongoDB >=5.0.

To configure MongoDB Stable API, pass the ``server_api`` keyword option to
:class:`~pymongo.mongo_client.MongoClient`::

    >>> from pymongo.mongo_client import MongoClient
    >>> from pymongo.server_api import ServerApi
    >>>
    >>> # Declare API version "1" for MongoClient "client"
    >>> server_api = ServerApi('1')
    >>> client = MongoClient(server_api=server_api)

The declared API version is applied to all commands run through ``client``,
including those sent through the generic
:meth:`~pymongo.database.Database.command` helper.

.. note:: Declaring an API version on the
   :class:`~pymongo.mongo_client.MongoClient` **and** specifying stable
   API options in :meth:`~pymongo.database.Database.command` command document
   is not supported and will lead to undefined behaviour.

To run any command without declaring a server API version or using a different
API version, create a separate :class:`~pymongo.mongo_client.MongoClient`
instance.

Strict Mode
```````````

Configuring ``strict`` mode will cause the MongoDB server to reject all
commands that are not part of the declared :attr:`ServerApi.version`. This
includes command options and aggregation pipeline stages.

For example::

    >>> server_api = ServerApi('1', strict=True)
    >>> client = MongoClient(server_api=server_api)
    >>> client.test.command('count', 'test')
    Traceback (most recent call last):
    ...
    pymongo.errors.OperationFailure: Provided apiStrict:true, but the command count is not in API Version 1, full error: {'ok': 0.0, 'errmsg': 'Provided apiStrict:true, but the command count is not in API Version 1', 'code': 323, 'codeName': 'APIStrictError'

Detecting API Deprecations
``````````````````````````

The ``deprecationErrors`` option can be used to enable command failures
when using functionality that is deprecated from the configured
:attr:`ServerApi.version`. For example::

    >>> server_api = ServerApi('1', deprecation_errors=True)
    >>> client = MongoClient(server_api=server_api)

Note that at the time of this writing, no deprecated APIs exist.

Classes
=======
    )annotations)AnyMutableMappingOptionalc                      \ rS rSrSrSrSrg)ServerApiVersion[   zSAn enum that defines values for :attr:`ServerApi.version`.

.. versionadded:: 3.12
1 N)__name__
__module____qualname____firstlineno____doc__V1__static_attributes__r       WC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/server_api.pyr   r   [   s    
 
B!r   r   c                  n    \ rS rSrSr S	     S
S jjr\SS j5       r\SS j5       r\SS j5       r	Sr
g)	ServerApie   zMongoDB Stable API.Nc                (   U[         R                  :w  a  [        SU 35      eUb,  [        U[        5      (       d  [        S[        U5       35      eUb,  [        U[        5      (       d  [        S[        U5       35      eXl        X l        X0l	        g)a  Options to configure MongoDB Stable API.

:param version: The API version string. Must be one of the values in
    :class:`ServerApiVersion`.
:param strict: Set to ``True`` to enable API strict mode.
    Defaults to ``None`` which means "use the server's default".
:param deprecation_errors: Set to ``True`` to enable
    deprecation errors. Defaults to ``None`` which means "use the
    server's default".

.. versionadded:: 3.12
zUnknown ServerApi version: NzHWrong type for ServerApi strict, value must be an instance of bool, not zTWrong type for ServerApi deprecation_errors, value must be an instance of bool, not )
r   r   
ValueError
isinstancebool	TypeErrortype_version_strict_deprecation_errors)selfversionstrictdeprecation_errorss       r   __init__ServerApi.__init__h   s     &))):7)DEEj&>&>  $V~/  )*=OQU2V2V,,01C,D+EG   #5 r   c                    U R                   $ )zVThe API version setting.

This value is sent to the server in the "apiVersion" field.
)r   r!   s    r   r"   ServerApi.version   s     }}r   c                    U R                   $ )zcThe API strict mode setting.

When set, this value is sent to the server in the "apiStrict" field.
)r   r(   s    r   r#   ServerApi.strict   s     ||r   c                    U R                   $ )zuThe API deprecation errors setting.

When set, this value is sent to the server in the
"apiDeprecationErrors" field.
)r    r(   s    r   r$   ServerApi.deprecation_errors   s     '''r   )r    r   r   )NN)r"   strr#   Optional[bool]r$   r/   )returnr.   )r0   r/   )r   r   r   r   r   r%   propertyr"   r#   r$   r   r   r   r   r   r   e   se     ae66$26O]6>     ( (r   r   c                    U(       d  gUR                   U S'   UR                  b  UR                  U S'   UR                  b  UR                  U S'   gg)zInternal helper which adds API versioning options to a command.

:param cmd: The command.
:param server_api: A :class:`ServerApi` or ``None``.
N
apiVersion	apiStrictapiDeprecationErrors)r"   r#   r$   )cmd
server_apis     r   _add_to_commandr8      sX     "**C$%,,K$$0&0&C&C"# 1r   N)r6   zMutableMapping[str, Any]r7   zOptional[ServerApi]r0   None)
r   
__future__r   typingr   r   r   r   r   r8   r   r   r   <module>r<      s2   FN # 0 0" "9( 9(xDr   