def encryption_materials()

in src/dynamodb_encryption_sdk/material_providers/most_recent.py [0:0]


    def encryption_materials(self, encryption_context):
        # type: (EncryptionContext) -> CryptographicMaterials
        """Return encryption materials.

        :param EncryptionContext encryption_context: Encryption context for request
        :raises AttributeError: if no encryption materials are available
        """
        ttl_action = self._ttl_action(self._version, _ENCRYPT_ACTION)

        _LOGGER.debug('TTL Action "%s" when getting encryption materials', ttl_action.name)

        provider = None

        if ttl_action is TtlActions.EXPIRED:
            self._cache.evict(self._version)

        if ttl_action is TtlActions.LIVE:
            try:
                _LOGGER.debug("Looking in cache for encryption materials provider version %d", self._version)
                _, provider = self._cache.get(self._version)
            except KeyError:
                _LOGGER.debug("Encryption materials provider not found in cache")
                ttl_action = TtlActions.EXPIRED

        if provider is None:
            _LOGGER.debug("Getting most recent materials provider version")
            provider = self._get_most_recent_version(ttl_action)

        return provider.encryption_materials(encryption_context)