Search in sources :

Example 1 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class CompareComplyServiceTest method setUp.

/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("COMPARE_COMPLY_APIKEY");
    Assume.assumeFalse("COMPARE_COMPLY_APIKEY is not defined", apiKey == null);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new CompareComply(VERSION, authenticator);
    service.setServiceUrl(System.getenv("COMPARE_COMPLY_URL"));
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Before(org.junit.Before)

Example 2 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class ToneAnalyzerChatExample method main.

public static void main(String[] args) {
    Authenticator authenticator = new IamAuthenticator("<iam_api_key>");
    ToneAnalyzer service = new ToneAnalyzer("2017-09-21", authenticator);
    String[] texts = { "My charger isn't working.", "Thanks for reaching out. Can you give me some more detail about the issue?", "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" + " charging. The charging icon comes on, but it stays on even when I take the charger out. " + "Which is ridiculous, it's brand new.", "I'm sorry you're having issues with charging. What kind of charger are you using?" };
    List<Utterance> utterances = new ArrayList<>();
    for (int i = 0; i < texts.length; i++) {
        Utterance utterance = new Utterance.Builder().text(texts[i]).build();
        utterances.add(utterance);
    }
    ToneChatOptions toneChatOptions = new ToneChatOptions.Builder().utterances(utterances).build();
    // Call the service
    UtteranceAnalyses utterancesTone = service.toneChat(toneChatOptions).execute().getResult();
    System.out.println(utterancesTone);
}
Also used : Utterance(com.ibm.watson.tone_analyzer.v3.model.Utterance) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) ToneChatOptions(com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions) ArrayList(java.util.ArrayList) UtteranceAnalyses(com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator)

Example 3 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class NaturalLanguageClassifierIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("NATURAL_LANGUAGE_CLASSIFIER_APIKEY");
    String serviceUrl = System.getenv("NATURAL_LANGUAGE_CLASSIFIER_URL");
    preCreatedClassifierId = System.getenv("NATURAL_LANGUAGE_CLASSIFIER_ID");
    if (apiKey == null) {
        apiKey = getProperty("natural_language_classifier.apikey");
        serviceUrl = getProperty("natural_language_classifier.url");
        preCreatedClassifierId = getProperty("natural_language_classifier.classifier_id");
    }
    assertNotNull("NATURAL_LANGUAGE_CLASSIFIER_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new NaturalLanguageClassifier(authenticator);
    service.setDefaultHeaders(getDefaultHeaders());
    service.setServiceUrl(serviceUrl);
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 4 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class VisualRecognitionIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String iamApiKey = System.getenv("VISUAL_RECOGNITION_APIKEY");
    assertNotNull("VISUAL_RECOGNITION_APIKEY is not defined", iamApiKey);
    String url = System.getenv("VISUAL_RECOGNITION_URL");
    classifierId = "default";
    Authenticator authenticator = new IamAuthenticator(iamApiKey);
    service = new VisualRecognition(VERSION, authenticator);
    service.setDefaultHeaders(getDefaultHeaders());
    service.setServiceUrl(url);
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 5 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class ToneAnalyzerIT method setUp.

/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("TONE_ANALYZER_APIKEY");
    Assert.assertNotNull("TONE_ANALYZER_APIKEY is not defined", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new ToneAnalyzer(VERSION_DATE_VALUE, authenticator);
    service.setServiceUrl(System.getenv("TONE_ANALYZER_URL"));
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Aggregations

IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)32 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)30 Before (org.junit.Before)15 SpeechRecognitionResults (com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults)5 File (java.io.File)4 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 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 BaseRecognizeCallback (com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback)2 ToneAnalysis (com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis)2 ToneOptions (com.ibm.watson.tone_analyzer.v3.model.ToneOptions)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 JsonObject (com.google.gson.JsonObject)1 HttpConfigOptions (com.ibm.cloud.sdk.core.http.HttpConfigOptions)1 ServiceCallback (com.ibm.cloud.sdk.core.http.ServiceCallback)1