
    d                        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S
KJr  \R                  R                   S\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 S5      rg)zAPI Wrapper lib for Cloud IDS.    )absolute_import)division)unicode_literalsN)
list_pager)apis)waiter)base)	resourcesv1c                 Z    [         R                  U 5      n[        R                  " SU5      $ Nids)_VERSION_MAPgetr   GetMessagesModulerelease_trackapi_versions     )lib/googlecloudsdk/api_lib/ids/ids_api.pyr   r   $   %      /+			{	33    c                 Z    [         R                  U 5      n[        R                  " SU5      $ r   )r   r   r   GetClientInstancer   s     r   r   r   )   r   r   c                 Z    [         R                  U 5      n[        R                  " SU5      $ r   )r   r   r   GetEffectiveApiEndpointr   s     r   r   r   .   s%      /+		%	%e[	99r   c                       \ rS rSrSrS rS r    SS jrS rS r	S	 r
SS
 jrS rS rS\R                  " SS94S jrS rS rSS jrSrg)Client3   zAPI client for IDS commands.c                 x   [        U5      U l        U R                  R                  U l        U R                  R                  U l        U R                  R                  U l        [        U5      U l	        [        R                  " 5       U l        U R                  R                  S[        R                  U5      5        g r   )r   _clientprojects_locations_endpoints_endpoint_clientprojects_locations_operations_operations_clientprojects_locations_locations_clientr   messagesr
   Registry_resource_parserRegisterApiByNamer   r   )selfr   s     r   __init__Client.__init__6   s    $]3DL LLEED"llHHD!\\<<D%m4DM%..0D++E,8,<,<],KMr   c                 |    U R                   R                  R                  R                  UR	                  5       5      $ )N)r'   EndpointSeverityValueValuesEnumlookup_by_nameupper)r+   severity_names     r   _ParseSeverityLevelClient._ParseSeverityLevel@   s1    ==!!99HH r   Nc	           	          U R                   R                  UUU R                  U5      UUUS9n	U R                   R                  XU	S9n
U R                  R                  U
5      $ )zCalls the CreateEndpoint API.)networkdescriptionseveritythreatExceptionstrafficLogslabels)
endpointIdparentendpoint)r'   r/   r4   *IdsProjectsLocationsEndpointsCreateRequestr"   Create)r+   namer>   r7   r9   threat_exceptionsr8   enable_traffic_logsr<   r?   reqs              r   CreateEndpointClient.CreateEndpointD   sr     }}%%))(3*' & H --
B
B C ;C  '',,r   c                     U R                   R                  UUS9nU R                   R                  XSR                  U5      S9nU R                  R                  U5      $ )zCalls the UpdateEndpoint API.)rB   r:   ,)rB   r?   
updateMask)r'   r/   )IdsProjectsLocationsEndpointsPatchRequestjoinr"   Patch)r+   rB   rC   update_maskr?   rE   s         r   UpdateEndpointClient.UpdateEndpointY   se    
 }}%%* & ,H --
A
A+1F B HC  &&s++r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zCalls the DeleteEndpoint API.rB   )r'   *IdsProjectsLocationsEndpointsDeleteRequestr"   Deleter+   rB   rE   s      r   DeleteEndpointClient.DeleteEndpointe   s0    
--
B
B
B
MC  '',,r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zCalls the GetEndpoint API.rR   )r'   'IdsProjectsLocationsEndpointsGetRequestr"   GetrU   s      r   DescribeEndpointClient.DescribeEndpointj   s0    
--
?
?T
?
JC  $$S))r   c           	      z    U R                   R                  XS9n[        R                  " U R                  UUUSSS9$ )zCalls the ListEndpoints API.)r>   filter	endpointspageSize
batch_sizelimitfieldbatch_size_attribute)r'   (IdsProjectsLocationsEndpointsListRequestr   YieldFromListr"   )r+   r>   rc   	page_sizelist_filterrE   s         r   ListEndpointsClient.ListEndpointso   sJ    
--
@
@ A +C##') )r   c                 p    U R                   R                  SU-   S9nU R                  R                  U5      $ )zCalls the ListLocations API.z	projects/rR   )r'   IdsProjectsLocationsListRequestr&   List)r+   projectrE   s      r   GetSupportedLocationsClient.GetSupportedLocations{   s<    
--
7
7[8?>@
7 AC!!&&s++r   c                 N    U R                   R                  UR                  S5      $ )zKConverts an Operation to a Resource that can be used with `waiter.WaitFor`.z!ids.projects.locations.operations)r)   ParseRelativeNamerB   )r+   	operations     r   GetOperationRefClient.GetOperationRef   s%      22;= =r   TiX  )secondsc                     U(       a,  [         R                  " U R                  U R                  5      nO [         R                  " U R                  5      n[         R
                  " XQX$R                  S-  S9$ )a  Waits for an operation to complete.

Polls the IDS Operation 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 (the IDS Endpoint) when it completes. If False, nothing will
    be returned (useful for Delete operations)
  max_wait:
    The time to wait for the operation to succeed before timing out.

Returns:
  if has_result = True, an Endpoint entity.
  Otherwise, None.
i  )max_wait_ms)r   CloudOperationPollerr"   r$   CloudOperationPollerNoResourcesWaitForrw   )r+   operation_refmessage
has_resultmax_waitpollers         r   WaitForOperationClient.WaitForOperation   sd    4 **4+@+@+/+B+BDf 55d6M6MNf>>w4D4Dt4KM Mr   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zCalls the CancelOperation API.rR   )r'   +IdsProjectsLocationsOperationsCancelRequestr$   CancelrU   s      r   CancelOperationsClient.CancelOperations   s0    
--
C
C
C
NC""))#..r   c                 j    U R                   R                  US9nU R                  R                  U5      $ )zCalls the Operations API.rR   )r'   (IdsProjectsLocationsOperationsGetRequestr$   rZ   rU   s      r   DescribeOperationClient.DescribeOperation   s0    
--
@
@d
@
KC""&&s++r   c           	      z    U R                   R                  XS9n[        R                  " U R                  UUUSSS9$ )zCalls the ListOperations API.)rB   r^   
operationsr`   ra   )r'   )IdsProjectsLocationsOperationsListRequestr   rg   r$   )r+   rB   rc   rh   ri   rE   s         r   ListOperationsClient.ListOperations   sJ    
--
A
A B 'C##') )r   )r    r"   r&   r$   r)   r'   )  FN)NNN)__name__
__module____qualname____firstlineno____doc__r,   r4   rF   rO   rV   r[   rj   rp   ru   datetime	timedeltar   r   r   r   __static_attributes__r   r   r   r   r   3   sj    $M (*!#). -*
,-
*

),= #' ( 2 23 ?	!MF/
,

)r   r   )r   
__future__r   r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.callioper	   googlecloudsdk.corer
   ReleaseTrackALPHABETAGAr   r   r   r   r   r   r   r   <module>r      s    % &  '  ' , . ( ) 	TD$ %)$5$5$8$8 4
 %)$5$5$8$8 4
 +/*;*;*>*> :
J) J)r   