
    :                         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  G d dej"                        Zy)z/gcloud dns record-sets transaction add command.    )absolute_import)division)unicode_literals)resource_record_sets)transaction_util)util)base)flags)logc                   6    e Zd ZdZed        Zed        Zd Zy)Adda  Append a record-set addition to the transaction.

  This command appends a record-set addition to the transaction.

  For a guide detailing how to manage records, see:
  https://cloud.google.com/dns/records/

  ## EXAMPLES

  To add an A record with an IP address of "1.2.3.4", domain name of
  "my.domain.", and a managed zone "MANAGED_ZONE", run:

    $ {command} "1.2.3.4" \
        --name=my.domain. --ttl=1234 \
        --type=A --zone=MANAGED_ZONE

  To add a TXT record with multiple data values while specifying time to
  live as 14400 seconds, run:

    $ {command} "Hello world" "Bye world" \
        --name=my.domain. --ttl=14400 \
        --type=TXT --zone=MANAGED_ZONE
  c                     | j                         t        j                   j                  t        j                   j                  fv S )N)ReleaseTrackr	   BETAALPHA)clss    .lib/surface/dns/record_sets/transaction/add.py_IsBetaOrAlphazAdd._IsBetaOrAlpha7   s:    $"3"3"8"8"&"3"3"9"9"; ; ;    c                     t        j                         j                  |        | j                  ddd       | j                  ddt        d       | j                  ddd	       | j                  d
dd       y )Nz--nameTz,DNS or domain name of the record-set to add.)requiredhelpz--ttlz-TTL (time to live) for the record-set to add.)r   typer   z--typez)DNS record type of the record-set to add.rrdatas+zDNS data (Address/CNAME/MX info, etc.) of the record-set to add. This is RDATA; the format of this information varies depending on the type and class of the resource record.)nargsr   )r
   
GetZoneArgAddToParseradd_argumentint)parsers    r   ArgszAdd.Args<   s    	""6*
4;  = $S<  > 48  : =  >r   c           	      z   d}| j                         t        j                   j                  k(  rd}n-| j                         t        j                   j                  k(  rd}t	        j
                  |j                        5 }t	        j                  ||      }d d d        t        j                  |      j                  |j                  t        j                  ||      d      }j                  j                  t        j                   ||j"                  || j%                                      t	        j
                  |j                  d      5 }t	        j&                  ||       d d d        t(        j*                  j-                  d	j/                  |j                               y # 1 sw Y   xY w# 1 sw Y   OxY w)
Nv1v1beta2v1alpha2)api_versionzdns.managedZones)params
collection)r'   allow_extended_recordswz1Record addition appended to transaction at [{0}].)r   r	   r   r   
trans_utilTransactionFiletransaction_fileChangeFromYamlFiler   GetRegistryParsezoneGetParamsForRegistry	additionsappendrrsets_utilCreateRecordSetFromArgsprojectr   WriteToYamlFiler   statusPrintformat)selfargsr'   
trans_filechangezone_refs         r   RunzAdd.RunN   sf   K d//444k				 1 1 7 7	7k		#	#D$9$9	:j,,
+/f 
; ,22		((d;% 3 'H ++##'#6#6#8		:; 
	#	#D$9$93	?:  V4 
@ JJ;BB!!	#$% 
;	: 
@	?s   =F$F1$F.1F:N)	__name__
__module____qualname____doc__classmethodr   staticmethodr"   rB    r   r   r   r      s4    0 ; ; > >"$r   r   N)rF   
__future__r   r   r   googlecloudsdk.api_lib.dnsr   r6   r   r,   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.dnsr
   googlecloudsdk.corer   Commandr   rI   r   r   <module>rP      s7     6 &  ' J E + ( 0 #M$$,, M$r   