a
    cņfH  ć                   @   s\  d Z ze W n ey"   eZY n0 dZdZegZz"ddlZe	dd eD Z
dZW n eyj   dZY n0 dd	lmZmZmZ zDdd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ zddlmZ e e” W n eyų   Y n0 e e” eedrejZddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddlm'Z' ddlm(Z( ddlm)Z) ddlm*Z* i Z+e&j,j- .” D ]\Z/Z0e0e+d 1e/”< q¶e&j2j- .” D ]\Z/Z0e0e+d  1e/”< qÜe&j3j4 .” D ]\Z/Z0e0e+d! 1e/”< qe j5 .” D ]\Z/Z0e0e+d" 1e/”< q&e j6j7 .” D ]\Z/Z0e0e+d# 1e/”< qLe j8j9 .” D ]\Z/Z0e0e+d$ 1e/”< qre j:j; .” D ]\Z/Z0e0e+d% 1e/”< qe"j<j- .” D ]\Z/Z0e0e+d& 1e/”< q¾e"j=j- .” D ]\Z/Z0e0e+d' 1e/”< qäe#j>j?j@ .” D ]\Z/Z0e0e+d( 1e/”< qe#j>j?jA .” D ]\Z/Z0e0e+d) 1e/”< q4e#j>jB .” D ]\Z/Z0e0e+d* 1e/”< qZe$jCj- .” D ]\Z/Z0e0e+d+ 1e/”< qe$jDj- .” D ]\Z/Z0e0e+d, 1e/”< q¦e%jEjF .” D ]\Z/Z0e0e+d- 1e/”< qĢe%jGjH .” D ]\Z/Z0e0e+d. 1e/”< qņe%jIjJ .” D ]\Z/Z0e0e+d/ 1e/”< qe'jKjLj- .” D ]\Z/Z0e0e+d0 1e/”< q@e(jMjN .” D ]\Z/Z0e0e+d1 1e/”< qfe O” ZPe QeP”ZReP SejT UejVjW”” eP SejT Ue jVjW”” eP SejT Ue!jVjW”” eP SejT Ue"jVjW”” eP SejT Ue#jVjW”” eP SejT Ue$jVjW”” eP SejT Ue%jVjW”” eP SejT Ue&jVjW”” eP SejT Ue'jVjW”” eP SejT Ue(jVjW”” eP SejT Ue)jVjW”” eP SejT Ue*jVjW”” e	d2d eD Z
dZXdZYG d3d4 d4eZZ[W nX eee\e]fy Z^ z6dZXedurņe^nd5ZYes
ed6 1eY”W Y dZ^[^n
dZ^[^0 0 d7d8d9d:d;d<Z_G d=d> d>eZZ`G d?d@ d@eZZadAdB ZbdS )CzXThis module contains the implementation of a helper class for MySQL X
Protobuf messages.))zMysqlx.ServerMessages.Type.OKz	Mysqlx.Ok)z Mysqlx.ServerMessages.Type.ERRORzMysqlx.Error)z,Mysqlx.ServerMessages.Type.CONN_CAPABILITIESzMysqlx.Connection.Capabilities)z5Mysqlx.ServerMessages.Type.SESS_AUTHENTICATE_CONTINUEz#Mysqlx.Session.AuthenticateContinue)z/Mysqlx.ServerMessages.Type.SESS_AUTHENTICATE_OKzMysqlx.Session.AuthenticateOk)z!Mysqlx.ServerMessages.Type.NOTICEzMysqlx.Notice.Frame)z5Mysqlx.ServerMessages.Type.RESULTSET_COLUMN_META_DATAzMysqlx.Resultset.ColumnMetaData)z(Mysqlx.ServerMessages.Type.RESULTSET_ROWzMysqlx.Resultset.Row)z/Mysqlx.ServerMessages.Type.RESULTSET_FETCH_DONEzMysqlx.Resultset.FetchDone)z4Mysqlx.ServerMessages.Type.RESULTSET_FETCH_SUSPENDEDzMysqlx.Resultset.FetchSuspended)z?Mysqlx.ServerMessages.Type.RESULTSET_FETCH_DONE_MORE_RESULTSETSz(Mysqlx.Resultset.FetchDoneMoreResultsets)z.Mysqlx.ServerMessages.Type.SQL_STMT_EXECUTE_OKzMysqlx.Sql.StmtExecuteOk)z?Mysqlx.ServerMessages.Type.RESULTSET_FETCH_DONE_MORE_OUT_PARAMSz'Mysqlx.Resultset.FetchDoneMoreOutParams)z&Mysqlx.ServerMessages.Type.COMPRESSIONzMysqlx.Connection.CompressionNé    c                 C   s"   g | ]\}}t t |”|fqS © )ŚintŚ	_mysqlxpbŚ
enum_value©Ś.0ŚkeyŚvalr   r   śU/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/mysqlx/protobuf/__init__.pyŚ
<listcomp>I   s   ’r   TFé   )Ś
BYTE_TYPESŚNUMERIC_TYPESŚencode_to_bytes)Śprotobuf)Śdescriptor_database)Śdescriptor_pb2)Śdescriptor_pool)Śmessage_factory)ŚRepeatedCompositeFieldContainer)ŚRepeatedCompositeContainerŚ__version__é   )Śmysqlx_connection_pb2)Śmysqlx_crud_pb2)Śmysqlx_cursor_pb2)Śmysqlx_datatypes_pb2)Śmysqlx_expect_pb2)Śmysqlx_expr_pb2)Śmysqlx_notice_pb2)Ś
mysqlx_pb2)Śmysqlx_prepare_pb2)Śmysqlx_resultset_pb2)Śmysqlx_session_pb2)Śmysqlx_sql_pb2zMysqlx.ClientMessages.Type.{0}zMysqlx.ServerMessages.Type.{0}zMysqlx.Error.Severity.{0}zMysqlx.Crud.DataModel.{0}zMysqlx.Crud.Find.RowLock.{0}zMysqlx.Crud.Order.Direction.{0}z*Mysqlx.Crud.UpdateOperation.UpdateType.{0}z Mysqlx.Datatypes.Scalar.Type.{0}zMysqlx.Datatypes.Any.Type.{0}z3Mysqlx.Expect.Open.Condition.ConditionOperation.{0}z$Mysqlx.Expect.Open.Condition.Key.{0}z#Mysqlx.Expect.Open.CtxOperation.{0}zMysqlx.Expr.Expr.Type.{0}z%Mysqlx.Expr.DocumentPathItem.Type.{0}zMysqlx.Notice.Frame.Scope.{0}zMysqlx.Notice.Warning.Level.{0}z/Mysqlx.Notice.SessionStateChanged.Parameter.{0}z,Mysqlx.Prepare.Prepare.OneOfMessage.Type.{0}z-Mysqlx.Resultset.ColumnMetaData.FieldType.{0}c                 C   s   g | ]\}}t | |fqS r   ©Ś	_MESSAGESr   r   r   r
   r   Ķ   ó    c                   @   s`   e Zd ZdZe ” Zedd Zedd Z	edd Z
edd	 Zed
d Zedd ZdS )Ś_mysqlxpb_purez]This class implements the methods in pure Python used by the
        _mysqlxpb C++ extension.c                 C   s   t j t | ””}| S ©N)r(   ŚfactoryZGetPrototypeŚ_DESCRIPTOR_POOLZFindMessageTypeByName)ŚnameŚclsr   r   r
   Śnew_messageŲ   s    ’z_mysqlxpb_pure.new_messagec                 C   s   t |  S r)   r%   )r   r   r   r
   r   Ž   s    z_mysqlxpb_pure.enum_valuec                 C   s   |   ” S r)   )ZSerializeToString©Śmsgr   r   r
   Śserialize_messageā   s    z _mysqlxpb_pure.serialize_messagec                 C   s   |   ” S r)   )ZSerializePartialToStringr/   r   r   r
   Śserialize_partial_messageę   s    z(_mysqlxpb_pure.serialize_partial_messagec                 C   s   t  | ”}| |” |S r)   )r(   r.   ŚParseFromString)Śmsg_type_nameŚpayloadr0   r   r   r
   Śparse_messageź   s    

