You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "quantranhong1999 (via GitHub)" <gi...@apache.org> on 2023/03/02 03:20:38 UTC

[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1471: JAMES-3893 Add a WebAdmin API allowing creation/updation user identity

quantranhong1999 commented on code in PR #1471:
URL: https://github.com/apache/james-project/pull/1471#discussion_r1122549856


##########
server/protocols/webadmin/webadmin-jmap/src/main/java/org/apache/james/webadmin/data/jmap/UserIdentityRoutes.java:
##########
@@ -20,42 +20,50 @@
 package org.apache.james.webadmin.data.jmap;
 
 import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static spark.Spark.halt;
 
 import java.util.Comparator;
 import java.util.List;
 import java.util.Optional;
 
 import javax.inject.Inject;
+import javax.mail.internet.AddressException;
 
 import org.apache.james.core.Username;
 import org.apache.james.jmap.api.identity.IdentityRepository;
 import org.apache.james.util.FunctionalUtils;
 import org.apache.james.webadmin.Routes;
 import org.apache.james.webadmin.data.jmap.dto.UserIdentity;
 import org.apache.james.webadmin.utils.ErrorResponder;
+import org.apache.james.webadmin.utils.JsonExtractException;
+import org.apache.james.webadmin.utils.JsonExtractor;
 import org.apache.james.webadmin.utils.JsonTransformer;
 import org.apache.james.webadmin.utils.ParametersExtractor;
 import org.eclipse.jetty.http.HttpStatus;
 
 import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
 import spark.HaltException;
 import spark.Request;
 import spark.Response;
 import spark.Service;
 
 public class UserIdentityRoutes implements Routes {
     public static final String USERS = "/users";
-    public static final String IDENTITIES = "/identities";
     private static final String USER_NAME = ":userName";
+    public static final String USERS_IDENTITY_BASE_PATH = USERS + SEPARATOR + USER_NAME + SEPARATOR + "/identities";

Review Comment:
   Just a reminder to remove the `/` out of `/identities` after rebase.



##########
server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc:
##########
@@ -718,6 +718,68 @@ In order to do that: `default=true`
 
 The web-admin server will return `404` response code when the default identity can not be found.
 
+=== Creating a user identity

Review Comment:
   ```suggestion
   === Provisioning a JMAP user-set identity
   



##########
server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc:
##########
@@ -718,6 +718,68 @@ In order to do that: `default=true`
 
 The web-admin server will return `404` response code when the default identity can not be found.
 
+=== Creating a user identity
+
+API to creating a new identity

Review Comment:
   ```suggestion
   API to create a new JMAP user-set identity
   ```
   Maybe? 
   The idea here is to distinguish with server-set identity which I guess we can not really create them with this API.



##########
server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc:
##########
@@ -718,6 +718,68 @@ In order to do that: `default=true`
 
 The web-admin server will return `404` response code when the default identity can not be found.
 
+=== Creating a user identity
+
+API to creating a new identity
+....
+curl -XPOST http://ip:port/users/{username}/identities \
+-d '{
+	"name": "Bob",
+	"email": "bob@domain.tld",
+	"mayDelete": true,
+	"htmlSignature": "a html signature",
+	"textSignature": "a text signature",
+	"bcc": [{
+		"email": "boss2@domain.tld",
+		"name": "My Boss 2"
+	}],
+	"replyTo": [{
+		"email": "boss@domain.tld",
+		"name": "My Boss"
+	}],
+	"sortOrder": 0
+ }' \
+-H "Content-Type: application/json"
+....
+
+Response codes:
+
+* 201: The new identity were successfully created
+* 404: The username is unknown
+* 400: The payload is invalid
+
+Resource name ``username'' represents a valid user
+
+=== Updating a user identity
+
+API to updating an exist identity

Review Comment:
   ```suggestion
   API to update an exist JMAP user-set identity



##########
src/site/markdown/server/manage-webadmin.md:
##########
@@ -523,6 +523,71 @@ Valid status includes:
  - `FAILED`: Error encountered while executing this step. Check the logs.
  - `ABORTED`: Won't be executed because of previous step failures.
 
+### Creating a user identity
+
+API to creating a new identity

Review Comment:
   idem as above



##########
server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc:
##########
@@ -718,6 +718,68 @@ In order to do that: `default=true`
 
 The web-admin server will return `404` response code when the default identity can not be found.
 
+=== Creating a user identity
+
+API to creating a new identity
+....
+curl -XPOST http://ip:port/users/{username}/identities \
+-d '{
+	"name": "Bob",
+	"email": "bob@domain.tld",
+	"mayDelete": true,
+	"htmlSignature": "a html signature",
+	"textSignature": "a text signature",
+	"bcc": [{
+		"email": "boss2@domain.tld",
+		"name": "My Boss 2"
+	}],
+	"replyTo": [{
+		"email": "boss@domain.tld",
+		"name": "My Boss"
+	}],
+	"sortOrder": 0
+ }' \
+-H "Content-Type: application/json"
+....
+
+Response codes:
+
+* 201: The new identity were successfully created
+* 404: The username is unknown
+* 400: The payload is invalid
+
+Resource name ``username'' represents a valid user
+
+=== Updating a user identity

Review Comment:
   ```suggestion
   === Updating a JMAP user-set identity



##########
server/apps/distributed-app/docs/modules/ROOT/pages/operate/webadmin.adoc:
##########
@@ -718,6 +718,68 @@ In order to do that: `default=true`
 
 The web-admin server will return `404` response code when the default identity can not be found.
 
+=== Creating a user identity
+
+API to creating a new identity
+....
+curl -XPOST http://ip:port/users/{username}/identities \
+-d '{
+	"name": "Bob",
+	"email": "bob@domain.tld",
+	"mayDelete": true,
+	"htmlSignature": "a html signature",
+	"textSignature": "a text signature",
+	"bcc": [{
+		"email": "boss2@domain.tld",
+		"name": "My Boss 2"
+	}],
+	"replyTo": [{
+		"email": "boss@domain.tld",
+		"name": "My Boss"
+	}],
+	"sortOrder": 0
+ }' \
+-H "Content-Type: application/json"
+....
+
+Response codes:
+
+* 201: The new identity were successfully created

Review Comment:
   ```suggestion
   * 201: The new identity was successfully created
   ```
   Or `is` to match the present tense as the below sentences.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org