
    p                     D   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  ej(                  ej*                  j,                  ej*                  j.                  ej*                  j0                         G d dej2                               Zy)z!Import workflow template command.    )absolute_import)division)unicode_literals)
exceptions)dataproc)base)flags)util)
console_ioc                   6    e Zd ZdZed        Zed        Zd Zy)Importa!  Import a workflow template.

  If the specified template resource already exists, it will be overwritten.
  Otherwise, a new template will be created.
  To edit an existing template, you can export the template to a file, edit its
  configuration, and then import the new configuration.
  c                 \    t        j                  | j                               j                  S )z3Returns the API version based on the release track.)dpDataprocReleaseTrackapi_version)clss    1lib/surface/dataproc/workflow_templates/import.pyGetApiVersionzImport.GetApiVersion(   s"     ;;s'')*666    c                 z    t        j                  |d| j                                t        j                  |       y )Nimport)r   )r	   AddTemplateResourceArgr   export_utilAddImportFlags)r   parsers     r   ArgszImport.Args-   s.    	  c&7&7&9;v&r   c                    t        j                  | j                               }|j                  }|j                  j
                  j                         }dj                  |j                         j                  d      dd       }t        j                  |j                  xs dd      }t        j                  |j                  |      }|j!                         |_        	 |j%                  |      }t        j4                  d
j7                  |j"                        d       |j8                  |_        |j                         |_        |j.                  j0                  j=                  |      S # t&        j(                  $ rS}	|	j*                  dk7  r|	|j-                  ||	      }
|j.                  j0                  j3                  |
      cY d }	~	S d }	~	ww xY w)N/r      -F)binary)message_typestreami  )parentworkflowTemplatez,Workflow template [{0}] will be overwritten.T)messagecancel_on_no)r   r   r   messagesCONCEPTStemplateParsejoinRelativeNamesplitr   ReadFromFileOrStdinsourcer   r   WorkflowTemplateNameidGetRegionsWorkflowTemplateapitools_exceptions	HttpErrorstatus_code5DataprocProjectsRegionsWorkflowTemplatesCreateRequestclient"projects_regions_workflowTemplatesCreatePromptContinueformatversionnameUpdate)selfargsr   msgstemplate_refr%   datar+   old_templateerrorrequests              r   Runz
Import.Run3   s   {{4,,./HD==))//1L
 XXl//177<QqABF))$++*<UKD!!**49H ##%HKP88Fl ?GGKK
 $++H --/HM??==DDXNN (( P			c	!JJ( K 4g__??FFwOOPs   !E- -G AGGGN)__name__
__module____qualname____doc__classmethodr   r   rJ    r   r   r   r      s5     7 7 ' '
#Or   r   N)rN   
__future__r   r   r   apitools.base.pyr   r6   googlecloudsdk.api_lib.dataprocr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataprocr	   !googlecloudsdk.command_lib.exportr
   r   googlecloudsdk.core.consoler   ReleaseTracksr   ALPHABETAGAUpdateCommandr   rP   r   r   <module>r]      s    ( &  ' > : ( 5 A 2 D%%++T->->-C-C%%((*7OT 7O*7Or   