
                             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	  G d d	e
      Z G d
 de
      Zd Zd Zy)zFBase classes for abstracting away common logic for Deployment Manager.    )absolute_import)division)unicode_literals)apis)
properties)	resourcesc                       e Zd ZdZ G d de      Z eddd      Z eddj                  d      d	      Z ed
dj                  d      d      Z	eee	fZ
y)DmApiVersionzAn enum representing the API version of Deployment Manager.

  The DM API version controls which version of DM API to use for a certain
  command under certain release track.
  c                   "    e Zd ZdZd Zd Zd Zy)DmApiVersion._VERSIONz;An enum representing the API version of Deployment Manager.c                 .    || _         || _        || _        y N)idhelp_tag	help_note)selfr   r   r   s       8lib/googlecloudsdk/api_lib/deployment_manager/dm_base.py__init__zDmApiVersion._VERSION.__init__&   s    dgdm dn    c                     | j                   S r   r   r   s    r   __str__zDmApiVersion._VERSION.__str__+   s    WWnr   c                 4    | j                   |j                   k(  S r   r   )r   others     r   __eq__zDmApiVersion._VERSION.__eq__.   s    WW  r   N)__name__
__module____qualname____doc__r   r   r    r   r   _VERSIONr   "   s    E!
!r   r"   v2Nalphaz{0}(ALPHA){0} *zAThe DM API currently used is ALPHA and may change without notice.v2betaz{0}(V2BETA){0} zBThe DM API currently used is V2BETA and may change without notice.)r   r   r   r    objectr"   V2formatALPHAV2BETA_ALLr!   r   r   r
   r
      sq    ! ! dD!"
c"IK%
 s#JL&
 eV	$r   r
   c                   z    e Zd ZdZej
                  ZdZdZdZ	d Z
ed        Zed        Zed        Zed        Zy)	DmCommandz:DmCommand is a base class for Deployment Manager commands.Nc                      y r   r!   r   s    r   r   zDmCommand.__init__H   s    r   c                     | j                   S r   _dm_versionr   s    r   versionzDmCommand.versionK   s    r   c                     | j                   /t        j                  d| j                  j                        | _         | j                   S )zSpecifies the DM client.deploymentmanager)
_dm_clientr   GetClientInstancer2   r   r   s    r   clientzDmCommand.clientO   s=     ../B/3/?/?/B/BDdo??r   c                     | j                   /t        j                  d| j                  j                        | _         | j                   S )zSpecifies the DM messages.r5   )_dm_messagesr   GetMessagesModuler2   r   r   s    r   messageszDmCommand.messagesW   sB      001D151A1A1D1DFdr   c                     | j                   St        j                  j                         | _         | j                   j	                  d| j
                  j                         | j                   S )z0Specifies the resources parser for DM resources.r5   )_dm_resourcesr   REGISTRYCloneRegisterApiByNamer2   r   r   s    r   r   zDmCommand.resources_   sZ     !$--335d
**+>+/+;+;+>+>@r   )r   r   r   r    r
   r(   r2   r6   r:   r>   r   propertyr3   r8   r<   r   r!   r   r   r.   r.   @   sr    B+*,-	        r   r.   c                       fd}|S )zMark this command class to use given Deployment Manager API version.

  Args:
    api_version: DM API version to use for the command

  Returns:
    The decorator function
  c                     | _         | S )z#Wrapper function for the decorator.r1   )	cmd_classapi_versions    r   InitApiHolderzUseDmApi.<locals>.InitApiHolderr   s     (Ir   r!   )rF   rG   s   ` r   UseDmApirH   i   s    
 
r   c                  j    t         j                  j                  j                  j	                  d      S )NT)required)r   VALUEScoreprojectGetr!   r   r   
GetProjectrO   z   s(    						'	'	+	+T	+	::r   N)r    
__future__r   r   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r'   r
   r.   rH   rO   r!   r   r   <module>rS      sA     M &  ' , * )"6 "J& &R";r   