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());
}
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);
}
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);
}
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);
}
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());
}
Aggregations