Search in sources :

Example 21 with VoidRequest

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

the class RolesEntity method addPermissions.

/**
 * Associate permissions with a role. Only the `permission_name` and
 * `resource_server_identifier` Permission attributes should be specified.
 * A token with update:roles is needed.
 * See https://auth0.com/docs/api/management/v2#!/Roles/post_role_permission_assignment
 *
 * @param roleId the role id
 * @param permissions a list of permission objects to associate to the role
 * @return a Request to execute
 */
public Request<Void> addPermissions(String roleId, List<Permission> permissions) {
    Asserts.assertNotNull(roleId, "role id");
    Asserts.assertNotEmpty(permissions, "permissions");
    Map<String, List<Permission>> body = new HashMap<>();
    body.put("permissions", permissions);
    final String url = baseUrl.newBuilder().addEncodedPathSegments("api/v2/roles").addEncodedPathSegments(roleId).addEncodedPathSegments("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 22 with VoidRequest

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

the class RolesEntity method delete.

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

Example 23 with VoidRequest

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

the class RulesConfigsEntity method delete.

/**
 * Delete an existing Rules Config. A token with scope delete:rules_configs is needed.
 * See https://auth0.com/docs/api/management/v2#!/Rules_Configs/delete_rules_configs_by_key
 *
 * @param rulesConfigKey the rules config key
 * @return a Request to execute.
 */
public Request<Void> delete(String rulesConfigKey) {
    Asserts.assertNotNull(rulesConfigKey, "rules config key");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/rules-configs").addPathSegment(rulesConfigKey).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 24 with VoidRequest

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

the class RulesEntity method delete.

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

Example 25 with VoidRequest

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

the class ActionsEntity method delete.

/**
 * Delete an action and all of its associated versions. A token with {@code delete:action} scope is required.
 *
 * @param actionId the ID of the action to delete.
 * @param force whether to force the action deletion even if it is bound to triggers.
 * @return a request to execute.
 *
 * <a href="https://auth0.com/docs/api/management/v2#!/Actions/get_triggers">https://auth0.com/docs/api/management/v2#!/Actions/get_triggers</a>
 */
public Request<Void> delete(String actionId, boolean force) {
    Asserts.assertNotNull(actionId, "action ID");
    String url = baseUrl.newBuilder().addPathSegments(ACTIONS_BASE_PATH).addPathSegment(ACTIONS_PATH).addPathSegment(actionId).addQueryParameter("force", String.valueOf(force)).build().toString();
    VoidRequest voidRequest = new VoidRequest(client, url, "DELETE");
    voidRequest.addHeader(AUTHORIZATION_HEADER, "Bearer " + apiToken);
    return voidRequest;
}
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