Mail¶
Internal service for sending e-mails.
Rationale¶
Currently only one end-point is exposed for sending a single email to one user at a time, and only
SERVICE
principals is authorized to do so. The endpoint does take multiple mails as a bulk request,
but they are sent individually
Email templates are pre-defined and are not controllable by clients.
Table of Contents¶
1. Examples
Description |
---|
Sending an email |
Forwarding a support ticket to Jira |
Changing e-mail settings |
2. Remote Procedure Calls
Name | Description |
---|---|
retrieveEmailSettings |
Changes an end-user's e-mail preferences |
sendDirect |
No description |
sendSupport |
Forwards a support ticket into Jira |
sendToUser |
Sends an email to an end-user based on a pre-defined template |
toggleEmailSettings |
Retrieves an end-user's e-mail preferences |
3. Data Models
Example: Sending an email¶
Frequency of use | Common |
---|---|
Actors |
|
Communication Flow: Kotlin
MailDescriptions.sendToUser.call(
bulkRequestOf(SendRequestItem(
mail = Mail.LowFundsMail(
categories = listOf("u1-standard"),
projectTitles = listOf("Science Project"),
providers = listOf("ucloud"),
subject = "Wallets low on resource",
),
mandatory = false,
receiver = "User#1234",
receivingEmail = null,
testMail = null,
)),
ucloud
).orThrow()
/*
Unit
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as ucloud
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/sendToUser" -d '{
"items": [
{
"receiver": "User#1234",
"mail": {
"type": "lowFunds",
"categories": [
"u1-standard"
],
"providers": [
"ucloud"
],
"projectTitles": [
"Science Project"
],
"subject": "Wallets low on resource"
},
"mandatory": false,
"receivingEmail": null,
"testMail": null
}
]
}'
# {
# }
Communication Flow: Visual
Example: Forwarding a support ticket to Jira¶
Frequency of use | Common |
---|---|
Actors |
|
Communication Flow: Kotlin
MailDescriptions.sendSupport.call(
SendSupportEmailRequest(
fromEmail = "foo@bar",
message = "Message",
subject = "Subject",
),
ucloud
).orThrow()
/*
Unit
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as ucloud
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/support" -d '{
"fromEmail": "foo@bar",
"subject": "Subject",
"message": "Message"
}'
# {
# }
Communication Flow: Visual
Example: Changing e-mail settings¶
Frequency of use | Common |
---|---|
Actors |
|
Communication Flow: Kotlin
MailDescriptions.retrieveEmailSettings.call(
RetrieveEmailSettingsRequest(
username = null,
),
user
).orThrow()
/*
RetrieveEmailSettingsResponse(
settings = EmailSettings(
applicationStatusChange = true,
applicationTransfer = true,
grantApplicationApproved = true,
grantApplicationRejected = true,
grantApplicationUpdated = true,
grantApplicationWithdrawn = true,
jobStarted = false,
jobStopped = false,
lowFunds = true,
newCommentOnApplication = true,
newGrantApplication = true,
projectUserInvite = true,
projectUserRemoved = true,
userLeft = true,
userRoleChange = true,
verificationReminder = true,
),
)
*/
MailDescriptions.toggleEmailSettings.call(
bulkRequestOf(EmailSettingsItem(
settings = EmailSettings(
applicationStatusChange = true,
applicationTransfer = true,
grantApplicationApproved = true,
grantApplicationRejected = true,
grantApplicationUpdated = true,
grantApplicationWithdrawn = true,
jobStarted = false,
jobStopped = false,
lowFunds = true,
newCommentOnApplication = true,
newGrantApplication = true,
projectUserInvite = true,
projectUserRemoved = true,
userLeft = true,
userRoleChange = true,
verificationReminder = false,
),
username = null,
)),
user
).orThrow()
/*
Unit
*/
MailDescriptions.retrieveEmailSettings.call(
RetrieveEmailSettingsRequest(
username = null,
),
user
).orThrow()
/*
RetrieveEmailSettingsResponse(
settings = EmailSettings(
applicationStatusChange = true,
applicationTransfer = true,
grantApplicationApproved = true,
grantApplicationRejected = true,
grantApplicationUpdated = true,
grantApplicationWithdrawn = true,
jobStarted = false,
jobStopped = false,
lowFunds = true,
newCommentOnApplication = true,
newGrantApplication = true,
projectUserInvite = true,
projectUserRemoved = true,
userLeft = true,
userRoleChange = true,
verificationReminder = false,
),
)
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as user
curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?"
# {
# "settings": {
# "newGrantApplication": true,
# "grantApplicationUpdated": true,
# "grantApplicationApproved": true,
# "grantApplicationRejected": true,
# "grantApplicationWithdrawn": true,
# "newCommentOnApplication": true,
# "applicationTransfer": true,
# "applicationStatusChange": true,
# "projectUserInvite": true,
# "projectUserRemoved": true,
# "verificationReminder": true,
# "userRoleChange": true,
# "userLeft": true,
# "lowFunds": true,
# "jobStarted": false,
# "jobStopped": false
# }
# }
curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/toggleEmailSettings" -d '{
"items": [
{
"username": null,
"settings": {
"newGrantApplication": true,
"grantApplicationUpdated": true,
"grantApplicationApproved": true,
"grantApplicationRejected": true,
"grantApplicationWithdrawn": true,
"newCommentOnApplication": true,
"applicationTransfer": true,
"applicationStatusChange": true,
"projectUserInvite": true,
"projectUserRemoved": true,
"verificationReminder": false,
"userRoleChange": true,
"userLeft": true,
"lowFunds": true,
"jobStarted": false,
"jobStopped": false
}
}
]
}'
# {
# }
curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?"
# {
# "settings": {
# "newGrantApplication": true,
# "grantApplicationUpdated": true,
# "grantApplicationApproved": true,
# "grantApplicationRejected": true,
# "grantApplicationWithdrawn": true,
# "newCommentOnApplication": true,
# "applicationTransfer": true,
# "applicationStatusChange": true,
# "projectUserInvite": true,
# "projectUserRemoved": true,
# "verificationReminder": false,
# "userRoleChange": true,
# "userLeft": true,
# "lowFunds": true,
# "jobStarted": false,
# "jobStopped": false
# }
# }
Communication Flow: Visual
Remote Procedure Calls¶
retrieveEmailSettings
¶
Changes an end-user’s e-mail preferences
Request | Response | Error |
---|---|---|
RetrieveEmailSettingsRequest |
RetrieveEmailSettingsResponse |
CommonErrorMessage |
sendDirect
¶
Request | Response | Error |
---|---|---|
BulkRequest<SendDirectMandatoryEmailRequest> |
Unit |
CommonErrorMessage |
sendSupport
¶
Forwards a support ticket into Jira
Request | Response | Error |
---|---|---|
SendSupportEmailRequest |
Unit |
CommonErrorMessage |
NOTE: This endpoint is meant only for use by SDU and might not work well with other deployments.
sendToUser
¶
Sends an email to an end-user based on a pre-defined template
Request | Response | Error |
---|---|---|
BulkRequest<SendRequestItem> |
Unit |
CommonErrorMessage |
toggleEmailSettings
¶
Retrieves an end-user’s e-mail preferences
Request | Response | Error |
---|---|---|
BulkRequest<EmailSettingsItem> |
Unit |
CommonErrorMessage |
Data Models¶
EmailSettings
¶
data class EmailSettings(
val newGrantApplication: Boolean?,
val grantApplicationUpdated: Boolean?,
val grantApplicationApproved: Boolean?,
val grantApplicationRejected: Boolean?,
val grantApplicationWithdrawn: Boolean?,
val newCommentOnApplication: Boolean?,
val applicationTransfer: Boolean?,
val applicationStatusChange: Boolean?,
val projectUserInvite: Boolean?,
val projectUserRemoved: Boolean?,
val verificationReminder: Boolean?,
val userRoleChange: Boolean?,
val userLeft: Boolean?,
val lowFunds: Boolean?,
val jobStarted: Boolean?,
val jobStopped: Boolean?,
)
Properties
newGrantApplication
: Boolean?
Boolean?
grantApplicationUpdated
: Boolean?
Boolean?
grantApplicationApproved
: Boolean?
Boolean?
grantApplicationRejected
: Boolean?
Boolean?
grantApplicationWithdrawn
: Boolean?
Boolean?
newCommentOnApplication
: Boolean?
Boolean?
applicationTransfer
: Boolean?
Boolean?
applicationStatusChange
: Boolean?
Boolean?
projectUserInvite
: Boolean?
Boolean?
projectUserRemoved
: Boolean?
Boolean?
verificationReminder
: Boolean?
Boolean?
userRoleChange
: Boolean?
Boolean?
userLeft
: Boolean?
Boolean?
lowFunds
: Boolean?
Boolean?
jobStarted
: Boolean?
Boolean?
jobStopped
: Boolean?
Boolean?
EmailSettingsItem
¶
data class EmailSettingsItem(
val username: String?,
val settings: EmailSettings,
)
Mail
¶
sealed class Mail {
abstract val subject: String
class GrantApplicationApproveMail : Mail()
class GrantApplicationApproveMailToAdmins : Mail()
class GrantApplicationRejectedMail : Mail()
class GrantApplicationStatusChangedToAdmin : Mail()
class GrantApplicationUpdatedMail : Mail()
class GrantApplicationUpdatedMailToAdmins : Mail()
class GrantApplicationWithdrawnMail : Mail()
class JobEvents : Mail()
class LowFundsMail : Mail()
class NewCommentOnApplicationMail : Mail()
class NewGrantApplicationMail : Mail()
class ProjectInviteMail : Mail()
class ResetPasswordMail : Mail()
class StillLowFundsMail : Mail()
class TransferApplicationMail : Mail()
class UserLeftMail : Mail()
class UserRemovedMail : Mail()
class UserRemovedMailToUser : Mail()
class UserRoleChangeMail : Mail()
class VerificationReminderMail : Mail()
class VerifyEmailAddress : Mail()
}
Properties
subject
: String
String
Mail.GrantApplicationApproveMail
¶
data class GrantApplicationApproveMail(
val projectTitle: String,
val subject: String?,
val type: String /* "applicationApproved" */,
)
Mail.GrantApplicationApproveMailToAdmins
¶
data class GrantApplicationApproveMailToAdmins(
val sender: String,
val projectTitle: String,
val subject: String?,
val type: String /* "applicationApprovedToAdmins" */,
)
Mail.GrantApplicationRejectedMail
¶
data class GrantApplicationRejectedMail(
val projectTitle: String,
val subject: String?,
val type: String /* "applicationRejected" */,
)
Mail.GrantApplicationStatusChangedToAdmin
¶
data class GrantApplicationStatusChangedToAdmin(
val status: String,
val projectTitle: String,
val sender: String,
val receivingProjectTitle: String,
val subject: String?,
val type: String /* "applicationStatusChangedToAdmins" */,
)
Mail.GrantApplicationUpdatedMail
¶
data class GrantApplicationUpdatedMail(
val projectTitle: String,
val sender: String,
val subject: String?,
val type: String /* "applicationUpdated" */,
)
Mail.GrantApplicationUpdatedMailToAdmins
¶
data class GrantApplicationUpdatedMailToAdmins(
val projectTitle: String,
val sender: String,
val receivingProjectTitle: String,
val subject: String?,
val type: String /* "applicationUpdatedToAdmins" */,
)
Mail.GrantApplicationWithdrawnMail
¶
data class GrantApplicationWithdrawnMail(
val projectTitle: String,
val sender: String,
val subject: String?,
val type: String /* "applicationWithdrawn" */,
)
Mail.JobEvents
¶
data class JobEvents(
val jobIds: List<String>,
val jobNames: List<String>,
val appTitles: List<String>,
val events: List<String>,
val subject: String?,
val type: String /* "jobEvents" */,
)
Mail.LowFundsMail
¶
data class LowFundsMail(
val categories: List<String>,
val providers: List<String>,
val projectTitles: List<String>,
val subject: String?,
val type: String /* "lowFunds" */,
)
Mail.NewCommentOnApplicationMail
¶
data class NewCommentOnApplicationMail(
val sender: String,
val projectTitle: String,
val receivingProjectTitle: String,
val subject: String?,
val type: String /* "newComment" */,
)
Mail.NewGrantApplicationMail
¶
data class NewGrantApplicationMail(
val sender: String,
val projectTitle: String,
val subject: String?,
val type: String /* "newGrantApplication" */,
)
Mail.ProjectInviteMail
¶
data class ProjectInviteMail(
val projectTitle: String,
val subject: String?,
val type: String /* "invitedToProject" */,
)
Mail.ResetPasswordMail
¶
data class ResetPasswordMail(
val token: String,
val subject: String?,
val type: String /* "resetPassword" */,
)
Mail.StillLowFundsMail
¶
data class StillLowFundsMail(
val category: String,
val provider: String,
val projectTitle: String,
val subject: String?,
val type: String /* "stillLowFunds" */,
)
Mail.TransferApplicationMail
¶
data class TransferApplicationMail(
val senderProject: String,
val receiverProject: String,
val applicationProjectTitle: String,
val subject: String?,
val type: String /* "transferApplication" */,
)
Mail.UserLeftMail
¶
data class UserLeftMail(
val leavingUser: String,
val projectTitle: String,
val subject: String?,
val type: String /* "userLeft" */,
)
Mail.UserRemovedMail
¶
data class UserRemovedMail(
val leavingUser: String,
val projectTitle: String,
val subject: String?,
val type: String /* "userRemoved" */,
)
Mail.UserRemovedMailToUser
¶
data class UserRemovedMailToUser(
val projectTitle: String,
val subject: String?,
val type: String /* "userRemovedToUser" */,
)
Mail.UserRoleChangeMail
¶
data class UserRoleChangeMail(
val subjectToChange: String,
val roleChange: String,
val projectTitle: String,
val subject: String?,
val type: String /* "userRoleChange" */,
)
Mail.VerificationReminderMail
¶
data class VerificationReminderMail(
val projectTitle: String,
val role: String,
val subject: String?,
val type: String /* "verificationReminder" */,
)
Mail.VerifyEmailAddress
¶
data class VerifyEmailAddress(
val verifyType: String,
val token: String,
val subject: String?,
val username: String?,
val type: String /* "verifyEmailAddress" */,
)
RetrieveEmailSettingsRequest
¶
data class RetrieveEmailSettingsRequest(
val username: String?,
)
Properties
username
: String?
String?
SendDirectMandatoryEmailRequest
¶
data class SendDirectMandatoryEmailRequest(
val recipientEmail: String,
val mail: Mail,
)
SendRequestItem
¶
data class SendRequestItem(
val receiver: String,
val mail: Mail,
val mandatory: Boolean?,
val receivingEmail: String?,
val testMail: Boolean?,
)
SendSupportEmailRequest
¶
data class SendSupportEmailRequest(
val fromEmail: String,
val subject: String,
val message: String,
)
RetrieveEmailSettingsResponse
¶
data class RetrieveEmailSettingsResponse(
val settings: EmailSettings,
)
Properties
settings
: EmailSettings
EmailSettings