
                             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d
l	mZ ddlmZ ddlmZ ej"                   G d dej$                               Zy)z5`gcloud domains registrations configure dns` command.    )absolute_import)division)unicode_literals)registrations)base)dns_util)flags)resource_args)util)
exceptions)logc                   &    e Zd ZdZed        Zd Zy)ConfigureDNSa  Configure DNS settings of a Cloud Domains registration.

  Configure DNS settings of a Cloud Domains registration.

  In most cases, this command is used for changing the authoritative name
  servers and DNSSEC options for the given domain. However, advanced options
  like glue records are available.

  ## EXAMPLES

  To start an interactive flow to configure DNS settings for ``example.com'',
  run:

    $ {command} example.com

  To use Cloud DNS managed-zone ``example-zone'' for ``example.com'', run:

    $ {command} example.com --cloud-dns-zone=example-zone

  DNSSEC will not be enabled as it may not be safe to enable it (e.g. when the
  Cloud DNS managed-zone was signed less than 24h ago).

  To use a signed Cloud DNS managed-zone ``example-zone'' for ``example.com''
  and enable DNSSEC, run:

    $ {command} example.com --cloud-dns-zone=example-zone --no-disable-dnssec

  To change DNS settings for ``example.com'' according to information from a
  YAML file ``dns_settings.yaml'', run:

    $ {command} example.com --dns-settings-from-file=dns_settings.yaml

  To disable DNSSEC, run:

    $ {command} example.com --disable-dnssec

  c                     t        j                  | d       t        j                  |        t        j                  | d       t        j
                  |        y )Nzto configure DNS settings forzconfigure DNS settings of the)r
   AddRegistrationResourceArgr	   $AddConfigureDNSSettingsFlagsToParserAddValidateOnlyFlagToParserAddAsyncFlagToParser)parsers    2lib/surface/domains/registrations/configure/dns.pyArgszConfigureDNS.ArgsG   sC    ,,V-LN	..v6	%%f.MN	v&    c           
         t        j                  |      }t        j                  |      }t        j                  |j
                        |_        |j                  j
                  j                         }|j                  d      }|r!|j                  rt        j                  d      |j                  |      }t        j                  ||       t        j                  j                   }|r'|j"                  rt        j                  j$                  }n(|r&|j"                  st        j                  j&                  }t        j(                  ||j*                  |j,                  |j.                  |j                  |j0                  ||j2                        \  }}	|3t        j4                  ||j0                  ||j2                        \  }}	|y |j2                  j6                  r+|	j8                  st:        j<                  j?                  d       t        j@                  |j2                        }
t        j@                  |      }|	j*                  xr! t        jB                  |j2                  |       }|
s|r7|r5t;        jD                  d       |jF                  st        jH                          |jK                  |||	|jL                        }|jL                  r!t:        j<                  j?                  d       |S t        jN                  |||jP                        }t;        jR                  |jU                         d|jP                         |S )	Ndisable_dnsseczgargument --disable-dnssec: At most one of --dns-settings-from-file | --disable-dnssec can be specified.)dnssec_updatedns_settingsz_Glue records will not be cleared. If you want to clear them, use --dns-settings-from-file flag.zName servers should not be changed if DS records are present or added. Disable DNSSEC first and wait 24 hours before you change name servers. Otherwise your domain may stop serving.)validate_onlyzKThe command will not have any effect because validate-only flag is present.registration)+r   GetApiVersionFromArgsRegistrationsClientr   NormalizeResourceNamer   CONCEPTSParseIsSpecifieddns_settings_from_filer   ErrorGetAssertRegistrationOperationalr   DNSSECUpdate	NO_CHANGEr   DISABLEENABLEParseDNSSettingsname_serverscloud_dns_zoneuse_google_domains_dnsregistrationsIddnsSettingsPromptForNameServersglueRecordsglue_recordsr   statusPrintDnssecEnabledNameServersEquivalentwarningunsafe_dns_updatePromptForUnsafeDnsUpdater   r   WaitForOperationasync_UpdatedResourceName)selfargsapi_versionclientregistration_refdnssec_flag_providedr   r   r   update_maskds_records_presentnew_ds_recordsname_servers_changedresponses                 r   RunzConfigureDNS.RunO   s   55d;K..{;F2243D3DED}}11779++,<= ; ;JK K ::./L&&{LA))33M 3 3++33m	d&9&9++22m ( 9 9####((#!--	!L+ "*"?"?


*
*%#//	#lK 
	++K4L4L	jj5
 "//0H0HI++L9N   	
..$$l
 
  	n2F	kk 2 3 ##))+""((	 # *H 	jj 8 9
 O &&{HdkkJh	*//1>4;;OOr   N)__name__
__module____qualname____doc__staticmethodr   rL    r   r   r   r      s"    $L ' 'Lr   r   N)rP   
__future__r   r   r   googlecloudsdk.api_lib.domainsr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.domainsr   r	   r
   r   googlecloudsdk.corer   r   DefaultUniverseOnlyUpdateCommandr   rR   r   r   <module>rZ      sU    < &  ' 8 ( 7 4 < 3 * # {4%% { {r   