Search in sources :

Example 31 with RequestBuilder

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

Example 32 with RequestBuilder

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

Example 33 with RequestBuilder

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

Example 34 with RequestBuilder

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);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder)

Example 35 with RequestBuilder

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

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