Skip to content

Commit

Permalink
Improve user invite api model to support RoleV2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanapriya committed Nov 13, 2023
1 parent 1fe8221 commit 5454189
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 128 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* 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.organization.user.invitation.management.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 Audience {

private String value;
private String display;
private String type;

/**
**/
public Audience value(String value) {

this.value = value;
return this;
}

@ApiModelProperty(example = "3645709f-ea8d-5595-7690-e1fa0efe3df9", value = "")
@JsonProperty("value")
@Valid
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}

/**
**/
public Audience display(String display) {

this.display = display;
return this;
}

@ApiModelProperty(example = "My Org", value = "")
@JsonProperty("display")
@Valid
public String getDisplay() {
return display;
}
public void setDisplay(String display) {
this.display = display;
}

/**
**/
public Audience type(String type) {

this.type = type;
return this;
}

@ApiModelProperty(example = "organization", value = "")
@JsonProperty("type")
@Valid
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Audience audience = (Audience) o;
return Objects.equals(this.value, audience.value) &&
Objects.equals(this.display, audience.display) &&
Objects.equals(this.type, audience.type);
}

@Override
public int hashCode() {
return Objects.hash(value, display, type);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class Audience {\n");

sb.append(" value: ").append(toIndentedString(value)).append("\n");
sb.append(" display: ").append(toIndentedString(display)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).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");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.organization.user.invitation.management.v1.model.RoleAssignmentRequestBody;
import javax.validation.constraints.*;


Expand All @@ -37,7 +36,7 @@ public class InvitationRequestBody {

private String username;
private String userDomain;
private List<RoleAssignmentRequestBody> roleAssignments = null;
private List<String> roles = null;


/**
Expand Down Expand Up @@ -83,27 +82,27 @@ public void setUserDomain(String userDomain) {
/**
* Role assignments which the user will be assigned to.
**/
public InvitationRequestBody roleAssignments(List<RoleAssignmentRequestBody> roleAssignments) {
public InvitationRequestBody roles(List<String> roles) {

this.roleAssignments = roleAssignments;
this.roles = roles;
return this;
}

@ApiModelProperty(value = "Role assignments which the user will be assigned to.")
@JsonProperty("roleAssignments")
@JsonProperty("roles")
@Valid
public List<RoleAssignmentRequestBody> getRoleAssignments() {
return roleAssignments;
public List<String> getRoles() {
return roles;
}
public void setRoleAssignments(List<RoleAssignmentRequestBody> roleAssignments) {
this.roleAssignments = roleAssignments;
public void setRoles(List<String> roles) {
this.roles = roles;
}

public InvitationRequestBody addRoleAssignmentsItem(RoleAssignmentRequestBody roleAssignmentsItem) {
if (this.roleAssignments == null) {
this.roleAssignments = new ArrayList<>();
public InvitationRequestBody addRolesItem(String rolesItem) {
if (this.roles == null) {
this.roles = new ArrayList<>();
}
this.roleAssignments.add(roleAssignmentsItem);
this.roles.add(rolesItem);
return this;
}

Expand All @@ -121,12 +120,12 @@ public boolean equals(java.lang.Object o) {
InvitationRequestBody invitationRequestBody = (InvitationRequestBody) o;
return Objects.equals(this.username, invitationRequestBody.username) &&
Objects.equals(this.userDomain, invitationRequestBody.userDomain) &&
Objects.equals(this.roleAssignments, invitationRequestBody.roleAssignments);
Objects.equals(this.roles, invitationRequestBody.roles);
}

@Override
public int hashCode() {
return Objects.hash(username, userDomain, roleAssignments);
return Objects.hash(username, userDomain, roles);
}

@Override
Expand All @@ -137,7 +136,7 @@ public String toString() {

sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" userDomain: ").append(toIndentedString(userDomain)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class InvitationResponse {
private String id;
private String username;
private String email;
private List<RoleAssignmentResponse> roleAssignments = null;
private List<RoleAssignmentResponse> roles = null;

private String status;
private String expiredAt;
Expand Down Expand Up @@ -105,27 +105,27 @@ public void setEmail(String email) {

/**
**/
public InvitationResponse roleAssignments(List<RoleAssignmentResponse> roleAssignments) {
public InvitationResponse roles(List<RoleAssignmentResponse> roles) {

this.roleAssignments = roleAssignments;
this.roles = roles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("roleAssignments")
@JsonProperty("roles")
@Valid
public List<RoleAssignmentResponse> getRoleAssignments() {
return roleAssignments;
public List<RoleAssignmentResponse> getRoles() {
return roles;
}
public void setRoleAssignments(List<RoleAssignmentResponse> roleAssignments) {
this.roleAssignments = roleAssignments;
public void setRoles(List<RoleAssignmentResponse> roles) {
this.roles = roles;
}

public InvitationResponse addRoleAssignmentsItem(RoleAssignmentResponse roleAssignmentsItem) {
if (this.roleAssignments == null) {
this.roleAssignments = new ArrayList<>();
public InvitationResponse addRolesItem(RoleAssignmentResponse rolesItem) {
if (this.roles == null) {
this.roles = new ArrayList<>();
}
this.roleAssignments.add(roleAssignmentsItem);
this.roles.add(rolesItem);
return this;
}

Expand Down Expand Up @@ -182,14 +182,14 @@ public boolean equals(java.lang.Object o) {
return Objects.equals(this.id, invitationResponse.id) &&
Objects.equals(this.username, invitationResponse.username) &&
Objects.equals(this.email, invitationResponse.email) &&
Objects.equals(this.roleAssignments, invitationResponse.roleAssignments) &&
Objects.equals(this.roles, invitationResponse.roles) &&
Objects.equals(this.status, invitationResponse.status) &&
Objects.equals(this.expiredAt, invitationResponse.expiredAt);
}

@Override
public int hashCode() {
return Objects.hash(id, username, email, roleAssignments, status, expiredAt);
return Objects.hash(id, username, email, roles, status, expiredAt);
}

@Override
Expand All @@ -201,7 +201,7 @@ public String toString() {
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" expiredAt: ").append(toIndentedString(expiredAt)).append("\n");
sb.append("}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class InvitationSuccessResponse {

private String username;
private String email;
private List<RoleAssignmentResponse> roleAssignments = new ArrayList<>();
private List<RoleAssignmentResponse> roles = new ArrayList<>();


/**
Expand Down Expand Up @@ -85,26 +85,26 @@ public void setEmail(String email) {
/**
* Role assignments which the user will be assigned to.
**/
public InvitationSuccessResponse roleAssignments(List<RoleAssignmentResponse> roleAssignments) {
public InvitationSuccessResponse roles(List<RoleAssignmentResponse> roles) {

this.roleAssignments = roleAssignments;
this.roles = roles;
return this;
}

@ApiModelProperty(required = true, value = "Role assignments which the user will be assigned to.")
@JsonProperty("roleAssignments")
@JsonProperty("roles")
@Valid
@NotNull(message = "Property roleAssignments cannot be null.")
@NotNull(message = "Property roles cannot be null.")

public List<RoleAssignmentResponse> getRoleAssignments() {
return roleAssignments;
public List<RoleAssignmentResponse> getRoles() {
return roles;
}
public void setRoleAssignments(List<RoleAssignmentResponse> roleAssignments) {
this.roleAssignments = roleAssignments;
public void setRoles(List<RoleAssignmentResponse> roles) {
this.roles = roles;
}

public InvitationSuccessResponse addRoleAssignmentsItem(RoleAssignmentResponse roleAssignmentsItem) {
this.roleAssignments.add(roleAssignmentsItem);
public InvitationSuccessResponse addRolesItem(RoleAssignmentResponse rolesItem) {
this.roles.add(rolesItem);
return this;
}

Expand All @@ -122,12 +122,12 @@ public boolean equals(java.lang.Object o) {
InvitationSuccessResponse invitationSuccessResponse = (InvitationSuccessResponse) o;
return Objects.equals(this.username, invitationSuccessResponse.username) &&
Objects.equals(this.email, invitationSuccessResponse.email) &&
Objects.equals(this.roleAssignments, invitationSuccessResponse.roleAssignments);
Objects.equals(this.roles, invitationSuccessResponse.roles);
}

@Override
public int hashCode() {
return Objects.hash(username, email, roleAssignments);
return Objects.hash(username, email, roles);
}

@Override
Expand All @@ -138,7 +138,7 @@ public String toString() {

sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Loading

0 comments on commit 5454189

Please sign in to comment.