
    N                         d 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 ddl	m
Z
 ddlmZ dd	lmZ d
ZdZdZd Zd ZddZ G d de      Zy)z3API client library for Cloud Domains Registrations.    )absolute_import)division)unicode_literals)
list_pager)apis)base)
exceptions)logv1alpha2v1beta1v1c                 2   | j                   j                         }|t        j                  j                  k(  rt        S |t        j                  j
                  k(  rt        S |t        j                  j                  k(  rt        S t        j                  |      )z!Return API version based on args.)calliope_commandReleaseTrackr   ALPHAALPHA_API_VERSIONBETABETA_API_VERSIONGAGA_API_VERSIONr	   UnsupportedReleaseTrackError)argsrelease_tracks     3lib/googlecloudsdk/api_lib/domains/registrations.pyGetApiVersionFromArgsr       su    ''446-d''---d'',,,d''***//>>    c                 .    t        j                  d|       S )Ndomains)r   GetClientInstance)api_versions    r   r   r   ,   s    				;	77r   Nc                 8    |xs t        |       }|j                  S N)r   MESSAGES_MODULE)r    clients     r   GetMessagesModuler%   0   s    3&{3&			r   c                       e Zd ZdZddZd Z	 	 	 	 ddZ	 	 	 ddZd Zd Z	dd	Z
d
 Zd Zd Zd Zd Z	 ddZddZd dZd Zd Zd Zd Zd Zd Zd Zd Zd Zy)!RegistrationsClientz:Client for registrations service in the Cloud Domains API.Nc                     |xs t        |      | _        |xs t        ||      | _        | j                  j                  | _        y r"   )r   r$   r%   messages projects_locations_registrations_service)selfr    r$   r)   s       r   __init__zRegistrationsClient.__init__8   s9    :-k:DKF 1+v FDMKK@@DMr   c                 F    d}t         j                  j                  |       y)zGPrints FYI acknowledgement about the Google Domains - Squarespace deal.a  Domain name registration services are provided by Squarespace (https://domains.squarespace.com),
pursuant to the Squarespace Terms of Service (https://www.squarespace.com/terms-of-service)
and Squarespace Domain Registration Agreement (https://www.squarespace.com/domain-registration-agreement),
which Google resells pursuant to an agreement with Squarespace.
Google shares your name, contact information, and other domain-related information with Squarespace.
You can review Squarespace's Privacy Policy (https://www.squarespace.com/privacy) for details on how they process your information.
Google's Privacy Policy (https://policies.google.com/privacy) describes how Google handles this information as a reseller.
By choosing to continue, you (1) acknowledge receipt of Google's Privacy Policy and direct us to share this information
with Squarespace; and (2) agree to the Squarespace Terms of Service (https://www.squarespace.com/terms-of-service) and
Squarespace Domain Registration Agreement (https://www.squarespace.com/domain-registration-agreement), and
acknowledge receipt of Squarespace's Privacy Policy (https://www.squarespace.com/privacy).
N)r
   statusPrint)r,   ack_messages     r   PrintSQSPAckz RegistrationsClient.PrintSQSPAck=   s     	3 2 JJ[!r   c
                    g }
|r+| j                   j                  j                  j                  g}
g }|r+| j                   j                  j                  j
                  g}| j                   j                  |j                         | j                   j                  | j                   j                  ||||      |
|||	            }| j                  j                  |      S )a?  Creates a Registration.

    Args:
      parent_ref: a Resource reference to a domains.projects.locations resource
        for the parent of this registration.
      domain: str, the name of the domain to register. Used as resource name.
      dns_settings: DnsSettings to be used.
      contact_settings: ContactSettings to be used.
      yearly_price: price for the domain registration and its cost for the
        following years.
      labels: Unified GCP Labels for the resource.
      hsts_notice_accepted: bool, Whether HSTS notice was presented & accepted.
      public_privacy_accepted: bool, Whether public privacy notice was presented
        & accepted.
      validate_only: If set to true, performs only validation, without creating.

    Returns:
      Operation: the long running operation to register a domain.
    
domainNamednsSettingscontactSettingslabels)registrationdomainNoticescontactNoticesyearlyPricevalidateOnly)parentregisterDomainRequest)r)   RegisterDomainRequest%DomainNoticesValueListEntryValuesEnumHSTS_PRELOADED&ContactNoticesValueListEntryValuesEnum#PUBLIC_CONTACT_DATA_ACKNOWLEDGEMENT4DomainsProjectsLocationsRegistrationsRegisterRequestRelativeNameRegistrationr+   Register)r,   
parent_refdomaindns_settingscontact_settingsyearly_pricer8   hsts_notice_acceptedpublic_privacy_acceptedvalidate_onlydomain_noticescontact_noticesreqs                r   rH   zRegistrationsClient.RegisterZ   s    > N
--
-
-
S
S
b
bn O
--
-
-
T
T
x
xo --
L
L&&("mmAA33!( 0	 4  )*$& B 
 M C  ==!!#&&r   c
           
         g }
