ó
č?F[c           @   s	  d  d l  m Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ	 d e f d     YZ
 d e
 f d     YZ d e
 f d     YZ d e
 e	 f d     YZ d S(   i˙˙˙˙(   t   STRINGt   BaseSchemaFieldc           B   s2   e  Z d  Z d Z e d  Z d   Z d   Z RS(   s´   
    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.
    c         C   s   | |  _  | |  _ d S(   sN  
        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(   t   namet	   data_type(   t   selfR   R   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyt   __init__   s    	c         C   s   i |  j  d 6|  j d 6S(   ső   
        Returns the attribute definition structure DynamoDB expects.

        Example::

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

        t   AttributeNamet   AttributeType(   R   R   (   R   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyt
   definition   s    
c         C   s   i |  j  d 6|  j d 6S(   sŕ   
        Returns the schema structure DynamoDB expects.

        Example::

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

        R   t   KeyType(   R   t	   attr_type(   R   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyt   schema-   s    
N(	   t   __name__t
   __module__t   __doc__t   NoneR
   R    R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR      s
   	t   HashKeyc           B   s   e  Z d  Z d Z RS(   sĹ   
    An field representing a hash key.

    Example::

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

    t   HASH(   R   R   R   R
   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   @   s   
t   RangeKeyc           B   s   e  Z d  Z d Z RS(   sĆ   
    An field representing a range key.

    Example::

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

    t   RANGE(   R   R   R   R
   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   N   s   
t   BaseIndexFieldc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sş   
    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   t   parts(   R   R   R   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   c   s    	c         C   s?   g  } x2 |  j  D]' } | j i | j d 6| j d 6 q W| S(   ső   
        Returns the attribute definition structure DynamoDB expects.

        Example::

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

        R   R   (   R   t   appendR   R   (   R   R   t   part(    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   g   s    	
c         C   sS   g  } x$ |  j  D] } | j | j    q Wi |  j d 6| d 6i |  j d 6d 6S(   sâ  
        Returns the schema structure DynamoDB expects.

        Example::

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

        t	   IndexNamet	   KeySchemat   ProjectionTypet
   Projection(   R   R   R   R   t   projection_type(   R   t
   key_schemaR   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   ~   s    
(   R   R   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   \   s   		t   AllIndexc           B   s   e  Z d  Z d Z RS(   sŕ   
    An index signifying all fields should be in the index.

    Example::

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

    t   ALL(   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   Ą   s   t   KeysOnlyIndexc           B   s   e  Z d  Z d Z RS(   sę   
    An index signifying only key fields should be in the index.

    Example::

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

    t	   KEYS_ONLY(   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR    °   s   t   IncludeIndexc           B   s&   e  Z d  Z d Z d   Z d   Z RS(   sű   
    An index signifying only certain fields should be in the index.

    Example::

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

    t   INCLUDEc         O   s2   | j  d g   |  _ t t |   j | |   d  S(   Nt   includes(   t   popt   includes_fieldst   superR"   R   (   R   t   argst   kwargs(    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   Í   s    c         C   s*   t  t |   j   } |  j | d d <| S(   NR   t   NonKeyAttributes(   R'   R"   R   R&   (   R   t   schema_data(    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   Ń   s    (   R   R   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR"   ż   s   	t   GlobalBaseIndexFieldc           B   s4   e  Z d  Z i d d 6d d 6Z d   Z d   Z RS(   sş   
    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.
    i   t   readt   writec         O   sG   | j  d d   } | d  k	 r* | |  _ n  t t |   j | |   d  S(   Nt
   throughput(   R%   R   R/   R'   R,   R   (   R   R(   R)   R/   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   ă   s    c         C   sK   t  t |   j   } i t |  j d  d 6t |  j d  d 6| d <| S(   sx  
        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
                }
            }

        R-   t   ReadCapacityUnitsR.   t   WriteCapacityUnitst   ProvisionedThroughput(   R'   R,   R   t   intR/   (   R   R+   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   ë   s
    (   R   R   R   R/   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR,   ×   s   
	t   GlobalAllIndexc           B   s   e  Z d  Z d Z RS(   sE  
    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   (   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR4     s   t   GlobalKeysOnlyIndexc           B   s   e  Z d  Z d Z RS(   sO  
    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,
        ... })

    R!   (   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR5     s   t   GlobalIncludeIndexc           B   s&   e  Z d  Z d Z d   Z d   Z RS(   sl  
    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,
        ... })

    R#   c         O   sO   | j  d d   } t j |  | |  | r8 | | d <n  t j |  | |  d  S(   NR/   (   R%   R   R"   R   R,   (   R   R(   R)   R/   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   E  s
    c         C   s)   t  j |   } | j t j |    | S(   N(   R"   R   t   updateR,   (   R   R+   (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR   L  s    (   R   R   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyR6   2  s   	N(   t   boto.dynamodb2.typesR    t   objectR   R   R   R   R   R    R"   R,   R4   R5   R6   (    (    (    s4   lib/python2.7/site-packages/boto/dynamodb2/fields.pyt   <module>   s   <E5