"""S3 logic.""" from oto import response import requests from promo_player import config from promo_player.constants import error from promo_player.constants import s3 def get_shared_static_assets_version(): """Get the shared static assets manifest from S3 and return its content. Returns: response.Response: containing the content of the manifest. """ url = '{0}/{1}/manifest'.format(config.CDN_URL, s3.SHARED_PREFIX) result = requests.get(url) if result.status_code != 200: return response.create_error_response( status=result.status_code, code=error.ERROR_CODE_S3_REQUEST, message=result.text) return response.Response(result.text.strip()) def get_player_static_assets_version(): """Get the player static assets manifest from S3 and return its content. Returns: response.Response: containing the content of the manifest. """ url = '{0}/{1}/manifest'.format(config.CDN_URL, s3.PLAYER_PREFIX) result = requests.get(url) if result.status_code != 200: return response.create_error_response( status=result.status_code, code=error.ERROR_CODE_S3_REQUEST, message=result.text) return response.Response(result.text.strip())