Beispiel #1
0
 def notify_approval_team(self, org_id, org_name):
     slack_msg = f"Organization with org_id {org_id} is submitted for approval"
     mail_template = get_org_approval_mail(org_id, org_name)
     utils.send_slack_notification(slack_msg=slack_msg, slack_url=SLACK_HOOK['hostname'] + SLACK_HOOK['path'],
                                   slack_channel=SLACK_CHANNEL_FOR_APPROVAL_TEAM)
     utils.send_email_notification([EMAILS["ORG_APPROVERS_DLIST"]], mail_template["subject"],
                                   mail_template["body"], NOTIFICATION_ARN, self.boto_utils)
Beispiel #2
0
    def service_build_status_notifier(self, org_id, service_id, build_status):

        if build_status == BUILD_FAILURE_CODE:
            BUILD_FAIL_MESSAGE = "Build failed please check your components"
            org_uuid, service = ServicePublisherRepository(
            ).get_service_for_given_service_id_and_org_id(org_id, service_id)

            contacts = [
                contributor.get("email_id", "")
                for contributor in service.contributors
            ]

            service_comment = ServiceComment(org_uuid, service.uuid,
                                             "SERVICE_APPROVAL",
                                             "SERVICE_APPROVER",
                                             self._username,
                                             BUILD_FAIL_MESSAGE)
            ServicePublisherRepository().save_service_comments(service_comment)
            ServicePublisherRepository().save_service(
                self._username, service, ServiceStatus.CHANGE_REQUESTED.value)
            logger.info(
                f"Build failed for org_id {org_id}  and service_id {service_id}"
            )
            try:
                BUILD_STATUS_SUBJECT = "Build failed for your service {}"
                BUILD_STATUS_MESSAGE = "Build failed for your org_id {} and service_id {}"
                send_email_notification(
                    contacts, BUILD_STATUS_SUBJECT.format(service_id),
                    BUILD_STATUS_MESSAGE.format(org_id, service_id),
                    NOTIFICATION_ARN, boto_util)
            except:
                logger.info(
                    f"Error happened while sending build_status mail for {org_id} and contacts {contacts}"
                )
 def notify_approval_team(self, org_id, org_name):
     slack_msg = f"Organization with org_id {org_id} is submitted for approval"
     mail_template = get_org_approval_mail(org_id, org_name)
     self.send_slack_message(slack_msg)
     send_email_notification([ORG_APPROVERS_DLIST],
                             mail_template["subject"],
                             mail_template["body"], NOTIFICATION_ARN,
                             self.boto_client)
Beispiel #4
0
 def notify_approval_team(self, org_id, org_name):
     slack_msg = f"Organization with org_id {org_id} is submitted for approval"
     mail_template = get_org_approval_mail(org_id, org_name)
     Utils().report_slack(slack_msg, APPROVAL_SLACK_HOOK)
     utils.send_email_notification([EMAILS["ORG_APPROVERS_DLIST"]],
                                   mail_template["subject"],
                                   mail_template["body"], NOTIFICATION_ARN,
                                   self.boto_utils)
 def notify_approval_team(self, service_id, service_name, org_id, org_name):
     slack_msg = f"Service {service_id} under org_id {org_id} is submitted for approval"
     utils.send_slack_notification(
         slack_msg=slack_msg,
         slack_url=SLACK_HOOK['hostname'] + SLACK_HOOK['path'],
         slack_channel=SLACK_CHANNEL_FOR_APPROVAL_TEAM)
     mail = get_service_approval_mail_template(service_id, service_name,
                                               org_id, org_name)
     send_email_notification([EMAILS["SERVICE_APPROVERS_DLIST"]],
                             mail["subject"], mail["body"],
                             NOTIFICATION_ARN, boto_util)
Beispiel #6
0
 def process_approval_comment(self, approval_type, state, comment, params):
     if approval_type == "organization":
         org = OrganizationPublisherRepository().get_org_for_org_id(
             org_id=params["org_id"])
         if org.org_state.state in [
                 OrganizationStatus.APPROVAL_PENDING.value,
                 OrganizationStatus.ONBOARDING.value
         ]:
             self.callback_verification_service(
                 org.uuid,
                 getattr(OrganizationStatus, state).value, self._username,
                 comment)
     elif approval_type == "service":
         org_uuid, service = ServicePublisherRepository(). \
             get_service_for_given_service_id_and_org_id(org_id=params["org_id"], service_id=params["service_id"])
         if service.service_state.state == ServiceStatus.APPROVAL_PENDING.value:
             ServicePublisherRepository().save_service(
                 username=self._username,
                 service=service,
                 state=getattr(ServiceStatus, state).value)
             service_comments = ServiceComment(
                 org_uuid=service.org_uuid,
                 service_uuid=service.uuid,
                 support_type=ServiceSupportType.SERVICE_APPROVAL.value,
                 user_type=UserType.SERVICE_APPROVER.value,
                 commented_by=self._username,
                 comment=comment)
             ServicePublisherRepository().save_service_comments(
                 service_comment=service_comments)
             slack_msg = f"Reviews for service with {service.service_id} is successfully submitted."
             # send_slack_notification(slack_msg=slack_msg, slack_url=SLACK_APPROVAL_CHANNEL_URL,
             #                         slack_channel="ai-approvals")
             recipients = [
                 contributor.get("email_id", "")
                 for contributor in service.contributors
             ]
             if not recipients:
                 logger.info(
                     f"Unable to find service contributors for service {service.service_id} under {params['org_id']}"
                 )
                 return
             notification_subject = f"Your service {service.service_id} is reviewed"
             notification_message = f"Your service {service.service_id} under {params['org_id']} is reviewed"
             send_email_notification(
                 recipients=recipients,
                 notification_subject=notification_subject,
                 notification_message=notification_message,
                 notification_arn=NOTIFICATION_ARN,
                 boto_util=boto_util)
         else:
             logger.info("Service state is not valid.")
     else:
         logger.info("Approval type is not valid")
Beispiel #7
0
    def send_mail_to_owner(self, owner_email_address, comment, org_id, status):
        if status == OrganizationStatus.REJECTED.value:
            mail_template = get_owner_mail_for_org_rejected(org_id, comment)
        elif status == OrganizationStatus.CHANGE_REQUESTED.value:
            mail_template = get_owner_mail_for_org_changes_requested(org_id, comment)
        elif status == OrganizationStatus.APPROVED.value:
            mail_template = get_owner_mail_for_org_approved(org_id)
        else:
            logger.info(f"Organization status: {status}")
            raise InvalidOrganizationStateException()

        utils.send_email_notification([owner_email_address], mail_template["subject"],
                                      mail_template["body"], NOTIFICATION_ARN, self.boto_utils)
Beispiel #8
0
 def notify_service_contributor_when_user_submit_for_approval(
         org_id, service_id, contributors):
     # notify service contributor for submission via email
     recipients = [
         contributor.get("email_id", "") for contributor in contributors
     ]
     if not recipients:
         logger.info(
             f"Unable to find service contributors for service {service_id} under {org_id}"
         )
         return
     notification_subject = f"Your service {service_id} has successfully submitted for approval"
     notification_message = f"Your service {service_id} under organization {org_id} has successfully been submitted " \
                            f"for approval. We will notify you once it is reviewed by our approval team. It usually " \
                            f"takes around five to ten business days for approval."
     utils.send_email_notification(recipients, notification_subject,
                                   notification_message, NOTIFICATION_ARN,
                                   boto_util)