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

  If the specified session template already exists, it will be overwritten.
  Otherwise, a new session template will be created.
  To edit an existing session template, you can export the session template
  to a file, edit its configuration, and then import the new configuration.

  This command does not allow output only fields, such as template id and
  resource name. It populates the id field based on the resource name specified
  as the first command line argument.

  ## EXAMPLES

  The following command creates or updates the contents of session template
  `example-session-template` based on a yaml file:

    $ {command} example-session-template --source=saved-template.yaml
  c                     t        j                         }t        j                  |d|j                         t        j                  |       y )Nimport)dpDataprocr
   AddSessionTemplateResourceArgapi_versionexport_utilAddImportFlags)clsparserr   s      0lib/surface/dataproc/session_templates/import.pyArgszImport.Args3   s6    {{}H	''(0(<(<>v&    c                    t        j                         }|j                  j                  j	                         }t        j                  ||j                        }	 t        j                  ||j                         |      S # t        j                  $ rp}|j                  dk7  r|t        j                  dj                  |j                         d       t        j"                  ||j                         |      cY d }~S d }~ww xY w)N)r   template_file_namei  z+Session template [{0}] will be overwritten.T)messagecancel_on_no)r   r   CONCEPTSsession_templateParser   ReadSessionTemplatesourceCreateSessionTemplateRelativeNameapitools_exceptions	HttpErrorstatus_coder   PromptContinueformatnameUpdateSessionTemplate)selfargsr   template_reftemplateerrors         r   Runz
Import.Run;   s    {{}H==11779L'';;(H2'',2K2K2M(02 2(( 
2			c	!@HHmm '',2K2K2M(02 2
2s   $B   DA%C>8D>DN)__name__
__module____qualname____doc__classmethodr   r2    r   r   r   r      s     & ' '2r   r   N)r6   
__future__r   r   r   apitools.base.pyr   r&   googlecloudsdk.api_lib.dataprocr   r   r   googlecloudsdk.callioper	   #googlecloudsdk.command_lib.dataprocr
   !googlecloudsdk.command_lib.exportr   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackBETACommandr   r8   r   r   <module>rD      s`    ' &  ' > : 0 ( 5 A 2 D%%**+02T\\ 02 ,02r   