clients: cbc_proxy sends message_type

When we ask the CBC Proxy to send a message, we should specify that we
want to send a real message, when we want a real message

We will do this by specifying the message_type which can have 4 types, 3
of which represent a real message:

| Name   | Effect                   |
| ------ | ------------------------ |
| alert  | Create an alert          |
| update | Update an existing alert |
| cancel | Cancel an existing alert |
| test   | Send a link test         |

We will use message_type to represent the table above

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Richard <richard.baker@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
This commit is contained in:
Toby Lorne
2020-10-27 14:44:04 +00:00
parent 5459d96c58
commit 7542709455
2 changed files with 115 additions and 0 deletions

View File

@@ -32,6 +32,12 @@ class CBCProxyNoopClient:
):
pass
def send_link_test(
self,
identifier,
):
pass
def create_and_send_broadcast(
self,
identifier, headline, description, areas
@@ -83,11 +89,33 @@ class CBCProxyClient:
if 'FunctionError' in result:
raise Exception('Function exited with unhandled exception')
def send_link_test(
self,
identifier,
):
payload_bytes = bytes(json.dumps({
'message_type': 'test',
'identifier': identifier,
}), encoding='utf8')
result = self._lambda_client.invoke(
FunctionName='bt-ee-1-proxy',
InvocationType='RequestResponse',
Payload=payload_bytes,
)
if result['StatusCode'] > 299:
raise Exception('Could not invoke lambda')
if 'FunctionError' in result:
raise Exception('Function exited with unhandled exception')
def create_and_send_broadcast(
self,
identifier, headline, description, areas,
):
payload_bytes = bytes(json.dumps({
'message_type': 'alert',
'identifier': identifier,
'headline': headline,
'description': description,