use of com.ibm.cloud.sdk.core.http.RequestBuilder in project cloudant-java-sdk by IBM.
the class Cloudant method getIndexesInformation.
/**
* Retrieve information about all indexes.
*
* When you make a GET request to `/db/_index`, you get a list of all indexes used by Cloudant Query in the database,
* including the primary index. In addition to the information available through this API, indexes are also stored in
* the `indexes` property of design documents.
*
* @param getIndexesInformationOptions the {@link GetIndexesInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link IndexesInformation}
*/
public ServiceCall<IndexesInformation> getIndexesInformation(GetIndexesInformationOptions getIndexesInformationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getIndexesInformationOptions, "getIndexesInformationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", getIndexesInformationOptions.db());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_index", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getIndexesInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<IndexesInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<IndexesInformation>() {
}.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 postAllDocsAsStream.
/**
* Query a list of all documents in a database as stream.
*
* Queries the primary index (all document IDs). The results that match the request body parameters are returned in a
* JSON object, including a list of matching documents with basic contents, such as the ID and revision. When no
* request body parameters are specified, results for all documents in the database are returned. Optionally, document
* content or additional metadata can be included in the response.
*
* @param postAllDocsOptions the {@link PostAllDocsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link InputStream}
*/
public ServiceCall<InputStream> postAllDocsAsStream(PostAllDocsOptions postAllDocsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(postAllDocsOptions, "postAllDocsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("db", postAllDocsOptions.db());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/{db}/_all_docs", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "postAllDocsAsStream");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (postAllDocsOptions.attEncodingInfo() != null) {
contentJson.addProperty("att_encoding_info", postAllDocsOptions.attEncodingInfo());
}
if (postAllDocsOptions.attachments() != null) {
contentJson.addProperty("attachments", postAllDocsOptions.attachments());
}
if (postAllDocsOptions.conflicts() != null) {
contentJson.addProperty("conflicts", postAllDocsOptions.conflicts());
}
if (postAllDocsOptions.descending() != null) {
contentJson.addProperty("descending", postAllDocsOptions.descending());
}
if (postAllDocsOptions.includeDocs() != null) {
contentJson.addProperty("include_docs", postAllDocsOptions.includeDocs());
}
if (postAllDocsOptions.inclusiveEnd() != null) {
contentJson.addProperty("inclusive_end", postAllDocsOptions.inclusiveEnd());
}
if (postAllDocsOptions.limit() != null) {
contentJson.addProperty("limit", postAllDocsOptions.limit());
}
if (postAllDocsOptions.skip() != null) {
contentJson.addProperty("skip", postAllDocsOptions.skip());
}
if (postAllDocsOptions.updateSeq() != null) {
contentJson.addProperty("update_seq", postAllDocsOptions.updateSeq());
}
if (postAllDocsOptions.endkey() != null) {
contentJson.addProperty("endkey", postAllDocsOptions.endkey());
}
if (postAllDocsOptions.key() != null) {
contentJson.addProperty("key", postAllDocsOptions.key());
}
if (postAllDocsOptions.keys() != null) {
contentJson.add("keys", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(postAllDocsOptions.keys()));
}
if (postAllDocsOptions.startkey() != null) {
contentJson.addProperty("startkey", postAllDocsOptions.startkey());
}
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 getSchedulerJobs.
/**
* Retrieve replication scheduler jobs.
*
* Retrieves information about replications that were created via `/_replicate` endpoint, as well as those created
* from replication documents. It doesn't include replications that completed or failed to start because replication
* documents were malformed. Each job description includes source and target information, replication ID, history of
* recent events, and other information.
*
* @param getSchedulerJobsOptions the {@link GetSchedulerJobsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SchedulerJobsResult}
*/
public ServiceCall<SchedulerJobsResult> getSchedulerJobs(GetSchedulerJobsOptions getSchedulerJobsOptions) {
if (getSchedulerJobsOptions == null) {
getSchedulerJobsOptions = new GetSchedulerJobsOptions.Builder().build();
}
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/jobs"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSchedulerJobs");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getSchedulerJobsOptions.limit() != null) {
builder.query("limit", String.valueOf(getSchedulerJobsOptions.limit()));
}
if (getSchedulerJobsOptions.skip() != null) {
builder.query("skip", String.valueOf(getSchedulerJobsOptions.skip()));
}
ResponseConverter<SchedulerJobsResult> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SchedulerJobsResult>() {
}.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 putCorsConfiguration.
/**
* Modify CORS configuration.
*
* Sets the CORS configuration. The configuration applies to all databases and all account level endpoints in your
* account.
*
* @param putCorsConfigurationOptions the {@link PutCorsConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Ok}
*/
public ServiceCall<Ok> putCorsConfiguration(PutCorsConfigurationOptions putCorsConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(putCorsConfigurationOptions, "putCorsConfigurationOptions cannot be null");
RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "putCorsConfiguration");
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("origins", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(putCorsConfigurationOptions.origins()));
if (putCorsConfigurationOptions.allowCredentials() != null) {
contentJson.addProperty("allow_credentials", putCorsConfigurationOptions.allowCredentials());
}
if (putCorsConfigurationOptions.enableCors() != null) {
contentJson.addProperty("enable_cors", putCorsConfigurationOptions.enableCors());
}
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 headSchedulerDocument.
/**
* Retrieve HTTP headers for a replication scheduler document.
*
* Retrieves the HTTP headers containing minimal amount of information about the specified replication scheduler
* document. Since the response body is empty, using the HEAD method is a lightweight way to check if the replication
* scheduler document exists or not.
*
* @param headSchedulerDocumentOptions the {@link HeadSchedulerDocumentOptions} containing the options for the call
* @return a {@link ServiceCall} with a void result
*/
public ServiceCall<Void> headSchedulerDocument(HeadSchedulerDocumentOptions headSchedulerDocumentOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(headSchedulerDocumentOptions, "headSchedulerDocumentOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("doc_id", headSchedulerDocumentOptions.docId());
RequestBuilder builder = RequestBuilder.head(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_scheduler/docs/_replicator/{doc_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "headSchedulerDocument");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
ResponseConverter<Void> responseConverter = ResponseConverterUtils.getVoid();
return createServiceCall(builder.build(), responseConverter);
}
Aggregations