z_mysqlxpb_pure.parse_messagec                 C   s4   t  | ”}|std | ”t |”}| |” |S )NzUnknown msg_type: {0})ŚSERVER_MESSAGESŚgetŚ
ValueErrorŚformatr(   r.   r3   )Śmsg_typer5   r4   r0   r   r   r
   Śparse_server_messageš   s    


z#_mysqlxpb_pure.parse_server_messageN)Ś__name__Ś
__module__Ś__qualname__Ś__doc__r   ZMessageFactoryr*   Śstaticmethodr.   r   r1   r2   r6   r<   r   r   r   r
   r(   Ņ   s   




r(   zProtobuf >=3.0.0 is requiredśProtobuf is not available: {})z-Mysqlx.Prepare.Prepare.OneOfMessage.Type.FINDŚfind)z/Mysqlx.Prepare.Prepare.OneOfMessage.Type.INSERTŚinsert)z/Mysqlx.Prepare.Prepare.OneOfMessage.Type.UPDATEŚupdate)z/Mysqlx.Prepare.Prepare.OneOfMessage.Type.DELETEŚdelete)z-Mysqlx.Prepare.Prepare.OneOfMessage.Type.STMTZstmt_execute)z$Mysqlx.ClientMessages.Type.CRUD_FINDz&Mysqlx.ClientMessages.Type.CRUD_INSERTz&Mysqlx.ClientMessages.Type.CRUD_UPDATEz&Mysqlx.ClientMessages.Type.CRUD_DELETEz+Mysqlx.ClientMessages.Type.SQL_STMT_EXECUTEc                   @   s4   e Zd ZdZereneZer dndZe	dd Z
dS )ŚProtobufzŲProtobuf class acts as a container of the Protobuf message class.
    It allows the switch between the C extension and pure Python implementation
    message handlers, by patching the `mysqlxpb` class attribute.
    FTc                 C   s@   | rt std t”n| s(ts(td| r0tntt_| t_	dS )z”Sets whether to use the C extension or pure Python implementation.

        Args:
            use_pure (bool): `True` to use pure Python implementation.
        rB   z-MySQL X Protobuf C extension is not availableN)
