use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method testGetAutocompletion.
/**
* This only works on a Cloud Pak for Data instance, so ignoring to just run manually.
*/
@Test
@Ignore
public void testGetAutocompletion() {
// fill in
Authenticator authenticator = new BearerTokenAuthenticator("");
Discovery service = new Discovery("2019-10-03", authenticator);
service.setServiceUrl("");
HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
service.configureClient(configOptions);
GetAutocompletionOptions options = new GetAutocompletionOptions.Builder().environmentId(// fill in
"").collectionId(// fill in
"").prefix("Ba").count(10L).build();
Completions response = service.getAutocompletion(options).execute().getResult();
// System.out.println(response);
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method testQueryWithSpellingSuggestions.
/**
* This only works on a Cloud Pak for Data instance, so ignoring to just run manually.
*/
@Test
@Ignore
public void testQueryWithSpellingSuggestions() {
// fill in
Authenticator authenticator = new BearerTokenAuthenticator("");
Discovery service = new Discovery("2019-10-03", authenticator);
service.setServiceUrl("");
HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
service.configureClient(configOptions);
QueryOptions options = new QueryOptions.Builder().naturalLanguageQuery("cluod").spellingSuggestions(true).environmentId(// fill in
"").collectionId(// fill in
"").build();
QueryResponse response = service.query(options).execute().getResult();
// System.out.println(response);
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project java-sdk by watson-developer-cloud.
the class AssistantTest method constructClientService.
// Constructs an instance of the service to be used by the tests
public void constructClientService() {
final String serviceName = "testService";
// set mock values for global params
String version = "testString";
final Authenticator authenticator = new NoAuthAuthenticator();
assistantService = new Assistant(version, serviceName, authenticator);
String url = server.url("/").toString();
assistantService.setServiceUrl(url);
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project knative-eventing-java-app by IBM.
the class SBApplicationConfig method cloudant.
/**
* Enables Spring to automatically create <code>Cloudant</code> instances
* configured to connect to the bound Cloudant client.
*
* @return A fully-configured <code>Cloudant</code> instance.
*/
@ConditionalOnMissingBean
@Bean
public Cloudant cloudant() {
// Create the authenticator.
Authenticator authenticator = new BasicAuthenticator.Builder().username(this.cloudantUsername).password(this.cloudantPassword).build();
// Create the client
Cloudant client = new Cloudant("", authenticator);
client.setServiceUrl(cloudantUrl);
return client;
}
use of com.ibm.cloud.sdk.core.security.Authenticator in project event-notifications-java-admin-sdk by IBM.
the class EventNotifications method newInstance.
/**
* Class method which constructs an instance of the `EventNotifications` client.
* The specified service name is used to configure the client instance.
*
* @param serviceName the service name to be used when configuring the client instance
* @return an instance of the `EventNotifications` client using external configuration
*/
public static EventNotifications newInstance(String serviceName) {
Authenticator authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName);
EventNotifications service = new EventNotifications(serviceName, authenticator);
service.configureService(serviceName);
return service;
}
Aggregations