
                            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  ej                   ej"                  j$                        ej&                   G d dej(                                      Zy)zPCommand for updating a Cloud Security Command Center RemediationIntent resource.    )absolute_import)division)print_function)unicode_literals)encoding)sps_api)base)flags)logc                   0    e Zd ZdZdddZed        Zd Zy)Updatez&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                 ^   t         j                  j                  |        t         j                  j                  | d       t	        j
                  |        t        j                  j                  |        t        j                  j                  |        | j                  j                  d       y )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ArgszUpdate.Args>   sr    OO'OOvu-	))&1	++77?	&&v.
!!&)    c                    t        j                  t        j                  j                        }t        j
                  t        j                  j                        }|j                  d}n|j                  }|j                  j                  j                         }|j                         }|j                  |t        j                  |j                  |j                        |      }|j                   j#                  |      }|j$                  }	|j&                  r"t(        j*                  j-                  d|	       |S t        j.                  t        j0                  |	      dd      S )a	  The 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   Runz
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____doc__detailed_helpstaticmethodr   rC    r   r   r   r      s2     /	H-8 * *1r   r   N)rG   
__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   rJ   r   r   <module>rT      sq    W &  % ' % B ( D # D%%++,YT Y  -Yr   