def get_project_endpoint_from_env(project_id=None, host=None):
  """Get Datastore project endpoint from environment variables.

  Args:
    project_id: The Cloud project, defaults to the environment
        variable DATASTORE_PROJECT_ID.
    host: The Cloud Datastore API host to use.

  Returns:
    the endpoint to use, for example
    https://datastore.googleapis.com/v1/projects/my-project

  Raises:
    ValueError: if the wrong environment variable was set or a project_id was
        not provided.
  """
  project_id = project_id or os.getenv(_DATASTORE_PROJECT_ID_ENV)
  if not project_id:
    raise ValueError('project_id was not provided. Either pass it in '
                     'directly or set DATASTORE_PROJECT_ID.')
  # DATASTORE_HOST is deprecated.
  if os.getenv(_DATASTORE_HOST_ENV):
    logging.warning('Ignoring value of environment variable DATASTORE_HOST. '
                    'To point datastore to a host running locally, use the '
                    'environment variable DATASTORE_EMULATOR_HOST')

  url_override = os.getenv(_DATASTORE_URL_OVERRIDE_ENV)
  if url_override:
    return '%s/projects/%s' % (url_override, project_id)

  localhost = os.getenv(_DATASTORE_EMULATOR_HOST_ENV)
  if localhost:
    return ('http://%s/%s/projects/%s'
            % (localhost, API_VERSION, project_id))

  host = host or GOOGLEAPIS_HOST
  return 'https://%s/%s/projects/%s' % (host, API_VERSION, project_id)
def get_project_endpoint_from_env ( project_id = None , host = None ) : project_id = project_id or os . getenv ( _DATASTORE_PROJECT_ID_ENV ) if not project_id : raise ValueError ( 'project_id was not provided. Either pass it in ' 'directly or set DATASTORE_PROJECT_ID.' ) if os . getenv ( _DATASTORE_HOST_ENV ) : logging . warning ( 'Ignoring value of environment variable DATASTORE_HOST. ' 'To point datastore to a host running locally, use the ' 'environment variable DATASTORE_EMULATOR_HOST' ) url_override = os . getenv ( _DATASTORE_URL_OVERRIDE_ENV ) if url_override : return '%s/projects/%s' % ( url_override , project_id ) localhost = os . getenv ( _DATASTORE_EMULATOR_HOST_ENV ) if localhost : return ( 'http://%s/%s/projects/%s' % ( localhost , API_VERSION , project_id ) ) host = host or GOOGLEAPIS_HOST return 'https://%s/%s/projects/%s' % ( host , API_VERSION , project_id )
Get Datastore project endpoint from environment variables.

  Args:
    project_id: The Cloud project, defaults to the environment
        variable DATASTORE_PROJECT_ID.
    host: The Cloud Datastore API host to use.

  Returns:
    the endpoint to use, for example
    https://datastore.googleapis.com/v1/projects/my-project

  Raises:
    ValueError: if the wrong environment variable was set or a project_id was
        not provided.