ŚHAVE_PROTOBUFŚImportErrorr:   ŚHAVE_PROTOBUF_ERRORŚHAVE_MYSQLXPB_CEXTr(   r   rG   ŚmysqlxpbŚuse_pure)rM   r   r   r
   Śset_use_pure  s    ’zProtobuf.set_use_pureN)r=   r>   r?   r@   rK   r   r(   rL   rM   rA   rN   r   r   r   r
   rG     s
   rG   c                   @   s¬   e Zd ZdZd#ddZdd Zdd Zd	d
 Zdd Zd$ddZ	dd Z
dd Zdd Zdd Zedd Zedd Zedd Zedd Zedd  Zed!d" ZdS )%ŚMessagezŠHelper class for interfacing with the MySQL X Protobuf extension.

    Args:
        msg_type_name (string): Protobuf type name.
        **kwargs: Arbitrary keyword arguments with values for the message.
    Nc                 K   s<   |rt j |”nd | jd< | ” D ]\}}|  ||” q"d S )NŚ_msg)rG   rL   r.   Ś__dict__ŚitemsŚ__setattr__)Śselfr4   Śkwargsr   Śvaluer   r   r
   Ś__init__-  s    ’’zMessage.__init__c                 C   s¶   t jrt|tr$t| j|t| q²t|ttfrBt| j|| q²t|t	r`t
| j| |” q²t|trt
| j| | ” ” q²t
| j| |” nt|trØ| ” n|| j|< d S r)   )rG   rM   Ś
isinstanceŚstrŚsetattrrP   r   r   r   ŚlistŚgetattrŚextendrO   Z	MergeFromŚget_message©rT   r,   rV   r   r   r
   rS   3  s    


’
’zMessage.__setattr__c                 C   s:   zt js| j| n
t| j|W S  ty4   tY n0 d S r)   )rG   rM   rP   r\   ŚKeyErrorŚAttributeError©rT   r,   r   r   r
   Ś__getattr__C  s    
’zMessage.__getattr__c                 C   s   |   ||” d S r)   )rS   r_   r   r   r
   Ś__setitem__J  s    zMessage.__setitem__c                 C   s
   |   |”S r)   )rc   rb   r   r   r
   Ś__getitem__M  s    zMessage.__getitem__c                 C   s*   t js| jd  ||”S t| jd ||S )a  Returns the value of an element of the message dictionary.

        Args:
            name (string): Key name.
            default (object): The default value if the key does not exists.

        Returns:
            object: The value of the provided key name.
        rP   )rG   rM   rQ   r8   r\   )rT   r,   Śdefaultr   r   r
   r8   P  s    ’žzMessage.getc                 C   s   || j d< dS )zdSets the message.

        Args:
            msg (dict): Dictionary representing a message.
        rP   N©rQ   )rT   r0   r   r   r
   Śset_message^  s    zMessage.set_messagec                 C   s
   | j d S )zøReturns the dictionary representing a message containing parsed
        data.

        Returns:
            dict: The dictionary representing a message containing parsed data.
        rP   rg   ©rT   r   r   r
   r^   f  s    zMessage.get_messagec                 C   s   t j | j”S )zSerializes a message to a string.

        Returns:
            str: A string representing a message containing parsed data.
        )rG   rL   r1   rP   ri   r   r   r
   Śserialize_to_stringo  s    zMessage.serialize_to_stringc                 C   s   t j | j”S )z’Serializes the protocol message to a binary string.

        This method is similar to serialize_to_string but doesn't check if the
        message is initialized.

        Returns:
            str: A string representation of the partial message.
        )rG   rL   r2   rP   ri   r   r   r
   Śserialize_partial_to_stringw  s    	z#Message.serialize_partial_to_stringc                 C   s   t js| jd S | jjjS )zstring: Message type name.Z_mysqlxpb_type_name)rG   rM   rP   Ś
DESCRIPTORZ	full_nameri   r   r   r
   Śtype  s    ’zMessage.typec                 C   s   t j | |”S )a>  Creates a new message, initialized with parsed data.

        Args:
            msg_type_name (string): Message type name.
            payload (string): Serialized message data.

        Returns:
            dict: The dictionary representing a message containing parsed data.

        .. versionadded:: 8.0.21
        )rG   rL   r6   )r4   r5   r   r   r
   Śparse  s    zMessage.parsec                 C   s   t jr|  ” S tt|  ” S )zéReturns the size of the message in bytes.

        Args:
            msg (mysqlx.protobuf.Message): MySQL X Protobuf Message.

        Returns:
            int: Size of the message in bytes.

        .. versionadded:: 8.0.21
        )rG   rM   ZByteSizeŚlenr   rj   r/   r   r   r
   Ś	byte_size  s    ’zMessage.byte_sizec                 C   s   t j | |”S )a  Creates a new server-side message, initialized with parsed data.

        Args:
            msg_type (int): Message type.
            payload (string): Serialized message data.

        Returns:
            dict: The dictionary representing a message containing parsed data.
        )rG   rL   r<   )r;   r5   r   r   r
   Śparse_from_server¦  s    zMessage.parse_from_serverc                 C   s   |  }|  tj ||”” |S )a  Creates a new message, initialized with parsed data and returns a
        :class:`mysqlx.protobuf.Message` object.

        Args:
            msg_type_name (string): Message type name.
            payload (string): Serialized message data.

        Returns:
            mysqlx.protobuf.Message: The Message representing a message
                                     containing parsed data.
        )rh   rG   rL   r6   )r-   r4   r5   r0   r   r   r
   Śfrom_message³  s    zMessage.from_messagec                 C   s   |  }|  tj ||”” |S )a  Creates a new server-side message, initialized with parsed data and
        returns a :class:`mysqlx.protobuf.Message` object.

        Args:
            msg_type (int): Message type.
            payload (string): Serialized message data.

        Returns:
            mysqlx.protobuf.Message: The Message representing a message
                                     containing parsed data.
        )rh   rG   rL   r<   )r-   r;   r5   r0   r   r   r
   Śfrom_server_messageÄ  s
    ’zMessage.from_server_message)N)N)r=   r>   r?   r@   rW   rS   rc   rd   re   r8   rh   r^   rj   rk   Śpropertyrm   rA   rn   rp   rq   Śclassmethodrr   rs   r   r   r   r
   rO   &  s.   

	




rO   c                 C   s   t j | ”S )zÆReturns the value of a MySQL X Protobuf enumerator.

    Args:
        name (string): MySQL X Protobuf numerator name.

    Returns:
        int: Value of the enumerator.
    )rG   rL   r   )r,   r   r   r
   Śmysqlxpb_enum×  s    	rv   )cr@   ŚModuleNotFoundErrorŚ	NameErrorrI   Z_SERVER_MESSAGES_TUPLESZPROTOBUF_VERSIONr[   ZPROTOBUF_REPEATED_TYPESr   Śdictr7   rK   Śhelpersr   r   r   Zgoogler   Zgoogle.protobufr   r   r   r   Z#google.protobuf.internal.containersr   Zgoogle.protobuf.pyext._messager   ŚappendŚhasattrr   Ś r   r   r   r   r   r   r   r    r!   r"   r#   r$   r&   ZClientMessagesŚTyperR   r   r	   r:   ZServerMessagesŚErrorZSeverityZ	DataModelZFindZRowLockZOrderZ	DirectionZUpdateOperationZ
UpdateTypeZScalarŚAnyZOpenŚ	ConditionZConditionOperationŚKeyZCtxOperationŚExprZDocumentPathItemŚFrameZScopeŚWarningZLevelZSessionStateChangedŚ	ParameterZPrepareZOneOfMessageZColumnMetaDataZ	FieldTypeZDescriptorDatabaseZ_DESCRIPTOR_DBZDescriptorPoolr+   ŚAddZFileDescriptorProtoZ
FromStringrl   Zserialized_pbrH   rJ   Śobjectr(   ŚSyntaxErrorŚ	TypeErrorŚerrZCRUD_PREPARE_MAPPINGrG   rO   rv   r   r   r   r
   Ś<module>   s:  
’

’’’’’’’’

’
’
’
’
’
’
’
’
’
’
’
’’&’’÷ 2