
                             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 r
S	 rS
 rS rS rS rS r SS jrg)z('notebooks environments create' command.    )absolute_import)division)unicode_literals)util)log)	resourcesc                 .  ^ U4S jnU4S jnU R                  S5      (       a	  U" U 5      nOU" U 5      nTR                  U R                  U R                  U R                  U R
                  S9nU R                  S5      (       a	  WUl        U$ WUl        U$ )zCreates the Environment message for the create request.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the Environment message.
c                 P   > TR                  U R                  U R                  S9nU$ )N)
repositorytag)ContainerImagecontainer_repositorycontainer_tag)argscontainer_imagemessagess     4lib/googlecloudsdk/api_lib/notebooks/environments.pyCreateContainerImageFromArgs7CreateEnvironment.<locals>.CreateContainerImageFromArgs%   s0    --,,$2D2D . FO    c                    > TR                  U R                  S9nU R                  S5      (       a  U R                  Ul        U$ U R
                  Ul        U$ )N)projectvm_image_family)VmImagevm_image_projectIsSpecifiedr   imageFamilyvm_image_name	imageName)r   vm_imager   s     r   CreateVmImageFromArgs0CreateEnvironment.<locals>.CreateVmImageFromArgs*   s]    %%   'H)**!11h O  --hOr   r   )namedescriptiondisplayNamepostStartupScript)r   Environmentenvironmentr$   display_namepost_startup_scriptvmImagecontainerImage)r   r   r   r!   r    r   r(   s    `     r   CreateEnvironmentr-      s    
 
())$T*H248O$$""##00	 % 2+
 
())"K 
 "1K	r   c                 x    [         R                  " U 5      n[        X5      nUR                  X#U R                  S9$ )N)parentr(   environmentId)r   GetParentForEnvironmentr-   3NotebooksProjectsLocationsEnvironmentsCreateRequestr(   )r   r   r/   r(   s       r   CreateEnvironmentCreateRequestr3   D   sB    ''-&!$1+		E	ED<L<L 
F 
N Nr   c                 L    [         R                  " U 5      nUR                  US9$ )N)r/   )r   GetParentFromArgs1NotebooksProjectsLocationsEnvironmentsListRequest)r   r   r/   s      r   CreateEnvironmentListRequestr7   K   s.    !!$'&		C	C 
D 
 r   c                 R    [        U 5      R                  5       nUR                  US9$ N)r#   )GetEnvironmentResourceRelativeName3NotebooksProjectsLocationsEnvironmentsDeleteRequestr   r   r(   s      r   CreateEnvironmentDeleteRequestr>   Q   s1    &t,99;+		E	E 
F 
 r   c                 R    [        U 5      R                  5       nUR                  US9$ r9   )r:   r;   0NotebooksProjectsLocationsEnvironmentsGetRequestr=   s      r    CreateEnvironmentDescribeRequestrA   W   s1    &t,99;+		B	B 
C 
 r   c                 J    U R                   R                  R                  5       $ )N)CONCEPTSr(   Parse)r   s    r   r:   r:   ]   s    		"	"	(	(	**r   c                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )Nz)notebooks.projects.locations.environments)
collection)r   REGISTRYParseRelativeNamer#   SelfLink)resourcer(   s     r   GetEnvironmentURIrK   a   s7    ""44mm K 5 M+				r   c                    U(       a  [         R                  O[         R                  nUR                  (       aB  U" [        R
                  " U R                  U5      SR                  UR                  5      SS9  U $ [        R                  " U SR                  UR                  U(       a  SOSU R                  5      UUUS9nU" [        R
                  " U R                  U5      SR                  UR                  5      SS9  U$ )	z8Handles Long Running Operations for both cases of async.znotebooks environment {0}T)kindis_asyncz/Waiting for Environment [{}] to be {} with [{}]deletedcreated)servicerelease_track	is_deleteF)
r   DeletedResourceCreatedResourceasync_r   GetOperationResourcer#   formatr(   WaitForOperation)	operationr   environment_servicerR   rS   logging_methodresponses          r   	HandleLROr^   g   s     +43&&9L9L.	[[!!)..-@(//0@0@A $$9@@9i)NN	 $#H !!)..-@(//0@0@A Or   N)F)__doc__
__future__r   r   r    googlecloudsdk.api_lib.notebooksr   googlecloudsdk.corer   r   r-   r3   r7   r>   rA   r:   rK   r^    r   r   <module>rd      sK    / &  ' 1 # )'TN+  	r   