
                         ^    d 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 d Z	 G d d	      Z
y
)z1Cloud database migration private connections API.    )absolute_import)division)unicode_literals)api_util)	resourcesc                 x    t         j                  j                  | j                  d      }|j	                         S )Nz3datamigration.projects.locations.privateConnections)
collection)r   REGISTRYParseRelativeNamenameSelfLink)resourceprivate_connections     Dlib/googlecloudsdk/api_lib/database_migration/private_connections.pyGetPrivateConnectionURIr      s:     ));;mmF < H 
	$	$	&&    c                   ,    e Zd ZdZddZd ZddZd Zy)	PrivateConnectionsClientz2Client for private connections service in the API.Nc                     |xs t        j                  |      | _        |xs t        j                  |      | _        | j                  j
                  | _        t        j                  |      | _        y N)	r   GetClientInstance_clientGetMessagesModule	_messages%projects_locations_privateConnections_serviceGetResourceParser_resource_parser)selfrelease_trackclientmessagess       r   __init__z!PrivateConnectionsClient.__init__#   sT    FX77FDLJ!;!;M!JDNLLFFDM$66}EDr   c                    | j                   j                  |i |j                        }|j                  d      r-| j                   j	                  |j
                        |_        |S |j                  j                  j                         }| j                   j                  |j                         |j                        |_        |S )z$Returns a private connection object.)r   labelsdisplayNamenetwork_attachment)networkAttachment)vpcNamesubnet)r   PrivateConnectiondisplay_nameIsKnownAndSpecifiedPscInterfaceConfigr'   pscInterfaceConfigCONCEPTSvpcParseVpcPeeringConfigRelativeNamer*   vpcPeeringConfig)r   private_connection_idargsprivate_connection_objvpc_peering_refs        r   _GetPrivateConnectionz.PrivateConnectionsClient._GetPrivateConnection)   s    !^^=="24;L;L > N 45
..
+
+ $ 7 7 ,  / "! ))//1o040O0O!..0 1P 1- "!r   c                 "   | j                  ||      }t        j                         }| j                  j                  } |||j
                  |||j                        }|j                  d      rd|_        | j                  j                  |      S )a  Creates a private connection.

    Args:
      parent_ref: a Resource reference to a parent
        datamigration.projects.locations resource for this private connection.
      private_connection_id: str, the name of the resource to create.
      args: argparse.Namespace, The arguments that this command was invoked
        with.

    Returns:
      Operation: the operation for creating the private connection.
    )privateConnectionprivateConnectionIdparent	requestIdvalidateOnlyskip_validationT)r:   r   GenerateRequestIdr   =DatamigrationProjectsLocationsPrivateConnectionsCreateRequestr   validate_onlyr-   skipValidationr   Create)r   
parent_refr6   r7   r   
request_idcreate_req_type
create_reqs           r   rF   zPrivateConnectionsClient.Create;   s     334I4P++-JTT  !,.33'')J  12"&j==
++r   c                     t        j                         }| j                  j                  } |||      }| j                  j                  |      S )zDeletes a private connection.

    Args:
      private_connection_name: str, the name of the resource to delete.

    Returns:
      Operation: the operation for deleting the private connection.
    )r   r?   )r   rB   r   =DatamigrationProjectsLocationsPrivateConnectionsDeleteRequestr   Delete)r   private_connection_namerH   delete_req_type
delete_reqs        r   rM   zPrivateConnectionsClient.DeleteZ   sL     ++-J	F	F  !$
<J ==
++r   )NNr   )__name__
__module____qualname____doc__r#   r:   rF   rM    r   r   r   r       s    :F"$,>,r   r   N)rT   
__future__r   r   r   )googlecloudsdk.api_lib.database_migrationr   googlecloudsdk.corer   r   r   rU   r   r   <module>rY      s*    8 &  ' > )'K, K,r   