use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method postBulkGetAsStream.
/**
* Bulk query revision information for multiple documents as stream.
*
* Fetch specific revisions or revision histories for multiple documents in bulk as replicators do.
*
* @param postBulkGetOptions the {@link PostBulkGetOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link InputStream}
*/
public ServiceCall<InputStream> postBulkGetAsStream(PostBulkGetOptions postBulkGetOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postBulkGetOptions, "postBulkGetOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postBulkGetOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_bulk_get", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postBulkGetAsStream");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (postBulkGetOptions.attachments() != null) {
builder.query("attachments", String.valueOf(postBulkGetOptions.attachments()));
}
if (postBulkGetOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(postBulkGetOptions.attEncodingInfo()));
}
if (postBulkGetOptions.latest() != null) {
builder.query("latest", String.valueOf(postBulkGetOptions.latest()));
}
if (postBulkGetOptions.revs() != null) {
builder.query("revs", String.valueOf(postBulkGetOptions.revs()));
}
final JsonObject contentJson = new JsonObject();
contentJson.add("docs", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postBulkGetOptions.docs()));
builder.bodyJson(contentJson);
ResponseConverter<InputStream> responseConverter = ResponseConverterUtils.getInputStream();
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 postActivityTrackerEvents.
/**
* Modify Activity Tracker events configuration.
*
* Configure event types that are being sent to IBM Cloud Activity Tracker for the IBM Cloudant instance.
*
* @param postActivityTrackerEventsOptions the {@link PostActivityTrackerEventsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> postActivityTrackerEvents(PostActivityTrackerEventsOptions postActivityTrackerEventsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postActivityTrackerEventsOptions, "postActivityTrackerEventsOptions cannot be null");
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/activity_tracker/events"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postActivityTrackerEvents");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("types", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postActivityTrackerEventsOptions.types()));
builder.bodyJson(contentJson);
ResponseConverter<Ok> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Ok>() {
}.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 putCapacityThroughputConfiguration.
/**
* Update the target provisioned throughput capacity.
*
* Sets the target provisioned throughput capacity for an IBM Cloudant instance. When target capacity is changed, the
* current capacity asynchronously changes to meet the target capacity.
*
* @param putCapacityThroughputConfigurationOptions the {@link PutCapacityThroughputConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CapacityThroughputInformation}
*/
public ServiceCall<CapacityThroughputInformation> putCapacityThroughputConfiguration(PutCapacityThroughputConfigurationOptions putCapacityThroughputConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putCapacityThroughputConfigurationOptions, "putCapacityThroughputConfigurationOptions cannot be null");
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/throughput"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCapacityThroughputConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("blocks", putCapacityThroughputConfigurationOptions.blocks());
builder.bodyJson(contentJson);
ResponseConverter<CapacityThroughputInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CapacityThroughputInformation>() {
}.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 postBulkGetAsMixed.
/**
* Bulk query revision information for multiple documents as mixed.
*
* Fetch specific revisions or revision histories for multiple documents in bulk as replicators do.
*
* @param postBulkGetOptions the {@link PostBulkGetOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link InputStream}
*/
public ServiceCall<InputStream> postBulkGetAsMixed(PostBulkGetOptions postBulkGetOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postBulkGetOptions, "postBulkGetOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postBulkGetOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_bulk_get", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postBulkGetAsMixed");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "multipart/mixed");
if (postBulkGetOptions.attachments() != null) {
builder.query("attachments", String.valueOf(postBulkGetOptions.attachments()));
}
if (postBulkGetOptions.attEncodingInfo() != null) {
builder.query("att_encoding_info", String.valueOf(postBulkGetOptions.attEncodingInfo()));
}
if (postBulkGetOptions.latest() != null) {
builder.query("latest", String.valueOf(postBulkGetOptions.latest()));
}
if (postBulkGetOptions.revs() != null) {
builder.query("revs", String.valueOf(postBulkGetOptions.revs()));
}
final JsonObject contentJson = new JsonObject();
contentJson.add("docs", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postBulkGetOptions.docs()));
builder.bodyJson(contentJson);
ResponseConverter<InputStream> responseConverter = ResponseConverterUtils.getInputStream();
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 getSecurity.
/**
* Retrieve database permissions information.
*
* See who has permission to read, write, and manage the database. The credentials you use to log in to the dashboard
* automatically include `_admin` permissions to all databases you create. Everyone and everything else, including
* users you share databases with and API keys you create, must be given a permission level explicitly.
*
* @param getSecurityOptions the {@link GetSecurityOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Security}
*/
public ServiceCall<Security> getSecurity(GetSecurityOptions getSecurityOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSecurityOptions, "getSecurityOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getSecurityOptions.db());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_security", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSecurity");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Security> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Security>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations