
    ;                     R   d Z ddlmZ ddlmZ ddlmZ ddl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&                  e
j(                  j*                  e
j(                  j,                  e
j(                  j.                         G d de
j0                               Zd Zy)zExport cluster command.    )absolute_import)division)unicode_literalsN)dataproc)base)clusters)flags)util)filesc                   >    e Zd ZdZddiZed        Zed        Zd Zy)ExportzExport a cluster.

  Exports an existing cluster's configuration to a file.
  This configuration can then be used to create new clusters using the import
  command.
  EXAMPLESz
To export a cluster to a YAML file, run:

  $ {command} my-cluster --region=us-central1 --destination=cluster.yaml

To export a cluster to standard output, run:

  $ {command} my-cluster --region=us-central1
c                      y)z3Returns the API version based on the release track.v1 )clss    'lib/surface/dataproc/clusters/export.pyGetApiVersionzExport.GetApiVersion4   s         c                     t        j                  | j                               }t        j                  |d|j
                         t        j                  |       y )Nexport)dpDataprocReleaseTrackr	   AddClusterResourceArgapi_versionexport_utilAddExportFlags)r   parserr   s      r   ArgszExport.Args9   s?    {{3++-.H	(2F2FGv&r   c                    t        j                  | j                               }|j                  j                  j                         }|j                  j                  |j                  |j                  |j                        }|j                  j                  j                  |      }t        j                  ||       t        j                   ||       t#        |       |j$                  r@t'        j(                  |j$                        5 }t+        j,                  ||       d d d        y t+        j,                  |t.        j0                         y # 1 sw Y   y xY w)N)	projectIdregionclusterName)messagestream)r   r   r   CONCEPTSclusterParsemessages)DataprocProjectsRegionsClustersGetRequestr"   r#   r$   clientprojects_regions_clustersGetr   DeleteGeneratedLabelsDeleteGeneratedPropertiesRemoveNonImportableFieldsdestinationr   
FileWriterr   r   sysstdout)selfargsr   cluster_refrequestr(   r&   s          r   Runz
Export.Run?   s   {{4,,./H--''--/KII''!!++ J -G
 oo77;;GDG ""7H5&&w9g&D,,-76: .- < .-s   EEN)	__name__
__module____qualname____doc__detailed_helpclassmethodr   r    r:   r   r   r   r   r      sE      
-   ' '
=r   r   c                    d| _         d| _        d| _        g | _        d| _        d| _        | j                  | j                  }|j                  "d|j                  _        d|j                  _	        |j                  |j                  |j                  g}|j                  D ]'  }|j                  |j                  j                          ) |D ]  }|g |_        d|_        d|_         yy)zHModifies cluster to exclude OUTPUT_ONLY and resource-identifying fields.N)r"   r$   statusstatusHistoryclusterUuidmetricsconfiglifecycleConfigidleStartTimeautoDeleteTimemasterConfigworkerConfigsecondaryWorkerConfigauxiliaryNodeGroupsappend	nodeGroupnodeGroupConfiginstanceNamesisPreemptiblemanagedGroupConfig)r(   rF   instance_group_configs
aux_configgroups        r   r1   r1   X   s     '''.'''/^^^^F)-1f* /3f+ 	V00&2N2N 00
##J$8$8$H$HI 1 (		 "#' 	 ('  r   )r>   
__future__r   r   r   r4   googlecloudsdk.api_lib.dataprocr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataprocr   r	   !googlecloudsdk.command_lib.exportr
   r   googlecloudsdk.core.utilr   ReleaseTracksr   ALPHABETAGADescribeCommandr   r1   r   r   r   <module>rb      s     &  ' 
 : ( 8 5 A * D%%++T->->-C-C%%((*4=T!! 4=*4=p!(r   