Search in sources :

Example 11 with VoidRequest

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

the class GrantsEntity method delete.

/**
 * Delete an existing Grant. A token with scope delete:grants is needed.
 * See https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id<br>
 *
 * @param grantId The id of the grant to delete.
 * @return a Request to execute.
 */
public Request<Void> delete(String grantId) {
    Asserts.assertNotNull(grantId, "grant id");
    final String url = baseUrl.newBuilder().addPathSegments("api/v2/grants").addPathSegment(grantId).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 12 with VoidRequest

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

the class GrantsEntity method deleteAll.

/**
 * Deletes all Grants of a given user. A token with scope delete:grants is needed.
 * See https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id<br>
 *
 * @param userId The id of the user whose grants are deleted.
 * @return a Request to execute.
 */
public Request<Void> deleteAll(String userId) {
    Asserts.assertNotNull(userId, "user id");
    final String url = baseUrl.newBuilder().addPathSegments("api/v2/grants").addQueryParameter("user_id", 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 13 with VoidRequest

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

the class UsersEntity method removeRoles.

/**
 * Remove roles from a user.
 * A token with update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/delete_user_roles
 *
 * @param userId  the user id
 * @param roleIds a list of role ids to remove from the user
 * @return a Request to execute
 */
public Request<Void> removeRoles(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, "DELETE");
    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 14 with VoidRequest

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

the class UsersEntity method removePermissions.

/**
 * Remove permissions from a user.
 * A token with update:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/delete_permissions
 *
 * @param userId      the user id
 * @param permissions a list of permission objects to remove from the user
 * @return a Request to execute
 */
public Request<Void> removePermissions(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, "DELETE");
    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 15 with VoidRequest

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

the class UsersEntity method delete.

/**
 * Delete an existing User.
 * A token with scope delete:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Users/delete_users_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/users").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)

Aggregations

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