Skip to content

Commit

Permalink
Implement endpoint for users
Browse files Browse the repository at this point in the history
  • Loading branch information
pathob committed Oct 26, 2023
1 parent b2953ec commit fad49e1
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 0 deletions.
328 changes: 328 additions & 0 deletions index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,297 @@ ifdef::internal-generation[]
endif::internal-generation[]


[.Users]
=== Users


[.getUser]
==== getUser

`GET /users`

Get a user

===== Description




// markup not found, no include::{specDir}users/GET/spec.adoc[opts=optional]



===== Parameters





====== Query Parameters

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| username
|
| X
| null
|

|===


===== Return Type

<<UserBean>>


===== Content Type

* application/json

===== Responses

.http response codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
| Returns the requested user details
| <<UserBean>>


| 0
| Returns a list of error messages.
| <<ErrorCollection>>

|===

===== Samples


// markup not found, no include::{snippetDir}users/GET/http-request.adoc[opts=optional]


// markup not found, no include::{snippetDir}users/GET/http-response.adoc[opts=optional]



// file not found, no * wiremock data link :users/GET/GET.json[]


ifdef::internal-generation[]
===== Implementation

// markup not found, no include::{specDir}users/GET/implementation.adoc[opts=optional]


endif::internal-generation[]


[.setUser]
==== setUser

`PUT /users`

Update an user

===== Description




// markup not found, no include::{specDir}users/PUT/spec.adoc[opts=optional]



===== Parameters


===== Body Parameter

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| UserBean
| <<UserBean>>
| X
|
|

|===



====== Query Parameters

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| username
|
| X
| null
|

|===


===== Return Type

<<UserBean>>


===== Content Type

* application/json

===== Responses

.http response codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
| Returns the updated user details
| <<UserBean>>


| 0
| Returns a list of error messages.
| <<ErrorCollection>>

|===

===== Samples


// markup not found, no include::{snippetDir}users/PUT/http-request.adoc[opts=optional]


// markup not found, no include::{snippetDir}users/PUT/http-response.adoc[opts=optional]



// file not found, no * wiremock data link :users/PUT/PUT.json[]


ifdef::internal-generation[]
===== Implementation

// markup not found, no include::{specDir}users/PUT/implementation.adoc[opts=optional]


endif::internal-generation[]


[.setUserPassword]
==== setUserPassword

`PUT /users/password`

Update a user password

===== Description




// markup not found, no include::{specDir}users/password/PUT/spec.adoc[opts=optional]



===== Parameters


===== Body Parameter

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| body
| <<string>>
| X
|
|

|===



====== Query Parameters

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| username
|
| X
| null
|

|===


===== Return Type

<<UserBean>>


===== Content Type

* application/json

===== Responses

.http response codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
| Returns the user details
| <<UserBean>>


| 0
| Returns a list of error messages.
| <<ErrorCollection>>

|===

===== Samples


// markup not found, no include::{snippetDir}users/password/PUT/http-request.adoc[opts=optional]


// markup not found, no include::{snippetDir}users/password/PUT/http-response.adoc[opts=optional]



// file not found, no * wiremock data link :users/password/PUT/PUT.json[]


ifdef::internal-generation[]
===== Implementation

// markup not found, no include::{specDir}users/password/PUT/implementation.adoc[opts=optional]


endif::internal-generation[]


[#models]
== Models

Expand Down Expand Up @@ -3549,3 +3840,40 @@ endif::internal-generation[]
|===


[#UserBean]
=== _UserBean_



[.fields-UserBean]
[cols="2,1,2,4,1"]
|===
| Field Name| Required| Type| Description| Format

| username
|
| String
|
|

| fullName
|
| String
|
|

| email
|
| String
|
|

| password
|
| String
|
|

|===


22 changes: 22 additions & 0 deletions src/main/java/de/aservo/confapi/crowd/model/UsersBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.aservo.confapi.crowd.model;

import de.aservo.confapi.commons.constants.ConfAPI;
import de.aservo.confapi.commons.model.UserBean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collection;

@Data
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = ConfAPI.USERS)
public class UsersBean {

@XmlElement
private Collection<UserBean> users;

}
35 changes: 35 additions & 0 deletions src/main/java/de/aservo/confapi/crowd/model/util/UserBeanUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package de.aservo.confapi.crowd.model.util;

import com.atlassian.crowd.model.user.User;
import de.aservo.confapi.commons.model.UserBean;

import javax.annotation.Nullable;

public class UserBeanUtil {

/**
* Build user bean.
*
* @param user the user
* @return the user bean
*/
@Nullable
public static UserBean toUserBean(
@Nullable final User user) {

if (user == null) {
return null;
}

final UserBean userBean = new UserBean();
userBean.setUsername(user.getName());
userBean.setFullName(user.getDisplayName());
userBean.setEmail(user.getEmailAddress());

return userBean;
}

private UserBeanUtil() {
}

}
Loading

0 comments on commit fad49e1

Please sign in to comment.