|r+| j                   j                  j                  j                  g}
| j                   j	                  ||||      }| j                   j                  |j                         | j                   j                  ||
| j                   j                  |      ||	            }| j                  j                  |      S )ab  Transfers a domain and creates a new Registration.

    Args:
      parent_ref: a Resource reference to a domains.projects.locations resource
        for the parent of this registration.
      domain: str, the name of the domain to transfer. Used as resource name.
      dns_settings: DnsSettings to be used.
      contact_settings: ContactSettings to be used.
      authorization_code: The authorization code needed to transfer the domain.
      yearly_price: price for the domain transfer and its cost for the following
        years.
      labels: Unified GCP Labels for the resource.
      public_privacy_accepted: bool, Whether public privacy notice was presented
        & accepted.
      validate_only: If set to true, performs only validation, without
        transferring.

    Returns:
      Operation: the long running operation to transfer a domain.
    r4   )code)r9   r;   authorizationCoder<   r=   )r>   transferDomainRequest)
r)   TransferDomainRequestrC   rD   rG   4DomainsProjectsLocationsRegistrationsTransferRequestrF   AuthorizationCoder+   Transfer)r,   rI   rJ   rK   rL   authorization_coderM   r8   rO   rP   rR   r9   rS   s                r   r[   zRegistrationsClient.Transfer   s    @ O
--
-
-
T
T
x
xo ==-- (	 . L --
L
L&&("mmAA%*"mm==' >  %& B 
 M C ==!!#&&r   c                     | j                   j                  |j                         | j                   j                  ||            }| j                  j                  |      S )a  Imports a domain and creates a new Registration.

    Args:
      parent_ref: a Resource reference to a domains.projects.locations resource
        for the parent of this registration.
      domain: str, the name of the domain to import. Used as resource name.
      labels: Unified GCP Labels for the resource.

    Returns:
      Operation: the long running operation to import a domain.
    )r5   r8   )r>   importDomainRequest)r)   2DomainsProjectsLocationsRegistrationsImportRequestrF   ImportDomainRequestr+   Import)r,   rI   rJ   r8   rS   s        r   ra   zRegistrationsClient.Import   s]     --
J
J&&( MM==f > 
 K C ==$$r   c                     | j                   j                  |j                               }| j                  j	                  |      S N)name)r)   2DomainsProjectsLocationsRegistrationsExportRequestrF   r+   Exportr,   registration_refrS   s      r   rf   zRegistrationsClient.Export   ?    
--
J
J**, K C ==$$r   c                     | j                   j                  |j                         | j                   j                  ||            }| j                  j                  |      S )N)r<   r=   )r9   renewDomainRequest)r)   7DomainsProjectsLocationsRegistrationsRenewDomainRequestrF   RenewDomainRequestr+   RenewDomain)r,   rh   rM   rP   rS   s        r   RenewzRegistrationsClient.Renew   s[    
--
O
O%224==;;$= < 
 P C ==$$S))r   c                     | j                   j                  |j                               }| j                  j	                  |      S rc   )r)   2DomainsProjectsLocationsRegistrationsDeleteRequestrF   r+   Deleterg   s      r   rr   zRegistrationsClient.Delete   ri   r   c                     | j                   j                  |j                               }| j                  j	                  |      S rc   )r)   /DomainsProjectsLocationsRegistrationsGetRequestrF   r+   Get)r,   rh   get_reqs      r   ru   zRegistrationsClient.Get   s?    mmKK**, L G ==W%%r   c                     | j                   j                  |j                               }| j                  j	                  |      S N)r9   )r)   EDomainsProjectsLocationsRegistrationsRetrieveAuthorizationCodeRequestrF   r+   RetrieveAuthorizationCoderg   s      r   rz   z-RegistrationsClient.RetrieveAuthorizationCode   s?    
--
]
]%224 ^ C ==22377r   c                     | j                   j                  |j                               }| j                  j	                  |      S rx   )r)   BDomainsProjectsLocationsRegistrationsResetAuthorizationCodeRequestrF   r+   ResetAuthorizationCoderg   s      r   r}   z*RegistrationsClient.ResetAuthorizationCode  s?    
--
Z
Z%224 [ C ==//44r   c                     | j                   j                  |j                         | j                   j                  |            }| j                  j                  |      S )N)tag)r9   initiatePushTransferRequest)r)   @DomainsProjectsLocationsRegistrationsInitiatePushTransferRequestrF   InitiatePushTransferRequestr+   InitiatePushTransfer)r,   rh   r   rS   s       r   r   z(RegistrationsClient.InitiatePushTransfer  sZ    
--
X
X%224$(MM$M$M %N %
 Y C ==--c22r   c           	          | j                   j                  |j                         |      }t        j                  | j
                  |dd||d      S )N)locationpageSizeRetrieveImportableDomainsr   r   )methodfieldlimit
