
                            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 ddlmZ  G d de      Z ej(                  ej*                  j,                         e
j.                  e
j0                  j2                         G d dej4                  e
j6                                      Z ej(                  ej*                  j:                         e
j.                  e
j0                  j:                         G d de                    Z ej(                  ej*                  j>                         G d de             Z y)zdeployments describe command.    )absolute_import)division)unicode_literals)
exceptions)dm_api_util)dm_base)base)alpha_flags)flags)
propertiesc                       e Zd ZdZd Zy)_Resultsz@Encapsulate results into a single object to fit the Run() model.c                 .    || _         || _        || _        y )N)
deployment	resourcesoutputs)selfr   r   r   s       6lib/surface/deployment_manager/deployments/describe.py__init__z_Results.__init__$   s     DODNDL    N)__name__
__module____qualname____doc__r    r   r   r   r   !   s
    Hr   r   c                   Z    e Zd ZdZddiZeej                  j                  fd       Z	d Z
y)DescribeoProvide information about a deployment.

  This command prints out all available details about a deployment.
  EXAMPLESzk          To display information about a deployment, run:

            $ {command} my-deployment
          c                 d    t        j                  |        | j                  j                  d       y)a\  Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
      version: The version this tool is running as. base.ReleaseTrack.GA
          is the default.
    a  
              table(
                deployment:format='default(name, id, description, fingerprint,
                insertTime, manifest.basename(), labels, operation.operationType,
                operation.name, operation.progress, operation.status,
                operation.user, operation.endTime, operation.startTime,
                operation.error, operation.warnings, update)',
                resources:format='table(
                  name:label=NAME,
                  type:wrap:label=TYPE,
                  update.state.yesno(no="COMPLETED"),
                  update.intent)',
              outputs:format='table(
                name:label=OUTPUTS,
                finalValue:label=VALUE)'
             )
    N)r   AddDeploymentNameFlagdisplay_info	AddFormat)parserversions     r   ArgszDescribe.Args:   s+     
'
!! # 	r   c                    | j                   j                  |j                  dt        j                  j
                  j                  j                  id      }	 | j                  j                  j                  | j                  j                  t        j                         |j                              }	 | j                  j                   j-                  | j                  j/                  t        j                         |j0                              }|j                   }| j3                         t4        j2                  j6                  u r2|j9                  d      s!|j:                  rt<        j>                  |_         g }t)        jB                  |      }|r| j                  jD                  j                  | j                  jG                  t        j                         |j                  |            }	|	jH                  rt)        jJ                  |	jH                        }tM        |||      S # t         j"                  $ r)}t%        j&                  |t(        j*                        d}~ww xY w# t         j"                  $ r d}Y w xY w)a"  Run 'deployments describe'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The requested Deployment.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    projectzdeploymentmanager.deployments)params
collection)r(   r   Nformat)r(   r   manifest)'r   Parsedeployment_namer   VALUEScorer(   	GetOrFailclientdeploymentsGetmessages&DeploymentmanagerDeploymentsGetRequestr   
GetProjectr   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATList%DeploymentmanagerResourcesListRequestnameReleaseTrackr	   ALPHAIsSpecifiedupdater
   5PREVIEWED_DEPLOYMENT_AND_RESOURCES_AND_OUTPUTS_FORMATr+   ExtractManifestName	manifests$DeploymentmanagerManifestsGetRequestlayoutFlattenLayoutOutputsr   )
r   argsdeployment_refr   errorresponser   r   r,   manifest_responses
             r   RunzDescribe.RunX   s    ^^)):,,1199CCD2 * 4NK;;**..
--
>
>((*'22 ? 45j&&++
--
=
=((*z > HIh $$i				 1 1 7 7	7  *1B1BOO + G..z:H++//33
--
<
<((*'22 =  
	!	!223D3K3KLJ	733A (( K$$UK,I,IJJK (( is,   AH' 5CI& 'I#:$II#&I?>I?N)r   r   r   r   detailed_helpstaticmethodr	   r?   GAr&   rN   r   r   r   r   r   *   s@      - ,,// 	 	:74r   r   c                        e Zd ZdZed        Zy)DescribeAlphar   c                     t         j                  | t        j                  j                         | j
                  j                  t        j                         y N)r%   )	r   r&   r	   r?   r@   r"   r#   r
   +DEPLOYMENT_AND_RESOURCES_AND_OUTPUTS_FORMATr$   s    r   r&   zDescribeAlpha.Args   s<    MM&$"3"3"9"9M:
!!??Ar   Nr   r   r   r   rP   r&   r   r   r   rS   rS      s    
 A Ar   rS   c                        e Zd ZdZed        Zy)DescribeBetar   c                 b    t         j                  | t        j                  j                         y rU   )r   r&   r	   r?   BETArW   s    r   r&   zDescribeBeta.Args   s    MM&$"3"3"8"8M9r   NrX   r   r   r   rZ   rZ      s    
 : :r   rZ   N)!r   
__future__r   r   r   apitools.base.pyr   r8   )googlecloudsdk.api_lib.deployment_managerr   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.deployment_managerr
   r   googlecloudsdk.corer   objectr   ReleaseTracksr?   rQ   UseDmApiDmApiVersionV2DescribeCommand	DmCommandr   r@   rS   r\   rZ   r   r   r   <module>rj      s*    $ &  ' > A = ( . E ? *v  D%%(()'&&))*c4t##W%6%6 c4 + *c4L D%%++,'&&,,-
AH 
A . -
A D%%**+:8 : ,:r   