
                            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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  SSKJr  \R.                  " \R0                  R2                  \R0                  R4                  \R0                  R6                  5      \R8                   " S S\R:                  5      5       5       rS rS r g)zLCommand for Updating Cloud Security Command Center finding's security marks.    )absolute_import)division)print_function)unicode_literals)encoding)securitycenter_client)arg_parsers)base)flags)util)
properties)timesc                   :    \ rS rSrSrSSSS.r\S 5       rS rSr	g	)
UpdateMarks"   z8Update Security Command Center finding's security marks.aP  
      Selectively update security mark `Key1` with value `v1` on testFinding. Note
      that other security marks on `testFinding` are untouched:

        $ {command} `testFinding` --organization=123456 --source=5678
          --security-marks="key1=v1" --update-mask="marks.markKey1"

      Update all security marks on `testFinding`, under project `example-project`
      and source `5678`:

        $ {command} projects/example-project/sources/5678/findings/testFinding
          --security-marks="key1=v1,key2=v2"

      Update all security marks on `testFinding`, under folder `456` and source
      `5678`:

        $ {command} folders/456/sources/5678/findings/testFinding
          --security-marks="key1=v1,key2=v2"

      Update all security marks on `testFinding`, under organization `123456` and
      source `5678`:

        $ {command} `testFinding` --organization=123456 --source=5678
          --security-marks="key1=v1,key2=v2"

      Delete all security marks on `testFinding`:

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

      Update all security marks on `testFinding`, under project `example-project`,
      source `5678` and `location=eu`:

        $ {command} projects/example-project/sources/5678/findings/testFinding
          --security-marks="key1=v1,key2=v2" --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                 p   [         R                  R                  U 5        [         R                  R                  U 5        [         R                  " U 5        [
        R                  R                  U 5        [
        R                  R                  U 5        [        R                  " SS[        R                  " 5       SS9R                  U 5        U R                  SSS9  U R                  SS	S9  U R                  R                  [        R                   R"                  R$                  R'                  5       5        g )
Nz--security-marksz
        SecurityMarks resource to be passed as the request body. It's a
        key=value pair separated by comma (,). For example:
        --security-marks="key1=val1,key2=val2".z	KEY=VALUE)helptypemetavarz--start-timez
        Time at which the updated SecurityMarks take effect. See `$ gcloud topic
        datetimes` for information on supported time formats.)r   z--update-maskaL  
        Use update-mask if you want to selectively update marks represented by
        --security-marks flag. For example:
        --update-mask="marks.key1,marks.key2". If you want to override all the
        marks for the given finding either skip the update-mask flag or provide
        an empty value (--update-mask '') for it.)r   FINDING_FLAGAddToParserSOURCE_FLAGAddParentGroup	scc_flagsAPI_VERSION_FLAGLOCATION_FLAGr
   Argumentr	   ArgDictadd_argumentdisplay_info	AddFormatr   VALUEScoredefault_formatGet)parsers    (lib/surface/scc/findings/update_marks.pyArgsUpdateMarks.ArgsU   s     
""6*	!!&)	 **62''/MM3   " k&
A   5   !!*"3"3"8"8"G"G"K"K"MN    c                 Z   [        U5      n[        R                  " U5      nUR                  5       nUR                  (       a;  [
        R                  " UR                  5      n[
        R                  " U5      Ul        [        R                  " U5      nUR                  Ul        US:X  aQ  UR                  5       n[        R                  " UR                  UR                  R                   5      Ul        Xtl        OVUS:X  aP  UR'                  5       n[        R                  " UR                  UR&                  R                   5      Ul        Xtl        [+        XU5      nUR                  b%  [,        R.                  " UR                  5      Ul        UR0                  R3                  U5      nU$ )Nv1v2)_GetApiVersionr   GetMessagesDSecuritycenterOrganizationsSourcesFindingsUpdateSecurityMarksRequest
start_timer   ParseDateTimeFormatDateTime	startTime	GetClientupdate_mask
updateMaskSecurityMarksr   DictToMessagesecurity_marks
MarksValuemarkssecurityMarks(GoogleCloudSecuritycenterV2SecurityMarks(googleCloudSecuritycenterV2SecurityMarks_ValidateParentAndUpdateNamescc_utilCleanUpUserMaskInputorganizations_sources_findingsUpdateSecurityMarks)	selfargsversionmessagesrequeststart_time_dtclientr<   r>   s	            r)   RunUpdateMarks.Runy   sW   T"G$009HUUW  ))$//:m..}=g",,W5F))G$--/n%33


x55@@n -	DHHJn%33




;
;
F
Fn :H6*4'BG%#889K9KLg11EEgNELr,    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr*   rN   __static_attributes__rP   r,   r)   r   r   "   s?    
 A I">FrO*-X !O !OF r,   r   c                 n    [         R                  " U 5        [         R                  " X5      S-   Ul        U$ )zAGenerate a security mark's name using org, source and finding id.z/securityMarks)r   .ValidateMutexOnFindingAndSourceAndOrganizationGetFullFindingNamename)rH   reqrI   s      r)   rB   rB      s-    55d;$$T36FF#(	*r,   c                 J    S/n[         R                  " X R                  U5      $ )zADetermine what version to call from --location and --api-version.r3   )rC   GetVersionFromArgumentsfinding)rH   deprecated_argss     r)   r0   r0      s     !N/		)	)$o	NNr,   N)!rU   
__future__r   r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.sccr   googlecloudsdk.callioper	   r
   googlecloudsdk.command_lib.sccr   r   r   rC   'googlecloudsdk.command_lib.scc.findingsgooglecloudsdk.corer   googlecloudsdk.core.utilr   ReleaseTracksReleaseTrackGABETAALPHADefaultUniverseOnlyUpdateCommandr   rB   r0   rP   r,   r)   <module>rq      s    S &  % ' % < / ( = ; 9 8 * * $++00$2C2C2I2I s$$$ s slOr,   