ibm_watson 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/ibm_watson.rb +1 -0
- data/lib/ibm_watson/assistant_v1.rb +22 -14
- data/lib/ibm_watson/assistant_v2.rb +7 -2
- data/lib/ibm_watson/discovery_v1.rb +2 -2
- data/lib/ibm_watson/discovery_v2.rb +762 -0
- data/lib/ibm_watson/speech_to_text_v1.rb +10 -0
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v4.rb +39 -6
- data/test/integration/test_assistant_v1.rb +2 -4
- data/test/integration/test_compare_comply_v1.rb +1 -1
- data/test/integration/test_discovery_v2.rb +144 -0
- data/test/unit/test_assistant_v1.rb +13 -403
- data/test/unit/test_assistant_v2.rb +8 -26
- data/test/unit/test_compare_comply_v1.rb +8 -93
- data/test/unit/test_discovery_v1.rb +10 -399
- data/test/unit/test_discovery_v2.rb +237 -0
- data/test/unit/test_visual_recognition_v4.rb +54 -131
- metadata +7 -4
@@ -1104,6 +1104,11 @@ module IBMWatson
|
|
1104
1104
|
# model is owned by the instance of the service whose credentials are used to create
|
1105
1105
|
# it.
|
1106
1106
|
#
|
1107
|
+
# You can create a maximum of 1024 custom language models, per credential. The
|
1108
|
+
# service returns an error if you attempt to create more than 1024 models. You do
|
1109
|
+
# not lose any models, but you cannot create any more until your model count is
|
1110
|
+
# below the limit.
|
1111
|
+
#
|
1107
1112
|
# **See also:** [Create a custom language
|
1108
1113
|
# model](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-languageCreate#createModel-language).
|
1109
1114
|
# @param name [String] A user-defined name for the new custom language model. Use a name that is unique
|
@@ -2225,6 +2230,11 @@ module IBMWatson
|
|
2225
2230
|
# model is owned by the instance of the service whose credentials are used to create
|
2226
2231
|
# it.
|
2227
2232
|
#
|
2233
|
+
# You can create a maximum of 1024 custom acoustic models, per credential. The
|
2234
|
+
# service returns an error if you attempt to create more than 1024 models. You do
|
2235
|
+
# not lose any models, but you cannot create any more until your model count is
|
2236
|
+
# below the limit.
|
2237
|
+
#
|
2228
2238
|
# **See also:** [Create a custom acoustic
|
2229
2239
|
# model](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-acoustic#createModel-acoustic).
|
2230
2240
|
# @param name [String] A user-defined name for the new custom acoustic model. Use a name that is unique
|
data/lib/ibm_watson/version.rb
CHANGED
@@ -16,11 +16,6 @@
|
|
16
16
|
|
17
17
|
# Provide images to the IBM Watson™ Visual Recognition service for analysis. The
|
18
18
|
# service detects objects based on a set of images with training data.
|
19
|
-
#
|
20
|
-
# **Beta:** The Visual Recognition v4 API and Object Detection model are beta features.
|
21
|
-
# For more information about beta features, see the [Release
|
22
|
-
# notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-recognition-release-notes#beta).
|
23
|
-
# {: important}
|
24
19
|
|
25
20
|
require "concurrent"
|
26
21
|
require "erb"
|
@@ -503,7 +498,9 @@ module IBMWatson
|
|
503
498
|
# Download a JPEG representation of an image.
|
504
499
|
# @param collection_id [String] The identifier of the collection.
|
505
500
|
# @param image_id [String] The identifier of the image.
|
506
|
-
# @param size [String]
|
501
|
+
# @param size [String] The image size. Specify `thumbnail` to return a version that maintains the
|
502
|
+
# original aspect ratio but is no larger than 200 pixels in the larger dimension.
|
503
|
+
# For example, an original 800 x 1000 image is resized to 160 x 200 pixels.
|
507
504
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
508
505
|
def get_jpeg_image(collection_id:, image_id:, size: nil)
|
509
506
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -614,6 +611,42 @@ module IBMWatson
|
|
614
611
|
)
|
615
612
|
response
|
616
613
|
end
|
614
|
+
|
615
|
+
##
|
616
|
+
# @!method get_training_usage(start_time: nil, end_time: nil)
|
617
|
+
# Get training usage.
|
618
|
+
# Information about the completed training events. You can use this information to
|
619
|
+
# determine how close you are to the training limits for the month.
|
620
|
+
# @param start_time [String] The earliest day to include training events. Specify dates in YYYY-MM-DD format.
|
621
|
+
# If empty or not specified, the earliest training event is included.
|
622
|
+
# @param end_time [String] The most recent day to include training events. Specify dates in YYYY-MM-DD
|
623
|
+
# format. All events for the day are included. If empty or not specified, the
|
624
|
+
# current day is used. Specify the same value as `start_time` to request events for
|
625
|
+
# a single day.
|
626
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
627
|
+
def get_training_usage(start_time: nil, end_time: nil)
|
628
|
+
headers = {
|
629
|
+
}
|
630
|
+
sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_training_usage")
|
631
|
+
headers.merge!(sdk_headers)
|
632
|
+
|
633
|
+
params = {
|
634
|
+
"version" => @version,
|
635
|
+
"start_time" => start_time,
|
636
|
+
"end_time" => end_time
|
637
|
+
}
|
638
|
+
|
639
|
+
method_url = "/v4/training_usage"
|
640
|
+
|
641
|
+
response = request(
|
642
|
+
method: "GET",
|
643
|
+
url: method_url,
|
644
|
+
headers: headers,
|
645
|
+
params: params,
|
646
|
+
accept_json: true
|
647
|
+
)
|
648
|
+
response
|
649
|
+
end
|
617
650
|
#########################
|
618
651
|
# User data
|
619
652
|
#########################
|
@@ -11,10 +11,8 @@ if !ENV["ASSISTANT_APIKEY"].nil? && !ENV["ASSISTANT_URL"].nil?
|
|
11
11
|
include Minitest::Hooks
|
12
12
|
attr_accessor :service
|
13
13
|
def before_all
|
14
|
-
|
15
|
-
|
16
|
-
version: "2018-02-16"
|
17
|
-
)
|
14
|
+
puts "before"
|
15
|
+
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "assistant")
|
18
16
|
@service = IBMWatson::AssistantV1.new(
|
19
17
|
version: "2018-02-16",
|
20
18
|
url: ENV["ASSISTANT_URL"],
|
@@ -12,7 +12,7 @@ if !ENV["COMPARE_COMPLY_APIKEY"].nil?
|
|
12
12
|
|
13
13
|
def before_all
|
14
14
|
authenticator = IBMWatson::Authenticators::IamAuthenticator.new(
|
15
|
-
apikey: ENV["
|
15
|
+
apikey: ENV["COMPARE_COMPLY_APIKEY"]
|
16
16
|
)
|
17
17
|
@service = IBMWatson::CompareComplyV1.new(
|
18
18
|
version: "2018-10-15",
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative("./../test_helper.rb")
|
4
|
+
require("minitest/hooks/test")
|
5
|
+
|
6
|
+
if !ENV["DISCOVERY_V2_TOKEN"].nil?
|
7
|
+
# Integration tests for the Discovery V2 Service
|
8
|
+
class DiscoveryV2Test < Minitest::Test
|
9
|
+
include Minitest::Hooks
|
10
|
+
attr_accessor :service, :environment_id, :collection_id
|
11
|
+
|
12
|
+
def before_all
|
13
|
+
token = ENV["DISCOVERY_V2_TOKEN"]
|
14
|
+
authenticator = IBMWatson::Authenticators::BearerTokenAuthenticator.new(
|
15
|
+
bearer_token: token
|
16
|
+
)
|
17
|
+
@service = IBMWatson::DiscoveryV2.new(
|
18
|
+
authenticator: authenticator,
|
19
|
+
version: "2019-11-21"
|
20
|
+
)
|
21
|
+
@service.service_url = ENV["DISCOVERY_V2_URL"]
|
22
|
+
@service.configure_http_client(disable_ssl_verification: true)
|
23
|
+
@project_id = ENV["DISCOVERY_V2_PROJECT_ID"]
|
24
|
+
@collection_id = ENV["DISCOVERY_V2_COLLECTION_ID"]
|
25
|
+
@document_id = nil
|
26
|
+
@service.add_default_headers(
|
27
|
+
headers: {
|
28
|
+
"X-Watson-Learning-Opt-Out" => "1",
|
29
|
+
"X-Watson-Test" => "1"
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_collections
|
35
|
+
service_response = service.list_collections(
|
36
|
+
project_id: @project_id
|
37
|
+
)
|
38
|
+
puts service_response.result
|
39
|
+
refute(service_response.result["collections"].nil?)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_query
|
43
|
+
service_response = service.query(
|
44
|
+
project_id: @project_id,
|
45
|
+
count: 10
|
46
|
+
)
|
47
|
+
refute(service_response.result["results"].nil?)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_get_autocompletion
|
51
|
+
service_response = service.get_autocompletion(
|
52
|
+
project_id: @project_id,
|
53
|
+
prefix: "hi how are "
|
54
|
+
)
|
55
|
+
refute(service_response.result["completions"].nil?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_query_notices
|
59
|
+
service_response = service.query_notices(
|
60
|
+
project_id: @project_id
|
61
|
+
)
|
62
|
+
refute(service_response.result.nil?)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_list_fields
|
66
|
+
service_response = service.list_fields(
|
67
|
+
project_id: @project_id,
|
68
|
+
collection_ids: [@collection_id]
|
69
|
+
)
|
70
|
+
refute(service_response.result.nil?)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_get_component_settings
|
74
|
+
service_response = service.get_component_settings(
|
75
|
+
project_id: @project_id
|
76
|
+
)
|
77
|
+
refute(service_response.result.nil?)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_add_update_delete_document
|
81
|
+
File.open(Dir.getwd + "/resources/simple.html") do |file_info|
|
82
|
+
service_response = service.add_document(
|
83
|
+
project_id: @project_id,
|
84
|
+
collection_id: @collection_id,
|
85
|
+
file: file_info
|
86
|
+
)
|
87
|
+
refute(service_response.nil?)
|
88
|
+
@document_id = service_response.result["document_id"]
|
89
|
+
end
|
90
|
+
return if @document_id.nil?
|
91
|
+
|
92
|
+
service_response = service.update_document(
|
93
|
+
project_id: @project_id,
|
94
|
+
collection_id: @collection_id,
|
95
|
+
document_id: @document_id,
|
96
|
+
file: "file",
|
97
|
+
filename: "file.name"
|
98
|
+
)
|
99
|
+
refute(service_response.result.nil?)
|
100
|
+
service.delete_document(
|
101
|
+
project_id: @project_id,
|
102
|
+
collection_id: @collection_id,
|
103
|
+
document_id: @document_id
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_list_training_queries
|
108
|
+
service_response = service.list_training_queries(
|
109
|
+
project_id: @project_id
|
110
|
+
)
|
111
|
+
refute(service_response.nil?)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_create_get_update_training_query
|
115
|
+
service_response = service.create_training_query(
|
116
|
+
project_id: @project_id,
|
117
|
+
natural_language_query: "How is the weather today?",
|
118
|
+
examples: []
|
119
|
+
)
|
120
|
+
query_id = service_response.result["query_id"]
|
121
|
+
refute(service_response.nil?)
|
122
|
+
|
123
|
+
service_response = service.get_training_query(
|
124
|
+
project_id: @project_id,
|
125
|
+
query_id: query_id
|
126
|
+
)
|
127
|
+
refute(service_response.nil?)
|
128
|
+
|
129
|
+
service_response = service.update_training_query(
|
130
|
+
project_id: @project_id,
|
131
|
+
query_id: query_id,
|
132
|
+
natural_language_query: "How is the weather tomorrow?",
|
133
|
+
examples: []
|
134
|
+
)
|
135
|
+
refute(service_response.nil?)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
else
|
139
|
+
class DiscoveryV2Test < Minitest::Test
|
140
|
+
def test_missing_credentials_skip_integration
|
141
|
+
skip "Skip discovery integration tests because credentials have not been provided"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -10,6 +10,16 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|
10
10
|
|
11
11
|
# Unit tests for the Watson Assistant V1 Service
|
12
12
|
class AssistantV1Test < Minitest::Test
|
13
|
+
include Minitest::Hooks
|
14
|
+
attr_accessor :service
|
15
|
+
def before_all
|
16
|
+
authenticator = IBMWatson::Authenticators::NoAuthAuthenticator.new
|
17
|
+
@service = IBMWatson::AssistantV1.new(
|
18
|
+
version: "2018-02-16",
|
19
|
+
authenticator: authenticator
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
13
23
|
def test_plain_to_json
|
14
24
|
response = {
|
15
25
|
"text" => "I want financial advice today.",
|
@@ -24,19 +34,10 @@ class AssistantV1Test < Minitest::Test
|
|
24
34
|
body: "{\"text\":\"I want financial advice today.\"}",
|
25
35
|
headers: {
|
26
36
|
"Accept" => "application/json",
|
27
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
28
37
|
"Content-Type" => "application/json",
|
29
38
|
"Host" => "gateway.watsonplatform.net"
|
30
39
|
}
|
31
40
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
32
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
33
|
-
username: "username",
|
34
|
-
password: "password"
|
35
|
-
)
|
36
|
-
service = IBMWatson::AssistantV1.new(
|
37
|
-
version: "2018-02-16",
|
38
|
-
authenticator: authenticator
|
39
|
-
)
|
40
41
|
service_response = service.create_counterexample(
|
41
42
|
workspace_id: "boguswid",
|
42
43
|
text: "I want financial advice today."
|
@@ -58,19 +59,10 @@ class AssistantV1Test < Minitest::Test
|
|
58
59
|
body: "{\"text\":\"I want financial advice today.\"}",
|
59
60
|
headers: {
|
60
61
|
"Accept" => "application/json",
|
61
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
62
62
|
"Content-Type" => "application/json",
|
63
63
|
"Host" => "gateway.watsonplatform.net"
|
64
64
|
}
|
65
65
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
66
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
67
|
-
username: "username",
|
68
|
-
password: "password"
|
69
|
-
)
|
70
|
-
service = IBMWatson::AssistantV1.new(
|
71
|
-
version: "2018-02-16",
|
72
|
-
authenticator: authenticator
|
73
|
-
)
|
74
66
|
service_response = service.create_counterexample(
|
75
67
|
workspace_id: "boguswid",
|
76
68
|
text: "I want financial advice today."
|
@@ -93,19 +85,10 @@ class AssistantV1Test < Minitest::Test
|
|
93
85
|
body: "{\"text\":\"I want financial advice today.\"}",
|
94
86
|
headers: {
|
95
87
|
"Accept" => "application/json",
|
96
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
97
88
|
"Content-Type" => "application/json",
|
98
89
|
"Host" => "gateway.watsonplatform.net"
|
99
90
|
}
|
100
91
|
).to_return(status: 429, body: error_response.to_json, headers: headers)
|
101
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
102
|
-
username: "username",
|
103
|
-
password: "password"
|
104
|
-
)
|
105
|
-
service = IBMWatson::AssistantV1.new(
|
106
|
-
version: "2018-02-16",
|
107
|
-
authenticator: authenticator
|
108
|
-
)
|
109
92
|
begin
|
110
93
|
service.create_counterexample(
|
111
94
|
workspace_id: "boguswid",
|
@@ -133,19 +116,10 @@ class AssistantV1Test < Minitest::Test
|
|
133
116
|
body: "{\"text\":\"I want financial advice today.\"}",
|
134
117
|
headers: {
|
135
118
|
"Accept" => "application/json",
|
136
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
137
119
|
"Content-Type" => "application/json",
|
138
120
|
"Host" => "gateway.watsonplatform.net"
|
139
121
|
}
|
140
122
|
).to_return(status: 407, body: error_response.to_json, headers: headers)
|
141
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
142
|
-
username: "username",
|
143
|
-
password: "password"
|
144
|
-
)
|
145
|
-
service = IBMWatson::AssistantV1.new(
|
146
|
-
version: "2018-02-16",
|
147
|
-
authenticator: authenticator
|
148
|
-
)
|
149
123
|
begin
|
150
124
|
service.create_counterexample(
|
151
125
|
workspace_id: "boguswid",
|
@@ -165,18 +139,9 @@ class AssistantV1Test < Minitest::Test
|
|
165
139
|
.with(
|
166
140
|
headers: {
|
167
141
|
"Accept" => "application/json",
|
168
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
169
142
|
"Host" => "gateway.watsonplatform.net"
|
170
143
|
}
|
171
144
|
).to_return(status: 200, body: {}.to_json, headers: headers)
|
172
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
173
|
-
username: "username",
|
174
|
-
password: "password"
|
175
|
-
)
|
176
|
-
service = IBMWatson::AssistantV1.new(
|
177
|
-
version: "2018-02-16",
|
178
|
-
authenticator: authenticator
|
179
|
-
)
|
180
145
|
service_response = service.delete_counterexample(
|
181
146
|
workspace_id: "boguswid",
|
182
147
|
text: "I want financial advice today"
|
@@ -197,18 +162,9 @@ class AssistantV1Test < Minitest::Test
|
|
197
162
|
.with(
|
198
163
|
headers: {
|
199
164
|
"Accept" => "application/json",
|
200
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
201
165
|
"Host" => "gateway.watsonplatform.net"
|
202
166
|
}
|
203
167
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
204
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
205
|
-
username: "username",
|
206
|
-
password: "password"
|
207
|
-
)
|
208
|
-
service = IBMWatson::AssistantV1.new(
|
209
|
-
version: "2018-02-16",
|
210
|
-
authenticator: authenticator
|
211
|
-
)
|
212
168
|
service_response = service.get_counterexample(
|
213
169
|
workspace_id: "boguswid",
|
214
170
|
text: "What are you wearing?"
|
@@ -241,18 +197,9 @@ class AssistantV1Test < Minitest::Test
|
|
241
197
|
.with(
|
242
198
|
headers: {
|
243
199
|
"Accept" => "application/json",
|
244
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
245
200
|
"Host" => "gateway.watsonplatform.net"
|
246
201
|
}
|
247
202
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
248
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
249
|
-
username: "username",
|
250
|
-
password: "password"
|
251
|
-
)
|
252
|
-
service = IBMWatson::AssistantV1.new(
|
253
|
-
version: "2018-02-16",
|
254
|
-
authenticator: authenticator
|
255
|
-
)
|
256
203
|
service_response = service.list_counterexamples(
|
257
204
|
workspace_id: "boguswid"
|
258
205
|
)
|
@@ -273,19 +220,10 @@ class AssistantV1Test < Minitest::Test
|
|
273
220
|
body: "{\"text\":\"What are you wearing?\"}",
|
274
221
|
headers: {
|
275
222
|
"Accept" => "application/json",
|
276
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
277
223
|
"Content-Type" => "application/json",
|
278
224
|
"Host" => "gateway.watsonplatform.net"
|
279
225
|
}
|
280
226
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
281
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
282
|
-
username: "username",
|
283
|
-
password: "password"
|
284
|
-
)
|
285
|
-
service = IBMWatson::AssistantV1.new(
|
286
|
-
version: "2018-02-16",
|
287
|
-
authenticator: authenticator
|
288
|
-
)
|
289
227
|
service_response = service.update_counterexample(
|
290
228
|
workspace_id: "boguswid",
|
291
229
|
text: "What are you wearing?",
|
@@ -312,19 +250,10 @@ class AssistantV1Test < Minitest::Test
|
|
312
250
|
body: "{\"entity\":\"pizza_toppings\",\"description\":\"Tasty pizza toppings\",\"metadata\":{\"property\":\"value\"}}",
|
313
251
|
headers: {
|
314
252
|
"Accept" => "application/json",
|
315
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
316
253
|
"Content-Type" => "application/json",
|
317
254
|
"Host" => "gateway.watsonplatform.net"
|
318
255
|
}
|
319
256
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
320
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
321
|
-
username: "username",
|
322
|
-
password: "password"
|
323
|
-
)
|
324
|
-
service = IBMWatson::AssistantV1.new(
|
325
|
-
version: "2018-02-16",
|
326
|
-
authenticator: authenticator
|
327
|
-
)
|
328
257
|
service_response = service.create_entity(
|
329
258
|
workspace_id: "boguswid",
|
330
259
|
entity: "pizza_toppings",
|
@@ -344,18 +273,9 @@ class AssistantV1Test < Minitest::Test
|
|
344
273
|
.with(
|
345
274
|
headers: {
|
346
275
|
"Accept" => "application/json",
|
347
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
348
276
|
"Host" => "gateway.watsonplatform.net"
|
349
277
|
}
|
350
278
|
).to_return(status: 200, body: "{}", headers: headers)
|
351
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
352
|
-
username: "username",
|
353
|
-
password: "password"
|
354
|
-
)
|
355
|
-
service = IBMWatson::AssistantV1.new(
|
356
|
-
version: "2018-02-16",
|
357
|
-
authenticator: authenticator
|
358
|
-
)
|
359
279
|
service_response = service.delete_entity(
|
360
280
|
workspace_id: "boguswid",
|
361
281
|
entity: "pizza_toppings"
|
@@ -380,18 +300,9 @@ class AssistantV1Test < Minitest::Test
|
|
380
300
|
.with(
|
381
301
|
headers: {
|
382
302
|
"Accept" => "application/json",
|
383
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
384
303
|
"Host" => "gateway.watsonplatform.net"
|
385
304
|
}
|
386
305
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
387
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
388
|
-
username: "username",
|
389
|
-
password: "password"
|
390
|
-
)
|
391
|
-
service = IBMWatson::AssistantV1.new(
|
392
|
-
version: "2018-02-16",
|
393
|
-
authenticator: authenticator
|
394
|
-
)
|
395
306
|
service_response = service.get_entity(
|
396
307
|
workspace_id: "boguswid",
|
397
308
|
entity: "pizza_toppings",
|
@@ -427,18 +338,9 @@ class AssistantV1Test < Minitest::Test
|
|
427
338
|
.with(
|
428
339
|
headers: {
|
429
340
|
"Accept" => "application/json",
|
430
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
431
341
|
"Host" => "gateway.watsonplatform.net"
|
432
342
|
}
|
433
343
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
434
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
435
|
-
username: "username",
|
436
|
-
password: "password"
|
437
|
-
)
|
438
|
-
service = IBMWatson::AssistantV1.new(
|
439
|
-
version: "2018-02-16",
|
440
|
-
authenticator: authenticator
|
441
|
-
)
|
442
344
|
service_response = service.list_entities(
|
443
345
|
workspace_id: "boguswid",
|
444
346
|
export: true
|
@@ -464,19 +366,10 @@ class AssistantV1Test < Minitest::Test
|
|
464
366
|
body: "{\"entity\":\"pizza_toppings\"}",
|
465
367
|
headers: {
|
466
368
|
"Accept" => "application/json",
|
467
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
468
369
|
"Content-Type" => "application/json",
|
469
370
|
"Host" => "gateway.watsonplatform.net"
|
470
371
|
}
|
471
372
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
472
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
473
|
-
username: "username",
|
474
|
-
password: "password"
|
475
|
-
)
|
476
|
-
service = IBMWatson::AssistantV1.new(
|
477
|
-
version: "2018-02-16",
|
478
|
-
authenticator: authenticator
|
479
|
-
)
|
480
373
|
service_response = service.update_entity(
|
481
374
|
workspace_id: "boguswid",
|
482
375
|
entity: "pizza_toppings",
|
@@ -499,19 +392,10 @@ class AssistantV1Test < Minitest::Test
|
|
499
392
|
body: "{\"text\":\"Gimme a pizza with pepperoni\",\"mentions\":[{\"mentioned\":\"yes\"}]}",
|
500
393
|
headers: {
|
501
394
|
"Accept" => "application/json",
|
502
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
503
395
|
"Content-Type" => "application/json",
|
504
396
|
"Host" => "gateway.watsonplatform.net"
|
505
397
|
}
|
506
398
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
507
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
508
|
-
username: "username",
|
509
|
-
password: "password"
|
510
|
-
)
|
511
|
-
service = IBMWatson::AssistantV1.new(
|
512
|
-
version: "2018-02-16",
|
513
|
-
authenticator: authenticator
|
514
|
-
)
|
515
399
|
service_response = service.create_example(
|
516
400
|
workspace_id: "boguswid",
|
517
401
|
intent: "pizza_order",
|
@@ -529,18 +413,9 @@ class AssistantV1Test < Minitest::Test
|
|
529
413
|
.with(
|
530
414
|
headers: {
|
531
415
|
"Accept" => "application/json",
|
532
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
533
416
|
"Host" => "gateway.watsonplatform.net"
|
534
417
|
}
|
535
418
|
).to_return(status: 200, body: "{}", headers: headers)
|
536
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
537
|
-
username: "username",
|
538
|
-
password: "password"
|
539
|
-
)
|
540
|
-
service = IBMWatson::AssistantV1.new(
|
541
|
-
version: "2018-02-16",
|
542
|
-
authenticator: authenticator
|
543
|
-
)
|
544
419
|
service_response = service.delete_example(
|
545
420
|
workspace_id: "boguswid",
|
546
421
|
intent: "pizza_order",
|
@@ -562,18 +437,9 @@ class AssistantV1Test < Minitest::Test
|
|
562
437
|
.with(
|
563
438
|
headers: {
|
564
439
|
"Accept" => "application/json",
|
565
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
566
440
|
"Host" => "gateway.watsonplatform.net"
|
567
441
|
}
|
568
442
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
569
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
570
|
-
username: "username",
|
571
|
-
password: "password"
|
572
|
-
)
|
573
|
-
service = IBMWatson::AssistantV1.new(
|
574
|
-
version: "2018-02-16",
|
575
|
-
authenticator: authenticator
|
576
|
-
)
|
577
443
|
service_response = service.get_example(
|
578
444
|
workspace_id: "boguswid",
|
579
445
|
intent: "pizza_order",
|
@@ -607,18 +473,9 @@ class AssistantV1Test < Minitest::Test
|
|
607
473
|
.with(
|
608
474
|
headers: {
|
609
475
|
"Accept" => "application/json",
|
610
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
611
476
|
"Host" => "gateway.watsonplatform.net"
|
612
477
|
}
|
613
478
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
614
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
615
|
-
username: "username",
|
616
|
-
password: "password"
|
617
|
-
)
|
618
|
-
service = IBMWatson::AssistantV1.new(
|
619
|
-
version: "2018-02-16",
|
620
|
-
authenticator: authenticator
|
621
|
-
)
|
622
479
|
service_response = service.list_examples(
|
623
480
|
workspace_id: "boguswid",
|
624
481
|
intent: "pizza_order"
|
@@ -640,19 +497,10 @@ class AssistantV1Test < Minitest::Test
|
|
640
497
|
body: "{\"text\":\"Gimme a pizza with pepperoni\",\"mentions\":[{\"mentioned\":\"yes\"}]}",
|
641
498
|
headers: {
|
642
499
|
"Accept" => "application/json",
|
643
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
644
500
|
"Content-Type" => "application/json",
|
645
501
|
"Host" => "gateway.watsonplatform.net"
|
646
502
|
}
|
647
503
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
648
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
649
|
-
username: "username",
|
650
|
-
password: "password"
|
651
|
-
)
|
652
|
-
service = IBMWatson::AssistantV1.new(
|
653
|
-
version: "2018-02-16",
|
654
|
-
authenticator: authenticator
|
655
|
-
)
|
656
504
|
service_response = service.update_example(
|
657
505
|
workspace_id: "boguswid",
|
658
506
|
intent: "pizza_order",
|
@@ -678,19 +526,10 @@ class AssistantV1Test < Minitest::Test
|
|
678
526
|
body: "{\"intent\":\"pizza_order\",\"description\":\"User wants to start a new pizza order\"}",
|
679
527
|
headers: {
|
680
528
|
"Accept" => "application/json",
|
681
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
682
529
|
"Content-Type" => "application/json",
|
683
530
|
"Host" => "gateway.watsonplatform.net"
|
684
531
|
}
|
685
532
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
686
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
687
|
-
username: "username",
|
688
|
-
password: "password"
|
689
|
-
)
|
690
|
-
service = IBMWatson::AssistantV1.new(
|
691
|
-
version: "2018-02-16",
|
692
|
-
authenticator: authenticator
|
693
|
-
)
|
694
533
|
service_response = service.create_intent(
|
695
534
|
workspace_id: "boguswid",
|
696
535
|
intent: "pizza_order",
|
@@ -707,18 +546,9 @@ class AssistantV1Test < Minitest::Test
|
|
707
546
|
.with(
|
708
547
|
headers: {
|
709
548
|
"Accept" => "application/json",
|
710
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
711
549
|
"Host" => "gateway.watsonplatform.net"
|
712
550
|
}
|
713
551
|
).to_return(status: 200, body: "{}", headers: headers)
|
714
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
715
|
-
username: "username",
|
716
|
-
password: "password"
|
717
|
-
)
|
718
|
-
service = IBMWatson::AssistantV1.new(
|
719
|
-
version: "2018-02-16",
|
720
|
-
authenticator: authenticator
|
721
|
-
)
|
722
552
|
service_response = service.delete_intent(
|
723
553
|
workspace_id: "boguswid",
|
724
554
|
intent: "pizza_order"
|
@@ -740,18 +570,9 @@ class AssistantV1Test < Minitest::Test
|
|
740
570
|
.with(
|
741
571
|
headers: {
|
742
572
|
"Accept" => "application/json",
|
743
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
744
573
|
"Host" => "gateway.watsonplatform.net"
|
745
574
|
}
|
746
575
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
747
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
748
|
-
username: "username",
|
749
|
-
password: "password"
|
750
|
-
)
|
751
|
-
service = IBMWatson::AssistantV1.new(
|
752
|
-
version: "2018-02-16",
|
753
|
-
authenticator: authenticator
|
754
|
-
)
|
755
576
|
service_response = service.get_intent(
|
756
577
|
workspace_id: "boguswid",
|
757
578
|
intent: "pizza_order",
|
@@ -782,18 +603,9 @@ class AssistantV1Test < Minitest::Test
|
|
782
603
|
.with(
|
783
604
|
headers: {
|
784
605
|
"Accept" => "application/json",
|
785
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
786
606
|
"Host" => "gateway.watsonplatform.net"
|
787
607
|
}
|
788
608
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
789
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
790
|
-
username: "username",
|
791
|
-
password: "password"
|
792
|
-
)
|
793
|
-
service = IBMWatson::AssistantV1.new(
|
794
|
-
version: "2018-02-16",
|
795
|
-
authenticator: authenticator
|
796
|
-
)
|
797
609
|
service_response = service.list_intents(
|
798
610
|
workspace_id: "boguswid",
|
799
611
|
export: false
|
@@ -816,7 +628,6 @@ class AssistantV1Test < Minitest::Test
|
|
816
628
|
body: "{\"intent\":\"pizza_order\",\"description\":\"User wants to start a new pizza order\"}",
|
817
629
|
headers: {
|
818
630
|
"Accept" => "application/json",
|
819
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
820
631
|
"Content-Type" => "application/json",
|
821
632
|
"Host" => "gateway.watsonplatform.net"
|
822
633
|
}
|
@@ -897,18 +708,9 @@ class AssistantV1Test < Minitest::Test
|
|
897
708
|
.with(
|
898
709
|
headers: {
|
899
710
|
"Accept" => "application/json",
|
900
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
901
711
|
"Host" => "gateway.watsonplatform.net"
|
902
712
|
}
|
903
713
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
904
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
905
|
-
username: "username",
|
906
|
-
password: "password"
|
907
|
-
)
|
908
|
-
service = IBMWatson::AssistantV1.new(
|
909
|
-
version: "2018-02-16",
|
910
|
-
authenticator: authenticator
|
911
|
-
)
|
912
714
|
service_response = service.list_logs(
|
913
715
|
workspace_id: "boguswid"
|
914
716
|
)
|
@@ -982,18 +784,9 @@ class AssistantV1Test < Minitest::Test
|
|
982
784
|
.with(
|
983
785
|
headers: {
|
984
786
|
"Accept" => "application/json",
|
985
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
986
787
|
"Host" => "gateway.watsonplatform.net"
|
987
788
|
}
|
988
789
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
989
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
990
|
-
username: "username",
|
991
|
-
password: "password"
|
992
|
-
)
|
993
|
-
service = IBMWatson::AssistantV1.new(
|
994
|
-
version: "2018-02-16",
|
995
|
-
authenticator: authenticator
|
996
|
-
)
|
997
790
|
service_response = service.list_all_logs(
|
998
791
|
filter: "language::en,request.context.metadata.deployment::deployment_1"
|
999
792
|
)
|
@@ -1001,14 +794,6 @@ class AssistantV1Test < Minitest::Test
|
|
1001
794
|
end
|
1002
795
|
|
1003
796
|
def test_message
|
1004
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1005
|
-
username: "username",
|
1006
|
-
password: "password"
|
1007
|
-
)
|
1008
|
-
service = IBMWatson::AssistantV1.new(
|
1009
|
-
version: "2018-02-16",
|
1010
|
-
authenticator: authenticator
|
1011
|
-
)
|
1012
797
|
# service.set_default_headers("x-watson-learning-opt-out" => true)
|
1013
798
|
workspace_id = "f8fdbc65-e0bd-4e43-b9f8-2975a366d4ec"
|
1014
799
|
message_response = {
|
@@ -1036,7 +821,6 @@ class AssistantV1Test < Minitest::Test
|
|
1036
821
|
body: "{\"input\":{\"text\":\"Turn on the lights\"}}",
|
1037
822
|
headers: {
|
1038
823
|
"Accept" => "application/json",
|
1039
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1040
824
|
"Content-Type" => "application/json",
|
1041
825
|
"Host" => "gateway.watsonplatform.net"
|
1042
826
|
}
|
@@ -1063,7 +847,6 @@ class AssistantV1Test < Minitest::Test
|
|
1063
847
|
body: "{\"input\":{\"text\":\"Turn on the lights\"},\"context\":\"{\\\"conversation_id\\\":\\\"1b7b67c0-90ed-45dc-8508-9488bc483d5b\\\",\\\"system\\\":{\\\"dialog_stack\\\":[\\\"root\\\"],\\\"dialog_turn_counter\\\":2,\\\"dialog_request_counter\\\":1}}\"}",
|
1064
848
|
headers: {
|
1065
849
|
"Accept" => "application/json",
|
1066
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1067
850
|
"Content-Type" => "application/json",
|
1068
851
|
"Host" => "gateway.watsonplatform.net"
|
1069
852
|
}
|
@@ -1090,19 +873,10 @@ class AssistantV1Test < Minitest::Test
|
|
1090
873
|
body: "{\"synonym\":\"a\"}",
|
1091
874
|
headers: {
|
1092
875
|
"Accept" => "application/json",
|
1093
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1094
876
|
"Content-Type" => "application/json",
|
1095
877
|
"Host" => "gateway.watsonplatform.net"
|
1096
878
|
}
|
1097
879
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
1098
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1099
|
-
username: "username",
|
1100
|
-
password: "password"
|
1101
|
-
)
|
1102
|
-
service = IBMWatson::AssistantV1.new(
|
1103
|
-
version: "2018-02-16",
|
1104
|
-
authenticator: authenticator
|
1105
|
-
)
|
1106
880
|
service_response = service.create_synonym(
|
1107
881
|
workspace_id: "boguswid",
|
1108
882
|
entity: "aeiou",
|
@@ -1120,18 +894,9 @@ class AssistantV1Test < Minitest::Test
|
|
1120
894
|
.with(
|
1121
895
|
headers: {
|
1122
896
|
"Accept" => "application/json",
|
1123
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1124
897
|
"Host" => "gateway.watsonplatform.net"
|
1125
898
|
}
|
1126
899
|
).to_return(status: 200, body: "", headers: headers)
|
1127
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1128
|
-
username: "username",
|
1129
|
-
password: "password"
|
1130
|
-
)
|
1131
|
-
service = IBMWatson::AssistantV1.new(
|
1132
|
-
version: "2018-02-16",
|
1133
|
-
authenticator: authenticator
|
1134
|
-
)
|
1135
900
|
service_response = service.delete_synonym(
|
1136
901
|
workspace_id: "boguswid",
|
1137
902
|
entity: "aeiou",
|
@@ -1154,18 +919,9 @@ class AssistantV1Test < Minitest::Test
|
|
1154
919
|
.with(
|
1155
920
|
headers: {
|
1156
921
|
"Accept" => "application/json",
|
1157
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1158
922
|
"Host" => "gateway.watsonplatform.net"
|
1159
923
|
}
|
1160
924
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1161
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1162
|
-
username: "username",
|
1163
|
-
password: "password"
|
1164
|
-
)
|
1165
|
-
service = IBMWatson::AssistantV1.new(
|
1166
|
-
version: "2018-02-16",
|
1167
|
-
authenticator: authenticator
|
1168
|
-
)
|
1169
925
|
service_response = service.get_synonym(
|
1170
926
|
workspace_id: "boguswid",
|
1171
927
|
entity: "grilling",
|
@@ -1203,18 +959,9 @@ class AssistantV1Test < Minitest::Test
|
|
1203
959
|
.with(
|
1204
960
|
headers: {
|
1205
961
|
"Accept" => "application/json",
|
1206
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1207
962
|
"Host" => "gateway.watsonplatform.net"
|
1208
963
|
}
|
1209
964
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1210
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1211
|
-
username: "username",
|
1212
|
-
password: "password"
|
1213
|
-
)
|
1214
|
-
service = IBMWatson::AssistantV1.new(
|
1215
|
-
version: "2018-02-16",
|
1216
|
-
authenticator: authenticator
|
1217
|
-
)
|
1218
965
|
service_response = service.list_synonyms(
|
1219
966
|
workspace_id: "boguswid",
|
1220
967
|
entity: "grilling",
|
@@ -1237,19 +984,10 @@ class AssistantV1Test < Minitest::Test
|
|
1237
984
|
body: "{\"synonym\":\"barbecue\"}",
|
1238
985
|
headers: {
|
1239
986
|
"Accept" => "application/json",
|
1240
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1241
987
|
"Content-Type" => "application/json",
|
1242
988
|
"Host" => "gateway.watsonplatform.net"
|
1243
989
|
}
|
1244
990
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1245
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1246
|
-
username: "username",
|
1247
|
-
password: "password"
|
1248
|
-
)
|
1249
|
-
service = IBMWatson::AssistantV1.new(
|
1250
|
-
version: "2018-02-16",
|
1251
|
-
authenticator: authenticator
|
1252
|
-
)
|
1253
991
|
service_response = service.update_synonym(
|
1254
992
|
workspace_id: "boguswid",
|
1255
993
|
entity: "grilling",
|
@@ -1276,19 +1014,10 @@ class AssistantV1Test < Minitest::Test
|
|
1276
1014
|
body: "{\"value\":\"aeiou\"}",
|
1277
1015
|
headers: {
|
1278
1016
|
"Accept" => "application/json",
|
1279
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1280
1017
|
"Content-Type" => "application/json",
|
1281
1018
|
"Host" => "gateway.watsonplatform.net"
|
1282
1019
|
}
|
1283
1020
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
1284
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1285
|
-
username: "username",
|
1286
|
-
password: "password"
|
1287
|
-
)
|
1288
|
-
service = IBMWatson::AssistantV1.new(
|
1289
|
-
version: "2018-02-16",
|
1290
|
-
authenticator: authenticator
|
1291
|
-
)
|
1292
1021
|
service_response = service.create_value(
|
1293
1022
|
workspace_id: "boguswid",
|
1294
1023
|
entity: "grilling",
|
@@ -1305,18 +1034,9 @@ class AssistantV1Test < Minitest::Test
|
|
1305
1034
|
.with(
|
1306
1035
|
headers: {
|
1307
1036
|
"Accept" => "application/json",
|
1308
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1309
1037
|
"Host" => "gateway.watsonplatform.net"
|
1310
1038
|
}
|
1311
1039
|
).to_return(status: 200, body: "", headers: headers)
|
1312
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1313
|
-
username: "username",
|
1314
|
-
password: "password"
|
1315
|
-
)
|
1316
|
-
service = IBMWatson::AssistantV1.new(
|
1317
|
-
version: "2018-02-16",
|
1318
|
-
authenticator: authenticator
|
1319
|
-
)
|
1320
1040
|
service_response = service.delete_value(
|
1321
1041
|
workspace_id: "boguswid",
|
1322
1042
|
entity: "grilling",
|
@@ -1342,18 +1062,9 @@ class AssistantV1Test < Minitest::Test
|
|
1342
1062
|
.with(
|
1343
1063
|
headers: {
|
1344
1064
|
"Accept" => "application/json",
|
1345
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1346
1065
|
"Host" => "gateway.watsonplatform.net"
|
1347
1066
|
}
|
1348
1067
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1349
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1350
|
-
username: "username",
|
1351
|
-
password: "password"
|
1352
|
-
)
|
1353
|
-
service = IBMWatson::AssistantV1.new(
|
1354
|
-
version: "2018-02-16",
|
1355
|
-
authenticator: authenticator
|
1356
|
-
)
|
1357
1068
|
service_response = service.get_value(
|
1358
1069
|
workspace_id: "boguswid",
|
1359
1070
|
entity: "grilling",
|
@@ -1390,18 +1101,9 @@ class AssistantV1Test < Minitest::Test
|
|
1390
1101
|
.with(
|
1391
1102
|
headers: {
|
1392
1103
|
"Accept" => "application/json",
|
1393
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1394
1104
|
"Host" => "gateway.watsonplatform.net"
|
1395
1105
|
}
|
1396
1106
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1397
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1398
|
-
username: "username",
|
1399
|
-
password: "password"
|
1400
|
-
)
|
1401
|
-
service = IBMWatson::AssistantV1.new(
|
1402
|
-
version: "2018-02-16",
|
1403
|
-
authenticator: authenticator
|
1404
|
-
)
|
1405
1107
|
service_response = service.list_values(
|
1406
1108
|
workspace_id: "boguswid",
|
1407
1109
|
entity: "grilling",
|
@@ -1428,19 +1130,10 @@ class AssistantV1Test < Minitest::Test
|
|
1428
1130
|
body: "{\"value\":\"BBQ sauce\",\"metadata\":{\"code\":1422}}",
|
1429
1131
|
headers: {
|
1430
1132
|
"Accept" => "application/json",
|
1431
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1432
1133
|
"Content-Type" => "application/json",
|
1433
1134
|
"Host" => "gateway.watsonplatform.net"
|
1434
1135
|
}
|
1435
1136
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1436
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1437
|
-
username: "username",
|
1438
|
-
password: "password"
|
1439
|
-
)
|
1440
|
-
service = IBMWatson::AssistantV1.new(
|
1441
|
-
version: "2018-02-16",
|
1442
|
-
authenticator: authenticator
|
1443
|
-
)
|
1444
1137
|
service_response = service.update_value(
|
1445
1138
|
workspace_id: "boguswid",
|
1446
1139
|
entity: "grilling",
|
@@ -1467,28 +1160,20 @@ class AssistantV1Test < Minitest::Test
|
|
1467
1160
|
}
|
1468
1161
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces?version=2018-02-16")
|
1469
1162
|
.with(
|
1470
|
-
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{},\"system_settings\":{\"system_settings\":\"yes\"}}",
|
1163
|
+
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{},\"system_settings\":{\"system_settings\":\"yes\"},\"webhooks\":[]}",
|
1471
1164
|
headers: {
|
1472
1165
|
"Accept" => "application/json",
|
1473
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1474
1166
|
"Content-Type" => "application/json",
|
1475
1167
|
"Host" => "gateway.watsonplatform.net"
|
1476
1168
|
}
|
1477
1169
|
).to_return(status: 201, body: response.to_json, headers: headers)
|
1478
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1479
|
-
username: "username",
|
1480
|
-
password: "password"
|
1481
|
-
)
|
1482
|
-
service = IBMWatson::AssistantV1.new(
|
1483
|
-
version: "2018-02-16",
|
1484
|
-
authenticator: authenticator
|
1485
|
-
)
|
1486
1170
|
service_response = service.create_workspace(
|
1487
1171
|
name: "Pizza app",
|
1488
1172
|
description: "Pizza app",
|
1489
1173
|
language: "en",
|
1490
1174
|
metadata: {},
|
1491
|
-
system_settings: { "system_settings" => "yes" }
|
1175
|
+
system_settings: { "system_settings" => "yes" },
|
1176
|
+
webhooks: []
|
1492
1177
|
)
|
1493
1178
|
assert_equal(response, service_response.result)
|
1494
1179
|
end
|
@@ -1501,18 +1186,9 @@ class AssistantV1Test < Minitest::Test
|
|
1501
1186
|
.with(
|
1502
1187
|
headers: {
|
1503
1188
|
"Accept" => "application/json",
|
1504
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1505
1189
|
"Host" => "gateway.watsonplatform.net"
|
1506
1190
|
}
|
1507
1191
|
).to_return(status: 200, body: "", headers: headers)
|
1508
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1509
|
-
username: "username",
|
1510
|
-
password: "password"
|
1511
|
-
)
|
1512
|
-
service = IBMWatson::AssistantV1.new(
|
1513
|
-
version: "2018-02-16",
|
1514
|
-
authenticator: authenticator
|
1515
|
-
)
|
1516
1192
|
service_response = service.delete_workspace(
|
1517
1193
|
workspace_id: "boguswid"
|
1518
1194
|
)
|
@@ -1538,18 +1214,9 @@ class AssistantV1Test < Minitest::Test
|
|
1538
1214
|
.with(
|
1539
1215
|
headers: {
|
1540
1216
|
"Accept" => "application/json",
|
1541
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1542
1217
|
"Host" => "gateway.watsonplatform.net"
|
1543
1218
|
}
|
1544
1219
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1545
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1546
|
-
username: "username",
|
1547
|
-
password: "password"
|
1548
|
-
)
|
1549
|
-
service = IBMWatson::AssistantV1.new(
|
1550
|
-
version: "2018-02-16",
|
1551
|
-
authenticator: authenticator
|
1552
|
-
)
|
1553
1220
|
service_response = service.get_workspace(
|
1554
1221
|
workspace_id: "boguswid",
|
1555
1222
|
export: false
|
@@ -1582,18 +1249,9 @@ class AssistantV1Test < Minitest::Test
|
|
1582
1249
|
.with(
|
1583
1250
|
headers: {
|
1584
1251
|
"Accept" => "application/json",
|
1585
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1586
1252
|
"Host" => "gateway.watsonplatform.net"
|
1587
1253
|
}
|
1588
1254
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1589
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1590
|
-
username: "username",
|
1591
|
-
password: "password"
|
1592
|
-
)
|
1593
|
-
service = IBMWatson::AssistantV1.new(
|
1594
|
-
version: "2018-02-16",
|
1595
|
-
authenticator: authenticator
|
1596
|
-
)
|
1597
1255
|
service_response = service.list_workspaces
|
1598
1256
|
assert_equal(response, service_response.result)
|
1599
1257
|
end
|
@@ -1616,19 +1274,10 @@ class AssistantV1Test < Minitest::Test
|
|
1616
1274
|
body: "{\"name\":\"Pizza app\",\"description\":\"Pizza app\",\"language\":\"en\",\"metadata\":{},\"system_settings\":{\"system_settings\":\"yes\"}}",
|
1617
1275
|
headers: {
|
1618
1276
|
"Accept" => "application/json",
|
1619
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1620
1277
|
"Content-Type" => "application/json",
|
1621
1278
|
"Host" => "gateway.watsonplatform.net"
|
1622
1279
|
}
|
1623
1280
|
).to_return(status: 200, body: response.to_json, headers: headers)
|
1624
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1625
|
-
username: "username",
|
1626
|
-
password: "password"
|
1627
|
-
)
|
1628
|
-
service = IBMWatson::AssistantV1.new(
|
1629
|
-
version: "2018-02-16",
|
1630
|
-
authenticator: authenticator
|
1631
|
-
)
|
1632
1281
|
service_response = service.update_workspace(
|
1633
1282
|
workspace_id: "pizza_app-e0f3",
|
1634
1283
|
name: "Pizza app",
|
@@ -1641,14 +1290,6 @@ class AssistantV1Test < Minitest::Test
|
|
1641
1290
|
end
|
1642
1291
|
|
1643
1292
|
def test_dialog_nodes
|
1644
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1645
|
-
username: "username",
|
1646
|
-
password: "password"
|
1647
|
-
)
|
1648
|
-
service = IBMWatson::AssistantV1.new(
|
1649
|
-
version: "2018-02-16",
|
1650
|
-
authenticator: authenticator
|
1651
|
-
)
|
1652
1293
|
headers = {
|
1653
1294
|
"Content-Type" => "application/json"
|
1654
1295
|
}
|
@@ -1658,7 +1299,6 @@ class AssistantV1Test < Minitest::Test
|
|
1658
1299
|
body: "{\"dialog_node\":\"location-done\",\"user_label\":\"labeled\"}",
|
1659
1300
|
headers: {
|
1660
1301
|
"Accept" => "application/json",
|
1661
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1662
1302
|
"Content-Type" => "application/json",
|
1663
1303
|
"Host" => "gateway.watsonplatform.net"
|
1664
1304
|
}
|
@@ -1674,7 +1314,6 @@ class AssistantV1Test < Minitest::Test
|
|
1674
1314
|
.with(
|
1675
1315
|
headers: {
|
1676
1316
|
"Accept" => "application/json",
|
1677
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1678
1317
|
"Host" => "gateway.watsonplatform.net"
|
1679
1318
|
}
|
1680
1319
|
).to_return(status: 200, body: { "description" => "deleted successfully" }.to_json, headers: headers)
|
@@ -1688,7 +1327,6 @@ class AssistantV1Test < Minitest::Test
|
|
1688
1327
|
.with(
|
1689
1328
|
headers: {
|
1690
1329
|
"Accept" => "application/json",
|
1691
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1692
1330
|
"Host" => "gateway.watsonplatform.net"
|
1693
1331
|
}
|
1694
1332
|
).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-atm" } }.to_json, headers: headers)
|
@@ -1702,7 +1340,6 @@ class AssistantV1Test < Minitest::Test
|
|
1702
1340
|
.with(
|
1703
1341
|
headers: {
|
1704
1342
|
"Accept" => "application/json",
|
1705
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1706
1343
|
"Host" => "gateway.watsonplatform.net"
|
1707
1344
|
}
|
1708
1345
|
).to_return(status: 200, body: { "application/json" => { "dialog_node" => "location-atm" } }.to_json, headers: headers)
|
@@ -1720,18 +1357,9 @@ class AssistantV1Test < Minitest::Test
|
|
1720
1357
|
.with(
|
1721
1358
|
headers: {
|
1722
1359
|
"Accept" => "application/json",
|
1723
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1724
1360
|
"Host" => "gateway.watsonplatform.net"
|
1725
1361
|
}
|
1726
1362
|
).to_return(status: 200, body: "", headers: headers)
|
1727
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1728
|
-
username: "username",
|
1729
|
-
password: "password"
|
1730
|
-
)
|
1731
|
-
service = IBMWatson::AssistantV1.new(
|
1732
|
-
version: "2018-02-16",
|
1733
|
-
authenticator: authenticator
|
1734
|
-
)
|
1735
1363
|
service_response = service.delete_user_data(
|
1736
1364
|
customer_id: "id"
|
1737
1365
|
)
|
@@ -1739,20 +1367,11 @@ class AssistantV1Test < Minitest::Test
|
|
1739
1367
|
end
|
1740
1368
|
|
1741
1369
|
def test_update_dialog_node
|
1742
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1743
|
-
username: "username",
|
1744
|
-
password: "password"
|
1745
|
-
)
|
1746
|
-
service = IBMWatson::AssistantV1.new(
|
1747
|
-
version: "2018-02-16",
|
1748
|
-
authenticator: authenticator
|
1749
|
-
)
|
1750
1370
|
stub_request(:post, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspace_id/dialog_nodes/dialog_node?version=2018-02-16")
|
1751
1371
|
.with(
|
1752
1372
|
body: "{\"description\":\"A new description\",\"user_label\":\"new_label\"}",
|
1753
1373
|
headers: {
|
1754
1374
|
"Accept" => "application/json",
|
1755
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1756
1375
|
"Content-Type" => "application/json",
|
1757
1376
|
"Host" => "gateway.watsonplatform.net"
|
1758
1377
|
}
|
@@ -1767,19 +1386,10 @@ class AssistantV1Test < Minitest::Test
|
|
1767
1386
|
end
|
1768
1387
|
|
1769
1388
|
def test_list_mentions
|
1770
|
-
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
1771
|
-
username: "username",
|
1772
|
-
password: "password"
|
1773
|
-
)
|
1774
|
-
service = IBMWatson::AssistantV1.new(
|
1775
|
-
version: "2018-02-16",
|
1776
|
-
authenticator: authenticator
|
1777
|
-
)
|
1778
1389
|
stub_request(:get, "https://gateway.watsonplatform.net/assistant/api/v1/workspaces/workspace_id/entities/entity/mentions?export=true&include_audit=true&version=2018-02-16")
|
1779
1390
|
.with(
|
1780
1391
|
headers: {
|
1781
1392
|
"Accept" => "application/json",
|
1782
|
-
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
1783
1393
|
"Host" => "gateway.watsonplatform.net"
|
1784
1394
|
}
|
1785
1395
|
).to_return(status: 200, body: { "list_mentions_response" => "yes" }.to_json, headers: { "Content-Type" => "application/json" })
|