U
    W+d~                     @   sX   d dl 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
 G dd deZdS )	    N)json)AWSQueryConnection)
RegionInfo)JSONResponseError)
exceptionsc                       s   e Zd ZdZdZdZdZdZdZe	Z
ejejejejejejdZ fdd	Zd
d Zd)ddZdd Zdd Zdd Zdd Zd*ddZd+ddZd,ddZdd Zd-dd Zd.d!d"Zd/d#d$Z d%d& Z!d'd( Z"  Z#S )0Route53DomainsConnectionz

    
    z
2014-05-15z	us-east-1z&route53domains.us-east-1.amazonaws.comZRoute53DomainsZRoute53Domains_v20140515)DuplicateRequestDomainLimitExceededInvalidInputOperationLimitExceededUnsupportedTLDTLDRulesViolationc                    sZ   | dd }|s t| | j| j}d|ks4|d d kr>|j|d< tt| jf | || _d S )Nregionhost)	popr   DefaultRegionNameDefaultRegionEndpointendpointsuperr   __init__r   )selfkwargsr   	__class__ ?/tmp/pip-unpacked-wheel-dlxw5sjy/boto/route53/domains/layer1.pyr   4   s    
z!Route53DomainsConnection.__init__c                 C   s   dgS )Nzhmac-v4r   )r   r   r   r   _required_auth_capability@   s    z2Route53DomainsConnection._required_auth_capabilityNc                 C   s,   d|i}|dk	r||d< | j dt|dS )a  
        This operation checks the availability of one domain name. You
        can access this API without authenticating. Note that if the
        availability status of a domain is pending, you must submit
        another request to determine the availability of the domain
        name.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type idn_lang_code: string
        :param idn_lang_code: Reserved for future use.

        
DomainNameNIdnLangCodeZCheckDomainAvailabilityactionbodymake_requestr   dumps)r   domain_nameidn_lang_codeparamsr   r   r   check_domain_availabilityC   s    z2Route53DomainsConnection.check_domain_availabilityc                 C   s   d|i}| j dt|dS )av  
        This operation removes the transfer lock on the domain
        (specifically the `clientTransferProhibited` status) to allow
        domain transfers. We recommend you refrain from performing
        this action unless you intend to transfer the domain to a
        different registrar. Successful submission returns an
        operation ID that you can use to track the progress and
        completion of the action. If the request is not completed
        successfully, the domain registrant will be notified by email.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        r   ZDisableDomainTransferLockr   r"   r   r%   r'   r   r   r   disable_domain_transfer_locka   s    z5Route53DomainsConnection.disable_domain_transfer_lockc                 C   s   d|i}| j dt|dS )a  
        This operation sets the transfer lock on the domain
        (specifically the `clientTransferProhibited` status) to
        prevent domain transfers. Successful submission returns an
        operation ID that you can use to track the progress and
        completion of the action. If the request is not completed
        successfully, the domain registrant will be notified by email.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        r   ZEnableDomainTransferLockr   r"   r)   r   r   r   enable_domain_transfer_lock}   s    z4Route53DomainsConnection.enable_domain_transfer_lockc                 C   s   d|i}| j dt|dS )a  
        This operation returns detailed information about the domain.
        The domain's contact information is also returned as part of
        the output.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        r   ZGetDomainDetailr   r"   r)   r   r   r   get_domain_detail   s    z*Route53DomainsConnection.get_domain_detailc                 C   s   d|i}| j dt|dS )a  
        This operation returns the current status of an operation that
        is not completed.

        :type operation_id: string
        :param operation_id: The identifier for the operation for which you
            want to get the status. Amazon Route 53 returned the identifier in
            the response to the original request.
        Type: String

        Default: None

        Required: Yes

        ZOperationIdZGetOperationDetailr   r"   )r   Zoperation_idr'   r   r   r   get_operation_detail   s    z-Route53DomainsConnection.get_operation_detailc                 C   s8   i }|dk	r||d< |dk	r$||d< | j dt|dS )a  
        This operation returns all the domain names registered with
        Amazon Route 53 for the current AWS account.

        :type marker: string
        :param marker: For an initial request for a list of domains, omit this
            element. If the number of domains that are associated with the
            current AWS account is greater than the value that you specified
            for `MaxItems`, you can use `Marker` to return additional domains.
            Get the value of `NextPageMarker` from the previous response, and
            submit another request that includes the value of `NextPageMarker`
            in the `Marker` element.
        Type: String

        Default: None

        Constraints: The marker must match the value specified in the previous
            request.

        Required: No

        :type max_items: integer
        :param max_items: Number of domains to be returned.
        Type: Integer

        Default: 20

        Constraints: A numeral between 1 and 100.

        Required: No

        NMarkerMaxItemsZListDomainsr   r"   r   markerZ	max_itemsr'   r   r   r   list_domains   s    !z%Route53DomainsConnection.list_domainsc                 C   s8   i }|dk	r||d< |dk	r$||d< | j dt|dS )a  
        This operation returns the operation IDs of operations that
        are not yet complete.

        :type marker: string
        :param marker: For an initial request for a list of operations, omit
            this element. If the number of operations that are not yet complete
            is greater than the value that you specified for `MaxItems`, you
            can use `Marker` to return additional operations. Get the value of
            `NextPageMarker` from the previous response, and submit another
            request that includes the value of `NextPageMarker` in the `Marker`
            element.
        Type: String

        Default: None

        Required: No

        :type max_items: integer
        :param max_items: Number of domains to be returned.
        Type: Integer

        Default: 20

        Constraints: A value between 1 and 100.

        Required: No

        Nr.   r/   ZListOperationsr   r"   r0   r   r   r   list_operations   s    z(Route53DomainsConnection.list_operationsc                 C   st   |||||d}|dk	r ||d< |dk	r0||d< |dk	r@||d< |	dk	rP|	|d< |
