Skip to content

Commit bd020b0

Browse files
committed
Added Support for Self-Service Profile
1 parent 920affc commit bd020b0

14 files changed

+799
-0
lines changed

src/main/java/com/auth0/client/mgmt/ManagementAPI.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,14 @@ public PromptsEntity prompts() {
388388
return new PromptsEntity(client, baseUrl, tokenProvider);
389389
}
390390

391+
/**
392+
* Getter for the SelfServiceProfiles Entity
393+
* @return the SelfServiceProfiles Entity
394+
*/
395+
public SelfServiceProfilesEntity selfServiceProfiles() {
396+
return new SelfServiceProfilesEntity(client, baseUrl, tokenProvider);
397+
}
398+
391399
/**
392400
* Builder for {@link ManagementAPI} API client instances.
393401
*/
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package com.auth0.client.mgmt;
2+
3+
import com.auth0.client.mgmt.filter.PageBasedPaginationFilter;
4+
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfile;
5+
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponse;
6+
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponsePage;
7+
import com.auth0.net.BaseRequest;
8+
import com.auth0.net.Request;
9+
import com.auth0.net.VoidRequest;
10+
import com.auth0.net.client.Auth0HttpClient;
11+
import com.auth0.net.client.HttpMethod;
12+
import com.auth0.utils.Asserts;
13+
import com.fasterxml.jackson.core.type.TypeReference;
14+
import okhttp3.HttpUrl;
15+
16+
import java.util.Map;
17+
18+
public class SelfServiceProfilesEntity extends BaseManagementEntity {
19+
20+
private final static String ORGS_PATH = "api/v2/self-service-profiles";
21+
22+
SelfServiceProfilesEntity(Auth0HttpClient client, HttpUrl baseUrl, TokenProvider tokenProvider) {
23+
super(client, baseUrl, tokenProvider);
24+
}
25+
26+
/**
27+
* Request the list of self-service profiles.
28+
* A token with scope read:self_service_profiles is needed
29+
* See <a href="https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles">https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles</a>
30+
* @param pageFilter the pagination filter to apply. Can be null to use the default values.
31+
* @return a Request to execute.
32+
*/
33+
public Request<SelfServiceProfileResponsePage> get(PageBasedPaginationFilter pageFilter) {
34+
HttpUrl.Builder builder = baseUrl.newBuilder()
35+
.addPathSegments(ORGS_PATH);
36+
37+
if (pageFilter != null) {
38+
for (Map.Entry<String, Object> e : pageFilter.getAsMap().entrySet()) {
39+
builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue()));
40+
}
41+
}
42+
43+
String url = builder.build().toString();
44+
return new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.GET, new TypeReference<SelfServiceProfileResponsePage>() {
45+
});
46+
}
47+
48+
/**
49+
* Create a new self-service profile.
50+
* A token with scope create:self_service_profiles is needed
51+
* See <a href="https://auth0.com/docs/api/management/v2/self-service-profiles/post-self-service-profiles">https://auth0.com/docs/api/management/v2/self-service-profiles/post-self-service-profiles</a>
52+
* @param selfServiceProfile the self-service profile to create.
53+
* @return a Request to execute.
54+
*/
55+
public Request<SelfServiceProfileResponse> create(SelfServiceProfile selfServiceProfile) {
56+
Asserts.assertNotNull(selfServiceProfile, "self service profile");
57+
Asserts.assertNotNull(selfServiceProfile.getName(), "name");
58+
59+
String url = baseUrl.newBuilder()
60+
.addPathSegments(ORGS_PATH)
61+
.build()
62+
.toString();
63+
64+
BaseRequest<SelfServiceProfileResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<SelfServiceProfileResponse>() {
65+
});
66+
request.setBody(selfServiceProfile);
67+
return request;
68+
}
69+
70+
/**
71+
* Request the self-service profile with the given ID.
72+
* A token with scope read:self_service_profiles is needed
73+
* See <a href="https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles-by-id">https://auth0.com/docs/api/management/v2/self-service-profiles/get-self-service-profiles-by-id</a>
74+
* @param id the self-service profile ID.
75+
* @return a Request to execute.
76+
*/
77+
public Request<SelfServiceProfileResponse> getById(String id) {
78+
Asserts.assertNotNull(id, "id");
79+
80+
String url = baseUrl.newBuilder()
81+
.addPathSegments(ORGS_PATH)
82+
.addPathSegment(id)
83+
.build()
84+
.toString();
85+
86+
return new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.GET, new TypeReference<SelfServiceProfileResponse>() {
87+
});
88+
}
89+
90+
/**
91+
* Delete the self-service profile with the given ID.
92+
* A token with scope delete:self_service_profiles is needed
93+
* See <a href="https://auth0.com/docs/api/management/v2/self-service-profiles/delete-self-service-profiles-by-id">https://auth0.com/docs/api/management/v2/self-service-profiles/delete-self-service-profiles-by-id</a>
94+
* @param id the self-service profile ID.
95+
* @return a Request to execute.
96+
*/
97+
public Request<Void> delete(String id) {
98+
Asserts.assertNotNull(id, "id");
99+
100+
String url = baseUrl.newBuilder()
101+
.addPathSegments(ORGS_PATH)
102+
.addPathSegment(id)
103+
.build()
104+
.toString();
105+
106+
return new VoidRequest(this.client, tokenProvider, url, HttpMethod.DELETE);
107+
}
108+
109+
/**
110+
* Update the self-service profile with the given ID.
111+
* A token with scope update:self_service_profiles is needed
112+
* See <a href="https://auth0.com/docs/api/management/v2/self-service-profiles/patch-self-service-profiles-by-id">https://auth0.com/docs/api/management/v2/self-service-profiles/patch-self-service-profiles-by-id</a>
113+
* @param selfServiceProfile the self-service profile to update.
114+
* @param id the self-service profile ID.
115+
* @return a Request to execute.
116+
*/
117+
public Request<SelfServiceProfileResponse> update(SelfServiceProfile selfServiceProfile, String id) {
118+
Asserts.assertNotNull(selfServiceProfile, "self service profile");
119+
Asserts.assertNotNull(id, "id");
120+
121+
String url = baseUrl.newBuilder()
122+
.addPathSegments(ORGS_PATH)
123+
.addPathSegment(id)
124+
.build()
125+
.toString();
126+
127+
BaseRequest<SelfServiceProfileResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<SelfServiceProfileResponse>() {
128+
});
129+
request.setBody(selfServiceProfile);
130+
return request;
131+
}
132+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.auth0.client.mgmt.filter;
2+
3+
/**
4+
* Class that represents a filter to be used when requesting a list of items with pagination.
5+
*/
6+
public class PageBasedPaginationFilter extends BaseFilter{
7+
8+
/**
9+
* Filter by page
10+
*
11+
* @param pageNumber the page number to retrieve.
12+
* @param amountPerPage the amount of items per page to retrieve.
13+
* @return this filter instance
14+
*/
15+
public PageBasedPaginationFilter withPage(int pageNumber, int amountPerPage) {
16+
parameters.put("page", pageNumber);
17+
parameters.put("per_page", amountPerPage);
18+
return this;
19+
}
20+
21+
/**
22+
* Include the query summary
23+
*
24+
* @param includeTotals whether to include or not the query summary.
25+
* @return this filter instance
26+
*/
27+
public PageBasedPaginationFilter withTotals(boolean includeTotals) {
28+
parameters.put("include_totals", includeTotals);
29+
return this;
30+
}
31+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonInclude(JsonInclude.Include.NON_NULL)
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public class Branding {
10+
@JsonProperty("logo_url")
11+
private String logoUrl;
12+
@JsonProperty("colors")
13+
private Color colors;
14+
15+
/**
16+
* Getter for the logo URL.
17+
* @return the logo URL.
18+
*/
19+
public String getLogoUrl() {
20+
return logoUrl;
21+
}
22+
23+
/**
24+
* Setter for the logo URL.
25+
* @param logoUrl the logo URL to set.
26+
*/
27+
public void setLogoUrl(String logoUrl) {
28+
this.logoUrl = logoUrl;
29+
}
30+
31+
/**
32+
* Getter for the colors.
33+
* @return the colors.
34+
*/
35+
public Color getColors() {
36+
return colors;
37+
}
38+
39+
/**
40+
* Setter for the colors.
41+
* @param colors the colors to set.
42+
*/
43+
public void setColors(Color colors) {
44+
this.colors = colors;
45+
}
46+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
public class Color {
11+
@JsonProperty("primary")
12+
private String primary;
13+
14+
/**
15+
* Creates a new instance of the Color class.
16+
*/
17+
public Color() {}
18+
19+
/**
20+
* Creates a new instance of the Color class.
21+
* @param primary the primary color.
22+
*/
23+
@JsonCreator
24+
public Color(@JsonProperty("primary") String primary) {
25+
this.primary = primary;
26+
}
27+
28+
/**
29+
* Getter for the primary color.
30+
* @return the primary color.
31+
*/
32+
public String getPrimary() {
33+
return primary;
34+
}
35+
36+
/**
37+
* Setter for the primary color.
38+
* @param primary the primary color to set.
39+
*/
40+
public void setPrimary(String primary) {
41+
this.primary = primary;
42+
}
43+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
import java.util.List;
9+
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
11+
@JsonIgnoreProperties(ignoreUnknown = true)
12+
public class SelfServiceProfile {
13+
@JsonProperty("name")
14+
private String name;
15+
@JsonProperty("description")
16+
private String description;
17+
@JsonProperty("user_attributes")
18+
private List<UserAttribute> userAttributes;
19+
@JsonProperty("branding")
20+
private Branding branding;
21+
@JsonProperty("allowed_strategies")
22+
private List<String> allowedStrategies;
23+
24+
/**
25+
* Getter for the name of the self-service profile.
26+
* @return the name of the self-service profile.
27+
*/
28+
public String getName() {
29+
return name;
30+
}
31+
32+
/**
33+
* Setter for the name of the self-service profile.
34+
* @param name the name of the self-service profile to set.
35+
*/
36+
public void setName(String name) {
37+
this.name = name;
38+
}
39+
40+
/**
41+
* Getter for the description of the self-service profile.
42+
* @return the description of the self-service profile.
43+
*/
44+
public String getDescription() {
45+
return description;
46+
}
47+
48+
/**
49+
* Setter for the description of the self-service profile.
50+
* @param description the description of the self-service profile to set.
51+
*/
52+
public void setDescription(String description) {
53+
this.description = description;
54+
}
55+
56+
/**
57+
* Getter for the user attributes of the self-service profile.
58+
* @return the user attributes of the self-service profile.
59+
*/
60+
public List<UserAttribute> getUserAttributes() {
61+
return userAttributes;
62+
}
63+
64+
/**
65+
* Setter for the user attributes of the self-service profile.
66+
* @param userAttributes the user attributes of the self-service profile to set.
67+
*/
68+
public void setUserAttributes(List<UserAttribute> userAttributes) {
69+
this.userAttributes = userAttributes;
70+
}
71+
72+
/**
73+
* Getter for the branding of the self-service profile.
74+
* @return the branding of the self-service profile.
75+
*/
76+
public Branding getBranding() {
77+
return branding;
78+
}
79+
80+
/**
81+
* Setter for the branding of the self-service profile.
82+
* @param branding the branding of the self-service profile to set.
83+
*/
84+
public void setBranding(Branding branding) {
85+
this.branding = branding;
86+
}
87+
88+
/**
89+
* Getter for the allowed strategies of the self-service profile.
90+
* @return the allowed strategies of the self-service profile.
91+
*/
92+
public List<String> getAllowedStrategies() {
93+
return allowedStrategies;
94+
}
95+
96+
/**
97+
* Setter for the allowed strategies of the self-service profile.
98+
* @param allowedStrategies the allowed strategies of the self-service profile to set.
99+
*/
100+
public void setAllowedStrategies(List<String> allowedStrategies) {
101+
this.allowedStrategies = allowedStrategies;
102+
}
103+
}

0 commit comments

Comments
 (0)