Search in sources :

Example 6 with URIBase

use of com.cloudant.client.internal.URIBase in project java-cloudant by cloudant.

the class SearchTests method escapingTest.

private void escapingTest(String expectedResult, String query) {
    URI uri = new URIBase(account.getBaseUri()).path("animaldb").path("_design").path("views101").path("_search").path("animals").query("include_docs", true).query("q", query).build();
    String uriBaseString = account.getBaseUri().toASCIIString();
    String expectedUriString = uriBaseString + "/animaldb/_design/views101/_search/animals?include_docs=true&q=" + expectedResult;
    String uriString = uri.toASCIIString();
    assertEquals(expectedUriString, uriString);
}
Also used : URI(java.net.URI) URIBase(com.cloudant.client.internal.URIBase)

Example 7 with URIBase

use of com.cloudant.client.internal.URIBase in project java-cloudant by cloudant.

the class CouchDbClient method uuids.

/**
 * Request a database sends a list of UUIDs.
 *
 * @param count The count of UUIDs.
 */
public List<String> uuids(long count) {
    final URI uri = new URIBase(clientUri).path("_uuids").query("count", count).build();
    final JsonObject json = get(uri, JsonObject.class);
    return getGson().fromJson(json.get("uuids").toString(), DeserializationTypes.STRINGS);
}
Also used : JsonObject(com.google.gson.JsonObject) URI(java.net.URI) URIBase(com.cloudant.client.internal.URIBase)

Example 8 with URIBase

use of com.cloudant.client.internal.URIBase in project java-cloudant by cloudant.

the class CloudantClient method generateApiKey.

/**
 * Use the authorization feature to generate new API keys to access your data. An API key is
 * similar to a username/password pair for granting others access to your data.
 * <P>Example usage:
 * </P>
 * <pre>
 * {@code
 * ApiKey key = client.generateApiKey();
 * System.out.println(key);
 * }
 * </pre>
 * <P> Example output:
 * </P>
 * <pre>
 * {@code key: isdaingialkyciffestontsk password: XQiDHmwnkUu4tknHIjjs2P64}
 * </pre>
 *
 * @return the generated key and password
 * @see Database#setPermissions(String, EnumSet)
 */
public ApiKey generateApiKey() {
    URI uri = new URIBase(getBaseUri()).path("_api").path("v2").path("api_keys").build();
    InputStream response = couchDbClient.post(uri, null);
    return getResponse(response, ApiKey.class, getGson());
}
Also used : InputStream(java.io.InputStream) URI(java.net.URI) URIBase(com.cloudant.client.internal.URIBase)

Example 9 with URIBase

use of com.cloudant.client.internal.URIBase in project java-cloudant by cloudant.

the class CloudantClient method getActiveTasks.

/**
 * Get the list of active tasks from the server.
 *
 * @return List of tasks
 * @see <a href="https://console.bluemix.net/docs/services/Cloudant/api/active_tasks.html">
 *     Active tasks</a>
 */
public List<Task> getActiveTasks() {
    InputStream response = null;
    URI uri = new URIBase(getBaseUri()).path("_active_tasks").build();
    try {
        response = couchDbClient.get(uri);
        return getResponseList(response, couchDbClient.getGson(), DeserializationTypes.TASKS);
    } finally {
        close(response);
    }
}
Also used : InputStream(java.io.InputStream) URI(java.net.URI) URIBase(com.cloudant.client.internal.URIBase)

Example 10 with URIBase

use of com.cloudant.client.internal.URIBase in project java-cloudant by cloudant.

the class CloudantClient method getMembership.

/**
 * Get the list of all nodes and the list of active nodes in the cluster.
 *
 * @return Membership object encapsulating lists of all nodes and the cluster nodes
 * @see <a
 * href="https://console.bluemix.net/docs/services/Cloudant/api/advanced.html#-get-_membership-">
 * _membership</a>
 */
public Membership getMembership() {
    URI uri = new URIBase(getBaseUri()).path("_membership").build();
    Membership membership = couchDbClient.get(uri, Membership.class);
    return membership;
}
Also used : Membership(com.cloudant.client.api.model.Membership) URI(java.net.URI) URIBase(com.cloudant.client.internal.URIBase)

Aggregations

URIBase (com.cloudant.client.internal.URIBase)10 URI (java.net.URI)7 InputStream (java.io.InputStream)3 CloudantClient (com.cloudant.client.api.CloudantClient)1 Database (com.cloudant.client.api.Database)1 Membership (com.cloudant.client.api.model.Membership)1 Response (com.cloudant.client.api.model.Response)1 CouchDbUtil.getResponse (com.cloudant.client.org.lightcouch.internal.CouchDbUtil.getResponse)1 HttpConnection (com.cloudant.http.HttpConnection)1 HttpConnectionInterceptorContext (com.cloudant.http.HttpConnectionInterceptorContext)1 HttpConnectionResponseInterceptor (com.cloudant.http.HttpConnectionResponseInterceptor)1 JsonObject (com.google.gson.JsonObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.jupiter.api.Test)1