Skip to content

Commit 80fd4a6

Browse files
authored
Added Connection's SCIM Server Support (#696)
1 parent d0fed49 commit 80fd4a6

22 files changed

+1410
-6
lines changed

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

Lines changed: 209 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.auth0.client.mgmt;
22

33
import com.auth0.client.mgmt.filter.ConnectionFilter;
4-
import com.auth0.json.mgmt.connections.Connection;
5-
import com.auth0.json.mgmt.connections.ConnectionsPage;
4+
import com.auth0.json.mgmt.connections.*;
65
import com.auth0.net.BaseRequest;
76
import com.auth0.net.Request;
87
import com.auth0.net.VoidRequest;
@@ -163,4 +162,212 @@ public Request<Void> deleteUser(String connectionId, String email) {
163162
.toString();
164163
return new VoidRequest(this.client, tokenProvider, url, HttpMethod.DELETE);
165164
}
165+
166+
/**
167+
* Get the Connections Scim Configuration.
168+
* A token with scope read:scim_config is needed.
169+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/get-scim-configuration">https://auth0.com/docs/api/management/v2#!/connections/get-scim-configuration</a>
170+
* @param connectionId the connection id.
171+
* @return a Request to execute.
172+
*/
173+
public Request<ScimConfigurationResponse> getScimConfiguration( String connectionId) {
174+
Asserts.assertNotNull(connectionId, "connection id");
175+
176+
String url = baseUrl
177+
.newBuilder()
178+
.addPathSegments("api/v2/connections")
179+
.addPathSegment(connectionId)
180+
.addPathSegment("scim-configuration")
181+
.build()
182+
.toString();
183+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ScimConfigurationResponse>() {
184+
});
185+
}
186+
187+
/**
188+
* Delete the Connections Scim Configuration.
189+
* A token with scope delete:scim_config is needed.
190+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/delete-scim-configuration">https://auth0.com/docs/api/management/v2#!/connections/delete-scim-configuration</a>
191+
* @param connectionId the connection id.
192+
* @return a Request to execute.
193+
*/
194+
public Request<Void> deleteScimConfiguration(String connectionId) {
195+
Asserts.assertNotNull(connectionId, "connection id");
196+
197+
String url = baseUrl
198+
.newBuilder()
199+
.addPathSegments("api/v2/connections")
200+
.addPathSegment(connectionId)
201+
.addPathSegment("scim-configuration")
202+
.build()
203+
.toString();
204+
return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
205+
}
206+
207+
/**
208+
* Update the Connections Scim Configuration.
209+
* A token with scope update:scim_config is needed.
210+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/patch-scim-configuration">https://auth0.com/docs/api/management/v2#!/connections/patch-scim-configuration</a>
211+
* @param connectionId the connection id.
212+
* @param scimConfigurationRequest the scim configuration request.
213+
* @return a Request to execute.
214+
*/
215+
public Request<ScimConfigurationResponse> updateScimConfiguration(String connectionId, ScimConfigurationRequest scimConfigurationRequest){
216+
Asserts.assertNotNull(connectionId, "connection id");
217+
Asserts.assertNotNull(scimConfigurationRequest, "scim configuration request");
218+
Asserts.assertNotNull(scimConfigurationRequest.getUserIdAttribute(), "user id attribute");
219+
Asserts.assertNotNull(scimConfigurationRequest.getMapping(), "mapping");
220+
221+
String url = baseUrl
222+
.newBuilder()
223+
.addPathSegments("api/v2/connections")
224+
.addPathSegment(connectionId)
225+
.addPathSegment("scim-configuration")
226+
.build()
227+
.toString();
228+
229+
BaseRequest<ScimConfigurationResponse> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<ScimConfigurationResponse>() {
230+
});
231+
request.setBody(scimConfigurationRequest);
232+
return request;
233+
}
234+
235+
/**
236+
* Create the Connections Scim Configuration.
237+
* A token with scope create:scim_config is needed.
238+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/post-scim-configuration">https://auth0.com/docs/api/management/v2#!/connections/post-scim-configuration</a>
239+
* @param connectionId the connection id.
240+
* @param request the scim configuration request.
241+
* @return a Request to execute.
242+
*/
243+
public Request<ScimConfigurationResponse> createScimConfiguration(String connectionId, ScimConfigurationRequest request){
244+
Asserts.assertNotNull(connectionId, "connection id");
245+
246+
String url = baseUrl
247+
.newBuilder()
248+
.addPathSegments("api/v2/connections")
249+
.addPathSegment(connectionId)
250+
.addPathSegment("scim-configuration")
251+
.build()
252+
.toString();
253+
254+
BaseRequest<ScimConfigurationResponse> baseRequest = new BaseRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<ScimConfigurationResponse>() {
255+
});
256+
baseRequest.setBody(request);
257+
return baseRequest;
258+
}
259+
260+
/**
261+
* Get the Scim Configuration default mapping by its connection Id.
262+
* A token with scope read:scim_config is needed.
263+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/get-default-mapping">https://auth0.com/docs/api/management/v2#!/connections/get-default-mapping</a>
264+
* @param connectionId the connection id.
265+
* @return a Request to execute.
266+
*/
267+
public Request<DefaultScimMappingResponse> getDefaultScimConfiguration(String connectionId){
268+
Asserts.assertNotNull(connectionId, "connection id");
269+
270+
String url = baseUrl
271+
.newBuilder()
272+
.addPathSegments("api/v2/connections")
273+
.addPathSegment(connectionId)
274+
.addPathSegment("scim-configuration")
275+
.addPathSegment("default-mapping")
276+
.build()
277+
.toString();
278+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<DefaultScimMappingResponse>() {
279+
});
280+
}
281+
282+
/**
283+
* Get the Connections Scim Tokens.
284+
* A token with scope read:scim_token is needed.
285+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/get-scim-tokens">https://auth0.com/docs/api/management/v2#!/connections/get-scim-tokens</a>
286+
* @param connectionId the connection id.
287+
* @return a Request to execute.
288+
*/
289+
public Request<List<ScimTokenResponse>> getScimToken(String connectionId){
290+
Asserts.assertNotNull(connectionId, "connection id");
291+
292+
String url = baseUrl
293+
.newBuilder()
294+
.addPathSegments("api/v2/connections")
295+
.addPathSegment(connectionId)
296+
.addPathSegments("scim-configuration/tokens")
297+
.build()
298+
.toString();
299+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<List<ScimTokenResponse>>() {
300+
});
301+
}
302+
303+
/**
304+
* Create a Connections Scim Token.
305+
* A token with scope create:scim_token is needed.
306+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/post-scim-token">https://auth0.com/docs/api/management/v2#!/connections/post-scim-token</a>
307+
* @param connectionId the connection id.
308+
* @param scimTokenRequest the scim token request.
309+
* @return a Request to execute.
310+
*/
311+
public Request<ScimTokenCreateResponse> createScimToken(String connectionId, ScimTokenRequest scimTokenRequest){
312+
Asserts.assertNotNull(connectionId, "connection id");
313+
Asserts.assertNotNull(scimTokenRequest, "scim token request");
314+
315+
String url = baseUrl
316+
.newBuilder()
317+
.addPathSegments("api/v2/connections")
318+
.addPathSegment(connectionId)
319+
.addPathSegments("scim-configuration/tokens")
320+
.build()
321+
.toString();
322+
323+
BaseRequest<ScimTokenCreateResponse> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<ScimTokenCreateResponse>() {
324+
});
325+
request.setBody(scimTokenRequest);
326+
return request;
327+
}
328+
329+
/**
330+
* Delete a Connections Scim Token.
331+
* A token with scope delete:scim_token is needed.
332+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/delete-tokens-by-token-id">https://auth0.com/docs/api/management/v2#!/connections/delete-tokens-by-token-id</a>
333+
* @param connectionId the connection id.
334+
* @param tokenId the token id.
335+
* @return a Request to execute.
336+
*/
337+
public Request<Void> deleteScimToken(String connectionId, String tokenId){
338+
Asserts.assertNotNull(connectionId, "connection id");
339+
Asserts.assertNotNull(tokenId, "token id");
340+
341+
String url = baseUrl
342+
.newBuilder()
343+
.addPathSegments("api/v2/connections")
344+
.addPathSegment(connectionId)
345+
.addPathSegments("scim-configuration/tokens")
346+
.addPathSegment(tokenId)
347+
.build()
348+
.toString();
349+
350+
return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
351+
}
352+
353+
/**
354+
* Check the Connection Status.
355+
* A token with scope read:connections is needed.
356+
* @see <a href="https://auth0.com/docs/api/management/v2#!/connections/get-status">https://auth0.com/docs/api/management/v2#!/connections/get-status</a>
357+
* @param connectionId the connection id.
358+
* @return a Request to execute.
359+
*/
360+
public Request<Void> checkConnectionStatus(String connectionId){
361+
Asserts.assertNotNull(connectionId, "connection id");
362+
363+
String url = baseUrl
364+
.newBuilder()
365+
.addPathSegments("api/v2/connections")
366+
.addPathSegment(connectionId)
367+
.addPathSegments("status")
368+
.build()
369+
.toString();
370+
371+
return new VoidRequest(client, tokenProvider, url, HttpMethod.GET);
372+
}
166373
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.auth0.json.mgmt.connections;
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+
@JsonIgnoreProperties(ignoreUnknown = true)
11+
@JsonInclude(JsonInclude.Include.NON_NULL)
12+
public class DefaultScimMappingResponse {
13+
@JsonProperty("mapping")
14+
private List<Mapping> mapping;
15+
16+
/**
17+
* Creates a new instance.
18+
*/
19+
@JsonCreator
20+
public DefaultScimMappingResponse() {
21+
}
22+
23+
/**
24+
* Creates a new instance with the given mapping.
25+
* @param mapping the mapping attribute.
26+
*/
27+
@JsonCreator
28+
public DefaultScimMappingResponse(@JsonProperty("mapping") List<Mapping> mapping) {
29+
this.mapping = mapping;
30+
}
31+
32+
/**
33+
* Getter for the mapping attribute.
34+
* @return the mapping attribute.
35+
*/
36+
public List<Mapping> getMapping() {
37+
return mapping;
38+
}
39+
40+
/**
41+
* Setter for the mapping attribute.
42+
* @param mapping the mapping attribute to set.
43+
*/
44+
public void setMapping(List<Mapping> mapping) {
45+
this.mapping = mapping;
46+
}
47+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.auth0.json.mgmt.connections;
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+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
@JsonInclude(JsonInclude.Include.NON_NULL)
10+
public class Mapping {
11+
@JsonProperty("auth0")
12+
private String auth0;
13+
@JsonProperty("scim")
14+
private String scim;
15+
16+
/**
17+
* Creates a new instance.
18+
*/
19+
@JsonCreator
20+
public Mapping() {
21+
22+
}
23+
24+
/**
25+
* Creates a new instance with the given Auth0 and SCIM attributes.
26+
* @param auth0 the Auth0 attribute.
27+
* @param scim the SCIM attribute.
28+
*/
29+
@JsonCreator
30+
public Mapping(@JsonProperty("auth0") String auth0, @JsonProperty("scim") String scim) {
31+
this.auth0 = auth0;
32+
this.scim = scim;
33+
}
34+
35+
/**
36+
* Getter for the Auth0 attribute.
37+
* @return the Auth0 attribute.
38+
*/
39+
public String getAuth0() {
40+
return auth0;
41+
}
42+
43+
/**
44+
* Setter for the Auth0 attribute.
45+
* @param auth0 the Auth0 attribute to set.
46+
*/
47+
public void setAuth0(String auth0) {
48+
this.auth0 = auth0;
49+
}
50+
51+
/**
52+
* Getter for the SCIM attribute.
53+
* @return the SCIM attribute.
54+
*/
55+
public String getScim() {
56+
return scim;
57+
}
58+
59+
/**
60+
* Setter for the SCIM attribute.
61+
* @param scim the SCIM attribute to set.
62+
*/
63+
public void setScim(String scim) {
64+
this.scim = scim;
65+
}
66+
}

0 commit comments

Comments
 (0)