Skip to content

Commit

Permalink
feat: add invite Client (litmuschaos#7)
Browse files Browse the repository at this point in the history
Signed-off-by: 잉퓨 <[email protected]>
  • Loading branch information
inpyu committed Nov 14, 2024
1 parent 52e4379 commit 5e27b3e
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/io/litmuschaos/LitmusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,31 @@ public CommonResponse deleteProject(String projectID) throws IOException, Litmus
return httpClient.post("/delete_project/" + projectID, token, CommonResponse.class);
}


public SendInvitationResponse sendInvitation(SendInvitationRequest request) throws IOException, LitmusApiException {
return httpClient.post("/send_invitation", token, request, SendInvitationResponse.class);
}

public CommonResponse acceptInvitation(AcceptInvitationRequest request) throws IOException, LitmusApiException {
return httpClient.post("/accept_invitation", token, request, CommonResponse.class);
}

public CommonResponse declineInvitation(DeclineInvitationRequest request) throws IOException, LitmusApiException {
return httpClient.post("/decline_invitation", token, request, CommonResponse.class);
}

public CommonResponse removeInvitation(RemoveInvitationRequest request) throws IOException, LitmusApiException {
return httpClient.post("/remove_invitation", token, request, CommonResponse.class);
}

public List<ListInvitationResponse> listInvitation(String status)
throws IOException, LitmusApiException {
return httpClient.get("/list_invitations_with_filters/" + status, token, List.class);
}

public List<InviteUsersResponse> inviteUsers(String projectId)
throws IOException, LitmusApiException {
return httpClient.get("/invite_users/" + projectId, token, List.class);
}

}
35 changes: 35 additions & 0 deletions src/main/java/io/litmuschaos/request/AcceptInvitationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.litmuschaos.request;

public class AcceptInvitationRequest {

private String projectId;
private String userId;

public AcceptInvitationRequest(String projectId, String userId) {
this.projectId = projectId;
this.userId = userId;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String projectId;
private String userId;

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder userId(String userId) {
this.userId = userId;
return this;
}

public AcceptInvitationRequest build() {
return new AcceptInvitationRequest(this.projectId, this.userId);
}
}
}
36 changes: 36 additions & 0 deletions src/main/java/io/litmuschaos/request/DeclineInvitationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.litmuschaos.request;

public class DeclineInvitationRequest {

private String projectId;
private String userId;

public DeclineInvitationRequest(String projectId, String userId) {
this.projectId = projectId;
this.userId = userId;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String projectId;
private String userId;

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder userId(String userId) {
this.userId = userId;
return this;
}

public DeclineInvitationRequest build() {
return new DeclineInvitationRequest(this.projectId, this.userId);
}
}

}
12 changes: 12 additions & 0 deletions src/main/java/io/litmuschaos/request/InviteUsersRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.litmuschaos.request;

public class InviteUsersRequest {

private String projectId;
private String userId;

public InviteUsersRequest(String projectId, String userId) {
this.projectId = projectId;
this.userId = userId;
}
}
35 changes: 35 additions & 0 deletions src/main/java/io/litmuschaos/request/ListInvitationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.litmuschaos.request;

public class ListInvitationRequest {

private String projectId;
private String userId;

public ListInvitationRequest(String projectId, String userId) {
this.projectId = projectId;
this.userId = userId;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String projectId;
private String userId;

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder userId(String userId) {
this.userId = userId;
return this;
}

public ListInvitationRequest build() {
return new ListInvitationRequest(this.projectId, this.userId);
}
}
}
35 changes: 35 additions & 0 deletions src/main/java/io/litmuschaos/request/RemoveInvitationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.litmuschaos.request;

public class RemoveInvitationRequest {

private String projectId;
private String userId;

public RemoveInvitationRequest(String projectId, String userId) {
this.projectId = projectId;
this.userId = userId;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String projectId;
private String userId;

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder userId(String userId) {
this.userId = userId;
return this;
}

public RemoveInvitationRequest build() {
return new RemoveInvitationRequest(this.projectId, this.userId);
}
}
}
55 changes: 55 additions & 0 deletions src/main/java/io/litmuschaos/request/SendInvitationRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.litmuschaos.request;

public class SendInvitationRequest {

private String projectId;
private String userId;
private String role;

public SendInvitationRequest(String projectId, String userId, String role) {
this.projectId = projectId;
this.userId = userId;
this.role = role;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String projectId;
private String userId;
private String role;

public Builder projectId(String projectId) {
this.projectId = projectId;
return this;
}

public Builder userId(String userId) {
this.userId = userId;
return this;
}

public Builder role(String role) {
this.role = role;
return this;
}

public SendInvitationRequest build() {
return new SendInvitationRequest(this.projectId, this.userId, this.role);
}
}

public String getProjectId() {
return projectId;
}

public String getUserId() {
return userId;
}

public String getRole() {
return role;
}
}
92 changes: 92 additions & 0 deletions src/main/java/io/litmuschaos/response/InviteUsersResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package io.litmuschaos.response;

public class InviteUsersResponse {

private long updatedAt;
private long createdAt;
private UserInfo createdBy;
private UserInfo updatedBy;
private boolean isRemoved;
private String userID;
private String username;
private String salt;
private String email;
private String name;
private String role;
private boolean isInitialLogin;

public class UserInfo {
private String userID;
private String username;
private String email;

public UserInfo(String userID, String username, String email) {
this.userID = userID;
this.username = username;
this.email = email;
}
}

public InviteUsersResponse(long updatedAt, long createdAt, UserInfo createdBy, UserInfo updatedBy, boolean isRemoved, String userID, String username, String salt, String email, String name, String role, boolean isInitialLogin) {
this.updatedAt = updatedAt;
this.createdAt = createdAt;
this.createdBy = createdBy;
this.updatedBy = updatedBy;
this.isRemoved = isRemoved;
this.userID = userID;
this.username = username;
this.salt = salt;
this.email = email;
this.name = name;
this.role = role;
this.isInitialLogin = isInitialLogin;
}

public long getUpdatedAt() {
return updatedAt;
}

public long getCreatedAt() {
return createdAt;
}

public UserInfo getCreatedBy() {
return createdBy;
}

public UserInfo getUpdatedBy() {
return updatedBy;
}

public boolean getIsRemoved() {
return isRemoved;
}

public String getUserID() {
return userID;
}

public String getUsername() {
return username;
}

public String getSalt() {
return salt;
}

public String getEmail() {
return email;
}

public String getName() {
return name;
}

public String getRole() {
return role;
}

public boolean getIsInitialLogin() {
return isInitialLogin;
}
}
Loading

0 comments on commit 5e27b3e

Please sign in to comment.