當前位置: 首頁>>代碼示例>>Python>>正文


Python environment_vars.LEGACY_PROJECT屬性代碼示例

本文整理匯總了Python中google.auth.environment_vars.LEGACY_PROJECT屬性的典型用法代碼示例。如果您正苦於以下問題:Python environment_vars.LEGACY_PROJECT屬性的具體用法?Python environment_vars.LEGACY_PROJECT怎麽用?Python environment_vars.LEGACY_PROJECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在google.auth.environment_vars的用法示例。


在下文中一共展示了environment_vars.LEGACY_PROJECT屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: provide_gcp_conn_and_credentials

# 需要導入模塊: from google.auth import environment_vars [as 別名]
# 或者: from google.auth.environment_vars import LEGACY_PROJECT [as 別名]
def provide_gcp_conn_and_credentials(
    key_file_path: Optional[str] = None,
    scopes: Optional[Sequence] = None,
    project_id: Optional[str] = None,
):
    """
    Context manager that provides both:

    - GCP credentials for application supporting `Application Default Credentials (ADC)
    strategy <https://cloud.google.com/docs/authentication/production>`__.
    - temporary value of :envvar:`AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT` connection

    :param key_file_path: Path to file with GCP credentials .json file.
    :type key_file_path: str
    :param scopes: OAuth scopes for the connection
    :type scopes: Sequence
    :param project_id: The id of GCP project for the connection.
    :type project_id: str
    """
    with ExitStack() as stack:
        if key_file_path:
            stack.enter_context(  # type; ignore  # pylint: disable=no-member
                provide_gcp_credentials(key_file_path)
            )
        if project_id:
            stack.enter_context(  # type; ignore  # pylint: disable=no-member
                patch_environ({PROJECT: project_id, LEGACY_PROJECT: project_id})
            )

        stack.enter_context(  # type; ignore  # pylint: disable=no-member
            provide_gcp_connection(key_file_path, scopes, project_id)
        )
        yield 
開發者ID:apache,項目名稱:airflow,代碼行數:35,代碼來源:credentials_provider.py

示例2: test_default_explict_legacy_project_id

# 需要導入模塊: from google.auth import environment_vars [as 別名]
# 或者: from google.auth.environment_vars import LEGACY_PROJECT [as 別名]
def test_default_explict_legacy_project_id(unused_get, monkeypatch):
    monkeypatch.setenv(environment_vars.LEGACY_PROJECT, "explicit-env")
    assert _default.default() == (mock.sentinel.credentials, "explicit-env") 
開發者ID:googleapis,項目名稱:google-auth-library-python,代碼行數:5,代碼來源:test__default.py


注:本文中的google.auth.environment_vars.LEGACY_PROJECT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。