
    !                        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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  SSKJr  \
R,                  " \
R.                  R0                  \
R.                  R2                  \
R.                  R4                  5      \
R6                   " S S\
R8                  5      5       5       rS rS rg)z:Command to Update a Cloud Security Command Center finding.    )absolute_import)division)print_function)unicode_literalsN)securitycenter_client)base)flags)util)log)
properties)timesc                   :    \ rS rSrSrSSSS.r\S 5       rS rSr	g	)
Update#   z)Update a Security Command Center finding.a  
        Update testFinding's state from `ACTIVE` to `INACTIVE`:

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

        Update testFinding's state from `ACTIVE` to `INACTIVE` using project name
        for example-project:

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

        Update testFinding's state from `ACTIVE` to `INACTIVE` using folder name
        `456`:

          $ {command} folders/456/sources/5678/findings/testFinding
            --state=INACTIVE

        Override all source properties on `testFinding`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --source-properties="propKey1=propVal1,propKey2=propVal2"

        Selectively update a specific source property on `testFinding`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --source-properties="propKey1=propVal1,propKey2=propVal2" --update-mask="source_properties.propKey1"

        Update finding `testFinding` with `location=eu`, state from `ACTIVE` to
        `INACTIVE`:

          $ {command} `testFinding` --organization=123456 --source=5678
            --state=INACTIVE --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                    [         R                  R                  U 5        [         R                  R                  U 5        [         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                  R                  [        R                   R"                  R$                  R'                  5       5        g )Nz--update-maska  
        Optional: If left unspecified (default), an update-mask is automatically
        created using the flags specified in the command and only those values
        are updated. For example: --external-uri='<some-uri>'
        --event-time='<some-time>' would automatically generate
        --update-mask='external_uri,event_time'. Note that as a result, only
        external-uri and event-time are updated for the given finding and
        everything else remains untouched. If you want to delete
        attributes/properties (that are not being changed in the update command)
        use an empty update-mask (''). That will delete all the mutable
        properties/attributes that aren't specified as flags in the update
        command. In the above example it would delete source-properties.
        State can be toggled from ACTIVE to INACTIVE and vice-versa but it
        cannot be deleted.)help)r	   FINDING_FLAGAddToParserSOURCE_FLAGAddParentGroupEVENT_TIME_FLAG_NOT_REQUIREDEXTERNAL_URI_FLAGSOURCE_PROPERTIES_FLAG
STATE_FLAG	scc_flagsAPI_VERSION_FLAGLOCATION_FLAGadd_argumentdisplay_info	AddFormatr   VALUEScoredefault_formatGet)parsers    "lib/surface/scc/findings/update.pyArgsUpdate.ArgsR   s     
""6*	!!&)	 	&&226:	''/	  ,,V4	  (**62''/
  " !!*"3"3"8"8"G"G"K"K"MN    c                 ~   [         R                  " XR                  5      n[        R                  " U5      nUR                  5       nUR                  Ul        UR                  (       dz  SSSSS.nSUl        UR                  5        H$  nXe;   d  M
  U=R                  SXV   -   -  sl        M&     UR                  R                  S5      (       a  UR                  SS  Ul        US	:X  a  UR                  5       Ul        UR                  UR                  l        UR                  (       a0  [        R                  " UR                  U5      UR                  l        [        R"                  " UR$                  U5      UR                  l        OUR'                  5       Ul        UR                  UR(                  l        UR                  (       a0  [        R                  " UR                  U5      UR(                  l        [        R"                  " UR$                  U5      UR(                  l        [+        X5      Ul        [         R.                  " UR                  5      Ul        [1        XU5      n[        R2                  " U5      nUR4                  R7                  U5      n[8        R:                  R=                  S
5        U$ )N	eventTimeexternalUrisourcePropertiesstate)z--event-timez--external-uriz--source-propertiesz--state ,   v1zUpdated.)scc_utilGetVersionFromArgumentsfindingr   GetMessages6SecuritycenterOrganizationsSourcesFindingsPatchRequestupdate_mask
updateMaskGetSpecifiedArgNames
startswithFindingexternal_urir.   source_propertiesr
   ConvertSourcePropertiesr/   ConvertStateInputr0   "GoogleCloudSecuritycenterV2Finding"googleCloudSecuritycenterV2Finding_GenerateFindingNamenameCleanUpUserMaskInput_UpdateEventTime	GetClientorganizations_sources_findingsPatchr   statusPrint)	selfargsversionmessagesrequestmutable_fieldsargclientresponses	            r(   Run
Update.Runq   s,   ..t\\BG$009HMMOG))G
 %)!3	n g**,# 


n&9 9
9
 -
 
			&	&s	+	+$//3$ ((*go$($5$5goo!			+/+G+G""G,
( #44TZZIgoo 
5
5
7 0 @D?P?Pg00<			(()?)?I 	22C :>9O9O
**g:g006 (6GL!66w7I7IJGtg6G",,W5F44::7CHJJZ Or+    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr)   rW   __static_attributes__rY   r+   r(   r   r   #   s=    
 2 A .BrG&-P O O<7r+   r   c                 Z    [         R                  " U 5        [         R                  " X5      $ )z;Generate a finding's name using org, source and finding id.)r
   .ValidateMutexOnFindingAndSourceAndOrganizationGetFullFindingName)rO   rP   s     r(   rE   rE      s!    55d;		 	 	//r+   c                    U R                   (       aq  [        R                  " U R                   5      nUS:X  a&  [        R                  " U5      UR                  l        O%[        R                  " U5      UR                  l        U R                   c  [        R                  R                  [        R                  R                  S9R                  S5      nUS:X  aF  UR                  c(  [        R                  " 5       R                  5       Ul        XAR                  l        OEUR                  c(  [        R                  " 5       R                  5       Ul        XAR                  l        UR                   S-   Ul        U$ )z0Process and include the event time of a finding.r4   )tzz%Y-%m-%dT%H:%M:%S.%fZz,event_time)
event_timer   ParseDateTimeFormatDateTimer7   r-   rD   datetimenowtimezoneutcstrftimer   r8   r>   rC   r;   )rO   reqrP   event_time_dtrg   s        r(   rH   rH      s    
__''8M$#22=Ackk9>9M9M
:c,,6
 
__""&&(*;*;*?*?&@IIJ $		+779AAC(kk		/	/	7!--/RRT 	. :D,,6^^m3CN	*r+   ) r^   
__future__r   r   r   r   rj   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sccr	   r   r
   r5   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.corer   r   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackGAALPHABETADefaultUniverseOnlyUpdateCommandr   rE   rH   rY   r+   r(   <module>r      s    A &  % '  < ( = ; 9 8 # * * $++1143D3D3I3I AT A AH0r+   