
    +"                     b    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K	r	 " S S	\
5      rg)
z7API utilities for gcloud compute vpn-gateways commands.    )absolute_import)division)unicode_literals)poller)waiterNc                       \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	    SS jr
S	 rS
 rS rS rSS jrS rSrg)VpnGatewayHelper   z2Helper for VPN gateway service in the Compute API.c                 H    UR                   U l        UR                  U l        g)zyInitializes the helper for VPN Gateway operations.

Args:
  holder: Object representing the Compute API holder instance.
N)client_compute_client	resources
_resources)selfholders     Elib/googlecloudsdk/api_lib/compute/vpn_gateways/vpn_gateways_utils.py__init__VpnGatewayHelper.__init__   s     "==D&&DO    c                 .    U R                   R                  $ N)r   apitools_clientr   s    r   _clientVpnGatewayHelper._client&   s    ///r   c                 .    U R                   R                  $ r   )r   messagesr   s    r   	_messagesVpnGatewayHelper._messages*   s    (((r   c                 .    U R                   R                  $ r   )r   vpnGatewaysr   s    r   _serviceVpnGatewayHelper._service.   s    <<###r   Nc	           	         Sn	Sn
Ub%  U R                   R                  R                  U5      n	Ub%  U R                   R                  R                  U5      n
UUUU	U
S.nUbn  / n[	        UR                  5       5       HK  u  pUR                  U R                   R                  [        U5      [        R                  " U5      S95        MM     XS'   U(       a  Ub  X{S'   U R                   R                  " S0 UD6$ )a  Returns the VpnGateway message for an insert request.

Args:
  name: String representing the name of the VPN Gateway resource.
  description: String representing the description for the VPN Gateway
    resource.
  network: String representing the network URL the VPN gateway resource
    belongs to.
  vpn_interfaces_with_interconnect_attachments: Dict representing pairs
    interface id and interconnected attachment associated with vpn gateway
    on this interface.
  stack_type: Enum presenting the stack type of the vpn gateway resource.
  gateway_ip_version: Enum presenting the gateway IP version of the vpn
    gateway resource.
  params: Dict representing the resource manager tags for the VPN gateway
    resource.
  support_tagging_at_creation: Boolean representing whether tagging is
    supported at creation time.

Returns:
  The VpnGateway message object that can be used in an insert request.
N)namedescriptionnetwork	stackTypegatewayIpVersion)idinterconnectAttachmentvpnInterfacesparams )r   
VpnGatewayStackTypeValueValuesEnumGatewayIpVersionValueValuesEnumsorteditemsappendVpnGatewayVpnGatewayInterfaceintsix	text_type)r   r%   r&   r'   ,vpn_interfaces_with_interconnect_attachments
stack_typegateway_ip_versionr-   support_tagging_at_creationtarget_stack_typetarget_gateway_ip_versionvpn_gateway_argsvpn_interfaceskeyvalues                  r   GetVpnGatewayForInsert'VpnGatewayHelper.GetVpnGatewayForInsert2   s   B  $..33LL
 %
..
#
#
C
C    "&5 4?n
6
<
<
>*# 	NN88s8CMM%4H 9 	
 +9' 	$#)x >>$$8'788r   c                 r    [         R                  " U R                  U5      n[        R                  " XBU5      $ )ap  Waits for the specified operation to complete and returns the target.

Args:
  vpn_gateway_ref: The VPN Gateway 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_gateway_refoperation_refwait_messageoperation_pollers        r   WaitForOperation!VpnGatewayHelper.WaitForOperation|   s+     }}T]]OD>>*<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 Gateway and returns the operation.

Args:
  ref: The VPN Gateway reference object.
  vpn_gateway: The VPN Gateway message object to use in the insert request.

Returns:
  The operation reference object for the insert request.
projectregion
vpnGatewaycompute.regionOperations
collection)	r   ComputeVpnGatewaysInsertRequestrP   rQ   r"   Insertr   ParseselfLink)r   refvpn_gatewayrequest	operations        r   CreateVpnGatewayHelper.Create   sk     nn<<CJJ; = H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 Gateway and returns the resource.

Args:
  ref: The VPN Gateway reference object.

Returns:
  The VPN Gateway resource object.
rO   )r   ComputeVpnGatewaysGetRequestrP   rQ   Namer"   Get)r   rZ   r\   s      r   DescribeVpnGatewayHelper.Describe   sH     nn99CJJ388: : G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 Gateway and returns the operation.

Args:
  ref: The VPN Gateway reference object.

Returns:
  The operation reference object for the delete request.
rO   rS   rT   )
r   ComputeVpnGatewaysDeleteRequestrP   rQ   rb   r"   Deleter   rX   rY   )r   rZ   r\   r]   s       r   rh   VpnGatewayHelper.Delete   sq     nn<<CJJ388: = G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 Gateway resource from the list of VPN Gateways.

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

Sends a List request to obtain the list of VPN Gateways in the specified
regions and yields the next VPN Gateway 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 use for the request.
NT)rP   rQ   filter	pageTokenreturnPartialSuccess)rP   rk   rl   rm   )r   ComputeVpnGatewaysListRequestr"   ListnextPageTokenr3   'ComputeVpnGatewaysAggregatedListRequestAggregatedListadditionalPropertiesrB   r!   )
r   rP   filter_exprregionsrQ   next_page_tokenr\   responser[   scoped_vpn_gatewayss
             r   ro   VpnGatewayHelper.List   s     &NN@@ '#' A ' ]]''0($22/%^^k ,     O
FF# G %g --g6h ..o!)!D!D
.44@@K
 A "E  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 Gateway and returns the operation.

Args:
  ref: The VPN Gateway 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)rP   rQ   resourceregionSetLabelsRequestrS   rT   )r   RegionSetLabelsRequest"ComputeVpnGatewaysSetLabelsRequestrP   rQ   rb   r"   	SetLabelsr   rX   rY   )r   rZ   existing_label_fingerprint
new_labelsset_labels_requestr\   r]   s          r   r   VpnGatewayHelper.SetLabels   s     >>3 ? Hnn??zz1	 @ 3G
 ''0I??  'A ! C Cr   )r   r   )NNNFr   )__name__
__module____qualname____firstlineno____doc__r   propertyr   r   r"   rC   rL   r^   rd   rh   ro   r   __static_attributes__r.   r   r   r	   r	      s~    :' 0 0 ) ) $ $ "'H9TIC &C+ZCr   r	   )r   
__future__r   r   r   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr   r7   objectr	   r.   r   r   <module>r      s,    > &  ' < . 
_Cv _Cr   