
    d                        d Z ddlmZ ddlmZ ddlmZ ddl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                  j                   dej                  j"                  dej                  j$                  diZej                  j$                  fdZej                  j$                  fdZej                  j$                  fdZ G d d      Zy)zAPI Wrapper lib for Cloud IDS.    )absolute_import)division)unicode_literalsN)
list_pager)apis)waiter)base)	resourcesv1c                 X    t         j                  |       }t        j                  d|      S Nids)_VERSION_MAPgetr   GetMessagesModulerelease_trackapi_versions     )lib/googlecloudsdk/api_lib/ids/ids_api.pyr   r   $   %      /+			{	33    c                 X    t         j                  |       }t        j                  d|      S r   )r   r   r   GetClientInstancer   s     r   r   r   )   r   r   c                 X    t         j                  |       }t        j                  d|      S r   )r   r   r   GetEffectiveApiEndpointr   s     r   r   r   .   s%      /+		%	%e[	99r   c                       e Zd ZdZd Zd Z	 	 	 	 ddZd Zd Zd Z	dd	Z
d
 Zd Zd ej                  d      fdZd Zd ZddZy)ClientzAPI client for IDS commands.c                 v   t        |      | _        | j                  j                  | _        | j                  j                  | _        | j                  j                  | _        t        |      | _	        t        j                         | _        | j                  j                  dt        j                  |             y 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__zClient.__init__6   s    $]3DL LLEED"llHHD!\\<<D%m4DM%..0D++E,8,<,<],KMr   c                 |    | j                   j                  j                  j                  |j	                               S )N)r&   EndpointSeverityValueValuesEnumlookup_by_nameupper)r*   severity_names     r   _ParseSeverityLevelzClient._ParseSeverityLevel@   s1    ==!!99HH r   Nc	                     | j                   j                  ||| j                  |      |||      }	| j                   j                  |||	      }
| j                  j                  |
      S )zCalls the CreateEndpoint API.)networkdescriptionseveritythreatExceptionstrafficLogslabels)
endpointIdparentendpoint)r&   r-   r2   *IdsProjectsLocationsEndpointsCreateRequestr!   Create)r*   namer;   r4   r6   threat_exceptionsr5   enable_traffic_logsr9   r<   reqs              r   CreateEndpointzClient.CreateEndpointD   st     }}%%))(3*' & H --
B
B C ;C  '',,r   c                     | j                   j                  ||      }| j                   j                  ||dj                  |            }| j                  j                  |      S )zCalls the UpdateEndpoint API.)r?   r7   ,)r?   r<   
updateMask)r&   r-   )IdsProjectsLocationsEndpointsPatchRequestjoinr!   Patch)r*   r?   r@   update_maskr<   rB   s         r   UpdateEndpointzClient.UpdateEndpointY   sg    
 }}%%* & ,H --
A
AH+1F B HC  &&s++r   c                 p    | j                   j                  |      }| j                  j                  |      S )zCalls the DeleteEndpoint API.r?   )r&   *IdsProjectsLocationsEndpointsDeleteRequestr!   Deleter*   r?   rB   s      r   DeleteEndpointzClient.DeleteEndpointe   s0    
--
B
B
B
MC  '',,r   c                 p    | j                   j                  |      }| j                  j                  |      S )zCalls the GetEndpoint API.rM   )r&   'IdsProjectsLocationsEndpointsGetRequestr!   GetrP   s      r   DescribeEndpointzClient.DescribeEndpointj   s0    
--
?
?T
?
JC  $$S))r   c                     | j                   j                  ||      }t        j                  | j                  |||dd      S )zCalls the ListEndpoints API.)r;   filter	endpointspageSize
batch_sizelimitfieldbatch_size_attribute)r&   (IdsProjectsLocationsEndpointsListRequestr   YieldFromListr!   )r*   r;   r\   	page_sizelist_filterrB   s         r   ListEndpointszClient.ListEndpointso   sL    
--
@
@k A +C##') )r   c                 v    | j                   j                  d|z         }| j                  j                  |      S )zCalls the ListLocations API.z	projects/rM   )r&   IdsProjectsLocationsListRequestr%   List)r*   projectrB   s      r   GetSupportedLocationszClient.GetSupportedLocations{   s<    
--
7
7[8?>@
7 AC!!&&s++r   c                 N    | j                   j                  |j                  d      S )zKConverts an Operation to a Resource that can be used with `waiter.WaitFor`.z!ids.projects.locations.operations)r(   ParseRelativeNamer?   )r*   	operations     r   GetOperationRefzClient.GetOperationRef   s%      22;= =r   TiX  )secondsc                     |r+t        j                  | j                  | j                        }nt        j                  | j                        }t        j
                  ||||j                  dz        S )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WaitForrm   )r*   operation_refmessage
has_resultmax_waitpollers         r   WaitForOperationzClient.WaitForOperation   sh    4 **4+@+@+/+B+BDf 55d6M6MNf>>wH4D4Dt4KM Mr   c                 p    | j                   j                  |      }| j                  j                  |      S )zCalls the CancelOperation API.rM   )r&   +IdsProjectsLocationsOperationsCancelRequestr#   CancelrP   s      r   CancelOperationszClient.CancelOperations   s0    
--
C
C
C
NC""))#..r   c                 p    | j                   j                  |      }| j                  j                  |      S )zCalls the Operations API.rM   )r&   (IdsProjectsLocationsOperationsGetRequestr#   rT   rP   s      r   DescribeOperationzClient.DescribeOperation   s0    
--
@
@d
@
KC""&&s++r   c                     | j                   j                  ||      }t        j                  | j                  |||dd      S )zCalls the ListOperations API.)r?   rW   
operationsrY   rZ   )r&   )IdsProjectsLocationsOperationsListRequestr   r`   r#   )r*   r?   r\   ra   rb   rB   s         r   ListOperationszClient.ListOperations   sL    
--
A
A+ B 'C##') )r   )  FN)NNN)__name__
__module____qualname____doc__r+   r2   rC   rK   rQ   rU   rc   rh   rl   datetime	timedeltarx   r|   r   r   r   r   r   r   r   3   sl    $M (*!#). -*
,-
*

),= #' 2 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   