use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method deleteReplicationDocument.
/**
* Cancel a replication.
*
* Cancels a replication by deleting the document that describes it from the `_replicator` database.
*
* @param deleteReplicationDocumentOptions the {@link DeleteReplicationDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> deleteReplicationDocument(DeleteReplicationDocumentOptions deleteReplicationDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteReplicationDocumentOptions, "deleteReplicationDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", deleteReplicationDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteReplicationDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteReplicationDocumentOptions.ifMatch() != null) {
builder.header("If-Match", deleteReplicationDocumentOptions.ifMatch());
}
if (deleteReplicationDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(deleteReplicationDocumentOptions.batch()));
}
if (deleteReplicationDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(deleteReplicationDocumentOptions.rev()));
}
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method putAttachment.
/**
* Create or modify an attachment.
*
* Uploads the supplied content as an attachment to the specified document. The attachment name that you provide must
* be a URL encoded string. You must supply the Content-Type header, and for an existing document, you must also
* supply either the `rev` query argument or the `If-Match` HTTP header. If you omit the revision, a new, otherwise
* empty, document is created with the provided attachment, or a conflict occurs. If the uploaded attachment uses an
* existing attachment name in the remote database, it updates the corresponding stored content of the database. Since
* you must supply the revision information to add an attachment to the document, this serves as validation to update
* the existing attachment.
*
* @param putAttachmentOptions the {@link PutAttachmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> putAttachment(PutAttachmentOptions putAttachmentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putAttachmentOptions, "putAttachmentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", putAttachmentOptions.db());
pathParamsMap.put("doc_id", putAttachmentOptions.docId());
pathParamsMap.put("attachment_name", putAttachmentOptions.attachmentName());
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putAttachment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.header("Content-Type", putAttachmentOptions.contentType());
if (putAttachmentOptions.ifMatch() != null) {
builder.header("If-Match", putAttachmentOptions.ifMatch());
}
if (putAttachmentOptions.rev() != null) {
builder.query("rev", String.valueOf(putAttachmentOptions.rev()));
}
builder.bodyContent(putAttachmentOptions.contentType(), null, null, putAttachmentOptions.attachment());
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method deleteDatabase.
/**
* Delete a database.
*
* Deletes the specified database and all documents and attachments contained within it. To avoid deleting a database,
* the server responds with a 400 HTTP status code when the request URL includes a `?rev=` parameter. This response
* suggests that a user wanted to delete a document but forgot to add the document ID to the URL.
*
* @param deleteDatabaseOptions the {@link DeleteDatabaseOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> deleteDatabase(DeleteDatabaseOptions deleteDatabaseOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDatabaseOptions, "deleteDatabaseOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", deleteDatabaseOptions.db());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteDatabase");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method getDesignDocumentInformation.
/**
* Retrieve information about a design document.
*
* Retrieves information about the specified design document, including the index, index size, and current status of
* the design document and associated index information.
*
* @param getDesignDocumentInformationOptions the {@link GetDesignDocumentInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DesignDocumentInformation}
*/
public ServiceCall<DesignDocumentInformation> getDesignDocumentInformation(GetDesignDocumentInformationOptions getDesignDocumentInformationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getDesignDocumentInformationOptions, "getDesignDocumentInformationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getDesignDocumentInformationOptions.db());
pathParamsMap.put("ddoc", getDesignDocumentInformationOptions.ddoc());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_design/{ddoc}/_info", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getDesignDocumentInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<DesignDocumentInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DesignDocumentInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.Cloudant in project cloudant-java-sdk by IBM.
the class Cloudant method deleteLocalDocument.
/**
* Delete a local document.
*
* Deletes the specified local document. The semantics are identical to deleting a standard document in the specified
* database, except that the document is not replicated.
*
* @param deleteLocalDocumentOptions the {@link DeleteLocalDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> deleteLocalDocument(DeleteLocalDocumentOptions deleteLocalDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteLocalDocumentOptions, "deleteLocalDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", deleteLocalDocumentOptions.db());
pathParamsMap.put("doc_id", deleteLocalDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_local/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "deleteLocalDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteLocalDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(deleteLocalDocumentOptions.batch()));
}
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations