U
    3ìd¹  ã                   @   sp   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dS )é    )Újsonc                   @   sD   e Zd ZdZddd„Zdd„ Zdd„ Zdd	d
„Zdd„ Zdd„ Z	dS )ÚOptionStatusa8  
    Presents a combination of status field (defined below) which are
    accessed as attributes and option values which are stored in the
    native Python dictionary.  In this class, the option values are
    merged from a JSON object that is stored as the Option part of
    the object.

    :ivar domain_name: The name of the domain this option is associated with.
    :ivar create_date: A timestamp for when this option was created.
    :ivar state: The state of processing a change to an option.
        Possible values:

        * RequiresIndexDocuments: the option's latest value will not
          be visible in searches until IndexDocuments has been called
          and indexing is complete.
        * Processing: the option's latest value is not yet visible in
          all searches but is in the process of being activated.
        * Active: the option's latest value is completely visible.

    :ivar update_date: A timestamp for when this option was updated.
    :ivar update_version: A unique integer that indicates when this
        option was last updated.
    Nc                 C   s&   || _ || _|| _|| _|  |¡ d S ©N)ÚdomainÚ
refresh_fnÚrefresh_keyÚsave_fnÚrefresh)Úselfr   Údatar   r   r   © r   úB/tmp/pip-unpacked-wheel-d7dsrkjd/boto/cloudsearch2/optionstatus.pyÚ__init__5   s
    zOptionStatus.__init__c                 C   s0   |d | _ |d | _|d | _t|d ƒ| _d S )NZCreationDateÚStateZ
UpdateDateZUpdateVersion)Zcreation_dateÚstatusZupdate_dateÚintZupdate_version)r
   r   r   r   r   Ú_update_status=   s    


zOptionStatus._update_statusc                 C   s   |r|   |¡ d S r   )Úupdate)r
   Úoptionsr   r   r   Ú_update_optionsC   s    zOptionStatus._update_optionsc                 C   sZ   |s6| j r6|   | jj¡}|r6| jr6| jD ]}|| }q(|rV|  |d ¡ |  |d ¡ dS )zÞ
        Refresh the local state of the object.  You can either pass
        new state data in as the parameter ``data`` or, if that parameter
        is omitted, the state data will be retrieved from CloudSearch.
        ZStatusÚOptionsN)r   r   Únamer   r   r   )r
   r   Úkeyr   r   r   r	   G   s    


zOptionStatus.refreshc                 C   s
   t  | ¡S )zL
        Return the JSON representation of the options as a string.
        )r   Údumps©r
   r   r   r   Úto_jsonY   s    zOptionStatus.to_jsonc                 C   s(   | j r$|   | jj|  ¡ ¡}|  |¡ dS )zf
        Write the current state of the local object back to the
        CloudSearch service.
        N)r   r   r   r   r	   )r
   r   r   r   r   Úsave_   s    zOptionStatus.save)NNNN)N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r	   r   r   r   r   r   r   r      s     ÿ

r   c                   @   s   e Zd Zdd„ ZdS )ÚIndexFieldStatusc                 C   s   d S r   r   r   r   r   r   r   j   s    zIndexFieldStatus.saveN©r   r   r   r   r   r   r   r   r!   i   s   r!   c                   @   s   e Zd Zdd„ ZdS )ÚAvailabilityOptionsStatusc                 C   s   d S r   r   r   r   r   r   r   o   s    zAvailabilityOptionsStatus.saveNr"   r   r   r   r   r#   n   s   r#   c                   @   s   e Zd ZdS )ÚScalingParametersStatusN©r   r   r   r   r   r   r   r$   s   s   r$   c                   @   s   e Zd ZdS )ÚExpressionStatusNr%   r   r   r   r   r&   w   s   r&   c                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚServicePoliciesStatusc                 C   s   dd|dd|giidœS )aì  
        Returns a new policy statement that will allow
        access to the service described by ``arn`` by the
        ip specified in ``ip``.

        :type arn: string
        :param arn: The Amazon Resource Notation identifier for the
            service you wish to provide access to.  This would be
            either the search service or the document service.

        :type ip: string
        :param ip: An IP address or CIDR block you wish to grant access
            to.
        ZAllowÚ*Ú	IpAddressúaws:SourceIp)ZEffectÚActionÚResourceÚ	Conditionr   )r
   ÚarnÚipr   r   r   Únew_statement}   s     ÿÿüz#ServicePoliciesStatus.new_statementc                 C   s°   d| kr(|   ||¡}|g| d< |  ¡  n„d}| d D ]P}|d |kr4|d D ]6}|dkrLd}|d | }||d krL|d  |¡ qLq4|r¤|   ||¡}| d  |¡ |  ¡  d S )NÚ	StatementTr,   r-   r)   Fr*   )r0   r   Úappend)r
   r.   r/   ÚsZadd_statementÚ	statementÚcondition_nameÚ	conditionr   r   r   Ú	_allow_ip—   s"    

zServicePoliciesStatus._allow_ipc                 C   s   | j j}|  ||¡ dS )zî
        Add the provided ip address or CIDR block to the list of
        allowable address for the search service.

        :type ip: string
        :param ip: An IP address or CIDR block you wish to grant access
            to.
        N©r   Úservice_arnr7   ©r
   r/   r.   r   r   r   Úallow_search_ip¬   s    	z%ServicePoliciesStatus.allow_search_ipc                 C   s   | j j}|  ||¡ dS )zð
        Add the provided ip address or CIDR block to the list of
        allowable address for the document service.

        :type ip: string
        :param ip: An IP address or CIDR block you wish to grant access
            to.
        Nr8   r:   r   r   r   Úallow_doc_ip¸   s    	z"ServicePoliciesStatus.allow_doc_ipc                 C   sz   d| krd S d}| d D ]P}|d |kr|d D ]6}|dkr0|d | }||d kr0|d   |¡ d}q0q|rv|  ¡  d S )Nr1   Fr,   r-   r)   r*   T)Úremover   )r
   r.   r/   Zneed_updater4   r5   r6   r   r   r   Ú_disallow_ipÄ   s    z"ServicePoliciesStatus._disallow_ipc                 C   s   | j j}|  ||¡ dS )zó
        Remove the provided ip address or CIDR block from the list of
        allowable address for the search service.

        :type ip: string
        :param ip: An IP address or CIDR block you wish to grant access
            to.
        N©r   r9   r>   r:   r   r   r   Údisallow_search_ipÓ   s    	z(ServicePoliciesStatus.disallow_search_ipc                 C   s   | j j}|  ||¡ dS )zõ
        Remove the provided ip address or CIDR block from the list of
        allowable address for the document service.

        :type ip: string
        :param ip: An IP address or CIDR block you wish to grant access
            to.
        Nr?   r:   r   r   r   Údisallow_doc_ipß   s    	z%ServicePoliciesStatus.disallow_doc_ipN)
r   r   r   r0   r7   r;   r<   r>   r@   rA   r   r   r   r   r'   {   s   r'   N)	Zboto.compatr   Údictr   r!   r#   r$   r&   r'   r   r   r   r   Ú<module>   s   M