batch_sizebatch_size_attribute)r)   EDomainsProjectsLocationsRegistrationsRetrieveImportableDomainsRequestrF   r   YieldFromListr+   )r,   rI   r   	page_sizer   requests         r   r   z-RegistrationsClient.RetrieveImportableDomains  sZ     mmaa((*Y b G ##*' r   c                     | j                   j                  |j                         |      }t        j                  | j
                  |||dd      S )a  List the domain registrations in a given project.

    Args:
      parent_ref: a Resource reference to a domains.projects.locations resource
        to list registrations for.
      limit: int, the total number of results to return from the API.
      page_size: int, the number of results in each batch from the API.
      list_filter: str, filter to apply in the list request.

    Returns:
      A generator of the domain registrations in the project.
    )r>   filterregistrationsr   )r   r   r   r   )r)   0DomainsProjectsLocationsRegistrationsListRequestrF   r   r   r+   )r,   rI   r   r   list_filterlist_reqs         r   ListzRegistrationsClient.List(  sW     }}MM&&( N H ##' r   c                     | j                   j                         }||_        d}| j                   j                  ||j	                         |      }| j
                  j                  |      S )a7  Updates a Registration.

    Used for updating labels.

    Args:
      registration_ref: a Resource reference to a
        domains.projects.locations.registrations resource.
      labels: Unified GCP Labels for the resource.

    Returns:
      Operation: the long running operation to patch registration.
    r8   )r9   rd   
