mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
code review feedback
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
from app.clients import Client, ClientException
|
||||
|
||||
|
||||
class CloudwatchClientResponseException(ClientException):
|
||||
"""
|
||||
Base Exception for SmsClientsResponses
|
||||
"""
|
||||
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
return "Message {}".format(self.message)
|
||||
|
||||
|
||||
class CloudwatchClient(Client):
|
||||
"""
|
||||
Base Cloudwatch client for checking sms.
|
||||
"""
|
||||
|
||||
def init_app(self, *args, **kwargs):
|
||||
raise NotImplementedError("TODO Need to implement.")
|
||||
|
||||
def check_sms(self, *args, **kwargs):
|
||||
raise NotImplementedError("TODO Need to implement.")
|
||||
|
||||
@@ -5,11 +5,11 @@ import time
|
||||
|
||||
from boto3 import client
|
||||
|
||||
from app.clients.cloudwatch import CloudwatchClient
|
||||
from app.clients import Client
|
||||
from app.cloudfoundry_config import cloud_config
|
||||
|
||||
|
||||
class AwsCloudwatchClient(CloudwatchClient):
|
||||
class AwsCloudwatchClient(Client):
|
||||
"""
|
||||
This client is responsible for retrieving sms delivery receipts from cloudwatch.
|
||||
"""
|
||||
@@ -21,7 +21,7 @@ class AwsCloudwatchClient(CloudwatchClient):
|
||||
aws_access_key_id=cloud_config.sns_access_key,
|
||||
aws_secret_access_key=cloud_config.sns_secret_key
|
||||
)
|
||||
super(CloudwatchClient, self).__init__(*args, **kwargs)
|
||||
super(Client, self).__init__(*args, **kwargs)
|
||||
self.current_app = current_app
|
||||
self._valid_sender_regex = re.compile(r"^\+?\d{5,14}$")
|
||||
|
||||
@@ -61,14 +61,8 @@ class AwsCloudwatchClient(CloudwatchClient):
|
||||
return all_log_events
|
||||
|
||||
def check_sms(self, message_id, notification_id):
|
||||
"""
|
||||
Go through the cloudwatch logs, filtering by message id. Check the success logs first. If we find
|
||||
the message id there, we are done. Otherwise check the failure logs. If we don't find the message
|
||||
in the success or failure logs, raise an exception. This method is called on a five minute delay,
|
||||
which is presumably enough time for the cloudwatch log to be populated.
|
||||
"""
|
||||
# TODO presumably there is a better way to get the aws account number
|
||||
account_number = os.getenv("SES_DOMAIN_ARN")
|
||||
# TODO this clumsy approach to getting the account number will be fixed as part of notify-api #258
|
||||
account_number = cloud_config.ses_domain_arn
|
||||
account_number = account_number.replace('arn:aws:ses:us-west-2:', '')
|
||||
account_number = account_number.split(":")
|
||||
account_number = account_number[0]
|
||||
|
||||
Reference in New Issue
Block a user