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


Python credentials.JSONFileCache方法代码示例

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


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

示例1: inject_assume_role_provider_cache

# 需要导入模块: from botocore import credentials [as 别名]
# 或者: from botocore.credentials import JSONFileCache [as 别名]
def inject_assume_role_provider_cache(session, **kwargs):
    try:
        cred_chain = session.get_component('credential_provider')
    except ProfileNotFound:
        # If a user has provided a profile that does not exist,
        # trying to retrieve components/config on the session
        # will raise ProfileNotFound.  Sometimes this is invalid:
        #
        # "ec2 describe-instances --profile unknown"
        #
        # and sometimes this is perfectly valid:
        #
        # "configure set region us-west-2 --profile brand-new-profile"
        #
        # Because we can't know (and don't want to know) whether
        # the customer is trying to do something valid, we just
        # immediately return.  If it's invalid something else
        # up the stack will raise ProfileNotFound, otherwise
        # the configure (and other) commands will work as expected.
        LOG.debug("ProfileNotFound caught when trying to inject "
                  "assume-role cred provider cache.  Not configuring "
                  "JSONFileCache for assume-role.")
        return
    provider = cred_chain.get_provider('assume-role')
    provider.cache = JSONFileCache(CACHE_DIR) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:27,代码来源:assumerole.py

示例2: initialize

# 需要导入模块: from botocore import credentials [as 别名]
# 或者: from botocore.credentials import JSONFileCache [as 别名]
def initialize(region="", profile=""):
        from botocore import credentials
        import botocore.session
        import os

        cli_cache = os.path.join(os.path.expanduser("~"), ".aws/cli/cache")

        params = {}
        if profile:
            params["profile"] = profile

        session = botocore.session.Session(**params)
        session.get_component("credential_provider").get_provider("assume-role").cache = credentials.JSONFileCache(
            cli_cache
        )

        from boto3.session import Session

        params = {}
        if region:
            params["region_name"] = region

        AWS.__session = Session(botocore_session=session, **params) 
开发者ID:theserverlessway,项目名称:formica,代码行数:25,代码来源:aws.py

示例3: __init__

# 需要导入模块: from botocore import credentials [as 别名]
# 或者: from botocore.credentials import JSONFileCache [as 别名]
def __init__(self, name, access_key=None, secret_key=None,
                     security_token=None, profile_name=None, **kwargs):
            """
            Create a new BotoCredentialAdapter.
            """
            # TODO: We take kwargs because new boto2 versions have an 'anon'
            # argument and we want to be future proof

            if (name == 'aws' or name is None) and access_key is None and not kwargs.get('anon', False):
                # We are on AWS and we don't have credentials passed along and we aren't anonymous.
                # We will backend into a boto3 resolver for getting credentials.
                # Make sure to enable boto3's own caching, so we can share that
                # cash with pure boto3 code elsewhere in Toil.
                self._boto3_resolver = create_credential_resolver(Session(profile=profile_name), cache=JSONFileCache())
            else:
                # We will use the normal flow
                self._boto3_resolver = None

            # Pass along all the arguments
            super(BotoCredentialAdapter, self).__init__(name, access_key=access_key,
                                                        secret_key=secret_key, security_token=security_token,
                                                        profile_name=profile_name, **kwargs) 
开发者ID:DataBiosphere,项目名称:toil,代码行数:24,代码来源:__init__.py

示例4: authenticate

# 需要导入模块: from botocore import credentials [as 别名]
# 或者: from botocore.credentials import JSONFileCache [as 别名]
def authenticate(self):
        cache = JSONFileCache()
        saml_fetcher = SAMLFetcher(
            self,
            cache=cache
        )

        credentials = saml_fetcher.fetch_credentials()

        return credentials 
开发者ID:godaddy,项目名称:aws-okta-processor,代码行数:12,代码来源:authenticate.py


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