Search in sources :

Example 41 with Configuration

use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.

the class Discovery method createCredentials.

/**
 * Create credentials.
 *
 * <p>Creates a set of credentials to connect to a remote source. Created credentials are used in
 * a configuration to associate a collection with the remote source.
 *
 * <p>**Note:** All credentials are sent over an encrypted connection and encrypted at rest.
 *
 * @param createCredentialsOptions the {@link CreateCredentialsOptions} containing the options for
 *     the call
 * @return a {@link ServiceCall} with a result of type {@link Credentials}
 */
public ServiceCall<Credentials> createCredentials(CreateCredentialsOptions createCredentialsOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(createCredentialsOptions, "createCredentialsOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("environment_id", createCredentialsOptions.environmentId());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/credentials", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCredentials");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    final JsonObject contentJson = new JsonObject();
    if (createCredentialsOptions.sourceType() != null) {
        contentJson.addProperty("source_type", createCredentialsOptions.sourceType());
    }
    if (createCredentialsOptions.credentialDetails() != null) {
        contentJson.add("credential_details", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createCredentialsOptions.credentialDetails()));
    }
    if (createCredentialsOptions.status() != null) {
        contentJson.add("status", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createCredentialsOptions.status()));
    }
    builder.bodyJson(contentJson);
    ResponseConverter<Credentials> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Credentials>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) Credentials(com.ibm.watson.discovery.v1.model.Credentials) DeleteCredentials(com.ibm.watson.discovery.v1.model.DeleteCredentials)

Example 42 with Configuration

use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.

the class Discovery method createGateway.

/**
 * Create Gateway.
 *
 * <p>Create a gateway configuration to use with a remotely installed gateway.
 *
 * @param createGatewayOptions the {@link CreateGatewayOptions} containing the options for the
 *     call
 * @return a {@link ServiceCall} with a result of type {@link Gateway}
 */
public ServiceCall<Gateway> createGateway(CreateGatewayOptions createGatewayOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(createGatewayOptions, "createGatewayOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("environment_id", createGatewayOptions.environmentId());
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/gateways", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createGateway");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    final JsonObject contentJson = new JsonObject();
    if (createGatewayOptions.name() != null) {
        contentJson.addProperty("name", createGatewayOptions.name());
    }
    builder.bodyJson(contentJson);
    ResponseConverter<Gateway> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Gateway>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) Gateway(com.ibm.watson.discovery.v1.model.Gateway) JsonObject(com.google.gson.JsonObject)

Example 43 with Configuration

use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.

the class Discovery method deleteConfiguration.

/**
 * Delete a configuration.
 *
 * <p>The deletion is performed unconditionally. A configuration deletion request succeeds even if
 * the configuration is referenced by a collection or document ingestion. However, documents that
 * have already been submitted for processing continue to use the deleted configuration. Documents
 * are always processed with a snapshot of the configuration as it existed at the time the
 * document was submitted.
 *
 * @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options
 *     for the call
 * @return a {@link ServiceCall} with a result of type {@link DeleteConfigurationResponse}
 */
public ServiceCall<DeleteConfigurationResponse> deleteConfiguration(DeleteConfigurationOptions deleteConfigurationOptions) {
    com.ibm.cloud.sdk.core.util.Validator.notNull(deleteConfigurationOptions, "deleteConfigurationOptions cannot be null");
    Map<String, String> pathParamsMap = new HashMap<String, String>();
    pathParamsMap.put("environment_id", deleteConfigurationOptions.environmentId());
    pathParamsMap.put("configuration_id", deleteConfigurationOptions.configurationId());
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/configurations/{configuration_id}", pathParamsMap));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteConfiguration");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    ResponseConverter<DeleteConfigurationResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DeleteConfigurationResponse>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) HashMap(java.util.HashMap) DeleteConfigurationResponse(com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse)

Aggregations

Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)27 Test (org.junit.Test)21 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)18 Configuration (com.ibm.watson.discovery.v1.model.Configuration)10 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)10 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)8 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)8 JsonObject (com.google.gson.JsonObject)7 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)7 CreateConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions)7 HashMap (java.util.HashMap)7 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 GetConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions)4 Conversions (com.ibm.watson.discovery.v1.model.Conversions)3 CreateConfigurationOptions (com.ibm.watson.discovery.v1.model.CreateConfigurationOptions)3 Enrichment (com.ibm.watson.discovery.v1.model.Enrichment)3 NormalizationOperation (com.ibm.watson.discovery.v1.model.NormalizationOperation)3 Source (com.ibm.watson.discovery.v1.model.Source)3