Search in sources :

Example 11 with RequestBuilder

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) InputStream(java.io.InputStream) JsonObject(com.google.gson.JsonObject)

Example 12 with RequestBuilder

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Ok(com.ibm.cloud.cloudant.v1.model.Ok)

Example 13 with RequestBuilder

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);
}
Also used : CapacityThroughputInformation(com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) JsonObject(com.google.gson.JsonObject)

Example 14 with RequestBuilder

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) InputStream(java.io.InputStream) JsonObject(com.google.gson.JsonObject)

Example 15 with RequestBuilder

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Security(com.ibm.cloud.cloudant.v1.model.Security)

Aggregations

RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)422 HashMap (java.util.HashMap)324 JsonObject (com.google.gson.JsonObject)111 MultipartBody (okhttp3.MultipartBody)30 InputStream (java.io.InputStream)27 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)12 Ok (com.ibm.cloud.cloudant.v1.model.Ok)8 MetricResponse (com.ibm.watson.discovery.v1.model.MetricResponse)4 DeleteModelResults (com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults)4 Collection (com.ibm.watson.visual_recognition.v4.model.Collection)4 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)3 ReplicationDocument (com.ibm.cloud.cloudant.v1.model.ReplicationDocument)3 TagsSubscriptionList (com.ibm.cloud.eventnotifications.event_notifications.v1.model.TagsSubscriptionList)3 Counterexample (com.ibm.watson.assistant.v1.model.Counterexample)3 DialogNode (com.ibm.watson.assistant.v1.model.DialogNode)3 Entity (com.ibm.watson.assistant.v1.model.Entity)3 Intent (com.ibm.watson.assistant.v1.model.Intent)3 Value (com.ibm.watson.assistant.v1.model.Value)3 DeleteCredentials (com.ibm.watson.discovery.v1.model.DeleteCredentials)3 TokenDictStatusResponse (com.ibm.watson.discovery.v1.model.TokenDictStatusResponse)3