
    <                         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	J
r
  SrS rS	 rS
 rS rS rS rS rS rS rS rS rS rg)z&services vpc-peering helper functions.    )absolute_import)division)unicode_literals)
exceptions)apiszprojects/%s/global/networks/%sc                 d   [        5       nUR                  nUR                  SU-   UR                  [        X4-  US9S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a@  Make API call to create a connection to a specific service.

Args:
  project_number: The number of the project for which to peer the service.
  service: The name of the service to peer with.
  network: The network in consumer project to peer with.
  ranges: The names of IP CIDR ranges for peering service to use.

Raises:
  exceptions.CreateConnectionsPermissionDeniedException: when the create
      connection API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The result of the create connection operation.
	services/networkreservedPeeringRanges)parent
connectionN)_GetClientInstanceMESSAGES_MODULE1ServicenetworkingServicesConnectionsCreateRequest
ConnectionNETWORK_URL_FORMATservices_connectionsCreateapitools_exceptionsHttpForbiddenErrorHttpNotFoundErrorr   ReraiseError*CreateConnectionsPermissionDeniedException)project_numberservicer   rangesclientmessagesrequestes           .lib/googlecloudsdk/api_lib/services/peering.pyCreateConnectionr#      s    $ &##( FF7"$$$'@@ & %  G '&&--g66,,++
  	:@@ 	   A $B/ %B**B/c                 b   [        5       nUR                  nUR                  SU-  UR                  [        X4-  S9S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to delete an existing connection to a specific service.

Args:
  project_number: The number of the project which is peered to the service.
  service: The name of the service peered with.
  network: The network in consumer project peered with.

Raises:
  exceptions.DeleteConnectionsPermissionDeniedException: when the delete
      connection API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The result of the delete connection operation.
services/%s/connections/-consumerNetwork)namedeleteConnectionRequestN)r   r   ;ServicenetworkingServicesConnectionsDeleteConnectionRequestDeleteConnectionRequestr   r   DeleteConnectionr   r   r   r   r   *DeleteConnectionsPermissionDeniedExceptionr   r   r   r   r   r    r!   s          r"   r-   r-   D   s    " &##( JJ*W4"*"B"B0N3LL #C # K  
&&77@@,,++
  	:@@ 	    A $B.?%B))B.c                 f   [        5       nUR                  nUR                  SU-  UR                  [        X4-  US9US9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to update a connection to a specific service.

Args:
  project_number: The number of the project for which to peer the service.
  service: The name of the service to peer with.
  network: The network in consumer project to peer with.
  ranges: The names of IP CIDR ranges for peering service to use.
  force: If true, update the connection even if the update can be destructive.

Raises:
  exceptions.UpdateConnectionsPermissionDeniedException: when the update
      connection API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The result of the update connection operation.
r&   r
   )r)   r   forceN)r   r   0ServicenetworkingServicesConnectionsPatchRequestr   r   r   Patchr   r   r   r   r   *UpdateConnectionsPermissionDeniedException)	r   r   r   r   r2   r   r   r    r!   s	            r"   UpdateConnectionr6   l   s    & &##( EE&0$$$'@@ & %   F '&&,,W55,,++
  	:@@ 	s   A $B0%B++B0c                 j   [        5       nUR                  nUR                  SU-   SR                  X5      S9n UR                  R                  U5      R                  $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to list connections of a network for a specific service.

Args:
  project_number: The number of the project for which to peer the service.
  service: The name of the service to peer with.
  network: The network in consumer project to peer with.

Raises:
  exceptions.ListConnectionsPermissionDeniedException: when the list
  connections API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The list of connections.
r	   z projects/{0}/global/networks/{1})r   r   N)r   r   /ServicenetworkingServicesConnectionsListRequestformatr   Listconnectionsr   r   r   r   r   (ListConnectionsPermissionDeniedExceptionr/   s          r"   ListConnectionsr=      s    " &##( DD7"077
 E '&&++G4@@@,,++
  	:>> 	s   $A $B2%B--B2c                 b   [        5       nUR                  nUR                  UR                  [        X4-  S9SU-   S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aF  Make API call to enable VPC service controls for a specific service.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to enable VPC service controls for.
  network: The network in the consumer project peered with the service.

Raises:
  exceptions.EnableVpcServiceControlsPermissionDeniedException: when the
  enable VPC service controls API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The result of the enable VPC service controls operation.
r'   r	   )enableVpcServiceControlsRequestr   N)r   r   8ServicenetworkingServicesEnableVpcServiceControlsRequestEnableVpcServiceControlsRequestr   servicesEnableVpcServiceControlsr   r   r   r   r   1EnableVpcServiceControlsPermissionDeniedExceptionr/   s          r"   rC   rC      s    " &##( MM&.&N&N,/HH 'O ' 7"	 N '??33G<<,,++
  	:GG 	r0   c                 H   [        5       nUR                  nUR                  SU< SU < SU< 3S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a?  Make API call to get VPC service controls for a specific service.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to get VPC service controls for.
  network: The network in the consumer project peered with the service.

Raises:
  exceptions.GetVpcServiceControlsPermissionDeniedException: when the
  get VPC service controls API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
  service.

Returns:
  The state of the VPC service controls for the peering connection.
r	   
/projects//global/networks/r)   N)r   r   KServicenetworkingServicesProjectsGlobalNetworksGetVpcServiceControlsRequest!services_projects_global_networksGetVpcServiceControlsr   r   r   r   r   .GetVpcServiceControlsPermissionDeniedExceptionr/   s          r"   rK   rK      s    " &##(``	.'+ a '
33II  ,,++
  	:DD 	s   A $B!2%BB!c                 b   [        5       nUR                  nUR                  UR                  [        X4-  S9SU-   S9n UR
                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)aK  Make API call to disable VPC service controls for a specific service.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to disable VPC service controls for.
  network: The network in the consumer project peered with the service.

Raises:
  exceptions.DisableVpcServiceControlsPermissionDeniedException: when the
  disable VPC service controls API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The result of the disable VPC service controls operation.
r'   r	   ) disableVpcServiceControlsRequestr   N)r   r   9ServicenetworkingServicesDisableVpcServiceControlsRequest DisableVpcServiceControlsRequestr   rB   DisableVpcServiceControlsr   r   r   r   r   2DisableVpcServiceControlsPermissionDeniedExceptionr/   s          r"   rQ   rQ     s    " &##( NN'/'P'P,/HH (Q ( 7"	 O '??44W==,,++
  	:HH 	r0   c                 d   [        5       nUR                  nUR                  SU< SU < SU< 3UR                  XCS9S9n UR                  R                  U5      $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a  Make API call to create a peered DNS domain for a specific connection.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to create a peered DNS domain for.
  network: The network in the consumer project peered with the service.
  name: The name of the peered DNS domain.
  dns_suffix: The DNS domain name suffix of the peered DNS domain.

Raises:
  exceptions.CreatePeeredDnsDomainPermissionDeniedException: when the create
  peered DNS domain API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
  service.

Returns:
  The result of the create peered DNS domain operation.
r	   rF   rG   )	dnsSuffixr)   )r   peeredDnsDomainN)r   r   LServicenetworkingServicesProjectsGlobalNetworksPeeredDnsDomainsCreateRequestPeeredDnsDomain2services_projects_global_networks_peeredDnsDomainsr   r   r   r   r   r   .CreatePeeredDnsDomainPermissionDeniedException)	r   r   r   r)   
dns_suffixr   r   r    r!   s	            r"   CreatePeeredDnsDomainr[   ,  s    & &##( aa	.'+...O b '
DDKK  ,,++
  	AA 	r$   c           
      P   [        5       nUR                  nUR                  SU< SU < SU< SU< 3S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)ae  Make API call to delete a peered DNS domain for a specific connection.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to delete a peered DNS domain for.
  network: The network in the consumer project peered with the service.
  name: The name of the peered DNS domain.

Raises:
  exceptions.DeletePeeredDnsDomainPermissionDeniedException: when the delete
  peered DNS domain API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
  service.

Returns:
  The result of the delete peered DNS domain operation.
r	   rF   rG   z/peeredDnsDomains/rH   N)r   r   LServicenetworkingServicesProjectsGlobalNetworksPeeredDnsDomainsDeleteRequestrX   Deleter   r   r   r   r   .DeletePeeredDnsDomainPermissionDeniedException)r   r   r   r)   r   r   r    r!   s           r"   DeletePeeredDnsDomainr`   V  s    $ &##( aa	.'41 b 'DDKK  ,,++
  	AA 	s   A $B%6%B  B%c                 \   [        5       nUR                  nUR                  SU< SU < SU< 3S9n UR                  R	                  U5      R
                  $ ! [        R                  [        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a%  Make API call to list the peered DNS domains for a specific connection.

Args:
  project_number: The number of the project which is peered with the service.
  service: The name of the service to list the peered DNS domains for.
  network: The network in the consumer project peered with the service.

Raises:
  exceptions.ListPeeredDnsDomainsPermissionDeniedException: when the delete
  peered DNS domain API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
  service.

Returns:
  The list of peered DNS domains.
r	   rF   rG   )r   N)r   r   JServicenetworkingServicesProjectsGlobalNetworksPeeredDnsDomainsListRequestrX   r:   peeredDnsDomainsr   r   r   r   r   -ListPeeredDnsDomainsPermissionDeniedExceptionr/   s          r"   ListPeeredDnsDomainsre   ~  s    " &##( __	.'+ ` 'DDII ,,++
  	@@ 	s   $A $B+<%B&&B+c                 0   [        5       nUR                  nUR                  U S9n UR                  R	                  U5      $ ! [
        R                  [
        R                  4 a/  n[        R                  " U[        R                  5         SnAgSnAff = f)a#  Make API call to get an operation.

Args:
  name: The name of operation.

Raises:
  exceptions.OperationErrorException: when the getting operation API fails.
  apitools_exceptions.HttpError: Another miscellaneous error with the peering
      service.

Returns:
  The long running operation.
rH   N)r   r   %ServicenetworkingOperationsGetRequest
operationsGetr   r   r   r   r   OperationErrorException)r)   r   r   r    r!   s        r"   GetOperationrk     s     &##(:::E'C  )),,++
 C AzAABB	Cs   A $B&%BBc                  .    [         R                  " SSSS9$ )Nservicenetworkingv1F)no_http)r   GetClientInstance     r"   r   r     s    			 3T5	IIrr   N)__doc__
__future__r   r   r   apitools.base.pyr   r   googlecloudsdk.api_lib.servicesgooglecloudsdk.api_lib.utilr   r   r#   r-   r6   r=   rC   rK   rQ   r[   r`   re   rk   r   rq   rr   r"   <module>rx      sj    - &  ' > 6 ,5 %P%P'T#L#L!H#L'T%P$NC4Jrr   