
                            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  ej$                  ej&                  j(                        ej*                   G d dej,                                      Z ej$                  ej&                  j0                        ej*                   G d dej,                                      Zy)zWCommand for listing all the Cloud Security Command Center postures for an organization.    )absolute_import)division)print_function)unicode_literals)
list_pager)util)base)errors)flagsc                   2    e Zd ZdZddddZed        Zd Zy)	ListILists all the Cloud Security Command Center postures for an organization.^
          Lists all the Cloud Security Command Center postures for an
          organization.  
          To list all the Cloud Security Command Center postures for an
          organization `123`
          and in the `global` location, run:

            $ {command} organizations/123/locations/global

            $ {command} --organization=123 --location=global

            z
      This command uses the securityposture/v1 API. The full documentation for
    this API can be found at: https://cloud.google.com/security-command-centerDESCRIPTIONEXAMPLESzAPI REFERENCEc                 l    t         j                  j                  |        t        j                  |        y Nr	   URI_FLAGRemoveFromParserr   AddParentOrFlagsGroupparsers     lib/surface/scc/postures/list.pyArgsz	List.Args8   &     	MM""6* 
'    c           	      0   t        j                  |d      }t        j                  t        j
                  j                        }t        j                  t        j
                  j                        }t        j                  ||      }|j                  d      r|j                  }nt        j                  |       d| }|j                  |t        |dd       t        |dd             }t        j                  |j                   |d|j"                  d	
      S )NT"version_specific_existing_resourcePARENT/locations/filter	page_sizeparentr%   pageSizer)   posturesbatch_size_attribute
batch_sizefield)scc_utilGetVersionFromArgumentssecurityposture_clientGetMessagesModuler	   ReleaseTrackGAGetClientInstanceValidateAndGetLocationIsKnownAndSpecifiedr#    GetParentFromPositionalArguments8SecuritypostureOrganizationsLocationsPosturesListRequestgetattrr   YieldFromList organizations_locations_posturesr&   selfargsversionmessagesclientlocationr(   requests           r   RunzList.Run@   s    ..G &778I8I8L8LMH#55d6G6G6J6JKF..tW=H  *{{f;;DAB+hZXf OOtXt,{D1 P G ##//'>> r   N__name__
__module____qualname____doc__detailed_helpstaticmethodr   rE    r   r   r   r      s8     R	R-* ( (r   r   c                   2    e Zd ZdZddddZed        Zd Zy)		ListAlphar   r   r   z
      This command uses the securityposture/v1alpha API. The full documentation
      for this API can be found at:
      https://cloud.google.com/security-command-centerr   c                 l    t         j                  j                  |        t        j                  |        y r   r   r   s    r   r   zListAlpha.Argsx   r   r   c           	      0   t        j                  |d      }t        j                  t        j
                  j                        }t        j                  t        j
                  j                        }t        j                  ||      }|j                  d      r7|j                  d      r&|j                  d      rt        j                  d      |j                  d      r|j                  }nR|j                  d      r,|j                  d      rt        j                  |       d| }nt        j                  d      |j                  |t!        |d	d       t!        |d
d             }t#        j$                  |j&                  |d|j(                  d      S )NTr!   r#   organizationrC   z^Cannot provide both a positional `PARENT` and argument (`--organization`, `--location`) flags.r$   zXMust provide either positional `PARENT` or both `--organization` and `--location` flags.r%   r&   r'   r)   r*   r+   )r/   r0   r1   r2   r	   r3   ALPHAr5   r6   r7   IsSpecifiedr
   InvalidSCCInputErrorr#   r8   r9   r:   r   r;   r<   r&   r=   s           r   rE   zListAlpha.Run   sm   ..G &778I8I8O8OPH#55d6G6G6M6MNF..tW=H  *(T-=-=j-I''4 
 	  *{{f


>
*t/?/?
/K;;DAB+hZXf''$  OOtXt,{D1 P G ##//'>> r   NrF   rM   r   r   rO   rO   _   s7     R	:-( ( ()r   rO   N)rJ   
__future__r   r   r   r   apitools.base.pyr   #googlecloudsdk.api_lib.scc.posturesr   r1   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sccr
   r/   'googlecloudsdk.command_lib.scc.posturesr   ReleaseTracksr3   r4   DefaultUniverseOnlyListCommandr   rS   rO   rM   r   r   <module>r_      s    ^ &  % ' ' N ( 1 ; 9 D%%(()<4 <  *<~ D%%++,H   H  -Hr   