Current File : //usr/lib/python3/dist-packages/boto3/dynamodb/__pycache__/transform.cpython-312.pyc
�

��em2���ddlZddlmZddlmZddlmZmZddlm	Z	m
Z
d�ZGd�de�Z
d	�ZGd
�d�ZGd�d
�ZGd�d�ZGd�d�Zy)�N)�collections_abc)�DocumentModifiedShape)�
ConditionBase�ConditionExpressionBuilder)�TypeDeserializer�TypeSerializerc�0�|jdt�y)Nr)�insert�DynamoDBHighLevelResource)�base_classes�kwargss  �:/usr/lib/python3/dist-packages/boto3/dynamodb/transform.py�register_high_level_interfacers������4�5�c��eZdZdZd�Zy)�_ForgetfulDictz�A dictionary that discards any items set on it. For use as `memo` in
    `copy.deepcopy()` when every instance of a repeated object in the deepcopied
    data structure should result in a separate copy.
    c��y�N�)�self�key�values   r�__setitem__z_ForgetfulDict.__setitem__s��rN)�__name__�
__module__�__qualname__�__doc__rrrrrrs���

rrc�@�tj|t���S)N)�memo)�copy�deepcopyr)�paramsr
s  r�copy_dynamodb_paramsr##s���=�=��n�&6�7�7rc���eZdZ�fd�Z�xZS)rc���t�|�|i|��|jjjjjdtd��t�|_|jjjjjd|jjd��|jjjjjd|jjd��|jjjjjd|jjd��td	d
dd�
�}tdddd�
�}tdddd�
�}|jjjjjd|jd��|jjjjjd|jd��|jjjjjd|jd��y)Nzprovide-client-params.dynamodbzdynamodb-create-params-copy)�	unique_idzbefore-parameter-build.dynamodbzdynamodb-condition-expressionzdynamodb-attr-value-inputzafter-call.dynamodbzdynamodb-attr-value-output�AttributeValuezvalid DynamoDB typez�- The value of the attribute. The valid value types are listed in the :ref:`DynamoDB Reference Guide<ref_valid_dynamodb_types>`.z`'string'|123|Binary(b'bytes')|True|None|set(['string'])|set([123])|set([Binary(b'bytes')])|[]|{})�new_type�new_description�new_example_value�
KeyExpressionz?condition from :py:class:`boto3.dynamodb.conditions.Key` methodz�The condition(s) a key(s) must meet. Valid conditions are listed in the :ref:`DynamoDB Reference Guide<ref_dynamodb_conditions>`.zKey('mykey').eq('myvalue')�ConditionExpressionz@condition from :py:class:`boto3.dynamodb.conditions.Attr` methodz�The condition(s) an attribute(s) must meet. Valid conditions are listed in the :ref:`DynamoDB Reference Guide<ref_dynamodb_conditions>`.z!Attr('myattribute').eq('myvalue')z"docs.*.dynamodb.*.complete-sectionzdynamodb-attr-value-docszdynamodb-key-expression-docszdynamodb-cond-expression-docs)�super�__init__�meta�client�events�registerr#�TransformationInjector�	_injector�inject_condition_expressions�inject_attribute_value_input�inject_attribute_value_outputr�(replace_documentation_for_matching_shape)r�argsr
�attr_value_shape_docs�key_expression_shape_docs�con_expression_shape_docs�	__class__s      �rr.z"DynamoDBHighLevelResource.__init__(s���
���$�)�&�)�	
�	�	�����$�$�-�-�,� �3�	.�	
�0�1���	
�	�	�����$�$�-�-�-��N�N�7�7�5�	.�	
�	
�	�	�����$�$�-�-�-��N�N�7�7�1�	.�	
�	
�	�	�����$�$�-�-�!��N�N�8�8�2�	.�	
�!6��*�M�
>�!
��%:���L�?�%
�!�%:�!��L�F�%
�!�	
�	�	�����$�$�-�-�0�!�J�J�0�	.�	
�	
�	�	�����$�$�-�-�0�%�N�N�4�	.�	
�	
�	�	�����$�$�-�-�0�%�N�N�5�	.�	
r)rrrr.�
__classcell__)r=s@rrr's���`
�`
rrc�2�eZdZdZ				dd�Zd�Zd�Zd�Zy)r3z>Injects the transformations into the user provided parameters.Nc���||_|�t�|_||_|�t�|_||_|�t�|_||_|�t�|_yyr)�_transformer�ParameterTransformer�_condition_builderr�_serializerr�
_deserializerr)r�transformer�condition_builder�
serializer�deserializers     rr.zTransformationInjector.__init__�sm��(����� 4� 6�D��"3����$�&@�&B�D�#�%�����-�/�D��)�����!1�!3�D�� rc���|jj�i}i}t|j||d��}|jj	||j
|d�t|j||d��}|jj	||j
|d�d}d}||vr||j
|�n|r|||<||vr||j
|�y|r|||<yy)	a7Injects the condition expression transformation into the parameters

        This injection includes transformations for ConditionExpression shapes
        and KeyExpression shapes. It also handles any placeholder names and
        values that are generated when transforming the condition expressions.
        F)�placeholder_names�placeholder_values�is_key_conditionr,Tr+�ExpressionAttributeNames�ExpressionAttributeValuesN)rC�reset�!ConditionExpressionTransformationrA�	transform�input_shape�update)	rr"�modelr
�generated_names�generated_values�transformation�expr_attr_names_input�expr_attr_values_inputs	         rr5z3TransformationInjector.inject_condition_expressions�s��	
���%�%�'�����;��#�#�-�/�"�	
��	
���#�#��E�%�%�~�7L�	
�
;��#�#�-�/�!�	
��	
���#�#��E�%�%�~��	
�!;��!<��!�F�*��(�)�0�0��A��0?��,�-�!�V�+��)�*�1�1�2B�C��1A��-�.� rc�|�|jj||j|jjd�y)z3Injects DynamoDB serialization into parameter inputr'N)rArRrSrD�	serialize)rr"rUr
s    rr6z3TransformationInjector.inject_attribute_value_input�s4�����#�#��������&�&��		
rc��|j�=|jj||j|jjd�yy)z/Injects DynamoDB deserialization into responsesNr')�output_shaperArRrE�deserialize)r�parsedrUr
s    rr7z4TransformationInjector.inject_attribute_value_output�sE�����)����'�'���"�"��"�"�.�.� �	
�*r)NNNN)rrrrr.r5r6r7rrrr3r3�s)��H�����4�.0B�d
�rr3c� �eZdZdZ	dd�Zd�Zy)rQz�Provides a transformation for condition expressions

    The ``ParameterTransformer`` class can call this class directly
    to transform the condition expressions in the parameters provided.
    c�<�||_||_||_||_yr)rC�_placeholder_names�_placeholder_values�_is_key_condition)rrGrKrLrMs     rr.z*ConditionExpressionTransformation.__init__�s$��#4���"3���#5�� �!1��rc� �t|t�r}|jj||j��}|j
j
|j�|jj
|j�|jS|S)N)rM)�
isinstancerrC�build_expressionrercrT�attribute_name_placeholdersrd�attribute_value_placeholders�condition_expression)rr�built_expressions   r�__call__z*ConditionExpressionTransformation.__call__�s����e�]�+� $�6�6�G�G���(>�(>� H� ��
�#�#�*�*� �<�<�
�
�$�$�+�+� �=�=�
�$�8�8�8��rN)F)rrrrr.rmrrrrQrQ�s����
2�rrQc�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)rBz?Transforms the input to and output from botocore based on shapec�,�|j||||�y)a�Transforms the dynamodb input to or output from botocore

        It applies a specified transformation whenever a specific shape name
        is encountered while traversing the parameters in the dictionary.

        :param params: The parameters structure to transform.
        :param model: The operation model.
        :param transformation: The function to apply the parameter
        :param target_shape: The name of the shape to apply the
            transformation to
        N)�_transform_parameters)rr"rUrX�target_shapes     rrRzParameterTransformer.transforms��	
�"�"�5�&�.�,�Orc�V�|j}|dvrt|d|���||||�yy)N)�	structure�map�list�_transform_)�	type_name�getattr)rrUr"rXrqrws      rrpz*ParameterTransformer._transform_parameters#s<���O�O�	��4�4�4�G�D�K�	�{�3�4��v�~�|�
�5rc���t|tj�sy|D]W}||jvs�|j|}|j}||k(r|||�||<�A|j|||||��Yyr)rgr�Mapping�members�namerp)rrUr"rXrq�param�member_model�member_shapes        r�_transform_structurez)ParameterTransformer._transform_structure,s����&�/�"9�"9�:���	�E���
�
�%�$�}�}�U�3��+�0�0���<�/�$2�6�%�=�$A�F�5�M��.�.�$��u�
�&�$�	�	rc���t|tj�sy|j}|j}|j�D]-\}}||k(r||�||<�|j
|||||��/yr)rgrrzrr|�itemsrp)	rrUr"rXrq�value_model�value_shaperrs	         r�_transform_mapz#ParameterTransformer._transform_map?ss���&�/�"9�"9�:���k�k��!�&�&�� �,�,�.�	�J�C���l�*�,�U�3��s���*�*�����n�l��		rc���t|tj�sy|j}|j}t|�D]-\}}||k(r||�||<�|j
|||||��/yr)rgr�MutableSequence�memberr|�	enumeraterp)	rrUr"rXrqr~r�i�items	         r�_transform_listz$ParameterTransformer._transform_listLsr���&�/�"A�"A�B���|�|��#�(�(�� ��(�	�G�A�t��|�+�*�4�0��q�	��*�*� �&��)�^�\��		rN)	rrrrrRrpr�r�r�rrrrBrBs��I�P���&�rrB)r �boto3.compatr�boto3.docs.utilsr�boto3.dynamodb.conditionsrr�boto3.dynamodb.typesrrr�dictrr#rr3rQrBrrr�<module>r�s]���(�2�O�A�6�
�T�
�8�a
�a
�H]�]�@$�$�NE�Er