
    	                         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  \R                  " 5          " S
 S\
R                  5      r " S S\5      rS rS rg)z)Helper methods for exporting record-sets.    )name)rdata)
rdataclass)	rdatatype)zone)	svcb_stub)
exceptions)resource_printerc                       \ rS rSrSrSrg)Error!   z%Base exception for all export errors. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       -lib/googlecloudsdk/api_lib/dns/export_util.pyr   r   !   s    -r   r   c                       \ rS rSrSrSrg)UnableToExportRecordsToFile%   z+Unable to export records to specified file.r   Nr   r   r   r   r   r   %   s    3r   r   c                    [         R                  " [        R                  " U5      5      nU H  nUR	                  UR                  UR
                  SS9nUR                   Hq  nUR                  [        R                  " [        R                  [        R                  " UR
                  5      [        U5      UR                  S9UR                  S9  Ms     M     UR                  U SS9  g)zWrites the given record-sets in zone file format to the given file.

Args:
  zone_file: file, File into which the records should be written.
  record_sets: list, ResourceRecordSets to be written out.
  domain: str, The origin domain for the zone file.
T)create)origin)ttlF)
relativizeN)r   Zoner   	from_textget_rdatasettyperrdatasaddr   r   INr   strr   r   to_file)	zone_filerecord_setsdomainzone_contents
record_setrdsetrrdatas          r   WriteToZoneFiler0   )   s     ))DNN623-j&&z'1.2 ' 4E $$ii
 ) 3 3JOO D #F'4';';= NN	  $ %	   	e4r   c                 0    [         R                  " USU S9  g)zWrites the given record-sets in yaml format to the given file.

Args:
  yaml_file: file, File into which the records should be written.
  record_sets: list, ResourceRecordSets to be written out.
yaml)print_formatoutN)r
   Print)	yaml_filer*   s     r   WriteToYamlFiler7   ?   s     6yIr   N)r   dnsr   r   r   r   r   googlecloudsdk.api_lib.dnsr   googlecloudsdk.corer	   googlecloudsdk.core.resourcer
   registerr   r   r0   r7   r   r   r   <module>r=      s[     0      0 * 9 
   .J .4% 45,Jr   