diff --git a/components/examples/emailTemplate.json b/components/examples/emailTemplate.json new file mode 100644 index 0000000..29058c5 --- /dev/null +++ b/components/examples/emailTemplate.json @@ -0,0 +1,14 @@ +{ + "success": true, + "emailTemplate": { + "id": 11, + "name": "Instance Shutdown Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceShutdown", + "template": "

{{{i18n \"gomorpheus.help.instance.shutdownEmailMessage\" user.displayName instance.displayName}}}

\n", + "enabled": false + } +} \ No newline at end of file diff --git a/components/examples/emailTemplateCreateSuccess.json b/components/examples/emailTemplateCreateSuccess.json new file mode 100644 index 0000000..95fae2f --- /dev/null +++ b/components/examples/emailTemplateCreateSuccess.json @@ -0,0 +1,14 @@ +{ + "success": true, + "emailTemplate": { + "id": 45, + "name": "Confirm Email on Register Template", + "account": { + "id": 1, + "name": "Morpheus QA" + }, + "code": "confirmEmail", + "template": "this is a test", + "enabled": true + } +} \ No newline at end of file diff --git a/components/examples/emailTemplateUpdateSuccess.json b/components/examples/emailTemplateUpdateSuccess.json new file mode 100644 index 0000000..f239ab8 --- /dev/null +++ b/components/examples/emailTemplateUpdateSuccess.json @@ -0,0 +1,14 @@ +{ + "success": true, + "emailTemplate": { + "id": 45, + "name": "Confirm Email on Register Template", + "account": { + "id": 1, + "name": "Test Account" + }, + "code": "confirmEmail", + "template": "this is a test", + "enabled": true + } +} \ No newline at end of file diff --git a/components/examples/emailTemplates.json b/components/examples/emailTemplates.json new file mode 100644 index 0000000..1489125 --- /dev/null +++ b/components/examples/emailTemplates.json @@ -0,0 +1,175 @@ +{ + "emailTemplates": [ + { + "id": 31, + "name": "Confirm Email on Register Template", + "account": { + "id": null, + "name": null + }, + "code": "confirmEmail", + "template": "

{{user.email}}

\n

{{{i18n \"gomorpheus.auth.email.confirm\" url}}}

\n

{{{i18n \"gomorpheus.auth.email.welcome\"}}}

\n

{{{i18n \"gomorpheus.auth.email.teamMorph\"}}}

\n", + "enabled": true + }, + { + "id": 28, + "name": "Confirm Password Update Template", + "account": { + "id": null, + "name": null + }, + "code": "confirmPassUpdate", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.password.email.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.password.email.message\"}}}

\n{{{i18n \"com.bertramlabs.plugins.accounts.password.email.linkLabel\"}}}\n

{{{i18n \"com.bertramlabs.plugins.accounts.password.email.signature\"}}}

\n\n", + "enabled": true + }, + { + "id": 26, + "name": "Disable Inactive User Template", + "account": { + "id": null, + "name": null + }, + "code": "disableInactiveUser", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.resetAccount.email.body\"}}}

\n

\n\n{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.linkLabel\"}}}\n\n

\n\n", + "enabled": true + }, + { + "id": 21, + "name": "Forgot Password Template", + "account": { + "id": null, + "name": null + }, + "code": "forgotPassword", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.message\"}}}

\n

\n\n{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.linkLabel\"}}}\n\n

\n\n", + "enabled": true + }, + { + "id": 23, + "name": "Inactive User Warning Template", + "account": { + "id": null, + "name": null + }, + "code": "inactiveWarning", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.inactiveAccountWarning.email.body\"}}}

\n

\n\n{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.linkLabel\"}}}\n\n

\n\n", + "enabled": true + }, + { + "id": 13, + "name": "Instance About to Expire Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceNotifyExpiring", + "template": "{{{i18n \"gomorpheus.email.instanceExpiring\" user.displayName instance.displayName instance.expireDate}}}\n

\n{{{i18n \"gomorpheus.label.info\"}}}
\n

\n{{#if instance.description}}\n
{{{i18n \"gomorpheus.label.description\"}}}:
\n
{{instance.description}}
\n{{/if}}\n
{{{i18n \"gomorpheus.label.createdBy\"}}}:
\n
{{user.userName}} ({{{user.displayName}}})
\n{{#if instance.instanceContext}}\n
{{{i18n \"gomorpheus.label.environment\"}}}:
\n
{{instance.instanceContext}}
\n{{/if}}\n
{{{i18n \"gomorpheus.label.group\"}}}:
\n
{{instance.site.name}}
\n
{{{i18n \"gomorpheus.label.layout\"}}}:
\n
{{instance.layout.name}}
\n{{#each instance.metadata}}\n {{#if name}}\n
{{name}}:
\n
{{value}}
\n {{/if}}\n {{/each}}\n
\n

\n{{#each instance.containers}}\n {{#if isDocker}}\n

\n {{{i18n \"gomorpheus.label.detailsFor\" name}}} \n
\n

\n
{{{i18n \"gomorpheus.label.plan\"}}}:
\n
{{plan.name}}
\n
{{{i18n \"gomorpheus.label.memory\"}}}:
\n
{{maxMemory}}
\n
{{{i18n \"gomorpheus.label.totalStorage\"}}}:
\n
{{maxStorage}}
\n
{{{i18n \"gomorpheus.label.status\"}}}:
\n
{{status}}
\n
{{{i18n \"gomorpheus.label.cloud\"}}}:
\n
{{server.zone.name}}
\n
{{{i18n \"gomorpheus.label.type\"}}}:
\n
{{containerType.name}}
\n
\n

\n{{else}}\n

\n{{{i18n \"gomorpheus.label.detailsFor\" server.displayName}}}\n

\n
{{{i18n \"gomorpheus.label.plan\"}}}:
\n
{{plan.name}}
\n
{{{i18n \"gomorpheus.label.cpuCores\"}}}
\n
{{maxCores}}
\n
{{{i18n \"gomorpheus.label.memory\"}}}:
\n
{{maxMemory}}
\n
{{{i18n \"gomorpheus.label.totalStorage\"}}}:
\n
{{maxStorage}}
\n
{{{i18n \"gomorpheus.label.status\"}}}:
\n
{{status}}
\n
{{{i18n \"gomorpheus.label.cloud\"}}}:
\n
{{server.zone.name}}
\n
{{{i18n \"gomorpheus.label.platform\"}}}:
\n
{{server.serverOs.name}}
\n
{{{i18n \"gomorpheus.label.sourceImage\"}}}:
\n
{{server.sourceImage.name}}
\n
{{{i18n \"gomorpheus.label.hostname\"}}}:
\n
{{server.externalFqdn}}
\n
\n

\n

\n{{{i18n \"gomorpheus.label.networks\"}}}
\n\n{{/if}}\n{{/each}}\n

\n{{{extendLink}}}\n

\n", + "enabled": true + }, + { + "id": 3, + "name": "Instance Expired Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceExpired", + "template": "{{#if deleteApprovedRequired}}\n {{{i18n \"gomorpheus.email.instanceExpired.deleteApprovalRequired\" user.displayName instance.displayName instance.site.name}}}\n{{else if delayedRemovalApplied}}\n {{{i18n \"gomorpheus.email.instanceExpired.delayedRemovalApplied\" user.displayName instance.displayName instance.site.name}}}\n{{else}}\n {{{i18n \"gomorpheus.email.instanceExpired\" user.displayName instance.displayName instance.site.name}}}\n{{/if}}\n", + "enabled": true + }, + { + "id": 35, + "name": "Instance Provision Complete Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceComplete", + "template": "{{#if success}}\n

{{{i18n \"gomorpheus.email.instanceComplete\" user.displayName instance.displayName}}}

\n{{else}}\n

{{{i18n \"gomorpheus.email.instanceCompleteError\" user.displayName instance.displayName}}}

\n{{/if}}\n{{#if instance.statusMessage}}\n

{{instance.statusMessage}}

\n{{/if}}\n{{#if instance.errorMessage}}\n

{{instance.errorMessage}}

\n{{else}}\n {{{i18n \"gomorpheus.action.viewInstance\"}}}\n{{/if}}\n", + "enabled": true + }, + { + "id": 44, + "name": "Instance Provision Complete Template", + "account": { + "id": 1, + "name": "Morpheus QA" + }, + "code": "instanceComplete", + "template": "Testesss", + "enabled": false + }, + { + "id": 37, + "name": "Instance Scale Complete Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceScaleComplete", + "template": "{{#if success}}\n

{{{i18n \"gomorpheus.email.instanceScaleComplete\" user.displayName instance.displayName}}}

\n{{else}}\n

{{{i18n \"gomorpheus.email.instanceScaleCompleteError\" user.displayName instance.displayName}}}

\n{{/if}}\n

\n {{{i18n \"gomorpheus.action.viewInstance\"}}}\n

\n", + "enabled": true + }, + { + "id": 11, + "name": "Instance Shutdown Template", + "account": { + "id": null, + "name": null + }, + "code": "instanceShutdown", + "template": "

{{{i18n \"gomorpheus.help.instance.shutdownEmailMessage\" user.displayName instance.displayName}}}

\n", + "enabled": false + }, + { + "id": 14, + "name": "Instance Shutdown Warning Template", + "account": { + "id": null, + "name": null + }, + "code": "notifyShutdownWarningInstance", + "template": "

{{{i18n \"gomorpheus.help.instance.shutdownWarningEmailMessage\" user.displayName instance.displayName instance.shutdownDate}}}

\n

{{{extendLink}}}

\n", + "enabled": true + }, + { + "id": 33, + "name": "Register Successful Template", + "account": { + "id": null, + "name": null + }, + "code": "registerSuccess", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.register.email.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.register.email.message\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.register.email.signature\"}}}

\n", + "enabled": true + }, + { + "id": 29, + "name": "User Account Updated Template", + "account": { + "id": null, + "name": null + }, + "code": "userAccountConfirmEmail", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.userAccount.email.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.userAccount.email.message\"}}}

\n{{{i18n \"com.bertramlabs.plugins.accounts.userAccount.email.linkLabel\"}}}\n

{{{i18n \"com.bertramlabs.plugins.accounts.password.email.signature\"}}}

\n\n", + "enabled": true + }, + { + "id": 25, + "name": "Warn Old Password Template", + "account": { + "id": null, + "name": null + }, + "code": "warnOldPassword", + "template": "

{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.greeting\"}}}

\n

{{{i18n \"com.bertramlabs.plugins.accounts.oldPasswordWarning.email.body\"}}}

\n

\n\n{{{i18n \"com.bertramlabs.plugins.accounts.forgotPasswordEmail.linkLabel\"}}}\n\n

\n\n", + "enabled": true + } + ], + "meta": { + "offset": 0, + "max": 25, + "size": 15, + "total": 15 + } +} \ No newline at end of file diff --git a/components/schemas/emailTemplate.yaml b/components/schemas/emailTemplate.yaml new file mode 100644 index 0000000..e037968 --- /dev/null +++ b/components/schemas/emailTemplate.yaml @@ -0,0 +1,35 @@ +type: object +properties: + id: + type: integer + format: int64 + name: + type: string + description: | + The name of the email template. This is set by morpheus. + code: + type: string + description: | + A unique code for the email template. This code is used to reference the email template and as a reference of the templates type. + account: + type: object + nullable: true + properties: + id: + type: integer + format: int64 + nullable: true + name: + type: string + nullable: true + description: | + The account that the email template is associated with. This is set by morpheus. + enabled: + type: boolean + description: | + Whether the email template is enabled or not. + template: + type: string + description: | + The email template. This is the actual email template that is sent to the user. This uses handlebars notation (not javascript) + \ No newline at end of file diff --git a/openapi.yaml b/openapi.yaml index b486b62..76143cd 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -164,6 +164,10 @@ paths: /api/clients/{id}: $ref: paths/api@clients@id.yaml + /api/email-templates: + $ref: paths/api@email-templates.yaml + /api/email-templates/{id}: + $ref: paths/api@email-templates@id.yaml /api/monitoring/apps: $ref: paths/api@monitoring@apps.yaml diff --git a/paths/api@email-templates.yaml b/paths/api@email-templates.yaml new file mode 100644 index 0000000..db0656b --- /dev/null +++ b/paths/api@email-templates.yaml @@ -0,0 +1,93 @@ +get: + summary: Retrieves all Email Templates + description: | + Retrieves all email templates. + operationId: listEmailTemplates + tags: + - Email Templates + parameters: + - $ref: ../components/parameters/max.yaml + - $ref: ../components/parameters/offset.yaml + - $ref: ../components/parameters/sort.yaml + - $ref: ../components/parameters/direction.yaml + - $ref: ../components/parameters/phrase.yaml + - $ref: ../components/parameters/name.yaml + responses: + '200': + description: Successful Request + content: + application/json: + schema: + allOf: + - type: object + properties: + emailTemplates: + type: array + items: + $ref: ../components/schemas/emailTemplate.yaml + - $ref: ../components/schemas/meta.yaml + examples: + Get Email Templates Response: + value: + $ref: ../components/examples/emailTemplates.json + '4XX': + $ref: ../components/responses/4xx.yaml + '5XX': + $ref: ../components/responses/5xx.yaml +post: + summary: Creates an Email Template + description: Use this command to create an email template. + operationId: addEmailTemplate + tags: + - Email Templates + requestBody: + content: + application/json: + schema: + type: object + required: + - emailTemplate + properties: + code: + type: string + enum: + - instanceExpired + - instanceShutdown + - instanceNotifyExpiring + - notifyShutdownWarningInstance + - forgotPassword + - inactiveWarning + - warnOldPassword + - confirmPassUpdate + - userAccountConfirmEmail + - confirmEmail + - registerSuccess + - instanceComplete + - instanceScaleComplete + template: + type: string + description: | + The email template. This is the actual email template that is sent to the user. This uses handlebars notation (not javascript) + enabled: + type: boolean + default: true + description: | + Whether the email template is enabled or not. + responses: + '200': + description: Successful Request + content: + application/json: + schema: + type: object + properties: + emailTemplate: + $ref: ../components/schemas/emailTemplate.yaml + examples: + Add Email Template Response: + value: + $ref: ../components/examples/emailTemplateCreateSuccess.json + '4XX': + $ref: ../components/responses/4xx.yaml + '5XX': + $ref: ../components/responses/5xx.yaml \ No newline at end of file diff --git a/paths/api@email-templates@id.yaml b/paths/api@email-templates@id.yaml new file mode 100644 index 0000000..fd1e63d --- /dev/null +++ b/paths/api@email-templates@id.yaml @@ -0,0 +1,92 @@ +get: + summary: Retrieves a Specific Email Template + description: | + Retrieves a specific email template. + operationId: getEmailTemplate + tags: + - Email Templates + parameters: + - $ref: ../components/parameters/id-path.yaml + responses: + '200': + description: Successful Request + content: + application/json: + schema: + allOf: + - type: object + properties: + emailTemplate: + $ref: ../components/schemas/emailTemplate.yaml + - $ref: ../components/schemas/200-success.yaml + examples: + Email Template Response: + value: + $ref: ../components/examples/emailTemplate.json + '4XX': + $ref: ../components/responses/4xx.yaml + '5XX': + $ref: ../components/responses/5xx.yaml +put: + summary: Updates an Email Template + description: Use this command to update an email template. + operationId: updateEmailTemplate + tags: + - Email Templates + parameters: + - $ref: ../components/parameters/id-path.yaml + requestBody: + content: + application/json: + schema: + type: object + required: + - emailTemplate + properties: + emailTemplate: + properties: + template: + type: string + description: The email template + enabled: + type: boolean + description: Whether the email template is enabled + default: true + responses: + '200': + description: Successful Request + content: + application/json: + schema: + type: object + properties: + emailTemplate: + $ref: ../components/schemas/emailTemplate.yaml + examples: + Update Email Template Response: + value: + $ref: ../components/examples/emailTemplateUpdateSuccess.json + '4XX': + $ref: ../components/responses/4xx.yaml + '5XX': + $ref: ../components/responses/5xx.yaml +delete: + summary: Deletes an Email Template + description: Use this command to delete an email template. + operationId: deleteEmailTemplate + tags: + - Email Templates + parameters: + - $ref: ../components/parameters/id-path.yaml + responses: + '200': + description: Successful Request + content: + application/json: + schema: + $ref: ../components/schemas/200-success.yaml + '4XX': + $ref: ../components/responses/4xx.yaml + '5XX': + $ref: ../components/responses/5xx.yaml + \ No newline at end of file