o
    È·ed   ã                   @   sÂ   d dl mZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZ	G dd„ deƒZ
G dd„ de
ƒZG dd„ de
ƒZG dd„ de
e	ƒZdS )é    )ÚSTRINGc                   @   s0   e Zd ZdZdZefdd„Zdd„ Zdd„ ZdS )	ÚBaseSchemaFieldz´
    An abstract class for defining schema fields.

    Contains most of the core functionality for the field. Subclasses must
    define an ``attr_type`` to pass to DynamoDB.
    Nc                 C   s   || _ || _dS )aN  
        Creates a Python schema field, to represent the data to pass to
        DynamoDB.

        Requires a ``name`` parameter, which should be a string name of the
        field.

        Optionally accepts a ``data_type`` parameter, which should be a
        constant from ``boto.dynamodb2.types``. (Default: ``STRING``)
        N©ÚnameÚ	data_type)Úselfr   r   © r   úL/var/www/ideatree/venv/lib/python3.10/site-packages/boto/dynamodb2/fields.pyÚ__init__   s   
zBaseSchemaField.__init__c                 C   ó   | j | jdœS )zõ
        Returns the attribute definition structure DynamoDB expects.

        Example::

            >>> field.definition()
            {
                'AttributeName': 'username',
                'AttributeType': 'S',
            }

        ©ÚAttributeNameÚAttributeTyper   ©r   r   r   r	   Ú
definition   ó   þzBaseSchemaField.definitionc                 C   r   )zà
        Returns the schema structure DynamoDB expects.

        Example::

            >>> field.schema()
            {
                'AttributeName': 'username',
                'KeyType': 'HASH',
            }

        )r   ÚKeyType)r   Ú	attr_typer   r   r   r	   Úschema-   r   zBaseSchemaField.schema)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r   r   r   r   r   r	   r      s    r   c                   @   ó   e Zd ZdZdZdS )ÚHashKeyzÅ
    An field representing a hash key.

    Example::

        >>> from boto.dynamodb2.types import NUMBER
        >>> HashKey('username')
        >>> HashKey('date_joined', data_type=NUMBER)

    ÚHASHN©r   r   r   r   r   r   r   r   r	   r   @   ó    
r   c                   @   r   )ÚRangeKeyzÆ
    An field representing a range key.

    Example::

        >>> from boto.dynamodb2.types import NUMBER
        >>> HashKey('username')
        >>> HashKey('date_joined', data_type=NUMBER)

    ÚRANGENr   r   r   r   r	   r   N   r   r   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚBaseIndexFieldzº
    An abstract class for defining schema indexes.

    Contains most of the core functionality for the index. Subclasses must
    define a ``projection_type`` to pass to DynamoDB.
    c                 C   s   || _ || _d S ©N)r   Úparts)r   r   r"   r   r   r	   r
   c   s   
zBaseIndexField.__init__c                 C   s(   g }| j D ]}| |j|jdœ¡ q|S )zõ
        Returns the attribute definition structure DynamoDB expects.

        Example::

            >>> index.definition()
            {
                'AttributeName': 'username',
                'AttributeType': 'S',
            }

        r   )r"   Úappendr   r   )r   r   Úpartr   r   r	   r   g   s   

þzBaseIndexField.definitionc                 C   s2   g }| j D ]	}| | ¡ ¡ q| j|d| jidœS )aâ  
        Returns the schema structure DynamoDB expects.

        Example::

            >>> index.schema()
            {
                'IndexName': 'LastNameIndex',
                'KeySchema': [
                    {
                        'AttributeName': 'username',
                        'KeyType': 'HASH',
                    },
                ],
                'Projection': {
                    'ProjectionType': 'KEYS_ONLY',
                }
            }

        ÚProjectionType)Ú	IndexNameÚ	KeySchemaÚ
