Search in sources :

Example 6 with UrlQueryStringBuilder

use of com.couchbase.client.core.util.UrlQueryStringBuilder 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

UrlQueryStringBuilder (com.couchbase.client.core.util.UrlQueryStringBuilder)6 CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)4 HashMap (java.util.HashMap)4 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)3 CoreHttpPath (com.couchbase.client.core.endpoint.http.CoreHttpPath)2 JsonObject (com.couchbase.client.java.json.JsonObject)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 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