Skip to content

Commit

Permalink
initial loading of notifications to end-users - #75
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard357 committed Jul 1, 2023
1 parent 811f171 commit 024291b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions cdk/parameters_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Parameters(Construct):

PARAMETER_SEPARATOR = "/" # /!\ to be duplicated in code/settings.py
ACCOUNTS_PARAMETER = "Accounts"
DOCUMENTS_PARAMETER = "Documents"
ORGANIZATIONAL_UNITS_PARAMETER = "OrganizationalUnits"
PREPARATION_BUILDSPEC_PARAMETER = "PreparationBuildspecTemplate"
PURGE_BUILDSPEC_PARAMETER = "PurgeBuildspecTemplate"
Expand Down Expand Up @@ -80,13 +81,32 @@ def __init__(self, scope: Construct, id: str, web_endpoints={}) -> None:
parameter_name=self.get_parameter(toggles.environment_identifier, self.WEB_ENDPOINTS_PARAMETER),
tier=ParameterTier.STANDARD if len(string_value) < 4096 else ParameterTier.ADVANCED)

if toggles.features_with_end_user_documents:
for label, file in toggles.features_with_end_user_documents.items():
content = self.get_document(label, file)
StringParameter(
self, label,
string_value=content,
data_type=ParameterDataType.TEXT,
description=f"Document {label}",
parameter_name=self.get_document_parameter(environment=toggles.environment_identifier,
identifier=label),
tier=ParameterTier.STANDARD if len(string_value) < 4096 else ParameterTier.ADVANCED)

@classmethod
def get_account_parameter(cls, environment, identifier=None):
attributes = ['', environment, cls.ACCOUNTS_PARAMETER]
if identifier:
attributes.append(identifier)
return cls.PARAMETER_SEPARATOR.join(attributes)

@classmethod
def get_document_parameter(cls, environment, identifier=None):
attributes = ['', environment, cls.DOCUMENTS_PARAMETER]
if identifier:
attributes.append(identifier)
return cls.PARAMETER_SEPARATOR.join(attributes)

@classmethod
def get_organizational_unit_parameter(cls, environment, identifier=None):
attributes = ['', environment, cls.ORGANIZATIONAL_UNITS_PARAMETER]
Expand All @@ -108,3 +128,8 @@ def get_buildspec_for_purge(self):
logging.debug("Getting buildspec for the purge of accounts")
with open(toggles.worker_purge_buildspec_template_file) as stream:
return stream.read()

def get_document(self, label, file):
logging.debug(f"Loading document {label} from file {file}")
with open(file) as stream:
return stream.read()
2 changes: 1 addition & 1 deletion tests/test_lambda_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from lambdas import Events, State

# pytestmark = pytest.mark.wip
# pytestmark = pytest.mark.wip


@pytest.mark.unit_tests
Expand Down

0 comments on commit 024291b

Please sign in to comment.