
                            S 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S
KJr  SSKJr  SSKJr  \R*                  \R,                  " \R.                  R0                  \R.                  R2                  \R.                  R4                  5       " S S\R6                  5      5       5       rg)z&gcloud dns record-sets export command.    )absolute_import)division)unicode_literals)
exceptions)
list_pager)export_util)util)base)flags)log)filesc                   .    \ rS rSrSr\S 5       rS rSrg)Export    a  Export your record-sets into a file.

This command exports the record-sets contained within the specified
managed-zone into a file.
The formats you can export to are YAML records format (default) and
BIND zone file format.

## EXAMPLES

To export record-sets into a yaml file, run:

  $ {command} records.yaml --zone=examplezonename

To export record-sets into a BIND zone formatted file instead, run:

  $ {command} pathto.zonefile --zone=examplezonename --zone-file-format

Similarly, to import record-sets into a BIND zone formatted zone file, run:

  $ gcloud dns record-sets import pathto.zonefile --zone-file-format \
    --zone=examplezonename
c                     [         R                  " 5       R                  U5        [         R                  " 5       R                  U5        UR	                  SSS9  UR	                  SSSSS9  g )	Nrecords_filez-File to which record-sets should be exported.)helpz--zone-file-formatF
store_truea  Indicates that records-file should be in the zone file format. When using this flag, expect the record-set to be exported to a BIND zone formatted file. If you omit this flag, the record-set is exported into a YAML formatted records file. Note, this format flag determines the format of the output recorded in the records-file; it is different from the global `--format` flag which affects console output alone.)requiredactionr   )r   
GetZoneArgAddToParserGetLocationArgadd_argument)clsparsers     %lib/surface/dns/record_sets/export.pyArgsExport.Args;   sl    	""6*	&&v.
L  N
J	  
K    c                    [         R                  " U R                  5       U5      n[         R                  " U5      n[         R                  " U5      R                  UR                  [         R                  " X!5      SS9n UR                  R                  UR                  UR                  S9nUS:X  a  UR                  Ul        UR                  R                  U5      n/ nUR                  R'                  UR                  UR)                  5       S9n	US:X  a  UR                  U	l        [*        R,                  " UR.                  U	SS9 HM  n
UR0                  (       a(  U
R2                  S:X  a  [4        R6                  " S5        M<  UR9                  U
5        MO      [:        R<                  " UR>                  5       nUR0                  (       a"  [@        RB                  " XURD                  5        O[@        RF                  " X5        S S S 5        [4        RN                  RQ                  S
RK                  UR>                  5      5        g ! [        R                    a  n["        R$                  " U5      eS nAff = f! , (       d  f       Ny= f! [H         a7  nS	RK                  UR>                  U5      n[@        RL                  " U5      eS nAff = f)Nzdns.managedZones)params
collection)projectmanagedZonev2rrsets)fieldALIASzSkipping ALIAS record found in zone, as ALIAS record are custom to Cloud DNS and do not have a standard BIND format. To export ALIAS records, use YAML format instead.z/Unable to export record-sets to file [{0}]: {1}zExported record-sets to [{0}].))r	   GetApiFromTrackAndArgsReleaseTrackGetApiClientGetRegistryParsezoneGetParamsForRegistryMESSAGES_MODULEDnsManagedZonesGetRequestr$   r%   locationmanagedZonesGetapitools_exceptions	HttpErrorcalliope_exceptionsHttpException DnsResourceRecordSetsListRequestNamer   YieldFromListresourceRecordSetszone_file_formattyper   warningappendr   
FileWriterr   r   WriteToZoneFilednsNameWriteToYamlFile	ExceptionformatUnableToExportRecordsToFilestatusPrint)selfargsapi_versiondnszone_refget_requestr/   errorrecord_setslist_request
record_setexport_fileexpmsgs                 r   Run
Export.RunM   sN   --d.?.?.A4HK


K
(C ,22		((;% 3 'H	5''AA""0D0D B Fk 
	#}}!!+.d
 K&&GG  hmmo H ?L d"mml ..H>
			??g% ++?
 $> 	9D--.+  

%
%k
M

%
%k
?	 / JJ5<<T=N=NOPM (( 5--e4458 /.
  9=DD


S"c33C889sP    A I  J =A
I:J I7I22I7:
JJ J 
K2KK N)	__name__
__module____qualname____firstlineno____doc__classmethodr   rX   __static_attributes__rZ   r    r   r   r       s#    . K K"8Qr    r   N)r_   
__future__r   r   r   apitools.base.pyr   r6   r   googlecloudsdk.api_lib.dnsr   r	   googlecloudsdk.callioper
   r8   googlecloudsdk.command_lib.dnsr   googlecloudsdk.corer   googlecloudsdk.core.utilr   UniverseCompatibleReleaseTracksr+   GABETAALPHACommandr   rZ   r    r   <module>ro      s    - &  ' > ' 2 + ( E 0 # * D%%(($*;*;*@*@%%++-bQT\\ bQ- bQr    