
    C                     Z    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\	5      r
g	)
z6API utilities for gcloud compute vpn-tunnels commands.    )absolute_import)division)unicode_literals)poller)waiterc                       \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	  SS jr
   SS	 jr    SS
 jr      SS jr    SS jr   SS jrS rS rS rS rSS jrS rSrg)VpnTunnelHelper   z1Helper for VPN tunnel service in the Compute API.c                 H    UR                   U l        UR                  U l        g)zxInitializes the helper for VPN tunnel operations.

Args:
  holder: Object representing the Compute API holder instance.
N)client_compute_client	resources
_resources)selfholders     Clib/googlecloudsdk/api_lib/compute/vpn_tunnels/vpn_tunnels_utils.py__init__VpnTunnelHelper.__init__   s     "==D&&DO    c                 .    U R                   R                  $ N)r   apitools_clientr   s    r   _clientVpnTunnelHelper._client%   s    ///r   c                 .    U R                   R                  $ r   )r   messagesr   s    r   	_messagesVpnTunnelHelper._messages)   s    (((r   c                 .    U R                   R                  $ r   )r   
vpnTunnelsr   s    r   _serviceVpnTunnelHelper._service-   s    <<"""r   Nc                 r    UUUUUUUUU	U
US.nU(       a  Ub  XS'   U R                   R                  " S0 UD6$ )aP  Returns the HA VpnTunnel message for an insert request.

Args:
  name: String representing the name of the VPN tunnel resource.
  description: String representing the description for the VPN tunnel
    resource.
  ike_version: The IKE protocol version for establishing the VPN tunnel.
  peer_ip: String representing the peer IP address for the VPN tunnel.
  shared_secret: String representing the shared secret (IKE pre-shared key).
  vpn_gateway: String representing the VPN Gateway URL the VPN tunnel
    resource should be associated with.
  vpn_gateway_interface: Integer representing the VPN Gateway interface ID
    that VPN tunnel resource should be associated with.
  router: String representing the Router URL the VPN tunnel resource should
    be associated with.
  peer_external_gateway: String representing of the peer side external VPN
    gateway to which the VPN tunnel is connected.
  peer_external_gateway_interface: Interface ID of the External VPN gateway
    to which this VPN tunnel is connected.
  peer_gcp_gateway:  String representing of peer side HA GCP VPN gateway to
    which this VPN tunnel is connected.
  params: Dictionary of params to set on the request.
  support_tagging_at_creation: Boolean representing the support of tagging
    at creation.

Returns:
  The VpnTunnel message object that can be used in an insert request.
)namedescription
ikeVersionpeerIpsharedSecret
vpnGatewayvpnGatewayInterfacerouterpeerExternalGatewaypeerExternalGatewayInterfacepeerGcpGatewayparams r   	VpnTunnel)r   r%   r&   ike_versionpeer_ipshared_secretvpn_gatewayvpn_gateway_interfacer,   peer_external_gatewaypeer_external_gateway_interfacepeer_gcp_gatewayr0   support_tagging_at_creationvpn_tunnel_argss                  r   %GetHighAvailabilityVpnTunnelForInsert5VpnTunnelHelper.GetHighAvailabilityVpnTunnelForInsert1   s^    Z "!%!44(G*O 	$(:"(h>>## 
 r   c                 t    UUUUUUUUU	U
UUS.nU(       a  Ub  XS'   U R                   R                  " S0 UD6$ )a  Returns the HA VpnTunnel message for an insert request.

Args:
  name: String representing the name of the VPN tunnel resource.
  description: String representing the description for the VPN tunnel
    resource.
  ike_version: The IKE protocol version for establishing the VPN tunnel.
  peer_ip: String representing the peer IP address for the VPN tunnel.
  shared_secret: String representing the shared secret (IKE pre-shared key).
  vpn_gateway: String representing the VPN Gateway URL the VPN tunnel
    resource should be associated with.
  vpn_gateway_interface: Integer representing the VPN Gateway interface ID
    that VPN tunnel resource should be associated with.
  router: String representing the Router URL the VPN tunnel resource should
    be associated with.
  peer_external_gateway: String representing of the peer side external VPN
    gateway to which the VPN tunnel is connected.
  peer_external_gateway_interface: Interface ID of the External VPN gateway
    to which this VPN tunnel is connected.
  peer_gcp_gateway:  String representing of peer side HA GCP VPN gateway to
    which this VPN tunnel is connected.
  cipher_suite: String representing the cipher suite to use for the VPN
    tunnel.
  params: Dictionary of params to set on the request.
  support_tagging_at_creation: Boolean representing the support of tagging
    at creation.

Returns:
  The VpnTunnel message object that can be used in an insert request.
)r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   cipherSuiter0   r1   r2   )r   r%   r&   r4   r5   r6   r7   r8   r,   r9   r:   r;   cipher_suiter0   r<   r=   s                   r   4GetHighAvailabilityVpnTunnelForInsertWithCipherSuiteDVpnTunnelHelper.GetHighAvailabilityVpnTunnelForInsertWithCipherSuiteq   sa    ` "!%!44(G*#O 	$(:"(h>>## 
 r   c           	          UUUUUUU=(       d    / U=(       d    / S.nU
(       a  U	b  XS'   U R                   R                  " S0 UD6$ )a.  Returns the Classic VpnTunnel message for an insert request.

Args:
  name: String representing the name of the VPN tunnel resource.
  description: String representing the description for the VPN tunnel
    resource.
  ike_version: The IKE protocol version for establishing the VPN tunnel.
  peer_ip: String representing the peer IP address for the VPN tunnel.
  shared_secret: String representing the shared secret (IKE pre-shared key).
  target_vpn_gateway: String representing the Target VPN Gateway URL the VPN
    tunnel resource should be associated with.
  local_traffic_selector: List of strings representing the local CIDR ranges
    that should be able to send traffic using this VPN tunnel.
  remote_traffic_selector: List of strings representing the remote CIDR
    ranges that should be able to send traffic using this VPN tunnel.
  params: Dictionary of params to set on the request.
  support_tagging_at_creation: Boolean representing the support of tagging
    at creation.

Returns:
  The VpnTunnel message object that can be used in an insert request.
)r%   r&   r'   r(   r)   targetVpnGatewaylocalTrafficSelectorremoteTrafficSelectorr0   r1   r2   )r   r%   r&   r4   r5   r6   target_vpn_gatewaylocal_traffic_selectorremote_traffic_selectorr0   r<   r=   s               r   GetClassicVpnTunnelForInsert,VpnTunnelHelper.GetClassicVpnTunnelForInsert   s_    D "!%. 6 <"!8!>B	O 	$(:"(h>>## 
 r   c                     UUUUUUUU=(       d    / U	=(       d    / U
S.
nU(       a  Ub  XS'   U R                   R                  " S0 UD6$ )a  Returns the Classic VpnTunnel message for an insert request.

Args:
  name: String representing the name of the VPN tunnel resource.
  description: String representing the description for the VPN tunnel
    resource.
  ike_version: The IKE protocol version for establishing the VPN tunnel.
  peer_ip: String representing the peer IP address for the VPN tunnel.
  shared_secret: String representing the shared secret (IKE pre-shared key).
  target_vpn_gateway: String representing the Target VPN Gateway URL the VPN
    tunnel resource should be associated with.
  router: String representing the Router URL the VPN tunnel resource should
    be associated with.
  local_traffic_selector: List of strings representing the local CIDR ranges
    that should be able to send traffic using this VPN tunnel.
  remote_traffic_selector: List of strings representing the remote CIDR
    ranges that should be able to send traffic using this VPN tunnel.
  cipher_suite: The cipher suite to use during IKE negotiation.
  params: Dictionary of params to set on the request.
  support_tagging_at_creation: Boolean representing the support of tagging
    at creation.

Returns:
  The VpnTunnel message object that can be used in an insert request.
)
r%   r&   r'   r(   r)   rF   r,   rG   rH   rA   r0   r1   r2   )r   r%   r&   r4   r5   r6   rI   r,   rJ   rK   rB   r0   r<   r=   s                 r   +GetClassicVpnTunnelForInsertWithCipherSuite;VpnTunnelHelper.GetClassicVpnTunnelForInsertWithCipherSuite   se    T "!%. 6 <"!8!>B#O 	$(:"(h>>## 
 r   c                     U R                   R                  5       nU(       a  X5l        U(       a  Xl        U(       a  X%l        U(       a  XEl        U(       d  U(       d  U(       d  U(       a  U$ g)z?Returns the phase 1 algorithms message object for a VPN tunnel.N)r   VpnTunnelPhase1Algorithmsdh
encryption	integrityprf)r   phase1_encryptionphase1_integrity	phase1_dh
phase1_prfphase1_algorithmss         r   GetVpnTunnelPhase1Algorithms,VpnTunnelHelper.GetVpnTunnelPhase1Algorithms#  sO    
 @@B&%6"$4!(&*:jr   c                     U R                   R                  5       nU(       a  Xl        U(       a  X$l        U(       a  X4l        U(       d  U(       d  U(       a  U$ g)z?Returns the phase 2 algorithms message object for a VPN tunnel.N)r   VpnTunnelPhase2AlgorithmsrT   rU   pfs)r   phase2_encryptionphase2_integrity
phase2_pfsphase2_algorithmss        r   GetVpnTunnelPhase2Algorithms,VpnTunnelHelper.GetVpnTunnelPhase2Algorithms6  sC     @@B%6"$4!(-r   c                 r    [         R                  " U R                  U5      n[        R                  " XBU5      $ )an  Waits for the specified operation to complete and returns the target.

Args:
  vpn_tunnel_ref: The VPN tunnel reference object.
  operation_ref: The operation reference object to wait for.
  wait_message: String representing the wait message to display while the
    operation is in progress.

Returns:
  The resulting resource object after the operation completes.
)r   Pollerr"   r   WaitFor)r   vpn_tunnel_refoperation_refwait_messageoperation_pollers        r   WaitForOperation VpnTunnelHelper.WaitForOperationF  s+     }}T]]NC>>*<HHr   c                     U R                   R                  UR                  UR                  US9nU R                  R                  U5      nU R                  R                  UR                  SS9$ )a   Sends an Insert request for a VPN tunnel and returns the operation.

Args:
  ref: The VPN tunnel reference object.
  vpn_tunnel: The VPN tunnel message object to use in the insert request.

Returns:
  The operation reference object for the insert request.
projectregion	vpnTunnelcompute.regionOperations
collection)	r   ComputeVpnTunnelsInsertRequestrr   rs   r"   Insertr   ParseselfLink)r   ref
vpn_tunnelrequest	operations        r   CreateVpnTunnelHelper.CreateU  sk     nn;;CJJ* < FG$$W-I??  'A ! C Cr   c                     U R                   R                  UR                  UR                  UR	                  5       S9nU R
                  R                  U5      $ )zSends a Get request for a VPN tunnel and returns the resource.

Args:
  ref: The VPN tunnel reference object.

Returns:
  The VPN tunnel resource object.
rq   )r   ComputeVpnTunnelsGetRequestrr   rs   Namer"   Get)r   r|   r~   s      r   DescribeVpnTunnelHelper.Describee  sH     nn88CJJ#((* 9 FG==W%%r   c                     U R                   R                  UR                  UR                  UR	                  5       S9nU R
                  R                  U5      nU R                  R                  UR                  SS9$ )zSends a Delete request for a VPN tunnel and returns the operation.

Args:
  ref: The VPN tunnel reference object.

Returns:
  The operation reference object for the delete request.
rq   ru   rv   )
r   ComputeVpnTunnelsDeleteRequestrr   rs   r   r"   Deleter   rz   r{   )r   r|   r~   r   s       r   r   VpnTunnelHelper.Deleter  sq     nn;;CJJ#((* < FG$$W-I??  'A ! C Cr   c           	   #     #    U(       aq  U Hj  nSn U R                   R                  UUUUSS9nU R                  R                  U5      nUR                  nUR
                   H  nUv   M	     U(       d  Mj  Mf     gSn U R                   R                  XUSS9nU R                  R                  U5      nUR                  nUR
                  R                   H$  n	U	R                  R                   H  nUv   M	     M&     U(       d  gM  7f)a  Yields a VPN tunnel resource from the list of VPN tunnels.

Sends an AggregatedList request to obtain the list of VPN tunnels and
yields the next VPN tunnel in this list.

Sends a List request to obtain the list of VPN tunnels in the specified
regions and yields the next VPN tunnel in this list.

Args:
  project: String representing the project to use for the request.
  filter_expr: The expression used to filter the results.
  regions: List of regions to list VPN tunnels from. If not specified,
    aggregated list is used.
NT)rr   rs   filter	pageTokenreturnPartialSuccess)rr   r   r   r   )r   ComputeVpnTunnelsListRequestr"   ListnextPageTokenitems&ComputeVpnTunnelsAggregatedListRequestAggregatedListadditionalPropertiesvaluer!   )
r   rr   filter_exprregionsrs   next_page_tokenr~   responser}   scoped_vpn_tunnelss
             r   r   VpnTunnelHelper.List  s     &NN?? '#' @ ' ]]''0($22/$NNj +     O
EE# F %g --g6h ..o ( C C
,22==J
 > !D  s   DDc                 .   U R                   R                  X#S9nU R                   R                  UR                  UR                  UR                  5       US9nU R                  R                  U5      nU R                  R                  UR                  SS9$ )a+  Sends a SetLabels request for a VPN tunnel and returns the operation.

Args:
  ref: The VPN tunnel reference object.
  existing_label_fingerprint: The existing label fingerprint.
  new_labels: List of new label key, value pairs.

Returns:
  The operation reference object for the SetLabels request.
)labelFingerprintlabels)rr   rs   resourceregionSetLabelsRequestru   rv   )r   RegionSetLabelsRequest!ComputeVpnTunnelsSetLabelsRequestrr   rs   r   r"   	SetLabelsr   rz   r{   )r   r|   existing_label_fingerprint
new_labelsset_labels_requestr~   r   s          r   r   VpnTunnelHelper.SetLabels  s     >>3 ? Hnn>>zz1	 ? 3G
 ''0I??  'A ! C Cr   )r   r   )NF)NNF)NNNF)NNNNNF)NNNN)NNNr   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r"   r>   rC   rL   rO   r\   re   rn   r   r   r   r   r   __static_attributes__r1   r   r   r	   r	      s    9' 0 0 ) ) # #  "'>Z "'BV ;?;?*.?D0t !""':x <@48-1.2& <@48.2 IC &C,\Cr   r	   N)r   
__future__r   r   r   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   objectr	   r1   r   r   <module>r      s)    = &  ' < .kCf kCr   