Search in sources :

Example 6 with CoreHttpResponse

use of com.couchbase.client.core.endpoint.http.CoreHttpResponse in project couchbase-jvm-clients by couchbase.

the class CoreAnalyticsLinkManager method getLinks.

/**
 * @param dataverseName (nullable)
 * @param linkType (nullable)
 * @param linkName (nullable) if present, dataverseName must also be present
 */
public CompletableFuture<byte[]> getLinks(String dataverseName, String linkType, String linkName, CoreCommonOptions options) {
    if (linkName != null && dataverseName == null) {
        throw InvalidArgumentException.fromMessage("When link name is specified, must also specify dataverse");
    }
    UrlQueryStringBuilder queryString = newQueryString().setIfNotNull("type", linkType);
    CoreHttpPath path = path("/analytics/link");
    if (dataverseName != null && dataverseName.contains("/")) {
        path = path.plus("/{dataverse}", mapOf("dataverse", dataverseName));
        if (linkName != null) {
            path = path.plus("/{linkName}", mapOf("linkName", linkName));
        }
    } else {
        queryString.setIfNotNull("dataverse", dataverseName).setIfNotNull("name", linkName);
    }
    return httpClient.get(path, options).queryString(queryString).trace(TracingIdentifiers.SPAN_REQUEST_MA_GET_ALL_LINKS).exec(core).thenApply(CoreHttpResponse::content);
}
Also used : CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) UrlQueryStringBuilder(com.couchbase.client.core.util.UrlQueryStringBuilder) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse)

Example 7 with CoreHttpResponse

use of com.couchbase.client.core.endpoint.http.CoreHttpResponse in project couchbase-jvm-clients by couchbase.

the class RateLimitingIntegrationTest method enforceRateLimits.

/**
 * Makes sure that the rate limits are enforced on the server.
 */
static void enforceRateLimits() throws Exception {
    CoreHttpClient client = adminCluster.core().httpClient(RequestTarget.manager());
    CoreHttpResponse result = client.post(path("/internalSettings"), CoreCommonOptions.DEFAULT).form(UrlQueryStringBuilder.create().add("enforceLimits", true)).exec(adminCluster.core()).get();
    assertEquals(ResponseStatus.SUCCESS, result.status());
}
Also used : CoreHttpClient(com.couchbase.client.core.endpoint.http.CoreHttpClient) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse)

Aggregations

CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)7 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)4 UrlQueryStringBuilder (com.couchbase.client.core.util.UrlQueryStringBuilder)3 HashMap (java.util.HashMap)3 JsonObject (com.couchbase.client.java.json.JsonObject)2 JsonNode (com.couchbase.client.core.deps.com.fasterxml.jackson.databind.JsonNode)1 CoreHttpPath (com.couchbase.client.core.endpoint.http.CoreHttpPath)1 CoreHttpRequest (com.couchbase.client.core.endpoint.http.CoreHttpRequest)1 AuthenticationFailureException (com.couchbase.client.core.error.AuthenticationFailureException)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)1 IgnoreWhen (com.couchbase.client.test.IgnoreWhen)1 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 InvalidDefinitionException (com.fasterxml.jackson.databind.exc.InvalidDefinitionException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ExecutionException (java.util.concurrent.ExecutionException)1