updateMask)r)   rG   r8   1DomainsProjectsLocationsRegistrationsPatchRequestrF   r+   Patch)r,   rh   r8   r9   update_mask	patch_reqs         r   r   zRegistrationsClient.PatchA  sf     ==--/L LKOO!**, P I ==y))r   c                 D   | j                   j                  ||      }g }|r|dgz  }|r|dgz  }dj                  |      }| j                   j                  |j	                         | j                   j                  ||            }| j                  j                  |      S )am  Updates management settings.

    Args:
      registration_ref: a Resource reference to a
        domains.projects.locations.registrations resource.
      transfer_lock: The transfer lock state.
      preferred_renewal_method: The preferred Renewal Method.

    Returns:
      Operation: the long running operation to configure management
        registration.
    )transferLockStatepreferredRenewalMethodtransfer_lock_statepreferred_renewal_method,)managementSettingsr   )r9   "configureManagementSettingsRequest)r)   ManagementSettingsjoinGDomainsProjectsLocationsRegistrationsConfigureManagementSettingsRequestrF   "ConfigureManagementSettingsRequestr+   ConfigureManagementSettings)r,   rh   transfer_lockr   management_settingsupdated_listr   rS   s           r   ConfigureManagementz'RegistrationsClient.ConfigureManagementZ  s     --::'7 ; 
 L,--l122l((<(K
--
_
_%224+/==+[+[2{ ,\ ,
 ` C ==44S99r   c                    g }|j                   r|dgz  }|j                  r|j                  r|dgz  }n|dgz  }|j                  r|j                  r|dgz  }n|dgz  }dj	                  |      }| j
                  j                  |j                         | j
                  j                  |||            }| j                  j                  |      S )	a:  Calls ConfigureDNSSettings method.

    Args:
      registration_ref: Registration resource reference.
      dns_settings: New DNS Settings.
      updated: dns_util.DnsUpdateMask object representing an update mask.
      validate_only: validate_only flag.

    Returns:
      Long Running Operation reference.
    glue_recordsgoogle_domains_dnszgoogle_domains_dns.ds_state
custom_dnszcustom_dns.ds_recordsr   )r6   r   r=   )r9   configureDnsSettingsRequest)r   google_domains_dnssecname_serverscustom_dnssecr   r)   @DomainsProjectsLocationsRegistrationsConfigureDnsSettingsRequestrF   ConfigureDnsSettingsRequestr+   ConfigureDnsSettings)r,   rh   rK   updatedrP   r   r   rS   s           r   ConfigureDNSz RegistrationsClient.ConfigureDNS~  s     L~&&l$$			-..677			&011((<(K --
X
X%224$(MM$M$M$"& %N %
 Y C ==--c22r   c           	         g }|r|dgz  }|| j                   j                  |      }ns| j                   j                  ||j                  |j                  |j                        }|j                  r|dgz  }|j                  r|dgz  }|j                  r|dgz  }dj                  |      }g }	|r+| j                   j                  j                  j                  g}	| j                   j                  |j                         | j                   j                  |||	|      	      }
| j                  j                  |
      S )
a]  Calls ConfigureContactSettings method.

    Args:
      registration_ref: Registration resource reference.
      contacts: New Contacts.
      contact_privacy: New Contact privacy.
      public_contacts_ack: Whether the user accepted public privacy.
      validate_only: validate_only flag.

    Returns:
      Long Running Operation reference.
    privacy)r   )r   registrantContactadminContacttechnicalContactregistrant_contactadmin_contacttechnical_contactr   )r7   r   r;   r=   r9   configureContactSettingsRequest)r)   ContactSettingsr   r   r   r   ConfigureContactSettingsRequestrC   rD   DDomainsProjectsLocationsRegistrationsConfigureContactSettingsRequestrF   r+   ConfigureContactSettings)r,   rh   contactscontact_privacypublic_contacts_ackrP   r   rL   r   noticesrS   s              r   ConfigureContactsz%RegistrationsClient.ConfigureContacts  sS   ( Lyk!l666O66!$66,,#44	 7  
	#	#-..			))		"	",--((<(KG
--
7
7
^
^  C  Cg
 --
\
\%224(,(U(U,""&	 )V )
 ] C ==11#66r   c                 0   | j                   j                  | j                   j                  |            }| j                   j                  |j	                         | j                   j                  |d            }| j                  j                  |      S )a  Sets a registrant contact.

    This resends registrant email confirmation.
    It's done by updating registrant email to the current value.

    Args:
      registration_ref: a Resource reference to a
        domains.projects.locations.registrations resource.
      registrant_email: The registrant email.

    Returns:
      Operation: the long running operation to configure contacts registration.
    )email)r   zregistrant_contact.email)r7   r   r   )r)   r   Contactr   rF   r   r+   r   )r,   rh   registrant_emailrL   rS   s        r   ConfigureRegistrantEmailz,RegistrationsClient.ConfigureRegistrantEmail  s     }}44--//6F/G 5 
 --
\
\%224(,(U(U,1 )V )
 ] C ==11#66r   c                     | j                   j                  |j                         |      }| j                  j	                  |      j
                  S N)r   r5   )r)   FDomainsProjectsLocationsRegistrationsRetrieveRegisterParametersRequestrF   r+   RetrieveRegisterParametersregisterParametersr,   rI   rJ   r   s       r   r   z.RegistrationsClient.RetrieveRegisterParameters  G    mmbb((*v c G ==33G<OOOr   c                     | j                   j                  |j                         |      }| j                  j	                  |      j
                  S r   )r)   FDomainsProjectsLocationsRegistrationsRetrieveTransferParametersRequestrF   r+   RetrieveTransferParameterstransferParametersr   s       r   r   z.RegistrationsClient.RetrieveTransferParameters
  r   r   c                     | j                   j                  |j                         |      }| j                  j	                  |      j
                  S )N)r   query)r)   9DomainsProjectsLocationsRegistrationsSearchDomainsRequestrF   r+   SearchDomainsr   )r,   rI   r   r   s       r   r   z!RegistrationsClient.SearchDomains  sL     	OO,,.e 	P 	
 
 ==&&w/BBBr   c                     | j                   j                  |j                         ||      }| j                  j	                  |      S )N)r9   	pageTokenr   )r)   KDomainsProjectsLocationsRegistrationsRetrieveGoogleDomainsDnsRecordsRequestrF   r+   RetrieveGoogleDomainsDnsRecords)r,   rh   r   
page_tokenr   s        r   r   z3RegistrationsClient.RetrieveGoogleDomainsDnsRecords  sG     mmgg%224 h G
 ==88AAr   c                     | j                   j                  |j                               }| j                  j	                  |      S rx   )r)   QDomainsProjectsLocationsRegistrationsRetrieveGoogleDomainsForwardingConfigRequestrF   r+   %RetrieveGoogleDomainsForwardingConfig)r,   rh   r   s      r   r   z9RegistrationsClient.RetrieveGoogleDomainsForwardingConfig%  s?    mmmm%224 n G ==>>wGGr   )NN)NFFF)NFF)F)NNNr"   )__name__
__module____qualname____doc__r-   r2   rH   r[   ra   rf   ro   rr   ru   rz   r}   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r'   r'   5   s    BA
"H  #9'F #:'x%(%*%&853 @D"2*2":H(3T<7|7:PPC	BHr   r'   r"   )r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   r   r   r   r   r%   objectr'   r   r   r   <module>r      sR    : &  ' ' , ( * #  	?8 
uH& uHr   