From f27a82b3a843a347a5aa2bdc1975a9e722c0ef4e Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Tue, 4 Jun 2024 09:58:09 +0530 Subject: [PATCH] Notification Template API implementation --- .../pom.xml | 60 + .../template/common/Constants.java | 152 +++ .../common/TemplatesServiceHolder.java | 28 + .../common/factory/OSGIServiceFactory.java | 56 + .../pom.xml | 179 +++ .../template/v1/NotificationApi.java | 721 ++++++++++ .../template/v1/NotificationApiService.java | 95 ++ .../NotificationApiServiceFactory.java | 32 + .../template/v1/model/EmailTemplate.java | 171 +++ .../v1/model/EmailTemplateWithID.java | 106 ++ .../notification/template/v1/model/Error.java | 165 +++ .../template/v1/model/SMSTemplate.java | 101 ++ .../template/v1/model/SMSTemplateWithID.java | 106 ++ .../template/v1/model/SimpleTemplate.java | 125 ++ .../template/v1/model/TemplateType.java | 125 ++ .../v1/model/TemplateTypeOverview.java | 101 ++ .../template/v1/model/TemplateTypeWithID.java | 106 ++ .../v1/core/ApplicationTemplatesService.java | 305 +++++ .../v1/core/OrganizationTemplatesService.java | 220 ++++ .../template/v1/core/TemplateTypeService.java | 157 +++ .../v1/impl/NotificationApiServiceImpl.java | 291 ++++ .../notification/template/v1/util/Util.java | 334 +++++ .../notification-template-server-v1-cxf.xml | 29 + .../main/resources/notification-template.yml | 1168 +++++++++++++++++ .../pom.xml | 37 + pom.xml | 7 + 26 files changed, 4977 insertions(+) create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/OrganizationTemplatesService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml create mode 100644 components/org.wso2.carbon.identity.api.server.notification.template/pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml new file mode 100644 index 0000000000..41f71c6d5b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/pom.xml @@ -0,0 +1,60 @@ + + + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template + 1.2.196-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.identity.api.server.notification.template.common + jar + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + javax.ws.rs + javax.ws.rs-api + provided + + + org.wso2.carbon.identity.event.handler.notification + org.wso2.carbon.email.mgt + + + org.springframework + spring-web + provided + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java new file mode 100644 index 0000000000..11c15e7a9e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/Constants.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.notification.template.common; + +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.Response.Status; + +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_ADDING_TEMPLATE; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.ERROR_UPDATING_TEMPLATE; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_ALREADY_EXISTS; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_NOT_FOUND; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_ALREADY_EXISTS; +import static org.wso2.carbon.email.mgt.constants.TemplateMgtConstants.ErrorCodes.TEMPLATE_TYPE_NOT_FOUND; + +/** + * Constants related to notification templates. + */ +public class Constants { + + public static final String NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX = "NTM-"; + public static final String NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL = "/email"; + public static final String NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS = "/sms"; + public static final String NOTIFICATION_TEMPLATES_API_PATH = "/notification"; + public static final String TEMPLATE_TYPES_PATH = "/template-types"; + public static final String APP_TEMPLATES_PATH = "/app-templates"; + public static final String ORG_TEMPLATES_PATH = "/org-templates"; + public static final String PATH_SEPARATOR = "/"; + public static final String NOTIFICATION_CHANNEL_EMAIL = "email"; + public static final String NOTIFICATION_CHANNEL_SMS = "sms"; + + // ERROR MESSAGES + private static final Map NTM_ERROR_CODE_MAP = new HashMap<>(); + + /** + * Enum for error messages. + */ + public enum ErrorMessage { + + ERROR_TEMPLATE_TYPE_ALREADY_EXISTS("65001", Status.CONFLICT, + "Template Type already exists in the system.", + "A template type for the provided template display name already exists " + + "in the system."), + ERROR_TEMPLATE_TYPE_NOT_FOUND("65002", Status.NOT_FOUND, + "Template Type does not exist.", + "Specified template type does not exist in the system."), + ERROR_TEMPLATE_ALREADY_EXISTS("65003", Status.CONFLICT, + "Template already exists in the system.", + "A template for the provided template id already exists in the system."), + ERROR_TEMPLATE_NOT_FOUND("65004", Status.NOT_FOUND, + "Template does not exist.", + "Specified template does not exist in the system."), + ERROR_ERROR_RETRIEVING_TEMPLATE_TYPES("60002", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve template types.", + "Server encountered an error while retrieving template types."), + ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE("60003", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve the template type.", + "Server encountered an error while retrieving the template " + + "type identified by the given template-type-id."), + ERROR_ERROR_ADDING_TEMPLATE_TYPE("60004", Status.INTERNAL_SERVER_ERROR, + "Unable to add the template type.", + "Server encountered an error while adding template type."), + ERROR_ERROR_DELETING_TEMPLATE_TYPE("60005", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the template type.", + "Server encountered an error while deleting the template type."), + ERROR_ERROR_ADDING_TEMPLATE("60006", Status.INTERNAL_SERVER_ERROR, + "Unable to add the template.", + "Server encountered an error while adding the template to the system."), + ERROR_ERROR_UPDATING_TEMPLATE("60007", Status.INTERNAL_SERVER_ERROR, + "Unable to update the template.", + "Server encountered an error while updating the template."), + ERROR_ERROR_RETRIEVING_TEMPLATE("60008", Status.INTERNAL_SERVER_ERROR, + "Unable to retrieve the template.", + "Server encountered an error while retrieving the template " + + "identified by the given template-type-id and the template-id."), + ERROR_ERROR_DELETING_EMAIL_TEMPLATE("60009", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the email template.", + "Server encountered an error while deleting the email template."), + ERROR_ERROR_DELETING_SMS_TEMPLATE("60010", Status.INTERNAL_SERVER_ERROR, + "Unable to delete the SMS template.", + "Server encountered an error while deleting the SMS template."); + + private final String message; + private final Status httpStatus; + private final String code; + private final String description; + + ErrorMessage(String code, Status httpStatus, String message, String description) { + + this.code = code; + this.httpStatus = httpStatus; + this.message = message; + this.description = description; + } + + public String getCode() { + + return NOTIFICATION_TEMPLATES_ERROR_CODE_PREFIX + code; + } + + public String getMessage() { + + return message; + } + + public String getDescription() { + + return description; + } + + public Status getHttpStatus() { + + return httpStatus; + } + + @Override + public String toString() { + + return code + " | " + message; + } + } + + static { + NTM_ERROR_CODE_MAP.put(TEMPLATE_TYPE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_TYPE_ALREADY_EXISTS); + NTM_ERROR_CODE_MAP.put(TEMPLATE_TYPE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + NTM_ERROR_CODE_MAP.put(TEMPLATE_ALREADY_EXISTS, ErrorMessage.ERROR_TEMPLATE_ALREADY_EXISTS); + NTM_ERROR_CODE_MAP.put(TEMPLATE_NOT_FOUND, ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + NTM_ERROR_CODE_MAP.put(ERROR_ADDING_TEMPLATE, ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + NTM_ERROR_CODE_MAP.put(ERROR_UPDATING_TEMPLATE, ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + + public static ErrorMessage getNTMMappedErrorMessage(String errorCode) { + + return NTM_ERROR_CODE_MAP.get(errorCode); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java new file mode 100644 index 0000000000..60b7d34f8b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/TemplatesServiceHolder.java @@ -0,0 +1,28 @@ +package org.wso2.carbon.identity.api.server.notification.template.common; + + +import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager; + +/** + * This class is used to hold the TemplateManager service. + */ +public class TemplatesServiceHolder { + + private static NotificationTemplateManager notificationTemplateManager; + + /** + * Get TemplateManager osgi service. + * @return TemplateManager + */ + public static NotificationTemplateManager getNotificationTemplateManager() { + return notificationTemplateManager; + } + + /** + * Set TemplateManager osgi service. + * @param notificationTemplateManager TemplateManager + */ + public static void setNotificationTemplateManager(NotificationTemplateManager notificationTemplateManager) { + TemplatesServiceHolder.notificationTemplateManager = notificationTemplateManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java new file mode 100644 index 0000000000..f2a067ac23 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.api.server.notification.template.common/src/main/java/org/wso2/carbon/identity/api/server/notification/template/common/factory/OSGIServiceFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.api.server.notification.template.common.factory; + +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.governance.service.notification.NotificationTemplateManager; + +import java.util.Hashtable; + +/** + * Factory Beans serves as a factory for creating other beans within the IOC container. This factory bean is used to + * instantiate the NotificationTemplateManager type of object inside the container. + */ +public class OSGIServiceFactory extends AbstractFactoryBean { + + private NotificationTemplateManager notificationTemplateManager; + + @Override + public Class getObjectType() { + return Object.class; + } + + @Override + protected NotificationTemplateManager createInstance() throws Exception { + + if (this.notificationTemplateManager == null) { + Hashtable serviceProperties = new Hashtable<>(); + serviceProperties.put("service.name", "NotificationTemplateManager"); + NotificationTemplateManager taskOperationService = (NotificationTemplateManager) PrivilegedCarbonContext. + getThreadLocalCarbonContext().getOSGiService(NotificationTemplateManager.class, serviceProperties); + if (taskOperationService != null) { + this.notificationTemplateManager = taskOperationService; + } else { + throw new Exception("Unable to retrieve NotificationTemplateManager service."); + } + } + return this.notificationTemplateManager; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml new file mode 100644 index 0000000000..0e5584f085 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/pom.xml @@ -0,0 +1,179 @@ + + + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template + 1.2.196-SNAPSHOT + + + 4.0.0 + org.wso2.carbon.identity.rest.api.server.notification.template.v1 + jar + + WSO2 Identity Server - Notification Templates Rest API v1 + WSO2 Identity Server - Notification Templates Rest API v1 + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + org.springframework + spring-web + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.event.handler.notification + org.wso2.carbon.email.mgt + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template.common + + + org.wso2.carbon.identity.governance + org.wso2.carbon.identity.recovery + provided + + + javax.ws.rs + jsr311-api + + + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java new file mode 100644 index 0000000000..d961ed1675 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApi.java @@ -0,0 +1,721 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1; + +import org.springframework.beans.factory.annotation.Autowired; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.Error; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/notification") +@Api(description = "The notification API") + +public class NotificationApi { + + @Autowired + private NotificationApiService delegate; + + @Valid + @POST + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new application email template to an existing email template type.", notes = "Another application email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + + return delegate.addAppEmailTemplate(templateTypeId, appUuid, emailTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new application SMS template to an existing SMS template type.", notes = "Another application SMS template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + + return delegate.addAppSMSTemplate(templateTypeId, appUuid, smSTemplateWithID ); + } + + @Valid + @POST + @Path("/email/template-types") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new email template type.", notes = "Adds a new email template type to the system. An email template type can have any number of organization or application email templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_email_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addEmailTemplateType(@ApiParam(value = "Email template type to be added." ) @Valid TemplateTypeOverview templateTypeOverview) { + + return delegate.addEmailTemplateType(templateTypeOverview ); + } + + @Valid + @POST + @Path("/email/template-types/{template-type-id}/org-templates") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new email template to an existing email template type.", notes = "Another email template with the same locale should not already exist in the respective email template type.
Scopes required:
* internal_email_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Email template to be added." ) @Valid EmailTemplateWithID emailTemplateWithID) { + + return delegate.addOrgEmailTemplate(templateTypeId, emailTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types/{template-type-id}/org-templates") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new organization SMS template to an existing SMS template type.", notes = "Another SMS organization template with the same locale should not already exist in the respective SMS template type.
Scopes required:
* internal_sms_mgt_create ", response = SimpleTemplate.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = SimpleTemplate.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "SMS template to be added." ) @Valid SMSTemplateWithID smSTemplateWithID) { + + return delegate.addOrgSMSTemplate(templateTypeId, smSTemplateWithID ); + } + + @Valid + @POST + @Path("/sms/template-types") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Adds a new SMS template type.", notes = "Adds a new SMS template type to the system. An SMS template type can have any number of organization or application SMS templates.
* Attribute _**displayName**_ of the template type should be unique.
Scopes required:
* internal_sms_mgt_create ", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Item Created", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 409, message = "Item Already Exists.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response addSMSTemplateType(@ApiParam(value = "SMS template type to be added." ) @Valid TemplateTypeOverview templateTypeOverview) { + + return delegate.addSMSTemplateType(templateTypeOverview ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteAppEmailTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an SMS template.", notes = "Removes an SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteAppSMSTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template type.", notes = "Removes an existing email template type with all its email templates from the system.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteEmailTemplateType(templateTypeId ); + } + + @Valid + @DELETE + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an email template.", notes = "Removes an email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteOrgEmailTemplate(templateTypeId, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an organization SMS template.", notes = "Removes an organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.deleteOrgSMSTemplate(templateTypeId, locale ); + } + + @Valid + @DELETE + @Path("/sms/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Removes an SMS template type.", notes = "Removes an existing SMS template type with all its SMS templates from the system.
Scopes required:
* internal_sms_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "Item Deleted.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response deleteSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.deleteSMSTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/email/template-types") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves all the email template types.", notes = "Retrieves all the email template types in the system.

