Skip to content

Commit 11e5178

Browse files
committed
chore(examples): Update examples with latest versions
1 parent a801f74 commit 11e5178

10 files changed

Lines changed: 41 additions & 18 deletions

examples/assistant_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# If service instance provides API key authentication
66
# assistant = AssistantV1(
7-
# version='2017-04-21',
7+
# version='2018-07-10',
88
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# url='https://gateway.watsonplatform.net/assistant/api',
1010
# iam_apikey='iam_apikey')
@@ -14,7 +14,7 @@
1414
password='YOUR SERVICE PASSWORD',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/assistant/api',
17-
version='2017-04-21')
17+
version='2018-07-10')
1818

1919
#########################
2020
# Workspaces

examples/conversation_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## If service instance provides API key authentication
66
# conversation = ConversationV1(
7-
# version='2018-02-16',
7+
# version='2018-07-10',
88
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# url='https://gateway.watsonplatform.net/conversation/api',
1010
# iam_apikey='iam_apikey')
@@ -14,7 +14,7 @@
1414
password='YOUR SERVICE PASSWORD',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/conversation/api',
17-
version='2018-02-16')
17+
version='2018-07-10')
1818

1919
# When you send multiple requests for the same conversation, include the
2020
# context object from the previous response.

examples/discovery_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
# If service instance provides API key authentication
77
# discovery = DiscoveryV1(
8-
# version='2017-10-16',
8+
# version='2018-08-01',
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/discovery/api',
1111
# iam_apikey='iam_apikey')
1212

1313
discovery = DiscoveryV1(
14-
version='2017-10-16',
14+
version='2018-08-01',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/discovery/api',
1717
username='YOUR SERVICE USERNAME',

examples/language_translator_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
from watson_developer_cloud import LanguageTranslatorV3
55

66
# language_translator = LanguageTranslatorV3(
7-
# version='2018-05-31',
7+
# version='2018-05-01.',
88
# ### url is optional, and defaults to the URL below. Use the correct URL for your region.
99
# # url='https://gateway.watsonplatform.net/language-translator/api',
1010
# iam_apikey='your_apikey')
1111

1212
# Authenticate with username/password if your service instance doesn't provide an API key
1313
language_translator = LanguageTranslatorV3(
14-
version='2018-05-31',
14+
version='2018-05-01.',
1515
username='YOUR SERVICE USERNAME',
1616
password='YOUR SERVICE PASSWORD')
1717

examples/natural_language_understanding_v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
# If service instance provides API key authentication
77
# service = NaturalLanguageUnderstandingV1(
8-
# version='2017-02-27',
8+
# version='2018-03-16',
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
1111
# iam_apikey='your_apikey')
1212

1313
service = NaturalLanguageUnderstandingV1(
14-
version='2017-02-27',
14+
version='2018-03-16',
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
1717
username='YOUR SERVICE USERNAME',

examples/personality_insights_v3.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66
import json
77
from os.path import join, dirname
88
from watson_developer_cloud import PersonalityInsightsV3
9+
import csv
910

1011
# # If service instance provides API key authentication
1112
# service = PersonalityInsightsV3(
12-
# version='2016-10-20',
13+
# version='2017-10-13',
1314
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1415
# url='https://gateway.watsonplatform.net/personality-insights/api',
1516
# iam_apikey='your_apikey')
1617

1718
service = PersonalityInsightsV3(
18-
version='2016-10-20',
19+
version='2017-10-13',
1920
## url is optional, and defaults to the URL below. Use the correct URL for your region.
2021
# url='https://gateway.watsonplatform.net/personality-insights/api',
2122
username='YOUR SERVICE USERNAME',
2223
password='YOUR SERVICE PASSWORD')
2324

25+
############################
26+
# Profile with JSON output #
27+
############################
28+
2429
with open(join(dirname(__file__), '../resources/personality-v3.json')) as \
2530
profile_json:
2631
profile = service.profile(
@@ -30,3 +35,21 @@
3035
consumption_preferences=True).get_result()
3136

3237
print(json.dumps(profile, indent=2))
38+
39+
###########################
40+
# Profile with CSV output #
41+
###########################
42+
43+
with open(join(dirname(__file__), '../resources/personality-v3.json')) as \
44+
profile_json:
45+
response = service.profile(
46+
profile_json.read(),
47+
content_type='application/json',
48+
accept="text/csv",
49+
csv_headers=True).get_result()
50+
51+
profile = response.content
52+
cr = csv.reader(profile.splitlines())
53+
my_list = list(cr)
54+
for row in my_list:
55+
print(row)

examples/tone_analyzer_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
# service = ToneAnalyzerV3(
99
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1010
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
11-
# version='2017-09-26',
11+
# version='2017-09-21',
1212
# iam_apikey='your_apikey')
1313

1414
service = ToneAnalyzerV3(
1515
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1616
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
1717
username='YOUR SERVICE USERNAME',
1818
password='YOUR SERVICE PASSWORD',
19-
version='2017-09-26')
19+
version='2017-09-21')
2020

2121
print("\ntone_chat() example 1:\n")
2222
utterances = [{

examples/visual_recognition_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
# # If service instance provides IAM API key authentication
1010
# service = VisualRecognitionV3(
11-
# '2016-05-20',
11+
# '2018-03-19',
1212
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
1313
# url='https://gateway.watsonplatform.net/visual-recognition/api',
1414
# iam_apikey='iam_apikey')
1515

16-
service = VisualRecognitionV3('2016-05-20',
16+
service = VisualRecognitionV3('2018-03-19',
1717
## url is optional, and defaults to the URL below. Use the correct URL for your region.
1818
# url='https://gateway.watsonplatform.net/visual-recognition/api',
1919
api_key='YOUR API KEY')

test/integration/test_discovery_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Discoveryv1(TestCase):
1111
def setUp(self):
1212
self.discovery = watson_developer_cloud.DiscoveryV1(
13-
version='2017-10-16',
13+
version='2018-08-01',
1414
username="YOUR SERVICE USERNAME",
1515
password="YOUR SERVICE PASSWORD")
1616
self.discovery.set_default_headers({

test/integration/test_visual_recognition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class IntegrationTestVisualRecognitionV3(TestCase):
1414
@classmethod
1515
def setup_class(cls):
1616
cls.visual_recognition = watson_developer_cloud.VisualRecognitionV3(
17-
'2016-05-20', api_key='YOUR API KEY')
17+
'2018-03-19', api_key='YOUR API KEY')
1818
cls.visual_recognition.set_default_headers({
1919
'X-Watson-Learning-Opt-Out':
2020
'1',

0 commit comments

Comments
 (0)