Search in sources :

Example 26 with VoidRequest

use of com.auth0.net.VoidRequest in project auth0-java by auth0.

the class UserBlocksEntity method delete.

/**
 * Delete any existing User Blocks. A token with scope update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/User_Blocks/delete_user_blocks_by_id
 *
 * @param userId the user id.
 * @return a Request to execute.
 */
public Request<Void> delete(String userId) {
    Asserts.assertNotNull(userId, "user id");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/user-blocks").addPathSegment(userId).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 27 with VoidRequest

use of com.auth0.net.VoidRequest in project auth0-java by auth0.

the class UserBlocksEntity method deleteByIdentifier.

/**
 * Delete any existing User Blocks for a given identifier. A token with scope update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/User_Blocks/delete_user_blocks
 *
 * @param identifier the identifier. Either a username, phone_number, or email.
 * @return a Request to execute.
 */
public Request<Void> deleteByIdentifier(String identifier) {
    Asserts.assertNotNull(identifier, "identifier");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/user-blocks").addQueryParameter("identifier", identifier).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 28 with VoidRequest

use of com.auth0.net.VoidRequest in project auth0-java by auth0.

the class UsersEntity method addPermissions.

/**
 * Assign permissions to a user.
 * A token with update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/post_permissions
 *
 * @param userId      the user id
 * @param permissions a list of permission objects to assign to the user
 * @return a Request to execute
 */
public Request<Void> addPermissions(String userId, List<Permission> permissions) {
    Asserts.assertNotNull(userId, "user id");
    Asserts.assertNotEmpty(permissions, "permissions");
    Map<String, List<Permission>> body = new HashMap<>();
    body.put("permissions", permissions);
    final String url = baseUrl.newBuilder().addPathSegments("api/v2/users").addPathSegments(userId).addPathSegments("permissions").build().toString();
    VoidRequest request = new VoidRequest(this.client, url, "POST");
    request.setBody(body);
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest) HashMap(java.util.HashMap) List(java.util.List)

Example 29 with VoidRequest

use of com.auth0.net.VoidRequest in project auth0-java by auth0.

the class UsersEntity method addRoles.

/**
 * Assign roles to a user.
 * A token with update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/post_user_roles
 *
 * @param userId  the user id
 * @param roleIds a list of role ids to assign to the user
 * @return a Request to execute
 */
public Request<Void> addRoles(String userId, List<String> roleIds) {
    Asserts.assertNotNull(userId, "user id");
    Asserts.assertNotEmpty(roleIds, "role ids");
    Map<String, List<String>> body = new HashMap<>();
    body.put("roles", roleIds);
    final String url = baseUrl.newBuilder().addPathSegments("api/v2/users").addPathSegments(userId).addPathSegments("roles").build().toString();
    VoidRequest request = new VoidRequest(this.client, url, "POST");
    request.setBody(body);
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest) HashMap(java.util.HashMap) List(java.util.List)

Example 30 with VoidRequest

use of com.auth0.net.VoidRequest in project auth0-java by auth0.

the class UsersEntity method deleteMultifactorProvider.

/**
 * Delete an existing User's Multifactor Provider.
 * A token with scope update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/delete_multifactor_by_provider
 *
 * @param userId   the user id
 * @param provider the multifactor provider
 * @return a Request to execute.
 */
public Request<Void> deleteMultifactorProvider(String userId, String provider) {
    Asserts.assertNotNull(userId, "user id");
    Asserts.assertNotNull(provider, "provider");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/users").addPathSegment(userId).addPathSegment("multifactor").addPathSegment(provider).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Aggregations

VoidRequest (com.auth0.net.VoidRequest)33 HashMap (java.util.HashMap)7 List (java.util.List)7 HttpUrl (okhttp3.HttpUrl)1