Projection)r"   r#   r   r   Úprojection_type)r   Ú
key_schemar$   r   r   r	   r   ~   s   
ÿýzBaseIndexField.schemaN)r   r   r   r   r
   r   r   r   r   r   r	   r    \   s
    r    c                   @   r   )ÚAllIndexzà
    An index signifying all fields should be in the index.

    Example::

        >>> AllIndex('MostRecentlyJoined', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ])

    ÚALLN©r   r   r   r   r)   r   r   r   r	   r+   ¡   ó    r+   c                   @   r   )ÚKeysOnlyIndexzê
    An index signifying only key fields should be in the index.

    Example::

        >>> KeysOnlyIndex('MostRecentlyJoined', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ])

    Ú	KEYS_ONLYNr-   r   r   r   r	   r/   °   r.   r/   c                       s0   e Zd ZdZdZ‡ fdd„Z‡ fdd„Z‡  ZS )ÚIncludeIndexzû
    An index signifying only certain fields should be in the index.

    Example::

        >>> IncludeIndex('GenderIndex', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ], includes=['gender'])

    ÚINCLUDEc                    s(   |  dg ¡| _tt| ƒj|i |¤Ž d S )NÚincludes)ÚpopÚincludes_fieldsÚsuperr1   r
   )r   ÚargsÚkwargs©Ú	__class__r   r	   r
   Í   s   zIncludeIndex.__init__c                    s    t t| ƒ ¡ }| j|d d< |S )Nr(   ÚNonKeyAttributes)r6   r1   r   r5   ©r   Úschema_datar9   r   r	   r   Ñ   s   zIncludeIndex.schema)r   r   r   r   r)   r
   r   Ú__classcell__r   r   r9   r	   r1   ¿   s
    r1   c                       s6   e Zd ZdZdddœZ‡ fdd„Z‡ fdd„Z‡  ZS )ÚGlobalBaseIndexFieldzº
    An abstract class for defining global indexes.

    Contains most of the core functionality for the index. Subclasses must
    define a ``projection_type`` to pass to DynamoDB.
    é   )ÚreadÚwritec                    s4   |  dd ¡}|d ur|| _tt| ƒj|i |¤Ž d S ©NÚ
throughput)r4   rD   r6   r?   r
   ©r   r7   r8   rD   r9   r   r	   r
   ã   s   zGlobalBaseIndexField.__init__c                    s4   t t| ƒ ¡ }t| jd ƒt| jd ƒdœ|d< |S )ax  
        Returns the schema structure DynamoDB expects.

        Example::

            >>> index.schema()
            {
                'IndexName': 'LastNameIndex',
                'KeySchema': [
                    {
                        'AttributeName': 'username',
                        'KeyType': 'HASH',
                    },
                ],
                'Projection': {
                    'ProjectionType': 'KEYS_ONLY',
                },
                'ProvisionedThroughput': {
                    'ReadCapacityUnits': 5,
                    'WriteCapacityUnits': 5
                }
            }

        rA   rB   )ÚReadCapacityUnitsÚWriteCapacityUnitsÚProvisionedThroughput)r6   r?   r   ÚintrD   r<   r9   r   r	   r   ë   s
   
þzGlobalBaseIndexField.schema)r   r   r   r   rD   r
   r   r>   r   r   r9   r	   r?   ×   s    þr?   c                   @   r   )ÚGlobalAllIndexaE  
    An index signifying all fields should be in the index.

    Example::

        >>> GlobalAllIndex('MostRecentlyJoined', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ],
        ... throughput={
        ...     'read': 2,
        ...     'write': 1,
        ... })

    r,   Nr-   r   r   r   r	   rJ     ó    rJ   c                   @   r   )ÚGlobalKeysOnlyIndexaO  
    An index signifying only key fields should be in the index.

    Example::

        >>> GlobalKeysOnlyIndex('MostRecentlyJoined', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ],
        ... throughput={
        ...     'read': 2,
        ...     'write': 1,
        ... })

    r0   Nr-   r   r   r   r	   rL     rK   rL   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )ÚGlobalIncludeIndexal  
    An index signifying only certain fields should be in the index.

    Example::

        >>> GlobalIncludeIndex('GenderIndex', parts=[
        ...     HashKey('username'),
        ...     RangeKey('date_joined')
        ... ],
        ... includes=['gender'],
        ... throughput={
        ...     'read': 2,
        ...     'write': 1,
        ... })

    r2   c                 O   sL   |  dd ¡}tj| g|¢R i |¤Ž |r||d< tj| g|¢R i |¤Ž d S rC   )r4   r1   r
   r?   rE   r   r   r	   r
   E  s
   zGlobalIncludeIndex.__init__c                 C   s   t  | ¡}| t | ¡¡ |S r!   )r1   r   Úupdater?   r<   r   r   r	   r   L  s   
zGlobalIncludeIndex.schemaN)r   r   r   r   r)   r
   r   r   r   r   r	   rM   2  s
    rM   N)Úboto.dynamodb2.typesr   Úobjectr   r   r   r    r+   r/   r1   r?   rJ   rL   rM   r   r   r   r	   Ú<module>   s    <E5