Search in sources :

Example 66 with Client

use of com.auth0.json.mgmt.client.Client 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 67 with Client

use of com.auth0.json.mgmt.client.Client 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 68 with Client

use of com.auth0.json.mgmt.client.Client in project auth0-java by auth0.

the class AuthAPI method buildNetworkingClient.

/**
 * Given a set of options, it creates a new instance of the {@link OkHttpClient}
 * configuring them according to their availability.
 *
 * @param options the options to set to the client.
 * @return a new networking client instance configured as requested.
 */
private OkHttpClient buildNetworkingClient(HttpOptions options) {
    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    final ProxyOptions proxyOptions = options.getProxyOptions();
    if (proxyOptions != null) {
        // Set proxy
        clientBuilder.proxy(proxyOptions.getProxy());
        // Set authentication, if present
        final String proxyAuth = proxyOptions.getBasicAuthentication();
        if (proxyAuth != null) {
            clientBuilder.proxyAuthenticator(new Authenticator() {

                private static final String PROXY_AUTHORIZATION_HEADER = "Proxy-Authorization";

                @Override
                public okhttp3.Request authenticate(Route route, Response response) throws IOException {
                    if (response.request().header(PROXY_AUTHORIZATION_HEADER) != null) {
                        return null;
                    }
                    return response.request().newBuilder().header(PROXY_AUTHORIZATION_HEADER, proxyAuth).build();
                }
            });
        }
    }
    configureLogging(options.getLoggingOptions());
    Dispatcher dispatcher = new Dispatcher();
    dispatcher.setMaxRequests(options.getMaxRequests());
    dispatcher.setMaxRequestsPerHost(options.getMaxRequestsPerHost());
    return clientBuilder.addInterceptor(logging).addInterceptor(telemetry).connectTimeout(options.getConnectTimeout(), TimeUnit.SECONDS).readTimeout(options.getReadTimeout(), TimeUnit.SECONDS).dispatcher(dispatcher).build();
}
Also used : PasswordlessSmsResponse(com.auth0.json.auth.PasswordlessSmsResponse) PasswordlessEmailResponse(com.auth0.json.auth.PasswordlessEmailResponse) ProxyOptions(com.auth0.client.ProxyOptions) Request(com.auth0.net.Request) IOException(java.io.IOException)

Example 69 with Client

use of com.auth0.json.mgmt.client.Client 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)

Example 70 with Client

use of com.auth0.json.mgmt.client.Client 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)

Aggregations

IOException (java.io.IOException)36 APIException (com.auth0.exception.APIException)27 Auth0Exception (com.auth0.exception.Auth0Exception)27 RateLimitException (com.auth0.exception.RateLimitException)27 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)26 List (java.util.List)25 Test (org.junit.Test)25 VoidRequest (com.auth0.net.VoidRequest)24 TokenHolder (com.auth0.json.auth.TokenHolder)22 JsonParseException (com.fasterxml.jackson.core.JsonParseException)19 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)19 ExpectedException (org.junit.rules.ExpectedException)19 RecordedMultipartRequest (com.auth0.net.multipart.RecordedMultipartRequest)16 Test (org.junit.jupiter.api.Test)14 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)14 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)13 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)9 AuthAPI (com.auth0.client.auth.AuthAPI)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 OkHttpClient (okhttp3.OkHttpClient)7