
                             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	 Zd
 Zd Z ej&                  ej(                  j*                         G d dej,                               Zy)z*Implements command to list guest policies.    )absolute_import)division)unicode_literals)
list_pager)utils)base)
propertiesc                 Z    d}| j                  dd      }t        |      |kD  r|d| dz   S |S )z2Returns a length-limited guest policy description.   description Nz..)getlen)resourcemax_lenr   s      4lib/surface/compute/os_config/guest_policies/list.py _TransformGuestPolicyDescriptionr      sG     ']B/+{#g- hw

 ?3>?    c                       fd}|S )zFReturns a transformation function from a guest policy resource to URI.c                     | j                   j                  d      d   }j                  | j                   dj                  |            }|j	                         S )N/r   zosconfig.{}.guestPolicies)
collection)namesplitParseformatSelfLink)r   parent_typerefregistrys      r   UriFuncz _MakeGetUriFunc.<locals>.UriFunc(   sS    --%%c*1-K
...55kB  DC <<>r    )r    r!   s   ` r   _MakeGetUriFuncr#   %   s     
.r   c                     | j                   j                  d       | j                   j                  dt        i       t	        j
                  |      }| j                   j                  t        |             y)z.Parses input flags and sets up output formats.z
        table(
          name.basename(),
          description(),
          create_time,
          update_time
        )
      r   N)display_info	AddFormatAddTransformsr   osconfig_api_utilsGetRegistry
AddUriFuncr#   )parserrelease_trackr    s      r   _Argsr-   2   se     	 !
  	##679++M:(  !:;r   c                   &    e Zd ZdZed        Zd Zy)ListzList guest policies in a project.

  ## EXAMPLES

    To list guest policies in the current project, run:

          $ {command}

  c                 L    t        | t        j                  j                         y)See base class.N)r-   r   ReleaseTrackBETA)r+   s    r   Argsz	List.ArgsO   s     
&$##(()r   c                    | j                         }t        j                  |      }t        j                  |      }t        j
                  j                  j                  j                         }|j                  |j                  t        j                  |            }|j                  }t        j                  |||j                   t        j"                  |      dd      S )r1   )pageSizeparentguestPoliciesr6   )limit
batch_sizefieldbatch_size_attribute)r2   r(   GetClientInstanceGetClientMessagesr	   VALUEScoreproject	GetOrFail(OsconfigProjectsGuestPoliciesListRequest	page_sizeosconfig_command_utilsGetProjectUriPathprojects_guestPoliciesr   YieldFromListr9   GetListBatchSize)selfargsr,   clientmessagesrA   requestservices           r   RunzList.RunT   s    %%'M11-@F!33MBH$$,,668G??%77@ @ G ++G##jj)::4@' r   N)__name__
__module____qualname____doc__staticmethodr4   rP   r"   r   r   r/   r/   C   s      * *r   r/   N)rT   
__future__r   r   r   apitools.base.pyr   (googlecloudsdk.api_lib.compute.os_configr   r(   googlecloudsdk.callioper   ,googlecloudsdk.command_lib.compute.os_configrE   googlecloudsdk.corer	   r   r#   r-   ReleaseTracksr2   r3   ListCommandr/   r"   r   r   <module>r^      sk    1 &  ' ' P ( X *?
<" D%%**+$4 $ ,$r   