
    
                         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 G d de      Zd Zd Zy)z)Helper methods for exporting record-sets.    )absolute_import)division)unicode_literals)name)rdata)
rdataclass)	rdatatype)zone)	svcb_stub)
exceptions)resource_printerc                       e Zd ZdZy)Errorz%Base exception for all export errors.N__name__
__module____qualname____doc__     -lib/googlecloudsdk/api_lib/dns/export_util.pyr   r   $   s    -r   r   c                       e Zd ZdZy)UnableToExportRecordsToFilez+Unable to export records to specified file.Nr   r   r   r   r   r   (   s    3r   r   c                    t        j                  t        j                  |            }|D ]  }|j	                  |j                  |j
                  d      }|j                  D ]t  }|j                  t        j                  t        j                  t        j                  |j
                        t        |      |j                        |j                         v  |j                  | d       y)a  Writes 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   WriteToZoneFiler/   ,   s     ))DNN623-j&&z'1.2 ' 4E $$ii
 ) 3 3JOO D #F'4';';= NN	  $ %	   	e4r   c                 4    t        j                  |d|        y)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   WriteToYamlFiler6   B   s     6yIr   N)r   
__future__r   r   r   dnsr   r   r   r	   r
   googlecloudsdk.api_lib.dnsr   googlecloudsdk.corer   googlecloudsdk.core.resourcer   registerr   r   r/   r6   r   r   r   <module>r=      sd     0 &  '      0 * 9 	   .J .4% 45,Jr   