Scopes required:
* internal_email_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAllEmailTemplateTypes() { + + return delegate.getAllEmailTemplateTypes(); + } + + @Valid + @GET + @Path("/sms/template-types") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves all the sms template types.", notes = "Retrieves all the SMS template types in the system.
Scopes required:
* internal_sms_mgt_view ", response = TemplateTypeWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAllSMSTemplateTypes() { + + return delegate.getAllSMSTemplateTypes(); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single email template of application.", notes = "Retrieves the application email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getAppEmailTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single SMS template of application.", notes = "Retrieves the application SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getAppSMSTemplate(templateTypeId, appUuid, locale ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of application email templates in the template type id.", notes = "Retrieves the list of application email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + + return delegate.getAppTemplatesListOfEmailTemplateType(templateTypeId, appUuid ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of application SMS templates in the template type id.", notes = "Retrieves the list of application SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getAppTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid) { + + return delegate.getAppTemplatesListOfSMSTemplateType(templateTypeId, appUuid ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the email template type corresponding to the template type id.", notes = "Retrieves the email template type in the system identified by the template-type-id.
Scopes required:
* internal_email_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single email template.", notes = "Retrieves the email template that matches to the template-type-id and the locale.
Scope required:
* internal_email_mgt_view ", response = EmailTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getOrgEmailTemplate(templateTypeId, locale ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves a single organization SMS template.", notes = "Retrieves the SMS template that matches to the template-type-id and the locale.
Scope required:
* internal_sms_mgt_view ", response = SMSTemplateWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale) { + + return delegate.getOrgSMSTemplate(templateTypeId, locale ); + } + + @Valid + @GET + @Path("/email/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of organization email templates in the template type id.", notes = "Retrieves the list of organization email templates in the template type id.
Scope required:
* internal_email_mgt_view
", response = EmailTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = EmailTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgTemplatesListOfEmailTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getOrgTemplatesListOfEmailTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}/org-templates") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the list of organization SMS templates in the template type id.", notes = "Retrieves the list of organization SMS templates in the template type id.
Scope required:
* internal_sms_mgt_view
", response = SMSTemplateWithID.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = SMSTemplateWithID.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getOrgTemplatesListOfSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getOrgTemplatesListOfSMSTemplateType(templateTypeId ); + } + + @Valid + @GET + @Path("/sms/template-types/{template-type-id}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieves the SMS template type corresponding to the template type id.", notes = "Retrieves the SMS template type in the system identified by the template-type-id.
Scopes required:
* internal_sms_mgt_view
", response = TemplateTypeWithID.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Template Types", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Search results matching the given criteria.", response = TemplateTypeWithID.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response getSMSTemplateType(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId) { + + return delegate.getSMSTemplateType(templateTypeId ); + } + + @Valid + @PUT + @Path("/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing application email template.", notes = "Replaces the application email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateAppEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + + return delegate.updateAppEmailTemplate(templateTypeId, appUuid, locale, emailTemplate ); + } + + @Valid + @PUT + @Path("/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing application SMS template.", notes = "Replaces the application SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Application SMS Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateAppSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "Application UUID.",required=true) @PathParam("app-uuid") String appUuid, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid SMSTemplate smSTemplate) { + + return delegate.updateAppSMSTemplate(templateTypeId, appUuid, locale, smSTemplate ); + } + + @Valid + @PUT + @Path("/email/template-types/{template-type-id}/org-templates/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing email template.", notes = "Replaces the email template identified by the template-type-id and the locale.
Scopes required:
* internal_email_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Email Templates", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateOrgEmailTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "Email templates for the template type." ) @Valid EmailTemplate emailTemplate) { + + return delegate.updateOrgEmailTemplate(templateTypeId, locale, emailTemplate ); + } + + @Valid + @PUT + @Path("/sms/template-types/{template-type-id}/org-templates/{locale}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Replaces an existing organization SMS template.", notes = "Replaces the organization SMS template identified by the template-type-id and the locale.
Scopes required:
* internal_sms_mgt_update ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "SMS Templates" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Item Updated.", response = Void.class), + @ApiResponse(code = 400, message = "Invalid input request.", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized.", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden.", response = Void.class), + @ApiResponse(code = 404, message = "The specified resource is not found.", response = Error.class), + @ApiResponse(code = 500, message = "Internal Server Error.", response = Error.class) + }) + public Response updateOrgSMSTemplate(@ApiParam(value = "Email Template Type ID.",required=true) @PathParam("template-type-id") String templateTypeId, @ApiParam(value = "This should be a valid locale.",required=true) @PathParam("locale") String locale, @ApiParam(value = "SMS templates for the template type." ) @Valid SMSTemplate smSTemplate) { + + return delegate.updateOrgSMSTemplate(templateTypeId, locale, smSTemplate ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java new file mode 100644 index 0000000000..3548a1cfce --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/NotificationApiService.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.*; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.*; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.Error; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import javax.ws.rs.core.Response; + + +public interface NotificationApiService { + + public Response addAppEmailTemplate(String templateTypeId, String appUuid, EmailTemplateWithID emailTemplateWithID); + + public Response addAppSMSTemplate(String templateTypeId, String appUuid, SMSTemplateWithID smSTemplateWithID); + + public Response addEmailTemplateType(TemplateTypeOverview templateTypeOverview); + + public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID); + + public Response addOrgSMSTemplate(String templateTypeId, SMSTemplateWithID smSTemplateWithID); + + public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview); + + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale); + + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale); + + public Response deleteEmailTemplateType(String templateTypeId); + + public Response deleteOrgEmailTemplate(String templateTypeId, String locale); + + public Response deleteOrgSMSTemplate(String templateTypeId, String locale); + + public Response deleteSMSTemplateType(String templateTypeId); + + public Response getAllEmailTemplateTypes(); + + public Response getAllSMSTemplateTypes(); + + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale); + + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale); + + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid); + + public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid); + + public Response getEmailTemplateType(String templateTypeId); + + public Response getOrgEmailTemplate(String templateTypeId, String locale); + + public Response getOrgSMSTemplate(String templateTypeId, String locale); + + public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId); + + public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId); + + public Response getSMSTemplateType(String templateTypeId); + + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, EmailTemplate emailTemplate); + + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, SMSTemplate smSTemplate); + + public Response updateOrgEmailTemplate(String templateTypeId, String locale, EmailTemplate emailTemplate); + + public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smSTemplate); +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java new file mode 100644 index 0000000000..8e708a033b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/factories/NotificationApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.factories; + +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.impl.NotificationApiServiceImpl; + +public class NotificationApiServiceFactory { + + private final static NotificationApiService service = new NotificationApiServiceImpl(); + + public static NotificationApiService getNotificationApi() + { + return service; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java new file mode 100644 index 0000000000..9f0c5e716b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplate.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class EmailTemplate { + + private String contentType; + private String subject; + private String body; + private String footer; + + /** + * Content type of the email template. + **/ + public EmailTemplate contentType(String contentType) { + + this.contentType = contentType; + return this; + } + + @ApiModelProperty(example = "text/html", required = true, value = "Content type of the email template.") + @JsonProperty("contentType") + @Valid + @NotNull(message = "Property contentType cannot be null.") + + public String getContentType() { + return contentType; + } + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * The subject of the email. + **/ + public EmailTemplate subject(String subject) { + + this.subject = subject; + return this; + } + + @ApiModelProperty(example = "WSO2 - Account Confirmation", required = true, value = "The subject of the email.") + @JsonProperty("subject") + @Valid + @NotNull(message = "Property subject cannot be null.") + + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + + /** + * The body of the email. + **/ + public EmailTemplate body(String body) { + + this.body = body; + return this; + } + + @ApiModelProperty(example = "HTML Body", required = true, value = "The body of the email.") + @JsonProperty("body") + @Valid + @NotNull(message = "Property body cannot be null.") + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + + /** + * The footer of the email. + **/ + public EmailTemplate footer(String footer) { + + this.footer = footer; + return this; + } + + @ApiModelProperty(example = "WSO2 Identity Server Team", value = "The footer of the email.") + @JsonProperty("footer") + @Valid + public String getFooter() { + return footer; + } + public void setFooter(String footer) { + this.footer = footer; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EmailTemplate emailTemplate = (EmailTemplate) o; + return Objects.equals(this.contentType, emailTemplate.contentType) && + Objects.equals(this.subject, emailTemplate.subject) && + Objects.equals(this.body, emailTemplate.body) && + Objects.equals(this.footer, emailTemplate.footer); + } + + @Override + public int hashCode() { + return Objects.hash(contentType, subject, body, footer); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class EmailTemplate {\n"); + + sb.append(" contentType: ").append(toIndentedString(contentType)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" footer: ").append(toIndentedString(footer)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java new file mode 100644 index 0000000000..758785ca4b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/EmailTemplateWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class EmailTemplateWithID extends EmailTemplate { + + private String locale; + + /** + * Locale of the email template. + **/ + public EmailTemplateWithID locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the email template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + EmailTemplateWithID emailTemplateWithID = (EmailTemplateWithID) o; + return Objects.equals(this.locale, emailTemplateWithID.locale); + } + + @Override + public int hashCode() { + return Objects.hash(locale); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class EmailTemplateWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java new file mode 100644 index 0000000000..2ae19eb2ca --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/Error.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "NTM-50000", required = true, value = "") + @JsonProperty("code") + @Valid + @NotNull(message = "Property code cannot be null.") + + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message", required = true, value = "") + @JsonProperty("message") + @Valid + @NotNull(message = "Property message cannot be null.") + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "TR0001", value = "") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java new file mode 100644 index 0000000000..788fce7c25 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplate.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SMSTemplate { + + private String body; + + /** + * The body of the SMS. + **/ + public SMSTemplate body(String body) { + + this.body = body; + return this; + } + + @ApiModelProperty(example = "SMS Body", required = true, value = "The body of the SMS.") + @JsonProperty("body") + @Valid + @NotNull(message = "Property body cannot be null.") + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SMSTemplate smSTemplate = (SMSTemplate) o; + return Objects.equals(this.body, smSTemplate.body); + } + + @Override + public int hashCode() { + return Objects.hash(body); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SMSTemplate {\n"); + + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java new file mode 100644 index 0000000000..406165c35e --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SMSTemplateWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SMSTemplateWithID extends SMSTemplate { + + private String locale; + + /** + * Locale of the SMS template. + **/ + public SMSTemplateWithID locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the SMS template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + SMSTemplateWithID smSTemplateWithID = (SMSTemplateWithID) o; + return Objects.equals(this.locale, smSTemplateWithID.locale); + } + + @Override + public int hashCode() { + return Objects.hash(locale); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SMSTemplateWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java new file mode 100644 index 0000000000..e47e891a59 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/SimpleTemplate.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class SimpleTemplate { + + private String locale; + private String self; + + /** + * Locale of the template. + **/ + public SimpleTemplate locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US", required = true, value = "Locale of the template.") + @JsonProperty("locale") + @Valid + @NotNull(message = "Property locale cannot be null.") + + public String getLocale() { + return locale; + } + public void setLocale(String locale) { + this.locale = locale; + } + + /** + * Location of the created/updated resource. + **/ + public SimpleTemplate self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US", required = true, value = "Location of the created/updated resource.") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SimpleTemplate simpleTemplate = (SimpleTemplate) o; + return Objects.equals(this.locale, simpleTemplate.locale) && + Objects.equals(this.self, simpleTemplate.self); + } + + @Override + public int hashCode() { + return Objects.hash(locale, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class SimpleTemplate {\n"); + + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java new file mode 100644 index 0000000000..a054eb72c2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateType.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateType { + + private String displayName; + private String self; + + /** + * Display name of the email template type. + **/ + public TemplateType displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the email template type.") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * Location of the created/updated resource. + **/ + public TemplateType self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Location of the created/updated resource.") + @JsonProperty("self") + @Valid + @NotNull(message = "Property self cannot be null.") + + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateType templateType = (TemplateType) o; + return Objects.equals(this.displayName, templateType.displayName) && + Objects.equals(this.self, templateType.self); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, self); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateType {\n"); + + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" self: ").append(toIndentedString(self)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java new file mode 100644 index 0000000000..1b60b13fbc --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeOverview.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateTypeOverview { + + private String displayName; + + /** + * Display name of the template type. + **/ + public TemplateTypeOverview displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Account Confirmation", required = true, value = "Display name of the template type.") + @JsonProperty("displayName") + @Valid + @NotNull(message = "Property displayName cannot be null.") + + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TemplateTypeOverview templateTypeOverview = (TemplateTypeOverview) o; + return Objects.equals(this.displayName, templateTypeOverview.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateTypeOverview {\n"); + + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java new file mode 100644 index 0000000000..dccfb2930f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/gen/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/model/TemplateTypeWithID.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateType; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class TemplateTypeWithID extends TemplateType { + + private String id; + + /** + * Unique ID of the template type. + **/ + public TemplateTypeWithID id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "YWNjb3VudGNvbmZpcm1hdGlvbg", required = true, value = "Unique ID of the template type.") + @JsonProperty("id") + @Valid + @NotNull(message = "Property id cannot be null.") + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + TemplateTypeWithID templateTypeWithID = (TemplateTypeWithID) o; + return Objects.equals(this.id, templateTypeWithID.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class TemplateTypeWithID {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java new file mode 100644 index 0000000000..0a936bd843 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/ApplicationTemplatesService.java @@ -0,0 +1,305 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; + +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.governance.model.NotificationTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; + +import java.util.List; + +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; + +/** + * Service class for application email templates. + */ +public class ApplicationTemplatesService { + + /** + * Adds a new application email template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param emailTemplateWithID New email template. + * @param applicationUuid Application UUID. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID, + String applicationUuid) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getTemplateLocation(templateTypeId, applicationUuid, + notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_EMAIL)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + /** + * Adds a new application SMS template to the given template type. Template ID should not exist in the system. + * + * @param templateTypeId Template type in which the template should be added. + * @param smsTemplateWithID New SMS template. + * @param applicationUuid Application UUID. + * @return Location of the newly created template if successful, 409 if template already exists, 500 otherwise. + */ + public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID smsTemplateWithID, + String applicationUuid) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getTemplateLocation(templateTypeId, applicationUuid, + notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_SMS)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + + /** + * Retrieves the list of application email templates of the given template type. + * + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @return List of email templates. + */ + public List getTemplatesListOfEmailTemplateType(String templateTypeId, + String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List emailTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + getTenantDomainFromContext(), applicationUuid); + return Util.buildEmailTemplateWithIDList(emailTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Retrieves the list of application SMS templates of the given template type. + * + * @param templateTypeId Template type ID. + * @param applicationUuid Application UUID. + * @return List of SMS templates. + */ + public List getTemplatesListOfSMSTemplateType(String templateTypeId, + String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List smsTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + getTenantDomainFromContext(), applicationUuid); + return Util.buildSMSTemplateWithIDList(smsTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Retrieves the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param applicationUuid Application UUID. + * @return Email template. + */ + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId, String applicationUuid) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, templateId, + getTenantDomainFromContext(), applicationUuid); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildEmailTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + /** + * Retrieves the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param applicationUuid Application UUID. + * @return SMS template. + */ + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId, String applicationUuid) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, templateId, + getTenantDomainFromContext(), applicationUuid); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildSMSTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + /** + * Updates the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param emailTemplate Updated email template. + * @param applicationUuid Application UUID. + */ + public void updateEmailTemplate(String templateTypeId, String templateId, EmailTemplate emailTemplate, + String applicationUuid) { + + EmailTemplateWithID emailTemplateWithID = + Util.buildEmailTemplateWithIdUsingEmailTemplate(emailTemplate, templateId); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + /** + * Updates the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param templateId Template ID. + * @param smsTemplate Updated SMS template. + * @param applicationUuid Application UUID. + */ + public void updateSMSTemplate(String templateTypeId, String templateId, SMSTemplate smsTemplate, + String applicationUuid) { + + SMSTemplateWithID smsTemplateWithID = + Util.buildSMSTemplateWithIdUsingSMSTemplate(smsTemplate, templateId); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), applicationUuid); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + /** + * Deletes the application email template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template locale. + * @param applicationUuid Application UUID. + */ + public void deleteEmailTemplate(String templateTypeId, String locale, String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + locale, getTenantDomainFromContext(), applicationUuid); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, locale, + getTenantDomainFromContext(), applicationUuid); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_EMAIL_TEMPLATE); + } + } + + /** + * Deletes the application SMS template of the given template type and locale. + * + * @param templateTypeId Template type ID. + * @param locale Template ID. + * @param applicationUuid Application UUID. + */ + public void deleteSMSTemplate(String templateTypeId, String locale, String applicationUuid) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + locale, getTenantDomainFromContext(), applicationUuid); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, locale, + getTenantDomainFromContext(), applicationUuid); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_SMS_TEMPLATE); + } + } + + private String getTemplateLocation(String templateTypeId, String applicationUuid, String locale, + String notificationType) { + + String templateLocation = Util.getTemplateTypeLocation(templateTypeId, notificationType); + return templateLocation + PATH_SEPARATOR + APP_TEMPLATES_PATH + PATH_SEPARATOR + applicationUuid + + PATH_SEPARATOR + locale; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/OrganizationTemplatesService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/OrganizationTemplatesService.java new file mode 100644 index 0000000000..fffc2429db --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/OrganizationTemplatesService.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; + +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.governance.model.NotificationTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; + +import java.util.List; + +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; + +/** + * This is the service implementation class for notification template management related operations. + */ +public class OrganizationTemplatesService { + + public SimpleTemplate addEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), null); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getTemplateLocation( + templateTypeId, notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_EMAIL)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + + public SimpleTemplate addSMSTemplate(String templateTypeId, SMSTemplateWithID smsTemplateWithID) { + + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), null); + + // Create and send the location of the created object as the response. + SimpleTemplate simpleEmailTemplate = new SimpleTemplate(); + simpleEmailTemplate.setSelf(getTemplateLocation( + templateTypeId, notificationTemplate.getLocale(), Constants.NOTIFICATION_CHANNEL_SMS)); + simpleEmailTemplate.setLocale(notificationTemplate.getLocale()); + return simpleEmailTemplate; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE); + } + } + + public List getTemplatesListOfEmailTemplateType(String templateTypeId) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List emailTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + getTenantDomainFromContext()); + return Util.buildEmailTemplateWithIDList(emailTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + public List getTemplatesListOfSMSTemplateType(String templateTypeId) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + List smsTemplates = TemplatesServiceHolder.getNotificationTemplateManager() + .getNotificationTemplatesOfType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + getTenantDomainFromContext()); + return Util.buildSMSTemplateWithIDList(smsTemplates); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + public EmailTemplateWithID getEmailTemplate(String templateTypeId, String templateId) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, templateId, + getTenantDomainFromContext()); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildEmailTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + public SMSTemplateWithID getSMSTemplate(String templateTypeId, String templateId) { + + try { + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate internalEmailTemplate = TemplatesServiceHolder.getNotificationTemplateManager(). + getNotificationTemplate(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, templateId, + getTenantDomainFromContext()); + // NotificationTemplateManager sends the default template if no matching template found. + // We need to check for the locale specifically. + if (!internalEmailTemplate.getLocale().equals(templateId)) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } else { + return Util.buildSMSTemplateWithID(internalEmailTemplate); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + + public void updateEmailTemplate(String templateTypeId, String locale, EmailTemplate emailTemplate) { + + EmailTemplateWithID emailTemplateWithID = + Util.buildEmailTemplateWithIdUsingEmailTemplate(emailTemplate, locale); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithEmailTemplateWithID( + templateTypeId, emailTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), null); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + public void updateSMSTemplate(String templateTypeId, String locale, SMSTemplate smsTemplate) { + + SMSTemplateWithID smsTemplateWithID = + Util.buildSMSTemplateWithIdUsingSMSTemplate(smsTemplate, locale); + try { + NotificationTemplate notificationTemplate = Util.buildNotificationTemplateWithSMSTemplateWithID( + templateTypeId, smsTemplateWithID); + TemplatesServiceHolder.getNotificationTemplateManager().updateNotificationTemplate(notificationTemplate, + getTenantDomainFromContext(), null); + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_UPDATING_TEMPLATE); + } + } + + public void deleteEmailTemplate(String templateTypeId, String locale) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, + locale, getTenantDomainFromContext()); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeDisplayName, locale, + getTenantDomainFromContext()); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_EMAIL_TEMPLATE); + } + } + + public void deleteSMSTemplate(String templateTypeId, String locale) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + Util.assertTemplateTypeExistence(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName); + boolean notificationTemplateExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateExists(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, + locale, getTenantDomainFromContext()); + if (notificationTemplateExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplate( + Constants.NOTIFICATION_CHANNEL_SMS, templateTypeDisplayName, locale, + getTenantDomainFromContext()); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_SMS_TEMPLATE); + } + } + + private String getTemplateLocation(String templateTypeId, String templateId, String type) { + + String templateLocation = Util.getTemplateTypeLocation(templateTypeId, type); + return templateLocation + Constants.ORG_TEMPLATES_PATH + Constants.PATH_SEPARATOR + templateId; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java new file mode 100644 index 0000000000..96095266bd --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/core/TemplateTypeService.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.core; + +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util; + +import java.util.ArrayList; +import java.util.List; + +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.rest.api.server.notification.template.v1.util.Util.getTemplateTypeLocation; + +/** + * Service class for the template types. + */ +public class TemplateTypeService { + + /** + * Add a new template type for a given channel. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateTypeOverview Template type overview. + * @return TemplateTypeWithID object. + */ + public TemplateTypeWithID addNotificationTemplateType(String notificationChannel, + TemplateTypeOverview templateTypeOverview) { + + String templateTypeDisplayName = templateTypeOverview.getDisplayName(); + try { + TemplatesServiceHolder.getNotificationTemplateManager().addNotificationTemplateType(notificationChannel, + templateTypeDisplayName, getTenantDomainFromContext()); + // Build a response object and send if everything is successful. + TemplateTypeWithID response = new TemplateTypeWithID(); + response.setDisplayName(templateTypeDisplayName); + String templateTypeId = Util.resolveTemplateIdFromDisplayName(templateTypeDisplayName); + response.setId(templateTypeId); + response.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + return response; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, Constants.ErrorMessage.ERROR_ERROR_ADDING_TEMPLATE_TYPE); + } + } + + /** + * Get all available notification template types for a notification chanel in the tenant. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @return List of TemplateTypeWithID objects. + */ + public List getAllNotificationTemplateTypes(String notificationChannel) { + + try { + List templateTypes = TemplatesServiceHolder.getNotificationTemplateManager() + .getAllNotificationTemplateTypes(notificationChannel, getTenantDomainFromContext()); + List templateTypeWithIDs = new ArrayList<>(); + if (templateTypes != null) { + for (String emailTemplateType : templateTypes) { + TemplateTypeWithID templateTypeWithID = new TemplateTypeWithID(); + templateTypeWithID.setDisplayName(emailTemplateType); + String templateTypeId = Util.resolveTemplateIdFromDisplayName(emailTemplateType); + templateTypeWithID.setId(templateTypeId); + templateTypeWithID.setSelf( + getTemplateTypeLocation(templateTypeId, notificationChannel)); + templateTypeWithIDs.add(templateTypeWithID); + } + } + return templateTypeWithIDs; + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPES); + } + } + + /** + * Delete a notification template type from the tenant. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateId ID of the template type. + */ + public void deleteNotificationTemplateType(String notificationChannel, String templateId) { + + String templateTypeDisplayName; + try { + templateTypeDisplayName = Util.decodeTemplateTypeId(templateId); + } catch (APIError e) { + // Ignoring the delete operation and return 204 response code, since the resource does not exist. + return; + } + try { + boolean isTemplateTypeExists = + TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + if (isTemplateTypeExists) { + TemplatesServiceHolder.getNotificationTemplateManager().deleteNotificationTemplateType( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_DELETING_TEMPLATE_TYPE); + } + } + + /** + * Get a specific notification template type. + * + * @param notificationChannel Notification channel (Eg: sms, email). + * @param templateTypeId ID of the template type. + * @return TemplateTypeWithID object. + */ + public TemplateTypeWithID getNotificationTemplateType(String notificationChannel, + String templateTypeId) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + try { + boolean isTemplateTypeExists = + TemplatesServiceHolder.getNotificationTemplateManager().isNotificationTemplateTypeExists( + notificationChannel, templateTypeDisplayName, getTenantDomainFromContext()); + if (isTemplateTypeExists) { + TemplateTypeWithID templateTypeWithID = new TemplateTypeWithID(); + templateTypeWithID.setDisplayName(templateTypeDisplayName); + templateTypeWithID.setId(templateTypeId); + templateTypeWithID.setSelf(getTemplateTypeLocation(templateTypeId, notificationChannel)); + return templateTypeWithID; + } else { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE); + } + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java new file mode 100644 index 0000000000..176a640505 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/impl/NotificationApiServiceImpl.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.impl; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.NotificationApiService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.ApplicationTemplatesService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.OrganizationTemplatesService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.core.TemplateTypeService; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SimpleTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeOverview; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.TemplateTypeWithID; + +import java.net.URI; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; +import static org.wso2.carbon.identity.api.server.common.ContextLoader.buildURIForHeader; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.APP_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; +import static org.wso2.carbon.identity.api.server.notification.template.common. + Constants.NOTIFICATION_TEMPLATES_API_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.ORG_TEMPLATES_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.TEMPLATE_TYPES_PATH; + +/** + * This is the service implementation class for notification template management related operations. + */ +public class NotificationApiServiceImpl implements NotificationApiService { + + @Autowired + private ApplicationTemplatesService applicationTemplatesService; + @Autowired + private OrganizationTemplatesService organizationTemplatesService; + @Autowired + private TemplateTypeService templateTypeService; + + @Override + public Response addAppEmailTemplate(String templateTypeId, String appUuid, + EmailTemplateWithID emailTemplateWithID) { + + SimpleTemplate simpleEmailTemplate = applicationTemplatesService.addEmailTemplate(templateTypeId, + emailTemplateWithID, appUuid); + URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + + templateTypeId + APP_TEMPLATES_PATH + PATH_SEPARATOR + appUuid + PATH_SEPARATOR + + simpleEmailTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleEmailTemplate).build(); + } + + @Override + public Response addAppSMSTemplate(String templateTypeId, String appUuid, SMSTemplateWithID smSTemplateWithID) { + + SimpleTemplate simpleSMSTemplate = applicationTemplatesService.addSMSTemplate(templateTypeId, + smSTemplateWithID, appUuid); + URI headerLocation = buildURIForHeader(V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + + templateTypeId + APP_TEMPLATES_PATH + PATH_SEPARATOR + appUuid + PATH_SEPARATOR + + smSTemplateWithID.getLocale()); + return Response.created(headerLocation).entity(simpleSMSTemplate).build(); + } + + @Override + public Response addEmailTemplateType(TemplateTypeOverview templateTypeOverview) { + + TemplateTypeWithID templateType = templateTypeService + .addNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeOverview); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + TEMPLATE_TYPES_PATH + + PATH_SEPARATOR + templateType.getId()); + return Response.created(headerLocation).entity(templateType).build(); + } + + @Override + public Response addOrgEmailTemplate(String templateTypeId, EmailTemplateWithID emailTemplateWithID) { + + SimpleTemplate simpleEmailTemplate = organizationTemplatesService.addEmailTemplate(templateTypeId, + emailTemplateWithID); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL + PATH_SEPARATOR + templateTypeId + + ORG_TEMPLATES_PATH + PATH_SEPARATOR + simpleEmailTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleEmailTemplate).build(); + } + + @Override + public Response addOrgSMSTemplate(String templateTypeId, SMSTemplateWithID smSTemplateWithID) { + + SimpleTemplate simpleSMSTemplate = organizationTemplatesService.addSMSTemplate(templateTypeId, + smSTemplateWithID); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + PATH_SEPARATOR + templateTypeId + + ORG_TEMPLATES_PATH + PATH_SEPARATOR + simpleSMSTemplate.getLocale()); + return Response.created(headerLocation).entity(simpleSMSTemplate).build(); + } + + @Override + public Response addSMSTemplateType(TemplateTypeOverview templateTypeOverview) { + + TemplateTypeWithID templateType = templateTypeService + .addNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeOverview); + URI headerLocation = buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + + NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS + TEMPLATE_TYPES_PATH + + PATH_SEPARATOR + templateType.getId()); + return Response.created(headerLocation).entity(templateType).build(); + } + + @Override + public Response deleteAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + + applicationTemplatesService.deleteEmailTemplate(templateTypeId, locale, appUuid); + return Response.noContent().build(); + } + + @Override + public Response deleteAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + + applicationTemplatesService.deleteSMSTemplate(templateTypeId, locale, appUuid); + return Response.noContent().build(); + } + + @Override + public Response deleteEmailTemplateType(String templateTypeId) { + + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId); + return Response.noContent().build(); + } + + @Override + public Response deleteOrgEmailTemplate(String templateTypeId, String locale) { + + organizationTemplatesService.deleteEmailTemplate(templateTypeId, locale); + return Response.noContent().build(); + } + + @Override + public Response deleteOrgSMSTemplate(String templateTypeId, String locale) { + + organizationTemplatesService.deleteSMSTemplate(templateTypeId, locale); + return Response.noContent().build(); + } + + @Override + public Response deleteSMSTemplateType(String templateTypeId) { + + templateTypeService.deleteNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, templateTypeId); + return Response.noContent().build(); + } + + @Override + public Response getAllEmailTemplateTypes() { + + return Response.ok().entity(templateTypeService + .getAllNotificationTemplateTypes(Constants.NOTIFICATION_CHANNEL_EMAIL)).build(); + } + + @Override + public Response getAllSMSTemplateTypes() { + + return Response.ok().entity(templateTypeService + .getAllNotificationTemplateTypes(Constants.NOTIFICATION_CHANNEL_SMS)).build(); + } + + @Override + public Response getAppEmailTemplate(String templateTypeId, String appUuid, String locale) { + + return Response.ok().entity(applicationTemplatesService.getEmailTemplate(templateTypeId, locale, appUuid)) + .build(); + } + + @Override + public Response getAppSMSTemplate(String templateTypeId, String appUuid, String locale) { + + return Response.ok().entity(applicationTemplatesService.getSMSTemplate(templateTypeId, locale, appUuid)) + .build(); + } + + @Override + public Response getAppTemplatesListOfEmailTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + applicationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId, appUuid)).build(); + } + + @Override + public Response getAppTemplatesListOfSMSTemplateType(String templateTypeId, String appUuid) { + + return Response.ok().entity( + applicationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId, appUuid)).build(); + } + + @Override + public Response getEmailTemplateType(String templateTypeId) { + + return Response.ok().entity(templateTypeService.getNotificationTemplateType( + Constants.NOTIFICATION_CHANNEL_EMAIL, templateTypeId)).build(); + } + + @Override + public Response getOrgEmailTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(organizationTemplatesService.getEmailTemplate(templateTypeId, locale)).build(); + } + + @Override + public Response getOrgSMSTemplate(String templateTypeId, String locale) { + + return Response.ok().entity(organizationTemplatesService.getSMSTemplate(templateTypeId, locale)).build(); + } + + @Override + public Response getOrgTemplatesListOfEmailTemplateType(String templateTypeId) { + + return Response.ok().entity(organizationTemplatesService.getTemplatesListOfEmailTemplateType(templateTypeId)) + .build(); + } + + @Override + public Response getOrgTemplatesListOfSMSTemplateType(String templateTypeId) { + + return Response.ok().entity(organizationTemplatesService.getTemplatesListOfSMSTemplateType(templateTypeId)) + .build(); + } + + @Override + public Response getSMSTemplateType(String templateTypeId) { + + return Response.ok().entity(templateTypeService.getNotificationTemplateType(Constants.NOTIFICATION_CHANNEL_SMS, + templateTypeId)).build(); + } + + @Override + public Response updateAppEmailTemplate(String templateTypeId, String appUuid, String locale, + EmailTemplate emailTemplate) { + + applicationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate, appUuid); + return Response.ok().build(); + } + + @Override + public Response updateAppSMSTemplate(String templateTypeId, String appUuid, String locale, + SMSTemplate smsTemplate) { + + applicationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate, appUuid); + return Response.ok().build(); + } + + @Override + public Response updateOrgEmailTemplate(String templateTypeId, String locale, + EmailTemplate emailTemplate) { + + organizationTemplatesService.updateEmailTemplate(templateTypeId, locale, emailTemplate); + return Response.ok().build(); + } + + @Override + public Response updateOrgSMSTemplate(String templateTypeId, String locale, SMSTemplate smsTemplate) { + + organizationTemplatesService.updateSMSTemplate(templateTypeId, locale, smsTemplate); + return Response.ok().build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java new file mode 100644 index 0000000000..83f15392f6 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/java/org/wso2/carbon/identity/rest/api/server/notification/template/v1/util/Util.java @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.identity.rest.api.server.notification.template.v1.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.email.mgt.util.I18nEmailUtil; +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; +import org.wso2.carbon.identity.api.server.notification.template.common.Constants; +import org.wso2.carbon.identity.api.server.notification.template.common.TemplatesServiceHolder; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerClientException; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerException; +import org.wso2.carbon.identity.governance.exceptions.notiification.NotificationTemplateManagerServerException; +import org.wso2.carbon.identity.governance.model.NotificationTemplate; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplateWithID; +import org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplateWithID; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response; + +import static org.wso2.carbon.identity.api.server.common.Constants.V1_API_PATH_COMPONENT; +import static org.wso2.carbon.identity.api.server.common.ContextLoader.getTenantDomainFromContext; +import static org.wso2.carbon.identity.api.server.common.Util.base64URLDecode; +import static org.wso2.carbon.identity.api.server.common.Util.base64URLEncode; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_CHANNEL_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.NOTIFICATION_TEMPLATES_API_PATH; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.PATH_SEPARATOR; +import static org.wso2.carbon.identity.api.server.notification.template.common.Constants.TEMPLATE_TYPES_PATH; + +/** + * Utility class for notification templates API + */ +public class Util { + + private static final Log log = LogFactory.getLog(Util.class); + + private static final String ERROR_CODE_DELIMITER = "-"; + + /** + * Converts a list of EmailTemplate objects to a list of NotificationTemplate objects. + * + * @param emailTemplates List of EmailTemplate objects. + * @return List of EmailTemplateWithID objects. + */ + public static List buildEmailTemplateWithIDList(List emailTemplates) { + + List emailTemplateWithIDs = new ArrayList<>(); + if (emailTemplates != null) { + for (NotificationTemplate emailTemplate : emailTemplates) { + EmailTemplateWithID emailTemplateWithID = new EmailTemplateWithID(); + emailTemplateWithID.setLocale(emailTemplate.getLocale()); + emailTemplateWithID.setContentType(emailTemplate.getContentType()); + emailTemplateWithID.setSubject(emailTemplate.getSubject()); + emailTemplateWithID.setBody(emailTemplate.getBody()); + emailTemplateWithID.setFooter(emailTemplate.getFooter()); + emailTemplateWithIDs.add(emailTemplateWithID); + } + } + return emailTemplateWithIDs; + } + + /** + * Converts a list of SMSTemplate objects to a list of SMSTemplateWithID objects. + * + * @param smsTemplates List of SMSTemplate objects. + * @return List of SMSTemplateWithID objects. + */ + public static List buildSMSTemplateWithIDList(List smsTemplates) { + + List smsTemplateWithIDs = new ArrayList<>(); + if (smsTemplates != null) { + for (NotificationTemplate smsTemplate : smsTemplates) { + SMSTemplateWithID emailTemplateWithID = new SMSTemplateWithID(); + emailTemplateWithID.setLocale(smsTemplate.getLocale()); + emailTemplateWithID.setBody(smsTemplate.getBody()); + smsTemplateWithIDs.add(emailTemplateWithID); + } + } + return smsTemplateWithIDs; + } + + /** + * Resolves templateID using the templateTypeDisplayName. + * + * @param templateTypeDisplayName Display name of the template type. + * @return templateID. + */ + public static String resolveTemplateIdFromDisplayName(String templateTypeDisplayName) { + + return base64URLEncode(templateTypeDisplayName); + } + + /** + * Decodes the template type ID. + * + * @param encodedTemplateTypeId Encoded template type ID. + * @return Decoded template type ID. + */ + public static String decodeTemplateTypeId(String encodedTemplateTypeId) { + + try { + return base64URLDecode(encodedTemplateTypeId); + } catch (Throwable e) { + throw handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } + + /** + * Handles the error and returns an APIError object. + * + * @param error Error message. + * @return APIError object. + */ + public static APIError handleError(Constants.ErrorMessage error) { + + return new APIError(error.getHttpStatus(), getErrorBuilder(error).build()); + } + + /** + * Handles the I18nEmailMgtException and returns an APIError object. + * + * @param exception I18nEmailMgtException. + * @param errorEnum Error message. + * @return APIError object. + */ + public static APIError handleNotificationTemplateManagerException(NotificationTemplateManagerException exception, + Constants.ErrorMessage errorEnum) { + + ErrorResponse errorResponse; + Response.Status status; + String errorCode = extractErrorCode(exception.getErrorCode()); + if (exception instanceof NotificationTemplateManagerServerException + && Constants.getNTMMappedErrorMessage(errorCode) != null) { + // Specific error with code is found. + Constants.ErrorMessage errorMessage = Constants.getNTMMappedErrorMessage(errorCode); + errorResponse = getErrorBuilder(errorMessage).build(log, exception, errorEnum.getDescription()); + status = errorMessage.getHttpStatus(); + } else if (exception instanceof NotificationTemplateManagerClientException) { + // Send client error with original exception message. + errorResponse = getErrorBuilder(errorEnum).build(log, exception.getMessage()); + errorResponse.setDescription(exception.getMessage()); + status = Response.Status.BAD_REQUEST; + } else { + // Server error + errorResponse = getErrorBuilder(errorEnum).build(log, exception, errorEnum.getDescription()); + status = Response.Status.INTERNAL_SERVER_ERROR; + } + return new APIError(status, errorResponse); + } + + /** + * Builds EmailTemplateWithID using NotificationTemplate. + * + * @param internalTemplate NotificationTemplate object. + * @return EmailTemplateWithID object. + */ + public static EmailTemplateWithID buildEmailTemplateWithID(NotificationTemplate internalTemplate) { + + EmailTemplateWithID templateWithID = new EmailTemplateWithID(); + templateWithID.setLocale(internalTemplate.getLocale()); + templateWithID.setContentType(internalTemplate.getContentType()); + templateWithID.setSubject(internalTemplate.getSubject()); + templateWithID.setBody(internalTemplate.getBody()); + templateWithID.setFooter(internalTemplate.getFooter()); + return templateWithID; + } + + /** + * Builds SMSTemplateWithID using NotificationTemplate. + * + * @param internalTemplate NotificationTemplate object. + * @return SMSTemplateWithID object. + */ + public static SMSTemplateWithID buildSMSTemplateWithID(NotificationTemplate internalTemplate) { + + SMSTemplateWithID templateWithID = new SMSTemplateWithID(); + templateWithID.setLocale(internalTemplate.getLocale()); + templateWithID.setBody(internalTemplate.getBody()); + return templateWithID; + } + + /** + * Builds NotificationTemplate object using SMSTemplateWithID object. + * @param templateTypeId Template type ID. + * @param smsTemplateWithID SMSTemplateWithID Object. + * @return NotificationTemplate object built using provided values. + */ + public static NotificationTemplate buildNotificationTemplateWithSMSTemplateWithID(String templateTypeId, + SMSTemplateWithID smsTemplateWithID) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate notificationTemplate = new NotificationTemplate(); + notificationTemplate.setNotificationChannel(Constants.NOTIFICATION_CHANNEL_SMS); + notificationTemplate.setLocale(smsTemplateWithID.getLocale()); + notificationTemplate.setBody(smsTemplateWithID.getBody()); + notificationTemplate.setDisplayName(templateTypeDisplayName); + notificationTemplate.setLocale(smsTemplateWithID.getLocale()); + notificationTemplate.setType(I18nEmailUtil.getNormalizedName(templateTypeDisplayName)); + return notificationTemplate; + } + + /** + * Builds NotificationTemplate object using EmailTemplateWithID object. + * @param templateTypeId Template type ID. + * @param emailTemplateWithID EmailTemplateWithID Object. + * @return NotificationTemplate object built using provided values. + */ + public static NotificationTemplate buildNotificationTemplateWithEmailTemplateWithID(String templateTypeId, + EmailTemplateWithID emailTemplateWithID) { + + String templateTypeDisplayName = Util.decodeTemplateTypeId(templateTypeId); + NotificationTemplate notificationTemplate = new NotificationTemplate(); + notificationTemplate.setNotificationChannel(Constants.NOTIFICATION_CHANNEL_EMAIL); + notificationTemplate.setLocale(emailTemplateWithID.getLocale()); + notificationTemplate.setBody(emailTemplateWithID.getBody()); + notificationTemplate.setDisplayName(templateTypeDisplayName); + notificationTemplate.setLocale(emailTemplateWithID.getLocale()); + notificationTemplate.setType(I18nEmailUtil.getNormalizedName(templateTypeDisplayName)); + notificationTemplate.setSubject(emailTemplateWithID.getSubject()); + notificationTemplate.setFooter(emailTemplateWithID.getFooter()); + notificationTemplate.setContentType(emailTemplateWithID.getContentType()); + return notificationTemplate; + } + + /** + * Asserts the existence of the template type. + * + * @param notificationChannel Notification channel. + * @param templateTypeDisplayName Template type display name. + */ + public static void assertTemplateTypeExistence(String notificationChannel, String templateTypeDisplayName) { + + try { + boolean isTemplateTypeExists = TemplatesServiceHolder.getNotificationTemplateManager() + .isNotificationTemplateTypeExists(notificationChannel, templateTypeDisplayName, + getTenantDomainFromContext()); + if (!isTemplateTypeExists) { + throw Util.handleError(Constants.ErrorMessage.ERROR_TEMPLATE_TYPE_NOT_FOUND); + } + } catch (NotificationTemplateManagerException e) { + throw Util.handleNotificationTemplateManagerException(e, + Constants.ErrorMessage.ERROR_ERROR_RETRIEVING_TEMPLATE_TYPE); + } + } + + /** + * Builds the location of the template type. + * + * @param templateTypeId Template type ID. + * @param templateType Notification channel type. + * @return Location of the template. + */ + public static String getTemplateTypeLocation(String templateTypeId, String templateType) { + + String templateTypePath; + // Only EMAIL and SMS are passed as the type. So, no need to check for other types. + if (templateType.equals(NOTIFICATION_CHANNEL_EMAIL)) { + templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_EMAIL; + } else { + templateTypePath = NOTIFICATION_TEMPLATES_API_BASE_PATH_SMS; + } + String location = V1_API_PATH_COMPONENT + NOTIFICATION_TEMPLATES_API_PATH + templateTypePath + + TEMPLATE_TYPES_PATH + PATH_SEPARATOR + templateTypeId; + return ContextLoader.buildURIForBody(location).toString(); + } + + /** + * Generates EmailTemplateWithID using provided values. + * + * @param emailTemplate EmailTemplate object. + * @param locale Locale. + * @return EmailTemplateWithID object. + */ + public static EmailTemplateWithID buildEmailTemplateWithIdUsingEmailTemplate( + org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.EmailTemplate emailTemplate, + String locale) { + EmailTemplateWithID emailTemplateWithID = new EmailTemplateWithID(); + emailTemplateWithID.setLocale(locale); + emailTemplateWithID.setContentType(emailTemplate.getContentType()); + emailTemplateWithID.setSubject(emailTemplate.getSubject()); + emailTemplateWithID.setBody(emailTemplate.getBody()); + emailTemplateWithID.setFooter(emailTemplate.getFooter()); + return emailTemplateWithID; + } + + /** + * Generates SMSTemplateWithID using provided values. + * + * @param smsTemplate SMSTemplate object. + * @param locale Locale. + * @return SMSTemplateWithID object. + */ + public static SMSTemplateWithID buildSMSTemplateWithIdUsingSMSTemplate( + org.wso2.carbon.identity.rest.api.server.notification.template.v1.model.SMSTemplate smsTemplate, + String locale) { + + SMSTemplateWithID smsTemplateWithID = new SMSTemplateWithID(); + smsTemplateWithID.setLocale(locale); + smsTemplateWithID.setBody(smsTemplate.getBody()); + return smsTemplateWithID; + } + + private static ErrorResponse.Builder getErrorBuilder(Constants.ErrorMessage errorMsg) { + + return new ErrorResponse.Builder().withCode(errorMsg.getCode()). + withMessage(errorMsg.getMessage()).withDescription(errorMsg.getDescription()); + } + + private static String extractErrorCode(String errorCodeWithScenario) { + + return errorCodeWithScenario.split(ERROR_CODE_DELIMITER)[1]; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml new file mode 100644 index 0000000000..a5f16fb98c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/META-INF/cxf/notification-template-server-v1-cxf.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml new file mode 100644 index 0000000000..3cd3110bf0 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/org.wso2.carbon.identity.rest.api.server.notification.template.v1/src/main/resources/notification-template.yml @@ -0,0 +1,1168 @@ +openapi: 3.0.0 +info: + title: "WSO2 Identity Server - Notification Template API" + version: 1.0.0 + description: >- + This is the RESTful API for managing notification templates inWSO2 Identity + Server. This API allows adding, retrieving, replacing, and removing email + templates and template types. +tags: + - name: Email Template Types + description: An email template type can have multiple email templates for different languages. + - name: Email Templates + description: An email template of a specific type and a language. + - name: Application Email Templates + description: An application email template of a specific type and a language. + - name: SMS Template Types + description: An sms template type can have multiple sms templates for different languages. + - name: SMS Templates + description: An SMS template of a specific type and a language. + - name: Application SMS Templates + description: An application email template of a specific type and a language. +security: + - OAuth2: [] + - BasicAuth: [] +paths: + /notification/email/template-types: + get: + tags: + - Email Template Types + summary: Retrieves all the email template types. + operationId: getAllEmailTemplateTypes + description: | + Retrieves all the email template types in the system.
+ +
+ Scopes required: +
* internal_email_mgt_view + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Email Template Types + summary: Adds a new email template type. + operationId: addEmailTemplateType + description: | + Adds a new email template type to the system. An email template type can have any number of + organization or application email templates.
+ + * Attribute _**displayName**_ of the template type should be unique.
+ + Scopes required: +
* internal_email_mgt_create + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateTypeOverview' + description: Email template type to be added. + responses: + '201': + description: Item Created + headers: + self: + description: Location of the newly created email template type. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}': + get: + tags: + - Email Template Types + summary: Retrieves the email template type corresponding to the template type id. + operationId: getEmailTemplateType + description: | + Retrieves the email template type in the system identified by the template-type-id.
+ + Scopes required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Email Template Types + summary: Removes an email template type. + operationId: deleteEmailTemplateType + description: | + Removes an existing email template type with all its email templates + from the system.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/org-templates': + get: + tags: + - Email Templates + summary: Retrieves the list of organization email templates in the template type id. + operationId: getOrgTemplatesListOfEmailTemplateType + description: | + Retrieves the list of organization email templates in the template type id.
+ + Scope required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Email Templates + summary: Adds a new email template to an existing email template type. + operationId: addOrgEmailTemplate + description: | + Another email template with the same locale should not already exist in the + respective email template type.
+ + Scopes required:
* internal_email_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + description: Email template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created email template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}': + get: + tags: + - Application Email Templates + summary: Retrieves the list of application email templates in the template type id. + operationId: getAppTemplatesListOfEmailTemplateType + description: | + Retrieves the list of application email templates in the template type id.
+ + Scope required:
+ * internal_email_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Application Email Templates + summary: Adds a new application email template to an existing email template type. + operationId: addAppEmailTemplate + description: | + Another application email template with the same locale should not already exist in the + respective email template type.
+ + Scopes required:
* internal_email_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + description: Email template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created email template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/org-templates/{locale}': + get: + tags: + - Email Templates + summary: Retrieves a single email template. + operationId: getOrgEmailTemplate + description: | + Retrieves the email template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_email_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Email Templates + summary: Replaces an existing email template. + operationId: updateOrgEmailTemplate + description: | + Replaces the email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Email Templates + summary: Removes an email template. + operationId: deleteOrgEmailTemplate + description: | + Removes an email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/email/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}': + get: + tags: + - Application Email Templates + summary: Retrieves a single email template of application. + operationId: getAppEmailTemplate + description: | + Retrieves the application email template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_email_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/EmailTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Application Email Templates + summary: Replaces an existing application email template. + operationId: updateAppEmailTemplate + description: | + Replaces the application email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmailTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Application Email Templates + summary: Removes an email template. + operationId: deleteAppEmailTemplate + description: | + Removes an email template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_email_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + /notification/sms/template-types: + get: + tags: + - SMS Template Types + summary: Retrieves all the sms template types. + operationId: getAllSMSTemplateTypes + description: | + Retrieves all the SMS template types in the system.
+ + Scopes required: +
* internal_sms_mgt_view + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - SMS Template Types + summary: Adds a new SMS template type. + operationId: addSMSTemplateType + description: | + Adds a new SMS template type to the system. An SMS template type can have any number of + organization or application SMS templates.
+ + * Attribute _**displayName**_ of the template type should be unique.
+ + Scopes required: +
* internal_sms_mgt_create + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TemplateTypeOverview' + description: SMS template type to be added. + responses: + '201': + description: Item Created + headers: + self: + description: Location of the newly created SMS template type. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}': + get: + tags: + - SMS Template Types + summary: Retrieves the SMS template type corresponding to the template type id. + operationId: getSMSTemplateType + description: | + Retrieves the SMS template type in the system identified by the template-type-id.
+ + Scopes required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/TemplateTypeWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - SMS Template Types + summary: Removes an SMS template type. + operationId: deleteSMSTemplateType + description: | + Removes an existing SMS template type with all its SMS templates + from the system.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}': + get: + tags: + - Application SMS Templates + summary: Retrieves the list of application SMS templates in the template type id. + operationId: getAppTemplatesListOfSMSTemplateType + description: | + Retrieves the list of application SMS templates in the template type id.
+ + Scope required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - Application SMS Templates + summary: Adds a new application SMS template to an existing SMS template type. + operationId: addAppSMSTemplate + description: | + Another application SMS template with the same locale should not already exist in the + respective SMS template type.
+ + Scopes required:
* internal_sms_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + description: SMS template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created SMS template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/app-templates/{app-uuid}/{locale}': + get: + tags: + - Application SMS Templates + summary: Retrieves a single SMS template of application. + operationId: getAppSMSTemplate + description: | + Retrieves the application SMS template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_sms_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - Application SMS Templates + summary: Replaces an existing application SMS template. + operationId: updateAppSMSTemplate + description: | + Replaces the application SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplate' + description: Email templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - Application SMS Templates + summary: Removes an SMS template. + operationId: deleteAppSMSTemplate + description: | + Removes an SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/appUuidPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/org-templates': + get: + tags: + - SMS Templates + summary: Retrieves the list of organization SMS templates in the template type id. + operationId: getOrgTemplatesListOfSMSTemplateType + description: | + Retrieves the list of organization SMS templates in the template type id.
+ + Scope required:
+ * internal_sms_mgt_view
+ parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + type: array + items: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + post: + tags: + - SMS Templates + summary: Adds a new organization SMS template to an existing SMS template type. + operationId: addOrgSMSTemplate + description: | + Another SMS organization template with the same locale should not already exist in the + respective SMS template type.
+ + Scopes required:
* internal_sms_mgt_create + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + description: SMS template to be added. + responses: + '201': + description: Item Created + headers: + Location: + description: Location of the newly created SMS template. + schema: + type: string + content: + 'application/json': + schema: + $ref: '#/components/schemas/SimpleTemplate' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '409': + $ref: '#/components/responses/Conflict' + '500': + $ref: '#/components/responses/ServerError' + '/notification/sms/template-types/{template-type-id}/org-templates/{locale}': + get: + tags: + - SMS Templates + summary: Retrieves a single organization SMS template. + operationId: getOrgSMSTemplate + description: | + Retrieves the SMS template that matches to the template-type-id and the locale.
+ + Scope required:
+ * internal_sms_mgt_view + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '200': + description: Search results matching the given criteria. + content: + 'application/json': + schema: + $ref: '#/components/schemas/SMSTemplateWithID' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + put: + tags: + - SMS Templates + summary: Replaces an existing organization SMS template. + operationId: updateOrgSMSTemplate + description: | + Replaces the organization SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_update + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SMSTemplate' + description: SMS templates for the template type. + responses: + '200': + $ref: '#/components/responses/Updated' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + delete: + tags: + - SMS Templates + summary: Removes an organization SMS template. + operationId: deleteOrgSMSTemplate + description: | + Removes an organization SMS template identified by the template-type-id and the locale.
+ + Scopes required:
+ * internal_sms_mgt_delete + parameters: + - $ref: '#/components/parameters/templateTypeIdPathParam' + - $ref: '#/components/parameters/localePathParam' + responses: + '204': + $ref: '#/components/responses/Deleted' + '400': + $ref: '#/components/responses/InvalidInput' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '500': + $ref: '#/components/responses/ServerError' + +servers: + # Added by API Auto Mocking Plugin + - description: SwaggerHub API Auto Mocking + url: https://virtserver.swaggerhub.com/RUSHANNANA/NotificationTemplateAPI/1.0.0 + - url: 'https://localhost:9443/t/{tenant-domain}/api/server/v1' + variables: + tenant-domain: + default: unknown + +components: + parameters: + templateTypeIdPathParam: + in: path + name: template-type-id + required: true + description: Email Template Type ID. + schema: + type: string + localePathParam: + in: path + name: locale + required: true + description: This should be a valid locale. + schema: + type: string + appUuidPathParam: + in: path + name: app-uuid + required: true + description: Application UUID. + schema: + type: string + offsetQueryParam: + in: query + name: offset + description: >- + Number of records to skip for pagination. _This option is not yet + supported._ + schema: + type: integer + format: int32 + minimum: 0 + limitQueryParam: + in: query + name: limit + description: >- + Maximum number of records to return. _This option is not yet + supported._ + schema: + type: integer + format: int32 + minimum: 0 + sortOrderQueryParam: + in: query + name: sortOrder + required: false + description: >- + Define the order in which the retrieved records should be sorted. _This + option is not yet supported._ + schema: + type: string + enum: + - asc + - desc + sortByQueryParam: + in: query + name: sortBy + required: false + description: >- + Attribute by which the retrieved records should be sorted. _This + option is not yet supported._ + schema: + type: string + responses: + NotFound: + description: The specified resource is not found. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Unauthorized: + description: Unauthorized. + Forbidden: + description: Forbidden. + ServerError: + description: Internal Server Error. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + InvalidInput: + description: Invalid input request. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Conflict: + description: Item Already Exists. + content: + 'application/json': + schema: + $ref: '#/components/schemas/Error' + Deleted: + description: Item Deleted. + Updated: + description: Item Updated. + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'https://localhost:9443/oauth2/token' + scopes: {} + schemas: + TemplateType: + type: object + required: + - displayName + - self + properties: + displayName: + type: string + example: Account Confirmation + description: Display name of the email template type. + self: + type: string + example: /t/{tenant-domain}/api/server/v1/notification/email/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg + description: Location of the created/updated resource. + TemplateTypeOverview: + type: object + required: + - displayName + properties: + displayName: + type: string + example: Account Confirmation + description: Display name of the template type. + TemplateTypeWithID: + allOf: + - $ref: '#/components/schemas/TemplateType' + - required: + - id + properties: + id: + type: string + example: YWNjb3VudGNvbmZpcm1hdGlvbg + description: Unique ID of the template type. + EmailTemplate: + type: object + required: + - contentType + - subject + - body + properties: + contentType: + type: string + example: text/html + description: Content type of the email template. + subject: + type: string + example: WSO2 - Account Confirmation + description: The subject of the email. + body: + type: string + example: HTML Body + description: The body of the email. + footer: + type: string + example: WSO2 Identity Server Team + description: The footer of the email. + EmailTemplateWithID: + allOf: + - $ref: '#/components/schemas/EmailTemplate' + - required: + - locale + properties: + locale: + type: string + example: en_US + description: >- + Locale of the email template. + SMSTemplate: + type: object + required: + - body + properties: + body: + type: string + example: SMS Body + description: The body of the SMS. + SMSTemplateWithID: + allOf: + - $ref: '#/components/schemas/SMSTemplate' + - required: + - locale + properties: + locale: + type: string + example: en_US + description: >- + Locale of the SMS template. + SimpleTemplate: + type: object + required: + - locale + - self + properties: + locale: + type: string + example: en_US + description: >- + Locale of the template. + self: + type: string + example: /t/{tenant-domain}/api/server/v1/notification/sms/template-types/YWNjb3VudGNvbmZpcm1hdGlvbg/templates/en_US + description: Location of the created/updated resource. + + Error: + type: object + required: + - code + - message + properties: + code: + type: string + example: NTM-50000 + message: + type: string + example: Some Error Message + description: + type: string + example: Some Error Description + traceId: + type: string + example: TR0001 diff --git a/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml new file mode 100644 index 0000000000..c1b2c6dded --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.template/pom.xml @@ -0,0 +1,37 @@ + + + + + + org.wso2.carbon.identity.server.api + identity-api-server + 1.2.196-SNAPSHOT + ../../pom.xml + + 4.0.0 + + org.wso2.carbon.identity.api.server.notification.template + pom + + + org.wso2.carbon.identity.api.server.notification.template.common + org.wso2.carbon.identity.rest.api.server.notification.template.v1 + + + diff --git a/pom.xml b/pom.xml index 78baa84f0f..0f87d69e1e 100644 --- a/pom.xml +++ b/pom.xml @@ -287,6 +287,12 @@ provided ${project.version} + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.notification.template.common + provided + ${project.version} + org.wso2.carbon.identity.server.api org.wso2.carbon.identity.api.server.application.management.common @@ -859,6 +865,7 @@ components/org.wso2.carbon.identity.api.server.tenant.management components/org.wso2.carbon.identity.api.server.cors components/org.wso2.carbon.identity.api.server.notification.sender + components/org.wso2.carbon.identity.api.server.notification.template components/org.wso2.carbon.identity.api.server.authenticators components/org.wso2.carbon.identity.api.server.secret.management components/org.wso2.carbon.identity.api.server.branding.preference.management