
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJ	r	  SSK
Jr  SS	K
Jr  SS
KJr  SSKJr  SS
KJr  SSKJr  SSKJr  \R*                  " \R,                  R.                  \R,                  R0                  \R,                  R2                  5       " S S\R4                  5      5       rSS jrg)zdCommand to Filter an organization or source's findings and group them by their specified properties.    )absolute_import)division)print_function)unicode_literalsN)securitycenter_client)arg_parsers)base)flags)util)timesc                   :    \ rS rSrSrSSSS.r\S 5       rS rS	r	g
)Group#   zZFilter an organization or source's findings and groups them by their specified properties.zF
          To group across all sources provide a '-' as the source id.a'  
          Group findings under organization `123456` across all sources by their
          category:

            $ {command} 123456 --group-by="category"

          Group findings under project `example-project` across all sources by
          their category:

            $ {command} projects/example-project --group-by="category"

          Group findings under folders `456` across all sources by their
          category:

            $ {command} folders/456 --group-by="category"

          Group findings under organization `123456` and source `5678`, by their
          category:

            $ {command} 123456 --source=5678 --group-by="category"

          Group ACTIVE findings under organization `123456` and source `5678`,
          by their category:

            $ {command} 123456 --source=5678 --group-by="category"
              --filter="state=\"ACTIVE\""

          Group findings under organization `123456` and `location=eu` across
          all sources by their category:

            $ {command} 123456 --group-by="category" --location=euz
      This command uses the Security Command Center API. For more information,
      see [Security Command Center API.](https://cloud.google.com/security-command-center/docs/reference/rest))DESCRIPTIONEXAMPLESzAPI REFERENCEc           	      l   [         R                  " 5       S   R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [
        R                  R                  U 5        [
        R                  R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        U R                  SSS9  U R                  SSS9  U R                  S[        R                  " S[        R                  S	S
9SS9  g )Nr   z--filtera  
        Expression that defines the filter to apply across findings. The
        expression is a list of one or more restrictions combined via logical
        operators 'AND' and 'OR'. Parentheses are supported, and 'OR' has higher
        precedence than 'AND'. Restrictions have the form
        '<field> <operator> <value>' and may have a '-' character in front of
        them to indicate negation. Examples include: name,
        source_properties.a_property, security_marks.marks.marka.
        The supported operators are:
        *  '=' for all value types.
        *  '>', '<', '>=', '<=' for integer values.
        *  ':', meaning substring matching, for strings.

        The supported value types are:string literals in quotes, integer
        literals without quotes, boolean literals 'true' and 'false' without
        quotes. Some example filters: 'source_properties.size = 100',
        'category=\"XSS\" AND event_time > 10' etc.)helpz
--group-byaS  
        Expression that defines what findings fields to use for grouping
        (including 'state'). String value should follow SQL syntax: comma
        separated list  of fields. For example: "parent,resource_name".
        The following fields are supported:
        * resource_name
        * category
        * state
        * parentz--page-size   T)	unlimitedzx
        Maximum number of results to return in a single response. Default is 10,
        minimum is 1, maximum is 1000.)typer   )	scc_flagsAppendParentArgAddToParserPAGE_TOKEN_FLAGREAD_TIME_FLAGr
   COMPARE_DURATION_FLAGSOURCE_FLAGAPI_VERSION_FLAGLOCATION_FLAGadd_argumentr   
BoundedIntsysmaxsize)parsers    !lib/surface/scc/findings/group.pyArgs
Group.ArgsP   s    "..v6))&1((0	++F3	!!&)**62''/
9  *    ##As{{dC*      c                    SS/n[         R                  " X5      n[        R                  " U5      nUR	                  5       nUR                  5       Ul        US:X  Ga   UR                  S5      (       aj  UR                  UR                  l	        [        R                  " UR                  R                  5      n[        R                  " U5      UR                  l	        UR                  S5      (       aj  UR                  UR                  l        [        R                  " UR                  R                  5      n[        R                   " U5      UR                  l        UR"                  UR                  l        UR$                  UR                  l        UR(                  UR                  l        UR,                  UR                  l        [1        XU5      n[        R2                  " U5      nUR4                  R7                  U5      n	U	$ )Ncompare_duration	read_timev1)r    GetApiVersionUsingDeprecatedArgsr   GetMessages6SecuritycenterOrganizationsSourcesFindingsGroupRequestGroupFindingsRequestgroupFindingsRequestIsKnownAndSpecifiedr*   compareDurationr   ParseDurationFormatDurationForJsonr+   readTimeParseDateTimeFormatDateTimefiltergroup_bygroupBy	page_sizepageSize
page_token	pageToken_GenerateParentForGroupCommand	GetClientorganizations_sources_findingsr   )
selfargsdeprecated_argsversionmessagesrequestcompare_duration_isoread_time_dtclientresults
             r%   Run	Group.Run   s   );7O33DJG$009HMMOG#+#@#@#BG  $ 
	!	!"4	5	57;7L7L$$4$22((88 
 ''(<= 	$$4 
	!	!+	.	.04$$-**((11
 160D0D1
$$- +/++G  '+/==G  (,0NNG  )-1__G  *,TGDG",,W5F2288AFMr(    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr&   rM   __static_attributes__rO   r(   r%   r   r   #   s=     cIF>rE%-N 1 1f&r(   r   c                    [         R                  " U 5        U R                  UR                  l        SU l        [        R
                  " S5      n[        R                  " U 5      nUR                  U5      (       a  XAl	        U$ [        R
                  " S5      nUR                  U5      (       a  X@l
        [         R                  " X5      Ul	        U$ )zFGenerate a finding's name and parent using org, source and finding id. z](organizations|projects|folders)/[a-z0-9]+/sources/[0-9-]{0,62}/locations/[A-Za-z0-9-]{0,62}$z@(organizations|projects|folders)/[a-z0-9]+/sources/[0-9-]{0,62}$)r   ValidateMutexOnSourceAndParentr9   r1   recompilescc_util GetParentFromPositionalArgumentsmatchparentsourceGetFullSourceName)rD   reqrF   region_resource_paternr`   resource_patterns         r%   r@   r@      s    %%d+$(KK#!$+::e 44T:&!!&))JJZZH F##K%%d4#*	*r(   )r,   )rT   
__future__r   r   r   r   r[   r"   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   r	   googlecloudsdk.command_lib.sccr
   r   r   r]   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.core.utilr   ReleaseTracksReleaseTrackGABETAALPHACommandr   r@   rO   r(   r%   <module>rr      s    k &  % ' 	 
 < / ( = ; 9 8 * $++00$2C2C2I2IDDLL DDNr(   