當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。