|
1 | 1 | package com.auth0.client.mgmt; |
2 | 2 |
|
3 | 3 | 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.*; |
6 | 5 | import com.auth0.net.BaseRequest; |
7 | 6 | import com.auth0.net.Request; |
8 | 7 | import com.auth0.net.VoidRequest; |
@@ -163,4 +162,212 @@ public Request<Void> deleteUser(String connectionId, String email) { |
163 | 162 | .toString(); |
164 | 163 | return new VoidRequest(this.client, tokenProvider, url, HttpMethod.DELETE); |
165 | 164 | } |
| 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 | + } |
166 | 373 | } |
0 commit comments