use of com.ibm.watson.discovery.v1.model.Credentials in project java-sdk by watson-developer-cloud.
the class Discovery method listCredentials.
/**
* List credentials.
*
* <p>List all the source credentials that have been created for this service instance.
*
* <p>**Note:** All credentials are sent over an encrypted connection and encrypted at rest.
*
* @param listCredentialsOptions the {@link ListCredentialsOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link CredentialsList}
*/
public ServiceCall<CredentialsList> listCredentials(ListCredentialsOptions listCredentialsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listCredentialsOptions, "listCredentialsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", listCredentialsOptions.environmentId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/credentials", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCredentials");
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<CredentialsList> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CredentialsList>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v1.model.Credentials 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);
}
Aggregations