
                         0   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  ej                  ej                  j                   ej                  j"                         e	j$                  e	j&                  j(                         G d
 dej*                  e	j,                                      Z ej                  ej                  j0                         e	j$                  e	j&                  j0                         G d de                    Zy)zresources list command.    )absolute_import)division)unicode_literals)
list_pager)dm_api_util)dm_base)base)alpha_flagsc                   .    e Zd ZdZddiZed        Zd Zy)ListqList resources in a deployment.

  Prints a table with summary information on all resources in the deployment.
  EXAMPLESz
To print out a list of resources in the deployment with some summary information about each, run:

  $ {command} --deployment=my-deployment

To print only the name of each resource, run:

  $ {command} --deployment=my-deployment --simple-list
c                 x    t         j                  j                  |        | j                  j	                  d       y)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.
    z
          table(
            name,
            type:wrap,
            update.state.yesno(no="COMPLETED"),
            update.error.errors.group(code),
            update.intent
          )
    N)r   SIMPLE_LIST_FLAGAddToParserdisplay_info	AddFormatparsers    0lib/surface/deployment_manager/resources/list.pyArgsz	List.Args1   s1       ,,V4
!! # 	    c           	         | j                   j                  t        j                         |j                        }t        j                  t        j                  | j                  j                  |d|j                  |j                              S )6  Run 'resources list'.

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

    Returns:
      The list of resources for the specified deployment.

    Raises:
      HttpException: An http error response was received while executing api
          request.
    project
deployment	resourcesfieldlimit
batch_sizemessages%DeploymentmanagerResourcesListRequestr   
GetProjectr   r   YieldWithHttpExceptionsr   YieldFromListclientr   r"   	page_size)selfargsrequests      r   RunzList.RunE   st     mmAA""$?? B G ..  !6!6!('2'+zz,0NN		<= =r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r/    r   r   r   r      s1      
- 	 	&=r   r   c                   >     e Zd ZdZed        Zd Zd Z fdZ xZ	S )	ListAlphar   c                 B    t         j                  j                  |        y)r   N)r   r   r   r   s    r   r   zListAlpha.Argsg   s       ,,V4r   c           	   #   >  K   | j                   j                  t        j                         |j                        }t        j                  t        j                  | j                  j                  |d|j                  |j                              }|D ]  }|  y w)Nr   r   r    r$   )r,   r-   r.   paginated_resourcesresources        r    _YieldPrintableResourcesOnErrorsz*ListAlpha._YieldPrintableResourcesOnErrorsr   s     mmAA""$?? B G
 &==  KK!!**~~	'( (n (s   BBc                     t        j                  | j                  | j                  t	        j
                         |j                        }|j                  ryy)NTF)r   FetchDeploymentr*   r%   r   r'   r   update)r,   r-   r   s      r   _isDeploymentInPreviewz ListAlpha._isDeploymentInPreview   sB    ,,T[[$---4-?-?-A-1__>J r   c                    |j                  d      rt        t        |   |       n<| j	                  |      rt
        j                  |_        nt
        j                  |_        t        j                  | j                  |            S )r   format)IsSpecifiedsuperr8   r/   rA   r
   LIST_PREVIEWED_RESOURCES_FORMATrC   LIST_RESOURCES_FORMATr   r(   r=   )r,   r-   	__class__s     r   r/   zListAlpha.Run   sk     !It &		$	$T	*??dk55dk..--d35 5r   )
r0   r1   r2   r3   r5   r   r=   rA   r/   __classcell__)rH   s   @r   r8   r8   _   s0    
 5 5 5 5r   r8   N)r3   
__future__r   r   r   apitools.base.pyr   )googlecloudsdk.api_lib.deployment_managerr   r   googlecloudsdk.callioper	   -googlecloudsdk.command_lib.deployment_managerr
   ReleaseTracksReleaseTrackGABETAUseDmApiDmApiVersionV2ListCommand	DmCommandr   ALPHAr8   r6   r   r   <module>rY      s      &  ' ' A = ( E D%%(($*;*;*@*@A'&&))*==4W.. == + B==@ D%%++,'&&,,-?5 ?5 . -?5r   