
    7                         S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  S rSS jrSS jrS rSS jrS rS rS rSS jrSS jrg)z-Contacts utilties for Cloud Domains commands.    )absolute_import)division)unicode_literalsN)messages)registrations)flags)util)
exceptions)log)
properties)
console_io)resource_printerc                 6  ^ [         R                  " U 5      m " U4S jS[        R                  5      n[        R
                  " XSR                  U5      5      nU(       d  gSnUR                  (       au  S H>  nUR                  U5      (       d  M  [        R                  " SR                  X5      5      e   TR                  UR                  UR                  UR                  S9nU$ TR                  UR                  UR                  UR                  S9nU$ )z%Parses contact data from a yaml file.c                   
  > \ rS rSrSr\R                  "  Y R                  S5      r\R                  "  Y R                  S5      r	\R                  "  Y R                  S5      r
\R                  "  Y R                  S5      rSrg)	%ParseContactData.<locals>.ContactData'   z?Message that should be present in YAML file with contacts data.             N)__name__
__module____qualname____firstlineno____doc__	_messagesMessageFieldContactallContactsregistrantContactadminContacttechnicalContact__static_attributes__)domains_messagess   7lib/googlecloudsdk/command_lib/domains/contacts_util.pyContactDatar   '   sn    I (()9)A)A1EK!../?/G/GK))*:*B*BAFL --.>.F.FJ    r'   z>Contact data file '{}' does not contain valid contact messagesNr!   r"   r#   zEContact data file '{}' cannot contain both allContacts and {} fields.)r   GetMessagesModuler   Messager	   ParseMessageFromYamlFileformatr    get_assigned_valuer
   ErrorContactSettingsr!   r"   r#   )api_versionpathr'   contactsparsed_contactfieldr%   s         @r&   ParseContactDatar6   #   s   "44[AKI%% K **
HOO
( 
.J		$	$U	+	+*+16$+>@ 	@ K
 &55"..))!-- 6 /N 
 &55"44**!22 6 4N
 
r(   c                 H   [         R                  " U 5      nUSL n[        R                  " SSUS9(       d  gU(       a  [	        U5      nUR                  UUUS9$ / SQn[        R                  " USSS	S
9nUS:X  a'  [	        UUR                  5      nUR                  UUUS9$ US:X  a%  [	        UUR                  5      nUR                  US9$ US:X  a%  [	        UUR                  5      nUR                  US9$ US:X  a%  [	        UUR                  5      nUR                  US9$ g)z4Interactively prompts for Whois Contact information.NzBContact data not provided using the --contact-data-from-file flag.z%Do you want to enter it interactively)prompt_stringdefaultr)   )z"all the contacts to the same valuezregistrant contactzadmin contactztechnical contactTr   z$Which contact do you want to change?)optionscancel_optionr9   messager   )r!   r   )r"   r   )r#   )
r   r*   r   PromptContinue_PromptForSingleContactr0   PromptChoicer!   r"   r#   )r1   current_contactsr%   create_callcontactchoicesindexs          r&   PromptForContactsrE   K   si   "44[A!T)+		"	"J;
 %&67G++!  , " "
'
 
!
!4	6% aZ%&6&6&H&HJG++!  , " " aZ%&6&6&H&HJG++g+FF
aZ%&6&6&C&CEG+++AA
aZ%&6&6&G&GIG++W+EE	r(   c                    U R                  5       nU R                  5       Ul        UR                  R                  R	                  [
        R                  " [
        R                  SSS95        [        R                  " S5      UR                  l
        [
        R                  " [
        R                  SS[        R                  R                  R                  R!                  5       S9Ul        [
        R                  " [
        R                  SS	S
S9Ul        [
        R&                  " SSS9Ul        [
        R                  " [
        R*                  SSSS9UR                  l        UR                  R,                  S:w  a  [.        R0                  R3                  S5        [        R                  " S5      UR                  l        [        R                  " S5      UR                  l        [        R                  " S5      UR                  l        UR                  R:                  R	                  [
        R                  " [
        R                  SSS95        / nSn[=        U5      S:  aQ  S[=        U5      -   n[        R                  " SR?                  U5      5      nU(       d  OX5/-  n[=        U5      S:  a  MQ  U(       a%  UR                  R:                  RA                  U5        U$ )z&Asks a user for a single contact data.z Name must not be empty.zFull name:  )	validatorerror_messager8   zOrganization (if applicable):  z Invalid email address.Email)rG   rH   r8   r9   z  Phone number must not be empty.zPhone number:  z;Enter phone number with country code, e.g. "+1.8005550123".)rG   rH   r8   r<   zFax number (if applicable):  z9Enter fax number with country code, e.g. "+1.8005550123".)r8   r<   z Country / Region code must be in ISO 3166-1 format, e.g. "US" or "PL".
 See https://support.google.com/business/answer/6270107 for a list of valid choices.zCountry / Region code:  z:Enter two-letter Country / Region code, e.g. "US" or "PL".USzuRefer to the guidelines for entering address field information at https://support.google.com/business/answer/6397478.zPostal / ZIP code:  z.State / Administrative area (if applicable):  zCity / Locality:  z" Address Line 1 must not be empty.zAddress Line 1:  r   r   z"Address Line {} (if applicable):  )!r   PostalAddresspostalAddress
recipientsappendr	   PromptWithValidatorValidateNonEmptyr   PromptResponseorganizationValidateEmailr   VALUEScoreaccountGetemailphoneNumberPrompt	faxNumberValidateRegionCode
regionCoder   statusPrint
postalCodeadministrativeArealocalityaddressLineslenr-   extend)r%   unused_current_contactrB   optional_address_linesaddress_line_numaddress_lines         r&   r>   r>   ~   sz   $$&'*88:'
 
""))
))2&()
 (2'@'@'()'$**""-$$,,002	4'-
 00%%6%K	M'
 kk3IK' &*%=%=''$ /J&L'" %%-JJ K L &0%>%>&'"-7-F-F6.8'*#-#<#<$' 	$$++
))<+-. "#a'3566,,,334DEGLn, 	"#a' &&--.DE	.r(   c                     [         R                  " U 5      nUc  g [        R                  " U5      R	                  U5      $ N)r   r*   r   ContactPrivacyEnumMapperGetEnumForChoice)r1   contact_privacyr%   s      r&   ParseContactPrivacyro      s>    "44[A		'	'(8	9	J	J
 r(   c                    U(       d  [         R                  " S5      e[        R                  " U 5      nUR	                  [
        R                  SS9  U(       a  [        U5      S:X  a/  [        R                  R                  SR                  U5      5        g[        R                  " SR                  U5      SS	S
9nU(       d  gSn[        U5       H2  u  pgU[
        R                  " U5      R!                  U5      :X  d  M0  UnM4     OSn[        U5      S:X  a=  [        R                  " SR                  US   5      SS
9nU(       d  g[#        XS   5      $ [        R$                  " UUSS9n	[#        XU	   5      $ )zAsks a user for Contacts Privacy.

Args:
  api_version: Cloud Domains API version to call.
  choices: List of privacy choices.
  current_privacy: Current privacy. Should be nonempty in update calls.

Returns:
  Privacy enum or None if the user cancelled.
z)Could not find supported contact privacy.T)keyreverser   z9Your current contact privacy is {}. It cannot be changed.Nz#Your current contact privacy is {}.zDo you want to change itFr9   r   z)The only supported contact privacy is {}.zSpecify contact privacy)r:   r9   r<   )r
   r/   r   r*   sortr   PrivacyChoiceStrengthrd   r   r^   r_   r-   r   r=   	enumeraterl   GetChoiceForEnumro   r?   )
r1   rC   current_privacyr%   updatecurrent_choiceixprivacyackrD   s
             r&   PromptForContactPrivacyr~      sZ    



F
GG"44[A	,,5..,=
7|q	jj
E
L
L  ((
/
6
6
G
$f N )	E22
,,_=
> *
 N\Q

#
#3::71:FC {AJ77##)+E {EN;;r(   c                     [         R                  " U 5      nUc  gU HO  n[        R                  " U5      R	                  U5      nXBR
                  R                  R                  :X  d  MM  Us  $    g)z@Parses Contact Notices. Returns public_contact_ack enum or None.NF)r   r*   r   ContactNoticeEnumMapperrm   ConfigureContactSettingsRequest&ContactNoticesValueListEntryValuesEnum#PUBLIC_CONTACT_DATA_ACKNOWLEDGEMENT)r1   noticesr%   noticeenums        r&   ParsePublicContactsAckr      sq    "44[A_f(()9:KKD ??ff  K  K  Kk  
r(   c                 $   [         R                  " U 5      nUc  UR                  5       nUR                  UR                  =(       d    UR                  UR                  =(       d    UR                  UR
                  =(       d    UR
                  S9$ )Nr)   )r   r*   r0   r!   r"   r#   )r1   prev_contactsnew_contactsr%   s       r&   MergeContactsr     s    "44[A#335L		)	)%77 9&88 --K1K1K$55 7%66 
* 
9 9r(   c                     U R                   U R                  :X  a&  U R                   U R                  :X  a  U R                   $ U $ )zNReturns one contact if all 3 contacts are equal, and all 3 contacts otherwise.r)   )r3   s    r&   _SimplifyContactsr     s;    8#8#88X=W=W[c[t[t=t%%%	/r(   c                     [         R                  R                  SR                  U 5      5        [	        U5      n[
        R                  " X[        R                  S9  [        R                  " SSSSS9$ )zAsks a user for Public Contacts Ack.

Args:
  domain: Domain name.
  contacts: Current Contacts. All 3 contacts should be present.
  print_format: Print format, e.g. 'default' or 'yaml'.

Returns:
  Boolean: whether the user accepted the notice or not.
a   You choose to make contact data of domain {} public.
Anyone who looks it up in the WHOIS directory will be able to see info
for the domain owner and administrative and technical contacts.
Make sure it's ok with them that their contact data is public.
This info will be publicly available:outNFTr<   r9   throw_if_unattendedcancel_on_no
r   r^   r_   r-   r   r   sysstderrr   r=   domainr3   print_formats      r&   PromptForPublicContactsAckr   #  sd     **. /5fVn> x((SZZ@		"	"Et$
P Pr(   c                     [         R                  R                  SR                  U 5      5        [	        U5      n[
        R                  " X[        R                  S9  [        R                  " SSSSS9$ )a$  Asks a user for Public Contacts Ack when the user updates contact settings.

Args:
  domain: Domain name.
  contacts: Current Contacts. All 3 contacts should be present.
  print_format: Print format, e.g. 'default' or 'yaml'.

Returns:
  Boolean: whether the user accepted the notice or not.
a  You choose to make contact data of domain {} public.
Anyone who looks it up in the WHOIS directory will be able to see info
for the domain owner and administrative and technical contacts.
Make sure it's ok with them that their contact data is public.

Please consider carefully any changes to contact privacy settings when
changing from "redacted-contact-data" to "public-contact-data."
There may be a delay in reflecting updates you make to registrant
contact information such that any changes you make to contact privacy
(including from "redacted-contact-data" to "public-contact-data")
will be applied without delay but changes to registrant contact
information may take a limited time to be publicized. This means that
changes to contact privacy from "redacted-contact-data" to
"public-contact-data" may make the previous registrant contact
data public until the modified registrant contact details are published.

This info will be publicly available:r   NFTr   r   r   s      r&    PromptForPublicContactsUpdateAckr   <  sd     **." /5fVn%>& x((SZZ@		"	"Et$
P Pr(   rk   rs   ) r   
__future__r   r   r   r   apitools.base.protorpcliter   r   googlecloudsdk.api_lib.domainsr   "googlecloudsdk.command_lib.domainsr   r	   googlecloudsdk.corer
   r   r   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer   r6   rE   r>   ro   r~   r   r   r   r   r   r   r(   r&   <module>r      sj    4 &  ' 
 < 8 4 3 * # * 2 9%P0f@F3<l 
9P2"Pr(   