def get_connection(client_email, private_key_path): """Shortcut method to establish a connection to the Cloud Datastore. Use this if you are going to access several datasets with the same set of credentials (unlikely): >>> import gclouddatastore >>> connection = gclouddatastore.get_connection(email, key_path) >>> dataset1 = connection.dataset('dataset1') >>> dataset2 = connection.dataset('dataset2') :type client_email: string :param client_email: The e-mail attached to the service account. :type private_key_path: string :param private_key_path: The path to a private key file (this file was given to you when you created the service account). :rtype: :class:`gclouddatastore.connection.Connection` :returns: A connection defined with the proper credentials. """ from connection import Connection from credentials import Credentials credentials = Credentials.get_for_service_account( client_email, private_key_path) return Connection(credentials=credentials)
def get_connection(dataset_id, client_email=None, private_key_path=None): credentials = Credentials.get_for_service_account( client_email, private_key_path) return Connection(dataset_id, credentials=credentials)