当前位置: 首页>>代码示例>>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;未经允许,请勿转载。