
    P                        S 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
r\
R                  R                  S\
R                  R                   S0r\
R                  R                  4S jr\
R                  R                  4S jr\
R                  R                  4S jrS\
R                  R                  \R*                  " SS94S jrg)z/Utility functions to call Security Posture API.    )absolute_import)division)unicode_literalsN)apis)waiter)base)	resourcessecurityposturev1alphav1c                 b    [         R                  U 5      n[        R                  " [        U5      $ N)VERSION_MAPgetr   GetMessagesModuleAPI_NAMErelease_trackapi_versions     =lib/googlecloudsdk/api_lib/scc/remediation_intents/sps_api.pyr   r   $   #    .+			+	66    c                 b    [         R                  U 5      n[        R                  " [        U5      $ r   )r   r   r   GetClientInstancer   r   s     r   r   r   )   r   r   c                 f    [         R                  R                  U S[        R	                  U5      S9$ )zOperations to Resource used for `waiter.WaitFor`.

Args:
  operation_id: The operation ID for which resource reference is required.
  release_track: The release track to use for the API version.

Returns:
  The resource reference for the operation.
z2securityposture.organizations.locations.operations)
collectionr   )r	   REGISTRYParseRelativeNamer   r   )operation_idr   s     r   GetOperationsRefr    .   s4     
			-	-E//-0 
. 
 r   FiX  )secondsc                     [        U5      nUR                  nUR                  nU(       a  [        R                  " Xg5      nO[        R
                  " U5      n[        R                  " XXR                  S-  S9n	U	$ )a  Waits for an operation to complete.

Polls the Security Posture Operations service until the operation completes,
fails, or max_wait_seconds elapses.

Args:
  operation_ref: A Resource created by GetOperationRef describing the
    Operation.
  message: The message to display to the user while they wait.
  has_result: If True, the function will return the target of the operation
    when it completes. If False, nothing will be returned.
  release_track: The release track to use for the API version.
  max_wait: The time to wait for the operation to succeed before timing out.

Returns:
  if has_result = True, a RemediationIntent entity.
  Otherwise, None.
i  )max_wait_ms)r   *organizations_locations_remediationIntents"organizations_locations_operationsr   CloudOperationPollerCloudOperationPollerNoResourcesWaitForr!   )
operation_refmessage
has_resultr   max_waitclientresource_clientoperations_clientpollerresponses
             r   WaitForOperationr2   ?   ss    2 ]+&EE/??((F
 334EFF^^W2B2BT2I( 
/r   )__doc__
__future__r   r   r   datetimegooglecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r   ReleaseTrackALPHAGAr   r   r   r    	timedeltar2    r   r   <module>r>      s    6 &  '  , . ( ) Y$ %)$5$5$;$; 7
 %)$5$5$;$; 7
 261B1B1H1H ( ##)),'r   