public class CloudantClient
extends java.lang.Object
This class is the main object to use to gain access to the Cloudant APIs.
Create a new Cloudant client instance:
CloudantClient client = new CloudantClient("mycloudantaccount","myusername","mypassword");
Start using the API by the client:
Server APIs is accessed by the client directly eg.: client.getAllDbs()
DB is accessed by getting to the Database from the client
Database db = client.database("customers",false);
Documents CRUD
APIs is accessed from the Database eg.: db.find(Foo.class, "doc-id")
Cloudant Query
db.findByIndex(" "selector": { "Person_name": "Alec Guinness" }", Movie.class)
db.deleteIndex("Person_name", "Person_name")
Cloudant Search db.search("views101/animals)
View APIs db.view()
Change Notifications db.changes()
Design documents db.design()
Replication account.replication()
and account.replicator()
At the end of a client usage; it's useful to call: shutdown()
to ensure proper release of resources.
Constructor and Description |
---|
CloudantClient(java.lang.String account,
java.lang.String authCookie)
Constructs a new instance of this class and connects to the cloudant account with the specified credentials
|
CloudantClient(java.lang.String account,
java.lang.String authCookie,
ConnectOptions connectOptions)
Constructs a new instance of this class and connects to the cloudant account with the specified credentials
|
CloudantClient(java.lang.String account,
java.lang.String loginUsername,
java.lang.String password)
Constructs a new instance of this class and connects to the cloudant account with the specified credentials
|
CloudantClient(java.lang.String account,
java.lang.String loginUsername,
java.lang.String password,
ConnectOptions connectOptions)
Constructs a new instance of this class and connects to the cloudant account with the specified credentials
|
Modifier and Type | Method and Description |
---|---|
void |
createDB(java.lang.String dbName)
Request to create a new database; if one doesn't exist.
|
Database |
database(java.lang.String name,
boolean create)
Get a database
|
void |
deleteDB(java.lang.String dbName,
java.lang.String confirm)
Request to delete a database.
|
org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpRequestBase request)
Executes a HTTP request.
|
ApiKey |
generateApiKey()
Generate an API key
|
java.util.List<Task> |
getActiveTasks()
Get all active tasks
|
java.util.List<java.lang.String> |
getAllDbs() |
java.net.URI |
getBaseUri() |
java.lang.String |
getCookie()
Get the cookieStore
|
Membership |
getMembership()
Get the list of nodes in a cluster
|
Replication |
replication()
Provides access to Cloudant replication APIs.
|
Replicator |
replicator()
Provides access to Cloudant replication APIs.
|
java.lang.String |
serverVersion() |
void |
shutdown()
Shuts down the connection manager used by this client instance.
|
java.util.List<java.lang.String> |
uuids(long count)
Request cloudant to send a list of UUIDs.
|
public CloudantClient(java.lang.String account, java.lang.String loginUsername, java.lang.String password)
account
- The cloudant account to connect tologinUsername
- The Username credentialpassword
- The Password credentialpublic CloudantClient(java.lang.String account, java.lang.String loginUsername, java.lang.String password, ConnectOptions connectOptions)
account
- The cloudant account to connect tologinUsername
- The Username credentialpassword
- The Password credentialconnectOptions
- optional properties to connect e.g connectionTime,socketTimeout,etcpublic CloudantClient(java.lang.String account, java.lang.String authCookie)
account
- The cloudant account to connect toauthCookie
- The cookie obtained from last loginpublic CloudantClient(java.lang.String account, java.lang.String authCookie, ConnectOptions connectOptions)
account
- The cloudant account to connect toauthCookie
- The cookie obtained from last loginconnectOptions
- optional properties to connect e.g connectionTime,socketTimeout,etcpublic ApiKey generateApiKey()
public java.util.List<Task> getActiveTasks()
public java.lang.String getCookie()
public Membership getMembership()
public Database database(java.lang.String name, boolean create)
name
- name of database to accesscreate
- flag indicating whether to create the database if doesnt exist.public void deleteDB(java.lang.String dbName, java.lang.String confirm)
dbName
- The database nameconfirm
- A confirmation string with the value: delete databasepublic void createDB(java.lang.String dbName)
dbName
- The Database namepublic java.net.URI getBaseUri()
public java.util.List<java.lang.String> getAllDbs()
public java.lang.String serverVersion()
public Replication replication()
Replication
public Replicator replicator()
Replication
public org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpRequestBase request)
Note: The response must be closed after use to release the connection.
request
- The HTTP request to execute.HttpResponse
public void shutdown()
public java.util.List<java.lang.String> uuids(long count)
count
- The count of UUIDs.