Search in sources :

Example 21 with Authenticator

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);
}
Also used : HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 22 with Authenticator

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);
}
Also used : HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 23 with Authenticator

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

Example 24 with Authenticator

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;
}
Also used : BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Cloudant(com.ibm.cloud.cloudant.v1.Cloudant) BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 25 with Authenticator

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

Aggregations

Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)58 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)32 Before (org.junit.Before)15 NoAuthAuthenticator (com.ibm.cloud.sdk.core.security.NoAuthAuthenticator)14 Test (org.testng.annotations.Test)8 SpeechRecognitionResults (com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults)5 BasicAuthenticator (com.ibm.cloud.sdk.core.security.BasicAuthenticator)4 BearerTokenAuthenticator (com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator)4 File (java.io.File)4 InputStream (java.io.InputStream)4 CouchDbSessionAuthenticator (com.ibm.cloud.cloudant.security.CouchDbSessionAuthenticator)3 HttpConfigOptions (com.ibm.cloud.sdk.core.http.HttpConfigOptions)3 Response (com.ibm.cloud.sdk.core.http.Response)2 MessageInput (com.ibm.watson.assistant.v1.model.MessageInput)2 MessageOptions (com.ibm.watson.assistant.v1.model.MessageOptions)2 MessageResponse (com.ibm.watson.assistant.v1.model.MessageResponse)2 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)2 TranslateOptions (com.ibm.watson.language_translator.v3.model.TranslateOptions)2 TranslationResult (com.ibm.watson.language_translator.v3.model.TranslationResult)2 RecognizeWithWebsocketsOptions (com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions)2