mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
clients: add cbc proxy clients
We are going to invoke a lambda to send a message to the CBC We need a CBC Proxy Client to do this The Client will be able to send/update/cancel broadcasts in the CBC Unless we have configured the app with AWS credentials for the CBCProxyClient, we just want to use a client that does nothing: the noop client The AWS access keys are separate for the CBC Proxy vs other Notify AWS things because the CBC Proxy lives in another AWS account Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk> Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk> Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -23,6 +23,7 @@ from werkzeug.local import LocalProxy
|
|||||||
|
|
||||||
from app.celery.celery import NotifyCelery
|
from app.celery.celery import NotifyCelery
|
||||||
from app.clients import Clients
|
from app.clients import Clients
|
||||||
|
from app.clients.cbc_proxy import CBCProxyClient, CBCProxyNoopClient
|
||||||
from app.clients.document_download import DocumentDownloadClient
|
from app.clients.document_download import DocumentDownloadClient
|
||||||
from app.clients.email.aws_ses import AwsSesClient
|
from app.clients.email.aws_ses import AwsSesClient
|
||||||
from app.clients.email.aws_ses_stub import AwsSesStubClient
|
from app.clients.email.aws_ses_stub import AwsSesStubClient
|
||||||
@@ -60,6 +61,7 @@ zendesk_client = ZendeskClient()
|
|||||||
statsd_client = StatsdClient()
|
statsd_client = StatsdClient()
|
||||||
redis_store = RedisClient()
|
redis_store = RedisClient()
|
||||||
performance_platform_client = PerformancePlatformClient()
|
performance_platform_client = PerformancePlatformClient()
|
||||||
|
cbc_proxy_client = CBCProxyNoopClient()
|
||||||
document_download_client = DocumentDownloadClient()
|
document_download_client = DocumentDownloadClient()
|
||||||
metrics = GDSMetrics()
|
metrics = GDSMetrics()
|
||||||
|
|
||||||
@@ -112,6 +114,10 @@ def create_app(application):
|
|||||||
performance_platform_client.init_app(application)
|
performance_platform_client.init_app(application)
|
||||||
document_download_client.init_app(application)
|
document_download_client.init_app(application)
|
||||||
|
|
||||||
|
if application.config['CBC_PROXY_AWS_ACCESS_KEY_ID']:
|
||||||
|
cbc_proxy_client = CBCProxyClient()
|
||||||
|
cbc_proxy_client.init_app(application)
|
||||||
|
|
||||||
register_blueprint(application)
|
register_blueprint(application)
|
||||||
register_v2_blueprints(application)
|
register_v2_blueprints(application)
|
||||||
|
|
||||||
|
|||||||
59
app/clients/cbc_proxy.py
Normal file
59
app/clients/cbc_proxy.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Noop = no operation
|
||||||
|
class CBCProxyNoopClient:
|
||||||
|
|
||||||
|
def init_app(self, app):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def create_and_send_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, headline, description,
|
||||||
|
):
|
||||||
|
# identifier=broadcast_message.identifier,
|
||||||
|
# headline="GOV.UK Notify Broadcast",
|
||||||
|
# description=broadcast_message.description,
|
||||||
|
pass
|
||||||
|
|
||||||
|
# We have not implementated updating a broadcast
|
||||||
|
def update_and_send_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, references, headline, description,
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# We have not implemented cancelling a broadcast
|
||||||
|
def cancel_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, references, headline, description,
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class CBCProxyClient:
|
||||||
|
|
||||||
|
def init_app(self, app):
|
||||||
|
self.aws_access_key_id = app.config['CBC_PROXY_AWS_ACCESS_KEY_ID']
|
||||||
|
self.aws_secret_access_key = app.config['CBC_PROXY_AWS_SECRET_ACCESS_KEY']
|
||||||
|
self.aws_region = 'eu-west-2'
|
||||||
|
|
||||||
|
def create_and_send_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, headline, description,
|
||||||
|
):
|
||||||
|
# identifier=broadcast_message.identifier,
|
||||||
|
# headline="GOV.UK Notify Broadcast",
|
||||||
|
# description=broadcast_message.description,
|
||||||
|
pass
|
||||||
|
|
||||||
|
# We have not implementated updating a broadcast
|
||||||
|
def update_and_send_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, references, headline, description,
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# We have not implemented cancelling a broadcast
|
||||||
|
def cancel_broadcast(
|
||||||
|
self,
|
||||||
|
identifier, references, headline, description,
|
||||||
|
):
|
||||||
|
pass
|
||||||
@@ -353,6 +353,11 @@ class Config(object):
|
|||||||
|
|
||||||
AWS_REGION = 'eu-west-1'
|
AWS_REGION = 'eu-west-1'
|
||||||
|
|
||||||
|
# CBC Proxy
|
||||||
|
# if the access keys are empty then noop client is used
|
||||||
|
CBC_PROXY_AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', '')
|
||||||
|
CBC_PROXY_AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', '')
|
||||||
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# Config overrides ###
|
# Config overrides ###
|
||||||
|
|||||||
Reference in New Issue
Block a user