
                            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  e	j$                  e	j&                  j(                  e	j&                  j*                  e	j&                  j,                        e	j.                   G d de	j0                                      Zd Zd Zy)z/Command for listing a finding's security marks.    )absolute_import)division)print_function)unicode_literals)securitycenter_client)base)flags)util)timesc                   2    e Zd ZdZddddZed        Zd Zy)	ListMarksz List a finding's security marks.a  
        List all security marks for `testFinding` under organization `123456` and
        source `5678`:

          $ {command} `testFinding` --organization=123456 --source=5678

        List all security marks for `testFinding` under project `example-project`
        and source `5678`:

          $ {command} projects/example-project/sources/5678/findings/testFinding

        List all security marks for `testFinding` under folder `456` and source
        `5678`:

          $ {command} folders/456/sources/5678/findings/testFinding

        List all security marks for `testFinding` under organization `123456`,
        source `5678` and `location=eu`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --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   t         j                  j                  |        t        j                  j                  |        t        j                  j                  |        t        j                  j                  |        t        j                  j                  |        t        j                  j                  |        t        j                  j                  |        | j                  d      }|j                  dd       |j                  dd       |j                  dd	       y )
NF)requiredz--organizationz:The organization ID (e.g., 123) that contains the finding.)helpz--folderz4The folder ID (e.g., 456) that contains the finding.z	--projectzAThe project ID (e.g., example-project) that contains the finding.)r   URI_FLAGRemoveFromParserr	   FINDING_FLAGAddToParserSOURCE_FLAG	scc_flagsPAGE_TOKEN_FLAGREAD_TIME_FLAGAPI_VERSION_FLAGLOCATION_FLAGadd_mutually_exclusive_groupadd_argument)parsergroups     &lib/surface/scc/findings/list_marks.pyArgszListMarks.ArgsB   s     	MM""6* 
""6*	!!&)))&1((0**62''////?E	I   
C   
O      c                    t        |      }t        j                  |      }|j                         }|j                  |_        |dk(  r[|j                  d      rJ|j                  |_        t        j                  |j                        }t        j                  |      |_        t        |||      }t        j                  |      }|j                  j                  |      }t!        j"                  |j$                  |      }|S )Nv1	read_time)_GetApiVersionr   GetMessages5SecuritycenterOrganizationsSourcesFindingsListRequest
page_token	pageTokenIsKnownAndSpecifiedr&   readTimer   ParseDateTimeFormatDateTime_GenerateParent	GetClientorganizations_sources_findingsListr
    ExtractSecurityMarksFromResponselistFindingsResults)	selfargsversionmessagesrequestread_time_dtclientlist_findings_responseresponses	            r!   RunzListMarks.Run_   s    T"G$009HLLNG G$433K@g(()9)9:l--l;gdGW5G",,W5F#BBGGP 4422DH Or#   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr"   r?    r#   r!   r   r      s7    
 ) 8*r/-8  8r#   r   c                     t        j                  |        t        j                  | |      }t        j                  ||      |_        dt        j
                  |       d|_        |S )zCGenerates a finding's parent and adds filter based on finding name.zname : "")r
   .ValidateMutexOnFindingAndSourceAndOrganizationGetFullFindingNameGetSourceParentFromFindingNameparentGetFindingIdFromNamefilter)r7   reqr8   finding_names       r!   r0   r0   x   sW    55d;((w7,22<I#*444\BC2F#*	*r#   c                 L    ddg}t        j                  | | j                  |      S )zADetermine what version to call from --location and --api-version.compare_durationr&   )scc_utilGetVersionFromArgumentsfinding)r7   deprecated_argss     r!   r'   r'      s*    '5/		)	)
DLL/
 r#   N)rC   
__future__r   r   r   r   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r   r
   rS   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.core.utilr   ReleaseTracksReleaseTrackGABETAALPHADefaultUniverseOnlyListCommandr   r0   r'   rF   r#   r!   <module>rd      s    6 &  % ' < ( = ; 9 8 * $++00$2C2C2I2I R   R Rjr#   