Search in sources :

Example 1 with CoreHttpPath

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

the class CoreAnalyticsLinkManager method sendLink.

private CompletableFuture<Void> sendLink(HttpMethod method, Map<String, String> link, CoreCommonOptions options, String tracingId) {
    // ensure mutability, and don't modify caller's map
    link = new HashMap<>(link);
    CoreHttpPath path = getLinkPathAndAdjustMap(link);
    UrlQueryStringBuilder form = newForm();
    link.forEach(form::set);
    return httpClient.newRequest(method, path, options).trace(tracingId).form(form).exec(core).exceptionally(t -> {
        throw translateCompilationFailureToInvalidArgument(t);
    }).thenApply(result -> null);
}
Also used : Builder.newForm(com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newForm) AnalyticsErrorContext(com.couchbase.client.core.error.context.AnalyticsErrorContext) HttpMethod(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod) UrlQueryStringBuilder(com.couchbase.client.core.util.UrlQueryStringBuilder) CoreHttpClient(com.couchbase.client.core.endpoint.http.CoreHttpClient) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) RequestTarget(com.couchbase.client.core.msg.RequestTarget) CompilationFailureException(com.couchbase.client.core.error.CompilationFailureException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) InvalidArgumentException(com.couchbase.client.core.error.InvalidArgumentException) CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) CoreCommonOptions(com.couchbase.client.core.endpoint.http.CoreCommonOptions) CbCollections.mapOf(com.couchbase.client.core.util.CbCollections.mapOf) TracingIdentifiers(com.couchbase.client.core.cnc.TracingIdentifiers) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse) Map(java.util.Map) CoreHttpPath.path(com.couchbase.client.core.endpoint.http.CoreHttpPath.path) Builder.newQueryString(com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newQueryString) Objects.requireNonNull(java.util.Objects.requireNonNull) Stability(com.couchbase.client.core.annotation.Stability) CbThrowables(com.couchbase.client.core.util.CbThrowables) Core(com.couchbase.client.core.Core) CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) UrlQueryStringBuilder(com.couchbase.client.core.util.UrlQueryStringBuilder)

Example 2 with CoreHttpPath

use of com.couchbase.client.core.endpoint.http.CoreHttpPath 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)

Aggregations

CoreHttpPath (com.couchbase.client.core.endpoint.http.CoreHttpPath)2 CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)2 UrlQueryStringBuilder (com.couchbase.client.core.util.UrlQueryStringBuilder)2 Core (com.couchbase.client.core.Core)1 Stability (com.couchbase.client.core.annotation.Stability)1 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)1 HttpMethod (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod)1 CoreCommonOptions (com.couchbase.client.core.endpoint.http.CoreCommonOptions)1 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)1 CoreHttpPath.path (com.couchbase.client.core.endpoint.http.CoreHttpPath.path)1 Builder.newForm (com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newForm)1 Builder.newQueryString (com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newQueryString)1 CompilationFailureException (com.couchbase.client.core.error.CompilationFailureException)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)1 AnalyticsErrorContext (com.couchbase.client.core.error.context.AnalyticsErrorContext)1 RequestTarget (com.couchbase.client.core.msg.RequestTarget)1 CbCollections.mapOf (com.couchbase.client.core.util.CbCollections.mapOf)1 CbThrowables (com.couchbase.client.core.util.CbThrowables)1 HashMap (java.util.HashMap)1