Exemple #1
0
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):

  >>> from gcloud import datastore
  >>> connection = datastore.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:`gcloud.datastore.connection.Connection`
  :returns: A connection defined with the proper credentials.
  """
  from gcloud.credentials import Credentials
  from gcloud.datastore.connection import Connection

  credentials = Credentials.get_for_service_account(
      client_email, private_key_path, scope=SCOPE)
  return Connection(credentials=credentials)
Exemple #2
0
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):

  >>> from gcloud import datastore
  >>> connection = datastore.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:`gcloud.datastore.connection.Connection`
  :returns: A connection defined with the proper credentials.
  """
    from gcloud.credentials import Credentials
    from gcloud.datastore.connection import Connection

    credentials = Credentials.get_for_service_account(client_email,
                                                      private_key_path,
                                                      scope=SCOPE)
    return Connection(credentials=credentials)
Exemple #3
0
def get_connection(project, client_email, private_key_path):
  """Shortcut method to establish a connection to Cloud Storage.

  Use this if you are going to access several buckets
  with the same set of credentials:

  >>> from gcloud import storage
  >>> connection = storage.get_connection(project, email, key_path)
  >>> bucket1 = connection.get_bucket('bucket1')
  >>> bucket2 = connection.get_bucket('bucket2')

  :type project: string
  :param project: The name of the project to connect to.

  :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:`gcloud.storage.connection.Connection`
  :returns: A connection defined with the proper credentials.
  """

  from gcloud.credentials import Credentials
  from gcloud.storage.connection import Connection

  credentials = Credentials.get_for_service_account(
      client_email, private_key_path, scope=SCOPE)
  return Connection(project=project, credentials=credentials)
Exemple #4
0
def get_connection(project, client_email, private_key_path):
    """Shortcut method to establish a connection to Cloud Storage.

  Use this if you are going to access several buckets
  with the same set of credentials:

  >>> from gcloud import storage
  >>> connection = storage.get_connection(project, email, key_path)
  >>> bucket1 = connection.get_bucket('bucket1')
  >>> bucket2 = connection.get_bucket('bucket2')

  :type project: string
  :param project: The name of the project to connect to.

  :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:`gcloud.storage.connection.Connection`
  :returns: A connection defined with the proper credentials.
  """

    from gcloud.credentials import Credentials
    from gcloud.storage.connection import Connection

    credentials = Credentials.get_for_service_account(client_email,
                                                      private_key_path,
                                                      scope=SCOPE)
    return Connection(project=project, credentials=credentials)
Exemple #5
0
def get_connection(project, client_email=None, private_key_path=None):
  """Gets a 

  :param project:
  :type project:
  :param client_email:
  :type client_email:
  :param private_key_path:
  :type private_key_path:
  :returns:
  :rtype:
  """
  from gcloud.pubsub.connection import Connection
  from gcloud.credentials import Credentials
  credentials = Credentials.get_for_service_account(
      client_email, private_key_path, AUTH_SCOPE)
  return Connection(project, credentials=credentials)
Exemple #6
0
def get_connection(project, email, private_key_path, scopes=None):
  """Shortcut for establishing a connection with Cloud DNS.

  :type project: string
  :param project: The name of the project to connect to.

  :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:`gcloud.dns.connection.Connection`
  :returns: A connection defined with the proper credentials.
  """
  scopes = scopes or DNS_SCOPE
  credentials = Credentials.get_for_service_account(
      email, private_key_path, scopes)
  return Connection(credentials=credentials, project=project)