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);
}
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);
}
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());
}
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);
}
}
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;
}
Aggregations