use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method getCorsInformation.
/**
* Retrieve CORS configuration information.
*
* Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the
* server interact to determine whether or not to allow the request.
*
* @param getCorsInformationOptions the {@link GetCorsInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CorsInformation}
*/
public ServiceCall<CorsInformation> getCorsInformation(GetCorsInformationOptions getCorsInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCorsInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<CorsInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CorsInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method headAttachment.
/**
* Retrieve the HTTP headers for an attachment.
*
* Returns the HTTP headers that contain a minimal amount of information about the specified attachment. This method
* supports the same query arguments as the `GET /{db}/{doc_id}/{attachment_name}` method, but only the header
* information (including attachment size, encoding, and the MD5 hash as an ETag), is returned.
*
* @param headAttachmentOptions the {@link HeadAttachmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> headAttachment(HeadAttachmentOptions headAttachmentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(headAttachmentOptions, "headAttachmentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", headAttachmentOptions.db());
pathParamsMap.put("doc_id", headAttachmentOptions.docId());
pathParamsMap.put("attachment_name", headAttachmentOptions.attachmentName());
RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/{doc_id}/{attachment_name}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headAttachment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
if (headAttachmentOptions.ifMatch() != null) {
builder.header("If-Match", headAttachmentOptions.ifMatch());
}
if (headAttachmentOptions.ifNoneMatch() != null) {
builder.header("If-None-Match", headAttachmentOptions.ifNoneMatch());
}
if (headAttachmentOptions.rev() != null) {
builder.query("rev", String.valueOf(headAttachmentOptions.rev()));
}
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method putReplicationDocument.
/**
* Create or modify a replication using a replication document.
*
* Creates or modifies a document in the `_replicator` database to start a new replication or to edit an existing
* replication.
*
* @param putReplicationDocumentOptions the {@link PutReplicationDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link DocumentResult}
*/
public ServiceCall<DocumentResult> putReplicationDocument(PutReplicationDocumentOptions putReplicationDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putReplicationDocumentOptions, "putReplicationDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", putReplicationDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putReplicationDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (putReplicationDocumentOptions.ifMatch() != null) {
builder.header("If-Match", putReplicationDocumentOptions.ifMatch());
}
if (putReplicationDocumentOptions.batch() != null) {
builder.query("batch", String.valueOf(putReplicationDocumentOptions.batch()));
}
if (putReplicationDocumentOptions.newEdits() != null) {
builder.query("new_edits", String.valueOf(putReplicationDocumentOptions.newEdits()));
}
if (putReplicationDocumentOptions.rev() != null) {
builder.query("rev", String.valueOf(putReplicationDocumentOptions.rev()));
}
builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(putReplicationDocumentOptions.replicationDocument()), "application/json");
ResponseConverter<DocumentResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DocumentResult>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method headUpInformation.
/**
* Retrieve HTTP headers about whether the server is up.
*
* Retrieves the HTTP headers about whether the server is up.
*
* @param headUpInformationOptions the {@link HeadUpInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> headUpInformation(HeadUpInformationOptions headUpInformationOptions) {
RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_up"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headUpInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method getActivityTrackerEvents.
/**
* Retrieve Activity Tracker events information.
*
* Check event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance.
*
* @param getActivityTrackerEventsOptions the {@link GetActivityTrackerEventsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link ActivityTrackerEvents}
*/
public ServiceCall<ActivityTrackerEvents> getActivityTrackerEvents(GetActivityTrackerEventsOptions getActivityTrackerEventsOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getActivityTrackerEvents");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<ActivityTrackerEvents> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<ActivityTrackerEvents>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations