use of com.cloudant.client.org.lightcouch.Response in project java-cloudant by cloudant.
the class Database method removeAttachment.
/**
* Removes the attachment from a document the specified {@code _id} and {@code _rev} and {@code attachmentName}
* values.
* <P>Example usage:</P>
* <pre>
* {@code
* Response response = db.removeAttachment("exampleId", "1-12345exampleRev", "example.jpg");
* }
* </pre>
*
* @param id the document _id field
* @param rev the document _rev field
* @param attachmentName the attachment name
* @return {@link com.cloudant.client.api.model.Response}
* @throws NoDocumentException If the document is not found in the database.
* @throws DocumentConflictException if the attachment cannot be removed because of a conflict
* @see <a
* href="https://console.bluemix.net/docs/services/Cloudant/api/attachments.html#delete"
* target="_blank">Documents - delete</a>
*/
public com.cloudant.client.api.model.Response removeAttachment(String id, String rev, String attachmentName) {
Response couchDbResponse = db.removeAttachment(id, rev, attachmentName);
com.cloudant.client.api.model.Response response = new com.cloudant.client.api.model.Response(couchDbResponse);
return response;
}
use of com.cloudant.client.org.lightcouch.Response in project java-cloudant by cloudant.
the class Database method save.
/**
* Saves a document in the database.
* <p>If the serialized object's JSON does not contain an {@code _id} field, then a UUID will
* be generated for the document ID.
* </p>
* <P>
* Example of inserting a JsonObject into the database:
* </P>
* <pre>
* {@code
* JsonObject json = new JsonObject();
* json.addProperty("_id", "test-doc-id-2");
* json.add("json-array", new JsonArray());
* Response response = db.save(json);
* }
* </pre>
* <P>
* Example of inserting a POJO into the database:
* </P>
* <pre>
* {@code
* Foo foo = new Foo();
* Response response = db.save(foo);
* }
* </pre>
* <P>
* Example of inserting a Map into the database:
* </P>
* <pre>
* {@code
* Map<String, Object> map = new HashMap<>();
* map.put("_id", "test-doc-id-1");
* map.put("title", "test-doc");
* Response response = db.save(map);
* }
* </pre>
*
* <P>
* Note that the Java object is not modified by the save operation and so will not include the
* revision generated by the database server. You can obtain the server revision for this write
* from the response, for example:
* </P>
* <pre>
* {@code
* Foo foo = new Foo();
* Response response = db.save(foo);
* foo.setRevision(response.getRevision());
* }
* </pre>
*
* @param object the object to save
* @return {@link com.cloudant.client.api.model.Response}
* @throws DocumentConflictException If a conflict is detected during the save.
*/
public com.cloudant.client.api.model.Response save(Object object) {
Response couchDbResponse = db.save(object);
com.cloudant.client.api.model.Response response = new com.cloudant.client.api.model.Response(couchDbResponse);
return response;
}
use of com.cloudant.client.org.lightcouch.Response in project java-cloudant by cloudant.
the class Replicator method remove.
/**
* Removes a document from the replicator database.
*
* @return {@link Response}
*/
public com.cloudant.client.api.model.Response remove() {
Response couchDbResponse = replicator.remove();
com.cloudant.client.api.model.Response response = new com.cloudant.client.api.model.Response(couchDbResponse);
return response;
}
use of com.cloudant.client.org.lightcouch.Response in project java-cloudant by cloudant.
the class Database method post.
/**
* Creates a document in the database using a HTTP {@code POST} request.
* <p>If the serialized object's JSON does not contain an {@code _id} field, then the server
* will generate a document ID.</p>
* <P>
* Example of creating a document in the database for a POJO:
* </P>
* <pre>
* {@code
* Foo foo = new Foo();
* Response response = db.post(foo);
* }
* </pre>
* <P>
* Note that the Java object is not modified by the create operation and so will not include the
* revision generated by the database server. You can obtain the server revision for this write
* from the response, for example:
* </P>
* <pre>
* {@code
* Foo foo = new Foo();
* Response response = db.post(foo);
* foo.setRevision(response.getRevision());
* }
* </pre>
*
* @param object The object to save
* @return {@link com.cloudant.client.api.model.Response}
* @see <a
* href="https://console.bluemix.net/docs/services/Cloudant/api/document.html#create"
* target="_blank">Documents - create</a>
*/
public com.cloudant.client.api.model.Response post(Object object) {
Response couchDbResponse = db.post(object);
com.cloudant.client.api.model.Response response = new com.cloudant.client.api.model.Response(couchDbResponse);
return response;
}
Aggregations