dk	r`|
|d< | j dt|d	S )
an  
        This operation registers a domain. Domains are registered by
        the AWS registrar partner, Gandi. For some top-level domains
        (TLDs), this operation requires extra parameters.

        When you register a domain, Amazon Route 53 does the
        following:


        + Creates a Amazon Route 53 hosted zone that has the same name
          as the domain. Amazon Route 53 assigns four name servers to
          your hosted zone and automatically updates your domain
          registration with the names of these name servers.
        + Enables autorenew, so your domain registration will renew
          automatically each year. We'll notify you in advance of the
          renewal date so you can choose whether to renew the
          registration.
        + Optionally enables privacy protection, so WHOIS queries
          return contact information for our registrar partner, Gandi,
          instead of the information you entered for registrant, admin,
          and tech contacts.
        + If registration is successful, returns an operation ID that
          you can use to track the progress and completion of the
          action. If the request is not completed successfully, the
          domain registrant is notified by email.
        + Charges your AWS account an amount based on the top-level
          domain. For more information, see `Amazon Route 53 Pricing`_.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type idn_lang_code: string
        :param idn_lang_code: Reserved for future use.

        :type duration_in_years: integer
        :param duration_in_years: The number of years the domain will be
            registered. Domains are registered for a minimum of one year. The
            maximum period depends on the top-level domain.
        Type: Integer

        Default: 1

        Valid values: Integer from 1 to 10

        Required: Yes

        :type auto_renew: boolean
        :param auto_renew: Indicates whether the domain will be automatically
            renewed ( `True`) or not ( `False`). Autorenewal only takes effect
            after the account is charged.
        Type: Boolean

        Valid values: `True` | `False`

        Default: `True`

        Required: No

        :type admin_contact: dict
        :param admin_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type registrant_contact: dict
        :param registrant_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type tech_contact: dict
        :param tech_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type privacy_protect_admin_contact: boolean
        :param privacy_protect_admin_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        :type privacy_protect_registrant_contact: boolean
        :param privacy_protect_registrant_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        :type privacy_protect_tech_contact: boolean
        :param privacy_protect_tech_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        )r   DurationInYearsAdminContactRegistrantContactTechContactNr   	AutoRenewPrivacyProtectAdminContactPrivacyProtectRegistrantContactPrivacyProtectTechContactZRegisterDomainr   r"   )r   r%   duration_in_yearsadmin_contactregistrant_contacttech_contactr&   
auto_renewprivacy_protect_admin_contact"privacy_protect_registrant_contactprivacy_protect_tech_contactr'   r   r   r   register_domain  s(     z(Route53DomainsConnection.register_domainc                 C   s   d|i}| j dt|dS )a	  
        This operation returns the AuthCode for the domain. To
        transfer a domain to another registrar, you provide this value
        to the new registrar.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        r   ZRetrieveDomainAuthCoder   r"   r)   r   r   r   retrieve_domain_auth_code  s    z2Route53DomainsConnection.retrieve_domain_auth_codec                 C   s   ||||||d}|dk	r"||d< |dk	r2||d< |	dk	rB|	|d< |
dk	rR|
|d< |dk	rb||d< |dk	rr||d< | j d	t|d
S )a  
        This operation transfers a domain from another registrar to
        Amazon Route 53. Domains are registered by the AWS registrar,
        Gandi upon transfer.

        To transfer a domain, you need to meet all the domain transfer
        criteria, including the following:


        + You must supply nameservers to transfer a domain.
        + You must disable the domain transfer lock (if any) before
          transferring the domain.
        + A minimum of 60 days must have elapsed since the domain's
          registration or last transfer.


        We recommend you use the Amazon Route 53 as the DNS service
        for your domain. You can create a hosted zone in Amazon Route
        53 for your current domain before transferring your domain.

        Note that upon transfer, the domain duration is extended for a
        year if not otherwise specified. Autorenew is enabled by
        default.

        If the transfer is successful, this method returns an
        operation ID that you can use to track the progress and
        completion of the action. If the request is not completed
        successfully, the domain registrant will be notified by email.

        Transferring domains charges your AWS account an amount based
        on the top-level domain. For more information, see `Amazon
        Route 53 Pricing`_.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type idn_lang_code: string
        :param idn_lang_code: Reserved for future use.

        :type duration_in_years: integer
        :param duration_in_years: The number of years the domain will be
            registered. Domains are registered for a minimum of one year. The
            maximum period depends on the top-level domain.
        Type: Integer

        Default: 1

        Valid values: Integer from 1 to 10

        Required: Yes

        :type nameservers: list
        :param nameservers: Contains details for the host and glue IP
            addresses.
        Type: Complex

        Children: `GlueIps`, `Name`

        :type auth_code: string
        :param auth_code: The authorization code for the domain. You get this
            value from the current registrar.
        Type: String

        Required: Yes

        :type auto_renew: boolean
        :param auto_renew: Indicates whether the domain will be automatically
            renewed (true) or not (false). Autorenewal only takes effect after
            the account is charged.
        Type: Boolean

        Valid values: `True` | `False`

        Default: true

        Required: No

        :type admin_contact: dict
        :param admin_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type registrant_contact: dict
        :param registrant_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type tech_contact: dict
        :param tech_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type privacy_protect_admin_contact: boolean
        :param privacy_protect_admin_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        :type privacy_protect_registrant_contact: boolean
        :param privacy_protect_registrant_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        :type privacy_protect_tech_contact: boolean
        :param privacy_protect_tech_contact: Whether you want to conceal
            contact information from WHOIS queries. If you specify true, WHOIS
            ("who is") queries will return contact information for our
            registrar partner, Gandi, instead of the contact information that
            you enter.
        Type: Boolean

        Default: `True`

        Valid values: `True` | `False`

        Required: No

        )r   r4   Nameserversr5   r6   r7   Nr   ZAuthCoder8   r9   r:   r;   ZTransferDomainr   r"   )r   r%   r<   nameserversr=   r>   r?   r&   Z	auth_coder@   rA   rB   rC   r'   r   r   r   transfer_domain  s.     *z(Route53DomainsConnection.transfer_domainc                 C   sL   d|i}|dk	r||d< |dk	r(||d< |dk	r8||d< | j dt|dS )a  
        This operation updates the contact information for a
        particular domain. Information for at least one contact
        (registrant, administrator, or technical) must be supplied for
        update.

        If the update is successful, this method returns an operation
        ID that you can use to track the progress and completion of
        the action. If the request is not completed successfully, the
        domain registrant will be notified by email.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type admin_contact: dict
        :param admin_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type registrant_contact: dict
        :param registrant_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        :type tech_contact: dict
        :param tech_contact: Provides detailed contact information.
        Type: Complex

        Children: `FirstName`, `MiddleName`, `LastName`, `ContactType`,
            `OrganizationName`, `AddressLine1`, `AddressLine2`, `City`,
            `State`, `CountryCode`, `ZipCode`, `PhoneNumber`, `Email`, `Fax`,
            `ExtraParams`

        Required: Yes

        r   Nr5   r6   r7   ZUpdateDomainContactr   r"   )r   r%   r=   r>   r?   r'   r   r   r   update_domain_contact  s    ;z.Route53DomainsConnection.update_domain_contactc                 C   sL   d|i}|dk	r||d< |dk	r(||d< |dk	r8||d< | j dt|dS )a	  
        This operation updates the specified domain contact's privacy
        setting. When the privacy option is enabled, personal
        information such as postal or email address is hidden from the
        results of a public WHOIS query. The privacy services are
        provided by the AWS registrar, Gandi. For more information,
        see the `Gandi privacy features`_.

        This operation only affects the privacy of the specified
        contact type (registrant, administrator, or tech). Successful
        acceptance returns an operation ID that you can use with
        GetOperationDetail to track the progress and completion of the
        action. If the request is not completed successfully, the
        domain registrant will be notified by email.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type admin_privacy: boolean
        :param admin_privacy: Whether you want to conceal contact information
            from WHOIS queries. If you specify true, WHOIS ("who is") queries
            will return contact information for our registrar partner, Gandi,
            instead of the contact information that you enter.
        Type: Boolean

        Default: None

        Valid values: `True` | `False`

        Required: No

        :type registrant_privacy: boolean
        :param registrant_privacy: Whether you want to conceal contact
            information from WHOIS queries. If you specify true, WHOIS ("who
            is") queries will return contact information for our registrar
            partner, Gandi, instead of the contact information that you enter.
        Type: Boolean

        Default: None

        Valid values: `True` | `False`

        Required: No

        :type tech_privacy: boolean
        :param tech_privacy: Whether you want to conceal contact information
            from WHOIS queries. If you specify true, WHOIS ("who is") queries
            will return contact information for our registrar partner, Gandi,
            instead of the contact information that you enter.
        Type: Boolean

        Default: None

        Valid values: `True` | `False`

        Required: No

        r   NZAdminPrivacyZRegistrantPrivacyZTechPrivacyZUpdateDomainContactPrivacyr   r"   )r   r%   Zadmin_privacyZregistrant_privacyZtech_privacyr'   r   r   r   update_domain_contact_privacy  s    Fz6Route53DomainsConnection.update_domain_contact_privacyc                 C   s   ||d}| j dt|dS )a9  
        This operation replaces the current set of name servers for
        the domain with the specified set of name servers. If you use
        Amazon Route 53 as your DNS service, specify the four name
        servers in the delegation set for the hosted zone for the
        domain.

        If successful, this operation returns an operation ID that you
        can use to track the progress and completion of the action. If
        the request is not completed successfully, the domain
        registrant will be notified by email.

        :type domain_name: string
        :param domain_name: The name of a domain.
        Type: String

        Default: None

        Constraints: The domain name can contain only the letters a through z,
            the numbers 0 through 9, and hyphen (-). Internationalized Domain
            Names are not supported.

        Required: Yes

        :type nameservers: list
        :param nameservers: A list of new name servers for the domain.
        Type: Complex

        Children: `Name`, `GlueIps`

        Required: Yes

        )r   rF   ZUpdateDomainNameserversr   r"   )r   r%   rG   r'   r   r   r   update_domain_nameservers$  s    #z2Route53DomainsConnection.update_domain_nameserversc           
      C   s   d| j |f | jjdtt|d}| jdddi ||d}| j|d dd}| d	}t	j
| |jd
kr~|rt|S n8t|}|dd }| j|| j}	|	|j|j|dd S )Nz%s.%szapplication/x-amz-json-1.1)zX-Amz-TargetHostzContent-TypezContent-LengthPOST/)methodpathZ	auth_pathr'   headersdata
   )ZsenderZoverride_num_retrieszutf-8   Z__type)r!   )TargetPrefixr   r   strlenZbuild_base_http_requestZ_mexereaddecodebotologdebugstatusr   loadsget_faultsResponseErrorreason)
r   r    r!   rQ   http_requestresponseZresponse_bodyZ	json_bodyZ
fault_nameZexception_classr   r   r   r#   M  s6    
    


z%Route53DomainsConnection.make_request)N)NN)NN)NNNNN)NNNNNN)NNN)NNN)$__name__
__module____qualname____doc__Z
APIVersionr   r   ZServiceNamerU   r   ra   r   r   r	   r
   r   r   r   r`   r   r   r(   r*   r+   r,   r-   r2   r3   rD   rE   rH   rI   rJ   rK   r#   __classcell__r   r   r   r   r      sb   


)
'      
 )        
 @    
E   
P)r   )rZ   Zboto.compatr   Zboto.connectionr   Zboto.regioninfor   Zboto.exceptionr   Zboto.route53.domainsr   r   r   r   r   r   <module>   s   