diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/common/NotificationSenderManagementConstants.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/common/NotificationSenderManagementConstants.java index 399a23e34b..cd90f6f28c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/common/NotificationSenderManagementConstants.java +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.common/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/common/NotificationSenderManagementConstants.java @@ -28,4 +28,5 @@ public class NotificationSenderManagementConstants { public static final String URL_ENCODED_SPACE = "%20"; public static final String EMAIL_PUBLISHER_TYPE = "email"; public static final String SMS_PUBLISHER_TYPE = "sms"; + public static final String PUSH_PUBLISHER_TYPE = "push"; } diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/.openapi-generator-ignore b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/.openapi-generator-ignore new file mode 100644 index 0000000000..766afebf5f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/.openapi-generator-ignore @@ -0,0 +1,26 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# Uncomment this line if you want to override the impl classes. +**/impl/* + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApi.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApi.java index 8cb17ff934..2b2efe686d 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApi.java +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApi.java @@ -28,6 +28,9 @@ import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Error; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest; @@ -77,6 +80,32 @@ public Response createEmailSender(@ApiParam(value = "" ) @Valid EmailSenderAdd e return delegate.createEmailSender(emailSenderAdd ); } + @Valid + @POST + @Path("/push") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Create a push notification sender", notes = "This API provides the capability to create a push notification sender.\\n\\nIf the 'name' is not defined, 'PushPublisher' is taken as the default name.
Permission required:
* /permission/admin/manage/identity/configmgt/add
Scope required:
* internal_config_mgt_add ", response = PushSender.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Push Notification Senders", }) + @ApiResponses(value = { + @ApiResponse(code = 201, message = "Successful Response", response = PushSender.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class), + @ApiResponse(code = 409, message = "Conflict", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response createPushSender(@ApiParam(value = "" ) @Valid PushSenderAdd pushSenderAdd) { + + return delegate.createPushSender(pushSenderAdd ); + } + @Valid @POST @Path("/sms") @@ -128,6 +157,31 @@ public Response deleteEmailSender(@ApiParam(value = "name of the email sender",r return delegate.deleteEmailSender(senderName ); } + @Valid + @DELETE + @Path("/push/{sender-name}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Delete a push notification sender by name", notes = "This API provides the capability to delete a push notification sender by name. The URL encoded push notification sender name is used as sender-name.
Permission required:
* /permission/admin/manage/identity/configmgt/delete
Scope required:
* internal_config_mgt_delete ", response = Void.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Push Notification Senders", }) + @ApiResponses(value = { + @ApiResponse(code = 204, message = "No Content", response = Void.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response deletePushSender(@ApiParam(value = "name of the email sender",required=true) @PathParam("sender-name") String senderName) { + + return delegate.deletePushSender(senderName ); + } + @Valid @DELETE @Path("/sms/{sender-name}") @@ -203,6 +257,56 @@ public Response getEmailSenders() { return delegate.getEmailSenders(); } + @Valid + @GET + @Path("/push/{sender-name}") + + @Produces({ "application/json" }) + @ApiOperation(value = "Retrieve a push notification sender by name", notes = "This API provides the capability to retrieve a push notification sender by name. The URL encoded push notification sender name is used as sender-name.
Permission required:
* /permission/admin/manage/identity/configmgt/view
Scope required:
* internal_config_mgt_view ", response = PushSender.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Push Notification Senders", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Successful Response", response = PushSender.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getPushSender(@ApiParam(value = "name of the push notification sender",required=true) @PathParam("sender-name") String senderName) { + + return delegate.getPushSender(senderName ); + } + + @Valid + @GET + @Path("/push") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get a list of push notification senders", notes = "This API provides the capability to retrieve the list of push notification senders.
Permission required:
* /permission/admin/manage/identity/configmgt/view
Scope required:
* internal_config_mgt_view ", response = PushSender.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Push Notification Senders", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Successful response", response = PushSender.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getPushSenders() { + + return delegate.getPushSenders(); + } + @Valid @GET @Path("/sms/{sender-name}") @@ -278,6 +382,31 @@ public Response updateEmailSender(@ApiParam(value = "name of the email sender",r return delegate.updateEmailSender(senderName, emailSenderUpdateRequest ); } + @Valid + @PUT + @Path("/push/{sender-name}") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "Update a push notification sender", notes = "This API provides the capability to update a push notification sender by name. The URL encoded push notification sender name is used as sender-name.
Permission required:
* /permission/admin/manage/identity/configmgt/update
Scope required:
* internal_config_mgt_update ", response = PushSender.class, authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Push Notification Senders", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Successful Response", response = PushSender.class), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 404, message = "Not Found", response = Error.class), + @ApiResponse(code = 405, message = "Method Not Allowed.", response = Error.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response updatePushSender(@ApiParam(value = "name of the push notification sender",required=true) @PathParam("sender-name") String senderName, @ApiParam(value = "" ,required=true) @Valid PushSenderUpdateRequest pushSenderUpdateRequest) { + + return delegate.updatePushSender(senderName, pushSenderUpdateRequest ); + } + @Valid @PUT @Path("/sms/{sender-name}") diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApiService.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApiService.java index 1b416b9c7e..3c4a6f2ebb 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApiService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/NotificationSendersApiService.java @@ -26,6 +26,9 @@ import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Error; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest; @@ -36,21 +39,31 @@ public interface NotificationSendersApiService { public Response createEmailSender(EmailSenderAdd emailSenderAdd); + public Response createPushSender(PushSenderAdd pushSenderAdd); + public Response createSMSSender(SMSSenderAdd smSSenderAdd); public Response deleteEmailSender(String senderName); + public Response deletePushSender(String senderName); + public Response deleteSMSSender(String senderName); public Response getEmailSender(String senderName); public Response getEmailSenders(); + public Response getPushSender(String senderName); + + public Response getPushSenders(); + public Response getSMSSender(String senderName); public Response getSMSSenders(); public Response updateEmailSender(String senderName, EmailSenderUpdateRequest emailSenderUpdateRequest); + public Response updatePushSender(String senderName, PushSenderUpdateRequest pushSenderUpdateRequest); + public Response updateSMSSender(String senderName, SMSSenderUpdateRequest smSSenderUpdateRequest); } diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSender.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSender.java new file mode 100644 index 0000000000..2277f07760 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSender.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2023, 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.api.server.notification.sender.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 java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Properties; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PushSender { + + private String name; + private String provider; + private List properties = null; + + + /** + **/ + public PushSender name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "PushPublisher", required = true, value = "") + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public PushSender provider(String provider) { + + this.provider = provider; + return this; + } + + @ApiModelProperty(example = "fcm", required = true, value = "") + @JsonProperty("provider") + @Valid + @NotNull(message = "Property provider cannot be null.") + + public String getProvider() { + return provider; + } + public void setProvider(String provider) { + this.provider = provider; + } + + /** + **/ + public PushSender properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(example = "[{\"key\":\"fcm.serviceAccount\",\"value\":\"jsonString\"},{\"key\":\"aws.keyId\",\"value\":\"sampleKeyId\"}]", value = "") + @JsonProperty("properties") + @Valid + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public PushSender addPropertiesItem(Properties propertiesItem) { + if (this.properties == null) { + this.properties = new ArrayList<>(); + } + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PushSender pushSender = (PushSender) o; + return Objects.equals(this.name, pushSender.name) && + Objects.equals(this.provider, pushSender.provider) && + Objects.equals(this.properties, pushSender.properties); + } + + @Override + public int hashCode() { + return Objects.hash(name, provider, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PushSender {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).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.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderAdd.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderAdd.java new file mode 100644 index 0000000000..1673d092d3 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderAdd.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2023, 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.api.server.notification.sender.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 java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Properties; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PushSenderAdd { + + private String name; + private String provider; + private List properties = new ArrayList<>(); + + + /** + **/ + public PushSenderAdd name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "PushPublisher", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public PushSenderAdd provider(String provider) { + + this.provider = provider; + return this; + } + + @ApiModelProperty(example = "fcm", required = true, value = "") + @JsonProperty("provider") + @Valid + @NotNull(message = "Property provider cannot be null.") + + public String getProvider() { + return provider; + } + public void setProvider(String provider) { + this.provider = provider; + } + + /** + **/ + public PushSenderAdd properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(example = "[{\"key\":\"fcm.serviceAccount\",\"value\":\"jsonString\"},{\"key\":\"aws.keyId\",\"value\":\"sampleKeyId\"}]", required = true, value = "") + @JsonProperty("properties") + @Valid + @NotNull(message = "Property properties cannot be null.") + + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public PushSenderAdd addPropertiesItem(Properties propertiesItem) { + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PushSenderAdd pushSenderAdd = (PushSenderAdd) o; + return Objects.equals(this.name, pushSenderAdd.name) && + Objects.equals(this.provider, pushSenderAdd.provider) && + Objects.equals(this.properties, pushSenderAdd.properties); + } + + @Override + public int hashCode() { + return Objects.hash(name, provider, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PushSenderAdd {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).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.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderUpdateRequest.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderUpdateRequest.java new file mode 100644 index 0000000000..d97d253caf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/gen/java/org/wso2/carbon/identity/api/server/notification/sender/v1/model/PushSenderUpdateRequest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2023, 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.api.server.notification.sender.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 java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Properties; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class PushSenderUpdateRequest { + + private String provider; + private List properties = new ArrayList<>(); + + + /** + **/ + public PushSenderUpdateRequest provider(String provider) { + + this.provider = provider; + return this; + } + + @ApiModelProperty(required = true, value = "") + @JsonProperty("provider") + @Valid + @NotNull(message = "Property provider cannot be null.") + + public String getProvider() { + return provider; + } + public void setProvider(String provider) { + this.provider = provider; + } + + /** + **/ + public PushSenderUpdateRequest properties(List properties) { + + this.properties = properties; + return this; + } + + @ApiModelProperty(example = "[{\"key\":\"fcm.serviceAccount\",\"value\":\"jsonString\"},{\"key\":\"aws.keyId\",\"value\":\"sampleKeyId\"}]", required = true, value = "") + @JsonProperty("properties") + @Valid + @NotNull(message = "Property properties cannot be null.") + + public List getProperties() { + return properties; + } + public void setProperties(List properties) { + this.properties = properties; + } + + public PushSenderUpdateRequest addPropertiesItem(Properties propertiesItem) { + this.properties.add(propertiesItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PushSenderUpdateRequest pushSenderUpdateRequest = (PushSenderUpdateRequest) o; + return Objects.equals(this.provider, pushSenderUpdateRequest.provider) && + Objects.equals(this.properties, pushSenderUpdateRequest.properties); + } + + @Override + public int hashCode() { + return Objects.hash(provider, properties); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class PushSenderUpdateRequest {\n"); + + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).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.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/core/NotificationSenderManagementService.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/core/NotificationSenderManagementService.java index d73c7f09ff..86060137a8 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/core/NotificationSenderManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/core/NotificationSenderManagementService.java @@ -26,10 +26,14 @@ import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.Properties; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest; import org.wso2.carbon.identity.notification.sender.tenant.config.dto.EmailSenderDTO; +import org.wso2.carbon.identity.notification.sender.tenant.config.dto.PushSenderDTO; import org.wso2.carbon.identity.notification.sender.tenant.config.dto.SMSSenderDTO; import org.wso2.carbon.identity.notification.sender.tenant.config.exception.NotificationSenderManagementClientException; import org.wso2.carbon.identity.notification.sender.tenant.config.exception.NotificationSenderManagementException; @@ -93,6 +97,24 @@ public SMSSender addSMSSender(SMSSenderAdd smsSenderAdd) { } } + /** + * Create a push sender resource with a resource file. + * + * @param pushSenderAdd Push sender post request. + * @return Push sender. + */ + public PushSender addPushSender(PushSenderAdd pushSenderAdd) { + + PushSenderDTO dto = buildPushSenderDTO(pushSenderAdd); + try { + PushSenderDTO pushSenderDTO = NotificationSenderServiceHolder.getNotificationSenderManagementService() + .addPushSender(dto); + return buildPushSenderFromDTO(pushSenderDTO); + } catch (NotificationSenderManagementException e) { + throw handleException(e); + } + } + /** * Delete a SMS/Email sender by name. * @@ -139,6 +161,23 @@ public SMSSender getSMSSender(String senderName) { } } + /** + * Retrieve the push sender details by name. + * + * @param senderName Push sender's name. + * @return Push sender. + */ + public PushSender getPushSender(String senderName) { + + try { + PushSenderDTO pushSenderDTO = NotificationSenderServiceHolder.getNotificationSenderManagementService() + .getPushSender(senderName, false); + return buildPushSenderFromDTO(pushSenderDTO); + } catch (NotificationSenderManagementException e) { + throw handleException(e); + } + } + /** * Retrieve all email senders of the tenant. * @@ -169,6 +208,22 @@ public List getSMSSenders() { } } + /** + * Retrieve all push senders of the tenant. + * + * @return Push senders of the tenant. + */ + public List getPushSenders() { + + try { + List pushSenders = NotificationSenderServiceHolder.getNotificationSenderManagementService() + .getPushSenders(false); + return pushSenders.stream().map(this::buildPushSenderFromDTO).collect(Collectors.toList()); + } catch (NotificationSenderManagementException e) { + throw handleException(e); + } + } + /** * Update email sender details by name. * @@ -205,6 +260,25 @@ public SMSSender updateSMSSender(String senderName, SMSSenderUpdateRequest smsSe } } + /** + * Update push sender details by name. + * + * @param senderName Push sender's name. + * @param pushSenderUpdateRequest Push sender's updated configurations. + * @return Updated push sender. + */ + public PushSender updatePushSender(String senderName, PushSenderUpdateRequest pushSenderUpdateRequest) { + + PushSenderDTO dto = buildPushSenderDTO(senderName, pushSenderUpdateRequest); + try { + PushSenderDTO pushSenderDTO = NotificationSenderServiceHolder.getNotificationSenderManagementService() + .updatePushSender(dto); + return buildPushSenderFromDTO(pushSenderDTO); + } catch (NotificationSenderManagementException e) { + throw handleException(e); + } + } + private EmailSenderDTO buildEmailSenderDTO(EmailSenderAdd emailSenderAdd) { EmailSenderDTO dto = new EmailSenderDTO(); @@ -318,6 +392,42 @@ private SMSSender buildSMSSenderFromDTO(SMSSenderDTO dto) { return smsSender; } + private PushSenderDTO buildPushSenderDTO(PushSenderAdd pushSenderAdd) { + + PushSenderDTO dto = new PushSenderDTO(); + dto.setName(pushSenderAdd.getName()); + dto.setProvider(pushSenderAdd.getProvider()); + List properties = pushSenderAdd.getProperties(); + properties.forEach((prop) -> dto.getProperties().put(prop.getKey(), prop.getValue())); + return dto; + } + + private PushSenderDTO buildPushSenderDTO(String senderName, PushSenderUpdateRequest pushSenderUpdateRequest) { + + PushSenderDTO dto = new PushSenderDTO(); + dto.setName(senderName); + dto.setProvider(pushSenderUpdateRequest.getProvider()); + List properties = pushSenderUpdateRequest.getProperties(); + properties.forEach((prop) -> dto.getProperties().put(prop.getKey(), prop.getValue())); + return dto; + } + + private PushSender buildPushSenderFromDTO(PushSenderDTO dto) { + + PushSender pushSender = new PushSender(); + pushSender.setName(dto.getName()); + pushSender.setProvider(dto.getProvider()); + List properties = new ArrayList<>(); + dto.getProperties().forEach((key, value) -> { + Properties prop = new Properties(); + prop.setKey(key); + prop.setValue(value); + properties.add(prop); + }); + pushSender.setProperties(properties); + return pushSender; + } + private APIError buildServerError(NotificationSenderManagementException e) { String errorCode = e.getErrorCode(); diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/impl/NotificationSendersApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/impl/NotificationSendersApiServiceImpl.java index 718770a624..0d15f372ed 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/impl/NotificationSendersApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/java/org/wso2/carbon/identity/api/server/notification/sender/v1/impl/NotificationSendersApiServiceImpl.java @@ -30,6 +30,9 @@ import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSender; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.EmailSenderUpdateRequest; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSender; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderAdd; +import org.wso2.carbon.identity.api.server.notification.sender.v1.model.PushSenderUpdateRequest; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSender; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderAdd; import org.wso2.carbon.identity.api.server.notification.sender.v1.model.SMSSenderUpdateRequest; @@ -46,6 +49,7 @@ import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.EMAIL_PUBLISHER_TYPE; import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.NOTIFICATION_SENDER_CONTEXT_PATH; import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.PLUS; +import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.PUSH_PUBLISHER_TYPE; import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.SMS_PUBLISHER_TYPE; import static org.wso2.carbon.identity.api.server.notification.sender.common.NotificationSenderManagementConstants.URL_ENCODED_SPACE; @@ -87,6 +91,24 @@ public Response createEmailSender(EmailSenderAdd emailSenderAdd) { return Response.created(location).entity(emailSender).build(); } + @Override + public Response createPushSender(PushSenderAdd pushSenderAdd) { + + PushSender pushSender = notificationSenderManagementService.addPushSender(pushSenderAdd); + URI location = null; + try { + location = ContextLoader.buildURIForHeader( + V1_API_PATH_COMPONENT + NOTIFICATION_SENDER_CONTEXT_PATH + "/" + PUSH_PUBLISHER_TYPE + "/" + + URLEncoder.encode(pushSender.getName(), StandardCharsets.UTF_8.name()) + .replace(PLUS, URL_ENCODED_SPACE)); + } catch (UnsupportedEncodingException e) { + ErrorResponse errorResponse = + new ErrorResponse.Builder().withMessage("Error due to unsupported encoding.").build(); + throw new APIError(Response.Status.METHOD_NOT_ALLOWED, errorResponse); + } + return Response.created(location).entity(pushSender).build(); + } + @Override public Response createSMSSender(SMSSenderAdd smSSenderAdd) { @@ -115,6 +137,13 @@ public Response deleteEmailSender(String senderName) { return Response.noContent().build(); } + @Override + public Response deletePushSender(String senderName) { + + notificationSenderManagementService.deleteNotificationSender(senderName); + return Response.noContent().build(); + } + @Override public Response deleteSMSSender(String senderName) { @@ -140,6 +169,18 @@ public Response getEmailSenders() { return Response.ok().entity(notificationSenderManagementService.getEmailSenders()).build(); } + @Override + public Response getPushSender(String senderName) { + + return Response.ok().entity(notificationSenderManagementService.getPushSender(senderName)).build(); + } + + @Override + public Response getPushSenders() { + + return Response.ok().entity(notificationSenderManagementService.getPushSenders()).build(); + } + @Override public Response getSMSSender(String senderName) { @@ -163,6 +204,14 @@ public Response updateEmailSender(String senderName, EmailSenderUpdateRequest em .build(); } + @Override + public Response updatePushSender(String senderName, PushSenderUpdateRequest pushSenderUpdateRequest) { + + return Response.ok() + .entity(notificationSenderManagementService.updatePushSender(senderName, pushSenderUpdateRequest)) + .build(); + } + @Override public Response updateSMSSender(String senderName, SMSSenderUpdateRequest smSSenderUpdateRequest) { diff --git a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/resources/notification-sender.yaml b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/resources/notification-sender.yaml index 7318ca2315..6f8370189c 100644 --- a/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/resources/notification-sender.yaml +++ b/components/org.wso2.carbon.identity.api.server.notification.sender/org.wso2.carbon.identity.api.server.notification.sender.v1/src/main/resources/notification-sender.yaml @@ -608,6 +608,291 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + /notification-senders/push: + get: + tags: + - Push Notification Senders + summary: Get a list of push notification senders + description: | + This API provides the capability to retrieve the list of push notification senders.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/view
+ Scope required:
+ * internal_config_mgt_view + operationId: getPushSenders + responses: + "200": + description: Successful response + content: + application/json: + schema: + $ref: '#/components/schemas/PushProviderList' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "401": + description: Unauthorized + "403": + description: Forbidden + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "405": + description: Method Not Allowed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + tags: + - Push Notification Senders + summary: Create a push notification sender + description: | + This API provides the capability to create a push notification sender.\n\nIf the 'name' is not defined, 'PushPublisher' is taken as the default name.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/add
+ Scope required:
+ * internal_config_mgt_add + operationId: createPushSender + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PushSenderAdd' + example: + provider: FCM + properties: + - key: FCM.serviceAccount + value: {"FCMUrl": "UrlValue"} + responses: + "201": + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PushSender' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "401": + description: Unauthorized + "403": + description: Forbidden + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "405": + description: Method Not Allowed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "409": + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /notification-senders/push/{sender-name}: + get: + tags: + - Push Notification Senders + summary: Retrieve a push notification sender by name + description: | + This API provides the capability to retrieve a push notification sender by name. + The URL encoded push notification sender name is used as sender-name.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/view
+ Scope required:
+ * internal_config_mgt_view + operationId: getPushSender + parameters: + - name: sender-name + in: path + description: name of the push notification sender + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PushSender' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "401": + description: Unauthorized + "403": + description: Forbidden + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "405": + description: Method Not Allowed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + put: + tags: + - Push Notification Senders + summary: Update a push notification sender + description: | + This API provides the capability to update a push notification sender by name. + The URL encoded push notification sender name is used as sender-name.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/update
+ Scope required:
+ * internal_config_mgt_update + operationId: updatePushSender + parameters: + - name: sender-name + in: path + description: name of the push notification sender + required: true + style: simple + explode: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PushSenderUpdateRequest' + example: + provider: FCM + properties: + - key: FCM.serviceAccount + value: {"FCMUrl": "UrlValue"} + required: true + responses: + "200": + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/PushSender' + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "401": + description: Unauthorized + "403": + description: Forbidden + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "405": + description: Method Not Allowed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + tags: + - Push Notification Senders + summary: Delete a push notification sender by name + description: | + This API provides the capability to delete a push notification sender by name. + The URL encoded push notification sender name is used as sender-name.
+ Permission required:
+ * /permission/admin/manage/identity/configmgt/delete
+ Scope required:
+ * internal_config_mgt_delete + operationId: deletePushSender + parameters: + - name: sender-name + in: path + description: name of the email sender + required: true + style: simple + explode: false + schema: + type: string + responses: + "204": + description: No Content + "400": + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "401": + description: Unauthorized + "403": + description: Forbidden + "404": + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "405": + description: Method Not Allowed. + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + "500": + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' components: schemas: Error: @@ -690,6 +975,27 @@ components: value: "X-Version: 1, Authorization: bearer ,Accept: application/json ,Content-Type: application/json" items: $ref: '#/components/schemas/Properties' + PushSenderAdd: + required: + - provider + - properties + type: object + properties: + name: + type: string + example: PushPublisher + provider: + type: string + example: fcm + properties: + type: array + example: + - key: fcm.serviceAccount + value: jsonString + - key: aws.keyId + value: sampleKeyId + items: + $ref: '#/components/schemas/Properties' EmailSender: required: - fromAddress @@ -761,6 +1067,26 @@ components: value: "X-Version: 1, Authorization: bearer ,Accept: application/json ,Content-Type: application/json" items: $ref: '#/components/schemas/Properties' + PushSender: + required: + - provider + - name + properties: + name: + type: string + example: PushPublisher + provider: + type: string + example: fcm + properties: + type: array + example: + - key: fcm.serviceAccount + value: "jsonString" + - key: aws.keyId + value: "sampleKeyId" + items: + $ref: '#/components/schemas/Properties' EmailSenderUpdateRequest: required: - fromAddress @@ -823,6 +1149,23 @@ components: value: "X-Version: 1, Authorization: bearer ,Accept: application/json ,Content-Type: application/json" items: $ref: '#/components/schemas/Properties' + PushSenderUpdateRequest: + required: + - provider + - properties + type: object + properties: + provider: + type: string + properties: + type: array + example: + - key: fcm.serviceAccount + value: "jsonString" + - key: aws.keyId + value: "sampleKeyId" + items: + $ref: '#/components/schemas/Properties' Properties: required: - key @@ -844,6 +1187,10 @@ components: type: array items: $ref: '#/components/schemas/SMSSender' + PushProviderList: + type: array + items: + $ref: '#/components/schemas/PushSender' parameters: typeQueryParam: name: type diff --git a/pom.xml b/pom.xml index c6c8e32a8e..32ee065ef3 100644 --- a/pom.xml +++ b/pom.xml @@ -831,7 +831,7 @@ 3.0.5 1.12.0 **/gen/**/* - 1.9.28 + 1.9.34 7.0.169 5.11.44 1.9.4