
                            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  \R                   " \R"                  R$                  5      \R&                   " S S\R(                  5      5       5       rg)zPCommand for updating a Cloud Security Command Center RemediationIntent resource.    )absolute_import)division)print_function)unicode_literals)encoding)sps_api)base)flags)logc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Update   z&Updates a remediation intent resource.a  
        Updates a Cloud Security Command Center (SCC)
        RemediationIntent resource.

        Fields specified in update-mask flag are updated. Updatable fields depends on the state transition.

        Valid state transitions are:

        a) ENQUEUED to IN_PROGRESS (mask: state,remediation_input)

        b) REMEDIATION_SUCCESS to PR_GENERATION_SUCCESS (mask: state,remediation_artifacts)

        c) REMEDIATION_SUCCESS to PR_GENERATION_FAILED (mask: state,error_details)

        An empty or * as field mask will result in updating the relevant fields as per the transition.

        Updated resource is returned as the response of the command.a  
          Sample usage:
          Update the remediation intent resource's state from ENQUEUED to IN_PROGRESS:
          $ {{command}} scc remediation-intents update organizations/123456789/locations/global/remediationIntents/123456789 --ri-from-file=/path/to/resource.yaml --update-mask=state,remediation_input
          

          Update the remediation intent resource's state from ENQUEUED to IN_PROGRESS (with empty update mask):
          $ {{command}} scc remediation-intents update organizations/123456789/locations/global/remediationIntents/123456789 --ri-from-file=/path/to/resource.yaml
          

          Update the remediation intent resource's state from REMEDIATION_SUCCESS to PR_GENERATION_SUCCESS:
          $ {{command}} scc remediation-intents update organizations/123456789/locations/global/remediationIntents/123456789 --ri-from-file=/path/to/resource.yaml --update-mask=state,remediation_artifacts
          

          Update the remediation intent resource's state from REMEDIATION_SUCCESS to PR_GENERATION_FAILED:
          $ {{command}} scc remediation-intents update organizations/123456789/locations/global/remediationIntents/123456789 --ri-from-file=/path/to/resource.yaml --update-mask=state,error_details
          )DESCRIPTIONEXAMPLESc                 `   [         R                  R                  U 5        [         R                  R                  U S5        [        R
                  " U 5        [        R                  R                  U 5        [        R                  R                  U 5        U R                  R                  S5        g )NFyaml)
r	   
ASYNC_FLAGAddToParser
SetDefaultr
   AddRemediationIntentResourceArg!REMEDIATION_INTENT_FROM_FILE_FLAGUPDATE_MASK_FLAGdisplay_info	AddFormat)parsers    -lib/surface/scc/remediation_intents/update.pyArgsUpdate.Args>   sr    OO'OOvu-	))&1	++77?	&&v.
!!&)    c                    [         R                  " [        R                  R                  5      n[         R
                  " [        R                  R                  5      nUR                  c  SnOUR                  nUR                  R                  R                  5       nUR                  5       nUR                  U[        R                  " UR                  UR                  5      US9nUR                   R#                  US9nUR$                  n	UR&                  (       a"  [(        R*                  R-                  SU	5        U$ [         R.                  " [         R0                  " U	5      SSS9$ )zThe main function which is called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.
Returns:
  Operation resource containing either resource or error.
*)nameremediationIntent
updateMask)requestz9Check for operation completion status using operation ID:z,Waiting for remediation intent to be updatedT)operation_refmessage
has_result)r   GetClientInstancer	   ReleaseTrackALPHAGetMessagesModuleupdate_maskCONCEPTSremediationintentParseRelativeNameCSecuritypostureOrganizationsLocationsRemediationIntentsPatchRequestr   DictToMessageri_from_fileRemediationIntent*organizations_locations_remediationIntentsPatchr"   async_r   statusPrintWaitForOperationGetOperationsRef)
selfargsclientmessagesr-   ri_refri_namer%   	operationoperation_ids
             r   Run
Update.RunG   s<    &&t'8'8'>'>?F(():):)@)@AH k$$k ]],,224F!!#G ZZ"00&&
  [ G AAGG H I >>L{{	jj
E
 %%00>@ r    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   rE   __static_attributes__rG   r   r   r   r      s2     /	H-8 * *1r   r   N)rL   
__future__r   r   r   r   apitools.base.pyr   .googlecloudsdk.api_lib.scc.remediation_intentsr   googlecloudsdk.callioper	   2googlecloudsdk.command_lib.scc.remediation_intentsr
   googlecloudsdk.corer   ReleaseTracksr*   r+   UniverseCompatibleUpdateCommandr   rG   r   r   <module>rY      so    W &  % ' % B ( D # D%%++,YT Y  -Yr   