当前位置: 首页>>代码示例>>Python>>正文


Python AwsHook.get_credentials方法代码示例

本文整理汇总了Python中airflow.contrib.hooks.aws_hook.AwsHook.get_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python AwsHook.get_credentials方法的具体用法?Python AwsHook.get_credentials怎么用?Python AwsHook.get_credentials使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.contrib.hooks.aws_hook.AwsHook的用法示例。


在下文中一共展示了AwsHook.get_credentials方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_credentials_from_login

# 需要导入模块: from airflow.contrib.hooks.aws_hook import AwsHook [as 别名]
# 或者: from airflow.contrib.hooks.aws_hook.AwsHook import get_credentials [as 别名]
 def test_get_credentials_from_login(self, mock_get_connection):
     mock_connection = Connection(login='aws_access_key_id',
                                  password='aws_secret_access_key')
     mock_get_connection.return_value = mock_connection
     hook = AwsHook()
     credentials_from_hook = hook.get_credentials()
     self.assertEqual(credentials_from_hook.access_key, 'aws_access_key_id')
     self.assertEqual(credentials_from_hook.secret_key, 'aws_secret_access_key')
     self.assertIsNone(credentials_from_hook.token)
开发者ID:AdamUnger,项目名称:incubator-airflow,代码行数:11,代码来源:test_aws_hook.py

示例2: test_get_credentials_from_extra

# 需要导入模块: from airflow.contrib.hooks.aws_hook import AwsHook [as 别名]
# 或者: from airflow.contrib.hooks.aws_hook.AwsHook import get_credentials [as 别名]
 def test_get_credentials_from_extra(self, mock_get_connection):
     mock_connection = Connection(
         extra='{"aws_access_key_id": "aws_access_key_id",'
         '"aws_secret_access_key": "aws_secret_access_key"}'
     )
     mock_get_connection.return_value = mock_connection
     hook = AwsHook()
     credentials_from_hook = hook.get_credentials()
     self.assertEqual(credentials_from_hook.access_key, 'aws_access_key_id')
     self.assertEqual(credentials_from_hook.secret_key, 'aws_secret_access_key')
     self.assertIsNone(credentials_from_hook.token)
开发者ID:AdamUnger,项目名称:incubator-airflow,代码行数:13,代码来源:test_aws_hook.py

示例3: _inject_aws_credentials

# 需要导入模块: from airflow.contrib.hooks.aws_hook import AwsHook [as 别名]
# 或者: from airflow.contrib.hooks.aws_hook.AwsHook import get_credentials [as 别名]
    def _inject_aws_credentials(self):
        if TRANSFER_SPEC not in self.body or AWS_S3_DATA_SOURCE not in self.body[TRANSFER_SPEC]:
            return

        aws_hook = AwsHook(self.aws_conn_id)
        aws_credentials = aws_hook.get_credentials()
        aws_access_key_id = aws_credentials.access_key
        aws_secret_access_key = aws_credentials.secret_key
        self.body[TRANSFER_SPEC][AWS_S3_DATA_SOURCE][AWS_ACCESS_KEY] = {
            ACCESS_KEY_ID: aws_access_key_id,
            SECRET_ACCESS_KEY: aws_secret_access_key,
        }
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:14,代码来源:gcp_transfer_operator.py

示例4: test_get_credentials_from_role_arn

# 需要导入模块: from airflow.contrib.hooks.aws_hook import AwsHook [as 别名]
# 或者: from airflow.contrib.hooks.aws_hook.AwsHook import get_credentials [as 别名]
 def test_get_credentials_from_role_arn(self, mock_get_connection):
     mock_connection = Connection(
         extra='{"role_arn":"arn:aws:iam::123456:role/role_arn"}')
     mock_get_connection.return_value = mock_connection
     hook = AwsHook()
     credentials_from_hook = hook.get_credentials()
     self.assertEqual(credentials_from_hook.access_key, 'AKIAIOSFODNN7EXAMPLE')
     self.assertEqual(credentials_from_hook.secret_key,
                      'aJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY')
     self.assertEqual(credentials_from_hook.token,
                      'BQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh'
                      '3c/LTo6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4I'
                      'gRmpRV3zrkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15'
                      'fjrBs2+cTQtpZ3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE')
开发者ID:AdamUnger,项目名称:incubator-airflow,代码行数:16,代码来源:test_aws_hook.py


注:本文中的airflow.contrib.hooks.aws_hook.AwsHook.get_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。