ibm_watson 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +258 -0
  3. data/bin/console +14 -0
  4. data/bin/setup +8 -0
  5. data/lib/ibm_watson.rb +16 -0
  6. data/lib/ibm_watson/assistant_v1.rb +1997 -0
  7. data/lib/ibm_watson/detailed_response.rb +21 -0
  8. data/lib/ibm_watson/discovery_v1.rb +2039 -0
  9. data/lib/ibm_watson/iam_token_manager.rb +166 -0
  10. data/lib/ibm_watson/language_translator_v3.rb +411 -0
  11. data/lib/ibm_watson/natural_language_classifier_v1.rb +309 -0
  12. data/lib/ibm_watson/natural_language_understanding_v1.rb +297 -0
  13. data/lib/ibm_watson/personality_insights_v3.rb +260 -0
  14. data/lib/ibm_watson/speech_to_text_v1.rb +2153 -0
  15. data/lib/ibm_watson/text_to_speech_v1.rb +716 -0
  16. data/lib/ibm_watson/tone_analyzer_v3.rb +287 -0
  17. data/lib/ibm_watson/version.rb +3 -0
  18. data/lib/ibm_watson/visual_recognition_v3.rb +579 -0
  19. data/lib/ibm_watson/watson_api_exception.rb +41 -0
  20. data/lib/ibm_watson/watson_service.rb +180 -0
  21. data/lib/ibm_watson/websocket/recognize_callback.rb +32 -0
  22. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +162 -0
  23. data/rakefile +45 -0
  24. data/test/integration/test_assistant_v1.rb +645 -0
  25. data/test/integration/test_discovery_v1.rb +200 -0
  26. data/test/integration/test_iam_assistant_v1.rb +707 -0
  27. data/test/integration/test_language_translator_v3.rb +81 -0
  28. data/test/integration/test_natural_language_classifier_v1.rb +69 -0
  29. data/test/integration/test_natural_language_understanding_v1.rb +98 -0
  30. data/test/integration/test_personality_insights_v3.rb +95 -0
  31. data/test/integration/test_speech_to_text_v1.rb +187 -0
  32. data/test/integration/test_text_to_speech_v1.rb +81 -0
  33. data/test/integration/test_tone_analyzer_v3.rb +72 -0
  34. data/test/integration/test_visual_recognition_v3.rb +64 -0
  35. data/test/test_helper.rb +22 -0
  36. data/test/unit/test_assistant_v1.rb +1598 -0
  37. data/test/unit/test_discovery_v1.rb +1144 -0
  38. data/test/unit/test_iam_token_manager.rb +165 -0
  39. data/test/unit/test_language_translator_v3.rb +461 -0
  40. data/test/unit/test_natural_language_classifier_v1.rb +187 -0
  41. data/test/unit/test_natural_language_understanding_v1.rb +132 -0
  42. data/test/unit/test_personality_insights_v3.rb +172 -0
  43. data/test/unit/test_speech_to_text_v1.rb +755 -0
  44. data/test/unit/test_text_to_speech_v1.rb +336 -0
  45. data/test/unit/test_tone_analyzer_v3.rb +200 -0
  46. data/test/unit/test_vcap_using_personality_insights.rb +150 -0
  47. data/test/unit/test_visual_recognition_v3.rb +345 -0
  48. metadata +302 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d7836c1857159d3d0a056c2a9afd46009534c5a8e84b6b716fbfef53c139bffb
4
+ data.tar.gz: 83142f7639dafcf4450cba44766cae7a635e7c341bf31b222fb4698ffea46815
5
+ SHA512:
6
+ metadata.gz: f396810bad65041babcf1e5e2aee11b250973649b5412ecbffdd2c4386ddc94182c5d1d45dc9d8b99e1c44b9c5955777802bb17bb2dbf2a7ba428eeef5d3bde3
7
+ data.tar.gz: 791fa8d8c263c62c60e95fc3cf589d02a4093e12ee42da841061dffdc25b3212dcb9fec8cddc0bc4afe717fc0b2fdeeb3d25f2439f4a0699868604f2d0731d79
@@ -0,0 +1,258 @@
1
+ # IBM Watson Ruby SDK
2
+
3
+ [![Build Status](https://travis-ci.org/watson-developer-cloud/ruby-sdk.svg?branch=master)](https://travis-ci.org/watson-developer-cloud/ruby-sdk)
4
+ [![Slack](https://wdc-slack-inviter.mybluemix.net/badge.svg)](https://wdc-slack-inviter.mybluemix.net)
5
+ [![codecov.io](https://codecov.io/github/watson-developer-cloud/ruby-sdk/coverage.svg?branch=master)](https://codecov.io/github/watson-developer-cloud/ruby-sdk?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/ibm_watson.svg)](https://badge.fury.io/rb/ibm_watson)
7
+
8
+ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
9
+
10
+ <details>
11
+ <summary>Table of Contents</summary>
12
+
13
+ * [Before you begin](#before-you-begin)
14
+ * [Installation](#installation)
15
+ * [Examples](#examples)
16
+ * [Running in IBM Cloud](#running-in-ibm-cloud)
17
+ * [Authentication](#authentication)
18
+ * [Getting credentials](#getting-credentials)
19
+ * [IAM](#iam)
20
+ * [Username and password](#username-and-password)
21
+ * [Sending requests asynchronously](#sending-requests-asynchronously)
22
+ * [Sending request headers](#sending-request-headers)
23
+ * [Parsing HTTP response info](#parsing-http-response-info)
24
+ * [Using Websockets](#using-websockets)
25
+ * [Ruby version](#ruby-version)
26
+ * [Contributing](#contributing)
27
+ * [License](#license)
28
+
29
+ </details>
30
+
31
+ ## Before you begin
32
+ * You need an [IBM Cloud][ibm-cloud-onboarding] account.
33
+
34
+ ## Installation
35
+
36
+ Install the gem:
37
+
38
+ ```bash
39
+ gem install ibm_watson
40
+ ```
41
+
42
+ Install with development dependencies:
43
+
44
+ ```bash
45
+ gem install --dev ibm_watson
46
+ ```
47
+
48
+ Inside of your Ruby program do:
49
+
50
+ ```ruby
51
+ require "ibm_watson"
52
+ ```
53
+
54
+ ## Examples
55
+
56
+ The [examples][examples] folder has basic and advanced examples. The examples within each service assume that you already have [service credentials](#getting-credentials).
57
+
58
+ ## Running in IBM Cloud
59
+
60
+ If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVICES`][vcap_services] environment variable.
61
+
62
+ ## Authentication
63
+
64
+ Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
65
+
66
+ - With some service instances, you authenticate to the API by using **[IAM](#iam)**.
67
+ - In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
68
+
69
+ ### Getting credentials
70
+ To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
71
+
72
+ 1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page.
73
+ 1. Either click an existing Watson service instance or click **Create**.
74
+ 1. Click **Show** to view your service credentials.
75
+ 1. Copy the `url` and either `apikey` or `username` and `password`.
76
+
77
+ ### IAM
78
+
79
+ IBM Cloud is migrating to token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
80
+
81
+ You supply either an IAM service **API key** or an **access token**:
82
+
83
+ - Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
84
+ - Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html).
85
+
86
+ #### Supplying the IAM API key
87
+
88
+ ```ruby
89
+ # In the constructor, letting the SDK manage the IAM token
90
+ discovery = IBMWatson::DiscoveryV1.new(
91
+ version: "2017-10-16",
92
+ iam_api_key: "<iam_api_key>",
93
+ iam_url: "<iam_url>" # optional - the default value is https://iam.ng.bluemix.net/identity/token
94
+ )
95
+ ```
96
+
97
+ ```ruby
98
+ # after instantiation, letting the SDK manage the IAM token
99
+ discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16")
100
+ discovery._iam_api_key(iam_api_key: "<iam_api_key>")
101
+ ```
102
+
103
+ #### Supplying the access token
104
+ ```ruby
105
+ # in the constructor, assuming control of managing IAM token
106
+ discovery = IBMWatson::DiscoveryV1.new(
107
+ version: "2017-10-16",
108
+ iam_access_token: "<iam_access_token>"
109
+ )
110
+ ```
111
+
112
+ ```ruby
113
+ # after instantiation, assuming control of managing IAM token
114
+ discovery = IBMWatson::DiscoveryV1.new(version: "2017-10-16")
115
+ discovery._iam_access_token(iam_access_token: "<access_token>")
116
+ ```
117
+
118
+ ### Username and password
119
+ ```ruby
120
+ require "ibm_watson"
121
+ include IBMWatson
122
+ # In the constructor
123
+ discovery = DiscoveryV1.new(version: "2017-10-16", username: "<username>", password: "<password>")
124
+ ```
125
+
126
+ ```ruby
127
+ # After instantiation
128
+ discovery = DiscoveryV1.new(version: "2017-10-16")
129
+ discovery.username = "<username>"
130
+ discovery.password = "<password>"
131
+ ```
132
+
133
+ ## Sending requests asynchronously
134
+ Requests can be sent asynchronously. There are two asynchronous methods available for the user, `async` & `await`. When used, these methods return an [Ivar][ivar] object.
135
+ * To call a method asynchronously, simply insert `.await` or `.async` into the call: `service.translate` would be `service.async.translate`
136
+ * To access the response from an [Ivar][ivar] object called `future`, simply call `future.value`
137
+
138
+ When `await` is used, the request is made synchronously.
139
+ ```ruby
140
+ speech_to_text = IBMWatson::SpeechToTextV1.new(
141
+ username: "username",
142
+ password: "password"
143
+ )
144
+ audio_file = File.open(Dir.getwd + "/resources/speech.wav")
145
+ future = speech_to_text.await.recognize(
146
+ audio: audio_file
147
+ )
148
+ p future.complete? # If the request is successful, then this will be true
149
+ output = future.value # The response is accessible at future.value
150
+ ```
151
+
152
+ When `async` is used, the request is made asynchronously
153
+ ```ruby
154
+ speech_to_text = IBMWatson::SpeechToTextV1.new(
155
+ username: "username",
156
+ password: "password"
157
+ )
158
+ audio_file = File.open(Dir.getwd + "/resources/speech.wav")
159
+ future = speech_to_text.async.recognize(
160
+ audio: audio_file
161
+ )
162
+ p future.complete? # Can be false if the request is still running
163
+ future.wait # Wait for the asynchronous call to finish
164
+ p future.complete? # If the request is successful, then this will now be true
165
+ output = future.value
166
+ ```
167
+
168
+ ## Sending request headers
169
+ Custom headers can be passed in any request in the form of a `Hash` as a parameter to the `headers` chainable method. For example, to send a header called `Custom-Header` to a call in Watson Assistant, pass the headers as a parameter to the `headers` chainable method:
170
+ ```ruby
171
+ require "ibm_watson"
172
+ include IBMWatson
173
+
174
+ assistant = AssistantV1.new(
175
+ username: "xxx",
176
+ password: "yyy",
177
+ version: "2017-04-21"
178
+ )
179
+
180
+ response = assistant.headers(
181
+ "Custom-Header" => "custom_value"
182
+ ).list_workspaces
183
+ ```
184
+
185
+ ## Parsing HTTP response info
186
+ HTTP requests all return `DetailedResponse` objects that have a `result`, `status`, and `headers`
187
+ ```ruby
188
+ require "ibm_watson"
189
+ include IBMWatson
190
+
191
+ assistant = AssistantV1.new(
192
+ username: "xxx",
193
+ password: "yyy",
194
+ version: "2017-04-21"
195
+ )
196
+
197
+ response = assistant.headers(
198
+ "Custom-Header" => "custom_value"
199
+ ).list_workspaces
200
+
201
+ p "Status: #{response.status}"
202
+ p "Headers: #{response.headers}"
203
+ p "Result: #{response.result}"
204
+ ```
205
+
206
+ This would give an output of `DetailedResponse` having the structure:
207
+ ```ruby
208
+ Status: 200
209
+ Headers: <http response headers>
210
+ Result: <response returned by service>
211
+ ```
212
+
213
+ ## Using Websockets
214
+
215
+ The Speech-to-Text service supports websockets with the `recognize-with-websockets` method. The method accepts a custom callback class. The `eventmachine` loop that the websocket uses blocks the main thread by default. Here is an example of using the websockets method:
216
+
217
+ ```ruby
218
+ require "ibm_watson"
219
+
220
+ callback = IBMWatson::RecognizeCallback.new
221
+ audio_file = "<Audio File for Analysis>"
222
+ speech_to_text = IBMWatson::SpeechToTextV1.new(
223
+ username: "<username>",
224
+ password: "<password>"
225
+ )
226
+ websocket = speech_to_text.recognize_with_websocket(
227
+ audio: audio_file,
228
+ recognize_callback: callback,
229
+ interim_results: true
230
+ )
231
+ thr = Thread.new do # Start the websocket inside of a thread
232
+ websocket.start # Starts the websocket and begins sending audio to the server.
233
+ # The `callback` processes the data from the server
234
+ end
235
+ thr.join # Wait for the thread to finish before ending the program or running other code
236
+ ```
237
+
238
+ ## Ruby version
239
+
240
+ Tested on Ruby 2.3, 2.4, 2.5
241
+
242
+ ## Contributing
243
+
244
+ See [CONTRIBUTING.md][CONTRIBUTING].
245
+
246
+ ## License
247
+
248
+ This library is licensed under the [Apache 2.0 license][license].
249
+
250
+ [wdc]: http://www.ibm.com/watson/developercloud/
251
+ [ibm_cloud]: https://console.bluemix.net
252
+ [watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=watson
253
+ [examples]: https://github.com/watson-developer-cloud/ruby-sdk/tree/master/examples
254
+ [CONTRIBUTING]: https://github.com/watson-developer-cloud/ruby-sdk/blob/master/CONTRIBUTING.md
255
+ [license]: http://www.apache.org/licenses/LICENSE-2.0
256
+ [vcap_services]: https://console.bluemix.net/docs/services/watson/getting-started-variables.html
257
+ [ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Ruby
258
+ [ivar]: http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/IVar.html
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ibm_watson"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Module for the Watson APIs
4
+ module IBMWatson
5
+ require_relative("./ibm_watson/personality_insights_v3.rb")
6
+ require_relative("./ibm_watson/tone_analyzer_v3.rb")
7
+ require_relative("./ibm_watson/assistant_v1.rb")
8
+ require_relative("./ibm_watson/text_to_speech_v1.rb")
9
+ require_relative("./ibm_watson/discovery_v1.rb")
10
+ require_relative("./ibm_watson/natural_language_understanding_v1.rb")
11
+ require_relative("./ibm_watson/speech_to_text_v1.rb")
12
+ require_relative("./ibm_watson/visual_recognition_v3.rb")
13
+ require_relative("./ibm_watson/natural_language_classifier_v1.rb")
14
+ require_relative("./ibm_watson/language_translator_v3.rb")
15
+ require_relative("./ibm_watson/websocket/recognize_callback.rb")
16
+ end
@@ -0,0 +1,1997 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 IBM All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # The IBM Watson&trade; Assistant service combines machine learning, natural language
18
+ # understanding, and integrated dialog tools to create conversation flows between your
19
+ # apps and your users.
20
+
21
+ require "concurrent"
22
+ require "erb"
23
+ require "json"
24
+ require_relative "./detailed_response"
25
+
26
+ require_relative "./watson_service"
27
+
28
+ module IBMWatson
29
+ ##
30
+ # The Assistant V1 service.
31
+ class AssistantV1
32
+ include Concurrent::Async
33
+ ##
34
+ # @!method initialize(args)
35
+ # Construct a new client for the Assistant service.
36
+ #
37
+ # @param args [Hash] The args to initialize with
38
+ # @option args version [String] The API version date to use with the service, in
39
+ # "YYYY-MM-DD" format. Whenever the API is changed in a backwards
40
+ # incompatible way, a new minor version of the API is released.
41
+ # The service uses the API version for the date you specify, or
42
+ # the most recent version before that date. Note that you should
43
+ # not programmatically specify the current date at runtime, in
44
+ # case the API has been updated since your application's release.
45
+ # Instead, specify a version date that is compatible with your
46
+ # application, and don't change it until your application is
47
+ # ready for a later version.
48
+ # @option args url [String] The base url to use when contacting the service (e.g.
49
+ # "https://gateway.watsonplatform.net/assistant/api").
50
+ # The base url may differ between Bluemix regions.
51
+ # @option args username [String] The username used to authenticate with the service.
52
+ # Username and password credentials are only required to run your
53
+ # application locally or outside of Bluemix. When running on
54
+ # Bluemix, the credentials will be automatically loaded from the
55
+ # `VCAP_SERVICES` environment variable.
56
+ # @option args password [String] The password used to authenticate with the service.
57
+ # Username and password credentials are only required to run your
58
+ # application locally or outside of Bluemix. When running on
59
+ # Bluemix, the credentials will be automatically loaded from the
60
+ # `VCAP_SERVICES` environment variable.
61
+ # @option args iam_api_key [String] An API key that can be used to request IAM tokens. If
62
+ # this API key is provided, the SDK will manage the token and handle the
63
+ # refreshing.
64
+ # @option args iam_access_token [String] An IAM access token is fully managed by the application.
65
+ # Responsibility falls on the application to refresh the token, either before
66
+ # it expires or reactively upon receiving a 401 from the service as any requests
67
+ # made with an expired token will fail.
68
+ # @option args iam_url [String] An optional URL for the IAM service API. Defaults to
69
+ # 'https://iam.ng.bluemix.net/identity/token'.
70
+ def initialize(args = {})
71
+ @__async_initialized__ = false
72
+ super()
73
+ defaults = {}
74
+ defaults[:version] = nil
75
+ defaults[:url] = "https://gateway.watsonplatform.net/assistant/api"
76
+ defaults[:username] = nil
77
+ defaults[:password] = nil
78
+ defaults[:iam_api_key] = nil
79
+ defaults[:iam_access_token] = nil
80
+ defaults[:iam_url] = nil
81
+ args = defaults.merge(args)
82
+ @watson_service = WatsonService.new(
83
+ vcap_services_name: "conversation",
84
+ url: args[:url],
85
+ username: args[:username],
86
+ password: args[:password],
87
+ iam_api_key: args[:iam_api_key],
88
+ iam_access_token: args[:iam_access_token],
89
+ iam_url: args[:iam_url],
90
+ use_vcap_services: true
91
+ )
92
+ @version = args[:version]
93
+ end
94
+
95
+ # :nocov:
96
+ def add_default_headers(headers: {})
97
+ @watson_service.add_default_headers(headers: headers)
98
+ end
99
+
100
+ def _iam_access_token(iam_access_token:)
101
+ @watson_service._iam_access_token(iam_access_token: iam_access_token)
102
+ end
103
+
104
+ def _iam_api_key(iam_api_key:)
105
+ @watson_service._iam_api_key(iam_api_key: iam_api_key)
106
+ end
107
+
108
+ # @return [DetailedResponse]
109
+ def request(args)
110
+ @watson_service.request(args)
111
+ end
112
+
113
+ # @note Chainable
114
+ # @param headers [Hash] Custom headers to be sent with the request
115
+ # @return [self]
116
+ def headers(headers)
117
+ @watson_service.headers(headers)
118
+ self
119
+ end
120
+
121
+ def password=(password)
122
+ @watson_service.password = password
123
+ end
124
+
125
+ def password
126
+ @watson_service.password
127
+ end
128
+
129
+ def username=(username)
130
+ @watson_service.username = username
131
+ end
132
+
133
+ def username
134
+ @watson_service.username
135
+ end
136
+
137
+ def url=(url)
138
+ @watson_service.url = url
139
+ end
140
+
141
+ def url
142
+ @watson_service.url
143
+ end
144
+ # :nocov:
145
+ #########################
146
+ # Message
147
+ #########################
148
+
149
+ ##
150
+ # @!method message(workspace_id:, input: nil, alternate_intents: nil, context: nil, entities: nil, intents: nil, output: nil, nodes_visited_details: nil)
151
+ # Get response to user input.
152
+ # Get a response to a user's input.
153
+ #
154
+ # There is no rate limit for this operation.
155
+ # @param workspace_id [String] Unique identifier of the workspace.
156
+ # @param input [InputData] An input object that includes the input text.
157
+ # @param alternate_intents [Boolean] Whether to return more than one intent. Set to `true` to return all matching
158
+ # intents.
159
+ # @param context [Context] State information for the conversation. Continue a conversation by including the
160
+ # context object from the previous response.
161
+ # @param entities [Array[RuntimeEntity]] Entities to use when evaluating the message. Include entities from the previous
162
+ # response to continue using those entities rather than detecting entities in the
163
+ # new input.
164
+ # @param intents [Array[RuntimeIntent]] Intents to use when evaluating the user input. Include intents from the previous
165
+ # response to continue using those intents rather than trying to recognize intents
166
+ # in the new input.
167
+ # @param output [OutputData] System output. Include the output from the previous response to maintain
168
+ # intermediate information over multiple requests.
169
+ # @param nodes_visited_details [Boolean] Whether to include additional diagnostic information about the dialog nodes that
170
+ # were visited during processing of the message.
171
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
172
+ def message(workspace_id:, input: nil, alternate_intents: nil, context: nil, entities: nil, intents: nil, output: nil, nodes_visited_details: nil)
173
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
174
+ headers = {
175
+ }
176
+ params = {
177
+ "version" => @version,
178
+ "nodes_visited_details" => nodes_visited_details
179
+ }
180
+ data = {
181
+ "input" => input,
182
+ "alternate_intents" => alternate_intents,
183
+ "context" => context,
184
+ "entities" => entities,
185
+ "intents" => intents,
186
+ "output" => output
187
+ }
188
+ method_url = "/v1/workspaces/%s/message" % [ERB::Util.url_encode(workspace_id)]
189
+ response = request(
190
+ method: "POST",
191
+ url: method_url,
192
+ headers: headers,
193
+ params: params,
194
+ json: data,
195
+ accept_json: true
196
+ )
197
+ response
198
+ end
199
+ #########################
200
+ # Workspaces
201
+ #########################
202
+
203
+ ##
204
+ # @!method list_workspaces(page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
205
+ # List workspaces.
206
+ # List the workspaces associated with a Watson Assistant service instance.
207
+ #
208
+ # This operation is limited to 500 requests per 30 minutes. For more information,
209
+ # see **Rate limiting**.
210
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
211
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
212
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
213
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
214
+ # and `workspace_id`.
215
+ # @param cursor [String] A token identifying the page of results to retrieve.
216
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
217
+ # the response.
218
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
219
+ def list_workspaces(page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
220
+ headers = {
221
+ }
222
+ params = {
223
+ "version" => @version,
224
+ "page_limit" => page_limit,
225
+ "include_count" => include_count,
226
+ "sort" => sort,
227
+ "cursor" => cursor,
228
+ "include_audit" => include_audit
229
+ }
230
+ method_url = "/v1/workspaces"
231
+ response = request(
232
+ method: "GET",
233
+ url: method_url,
234
+ headers: headers,
235
+ params: params,
236
+ accept_json: true
237
+ )
238
+ response
239
+ end
240
+
241
+ ##
242
+ # @!method create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil)
243
+ # Create workspace.
244
+ # Create a workspace based on component objects. You must provide workspace
245
+ # components defining the content of the new workspace.
246
+ #
247
+ # This operation is limited to 30 requests per 30 minutes. For more information, see
248
+ # **Rate limiting**.
249
+ # @param name [String] The name of the workspace. This string cannot contain carriage return, newline, or
250
+ # tab characters, and it must be no longer than 64 characters.
251
+ # @param description [String] The description of the workspace. This string cannot contain carriage return,
252
+ # newline, or tab characters, and it must be no longer than 128 characters.
253
+ # @param language [String] The language of the workspace.
254
+ # @param intents [Array[CreateIntent]] An array of objects defining the intents for the workspace.
255
+ # @param entities [Array[CreateEntity]] An array of objects defining the entities for the workspace.
256
+ # @param dialog_nodes [Array[CreateDialogNode]] An array of objects defining the nodes in the workspace dialog.
257
+ # @param counterexamples [Array[CreateCounterexample]] An array of objects defining input examples that have been marked as irrelevant
258
+ # input.
259
+ # @param metadata [Object] Any metadata related to the workspace.
260
+ # @param learning_opt_out [Boolean] Whether training data from the workspace can be used by IBM for general service
261
+ # improvements. `true` indicates that workspace training data is not to be used.
262
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
263
+ def create_workspace(name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil)
264
+ headers = {
265
+ }
266
+ params = {
267
+ "version" => @version
268
+ }
269
+ data = {
270
+ "name" => name,
271
+ "description" => description,
272
+ "language" => language,
273
+ "intents" => intents,
274
+ "entities" => entities,
275
+ "dialog_nodes" => dialog_nodes,
276
+ "counterexamples" => counterexamples,
277
+ "metadata" => metadata,
278
+ "learning_opt_out" => learning_opt_out
279
+ }
280
+ method_url = "/v1/workspaces"
281
+ response = request(
282
+ method: "POST",
283
+ url: method_url,
284
+ headers: headers,
285
+ params: params,
286
+ json: data,
287
+ accept_json: true
288
+ )
289
+ response
290
+ end
291
+
292
+ ##
293
+ # @!method get_workspace(workspace_id:, export: nil, include_audit: nil)
294
+ # Get information about a workspace.
295
+ # Get information about a workspace, optionally including all workspace content.
296
+ #
297
+ # With **export**=`false`, this operation is limited to 6000 requests per 5 minutes.
298
+ # With **export**=`true`, the limit is 20 requests per 30 minutes. For more
299
+ # information, see **Rate limiting**.
300
+ # @param workspace_id [String] Unique identifier of the workspace.
301
+ # @param export [Boolean] Whether to include all element content in the returned data. If
302
+ # **export**=`false`, the returned data includes only information about the element
303
+ # itself. If **export**=`true`, all content, including subelements, is included.
304
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
305
+ # the response.
306
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
307
+ def get_workspace(workspace_id:, export: nil, include_audit: nil)
308
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
309
+ headers = {
310
+ }
311
+ params = {
312
+ "version" => @version,
313
+ "export" => export,
314
+ "include_audit" => include_audit
315
+ }
316
+ method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
317
+ response = request(
318
+ method: "GET",
319
+ url: method_url,
320
+ headers: headers,
321
+ params: params,
322
+ accept_json: true
323
+ )
324
+ response
325
+ end
326
+
327
+ ##
328
+ # @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, append: nil)
329
+ # Update workspace.
330
+ # Update an existing workspace with new or modified data. You must provide component
331
+ # objects defining the content of the updated workspace.
332
+ #
333
+ # This operation is limited to 30 request per 30 minutes. For more information, see
334
+ # **Rate limiting**.
335
+ # @param workspace_id [String] Unique identifier of the workspace.
336
+ # @param name [String] The name of the workspace. This string cannot contain carriage return, newline, or
337
+ # tab characters, and it must be no longer than 64 characters.
338
+ # @param description [String] The description of the workspace. This string cannot contain carriage return,
339
+ # newline, or tab characters, and it must be no longer than 128 characters.
340
+ # @param language [String] The language of the workspace.
341
+ # @param intents [Array[CreateIntent]] An array of objects defining the intents for the workspace.
342
+ # @param entities [Array[CreateEntity]] An array of objects defining the entities for the workspace.
343
+ # @param dialog_nodes [Array[CreateDialogNode]] An array of objects defining the nodes in the workspace dialog.
344
+ # @param counterexamples [Array[CreateCounterexample]] An array of objects defining input examples that have been marked as irrelevant
345
+ # input.
346
+ # @param metadata [Object] Any metadata related to the workspace.
347
+ # @param learning_opt_out [Boolean] Whether training data from the workspace can be used by IBM for general service
348
+ # improvements. `true` indicates that workspace training data is not to be used.
349
+ # @param append [Boolean] Whether the new data is to be appended to the existing data in the workspace. If
350
+ # **append**=`false`, elements included in the new data completely replace the
351
+ # corresponding existing elements, including all subelements. For example, if the
352
+ # new data includes **entities** and **append**=`false`, all existing entities in
353
+ # the workspace are discarded and replaced with the new entities.
354
+ #
355
+ # If **append**=`true`, existing elements are preserved, and the new elements are
356
+ # added. If any elements in the new data collide with existing elements, the update
357
+ # request fails.
358
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
359
+ def update_workspace(workspace_id:, name: nil, description: nil, language: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, metadata: nil, learning_opt_out: nil, append: nil)
360
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
361
+ headers = {
362
+ }
363
+ params = {
364
+ "version" => @version,
365
+ "append" => append
366
+ }
367
+ data = {
368
+ "name" => name,
369
+ "description" => description,
370
+ "language" => language,
371
+ "intents" => intents,
372
+ "entities" => entities,
373
+ "dialog_nodes" => dialog_nodes,
374
+ "counterexamples" => counterexamples,
375
+ "metadata" => metadata,
376
+ "learning_opt_out" => learning_opt_out
377
+ }
378
+ method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
379
+ response = request(
380
+ method: "POST",
381
+ url: method_url,
382
+ headers: headers,
383
+ params: params,
384
+ json: data,
385
+ accept_json: true
386
+ )
387
+ response
388
+ end
389
+
390
+ ##
391
+ # @!method delete_workspace(workspace_id:)
392
+ # Delete workspace.
393
+ # Delete a workspace from the service instance.
394
+ #
395
+ # This operation is limited to 30 requests per 30 minutes. For more information, see
396
+ # **Rate limiting**.
397
+ # @param workspace_id [String] Unique identifier of the workspace.
398
+ # @return [nil]
399
+ def delete_workspace(workspace_id:)
400
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
401
+ headers = {
402
+ }
403
+ params = {
404
+ "version" => @version
405
+ }
406
+ method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
407
+ request(
408
+ method: "DELETE",
409
+ url: method_url,
410
+ headers: headers,
411
+ params: params,
412
+ accept_json: true
413
+ )
414
+ nil
415
+ end
416
+ #########################
417
+ # Intents
418
+ #########################
419
+
420
+ ##
421
+ # @!method list_intents(workspace_id:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
422
+ # List intents.
423
+ # List the intents for a workspace.
424
+ #
425
+ # With **export**=`false`, this operation is limited to 2000 requests per 30
426
+ # minutes. With **export**=`true`, the limit is 400 requests per 30 minutes. For
427
+ # more information, see **Rate limiting**.
428
+ # @param workspace_id [String] Unique identifier of the workspace.
429
+ # @param export [Boolean] Whether to include all element content in the returned data. If
430
+ # **export**=`false`, the returned data includes only information about the element
431
+ # itself. If **export**=`true`, all content, including subelements, is included.
432
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
433
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
434
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
435
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
436
+ # and `workspace_id`.
437
+ # @param cursor [String] A token identifying the page of results to retrieve.
438
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
439
+ # the response.
440
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
441
+ def list_intents(workspace_id:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
442
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
443
+ headers = {
444
+ }
445
+ params = {
446
+ "version" => @version,
447
+ "export" => export,
448
+ "page_limit" => page_limit,
449
+ "include_count" => include_count,
450
+ "sort" => sort,
451
+ "cursor" => cursor,
452
+ "include_audit" => include_audit
453
+ }
454
+ method_url = "/v1/workspaces/%s/intents" % [ERB::Util.url_encode(workspace_id)]
455
+ response = request(
456
+ method: "GET",
457
+ url: method_url,
458
+ headers: headers,
459
+ params: params,
460
+ accept_json: true
461
+ )
462
+ response
463
+ end
464
+
465
+ ##
466
+ # @!method create_intent(workspace_id:, intent:, description: nil, examples: nil)
467
+ # Create intent.
468
+ # Create a new intent.
469
+ #
470
+ # This operation is limited to 2000 requests per 30 minutes. For more information,
471
+ # see **Rate limiting**.
472
+ # @param workspace_id [String] Unique identifier of the workspace.
473
+ # @param intent [String] The name of the intent. This string must conform to the following restrictions:
474
+ # - It can contain only Unicode alphanumeric, underscore, hyphen, and dot
475
+ # characters.
476
+ # - It cannot begin with the reserved prefix `sys-`.
477
+ # - It must be no longer than 128 characters.
478
+ # @param description [String] The description of the intent. This string cannot contain carriage return,
479
+ # newline, or tab characters, and it must be no longer than 128 characters.
480
+ # @param examples [Array[CreateExample]] An array of user input examples for the intent.
481
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
482
+ def create_intent(workspace_id:, intent:, description: nil, examples: nil)
483
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
484
+ raise ArgumentError("intent must be provided") if intent.nil?
485
+ headers = {
486
+ }
487
+ params = {
488
+ "version" => @version
489
+ }
490
+ data = {
491
+ "intent" => intent,
492
+ "description" => description,
493
+ "examples" => examples
494
+ }
495
+ method_url = "/v1/workspaces/%s/intents" % [ERB::Util.url_encode(workspace_id)]
496
+ response = request(
497
+ method: "POST",
498
+ url: method_url,
499
+ headers: headers,
500
+ params: params,
501
+ json: data,
502
+ accept_json: true
503
+ )
504
+ response
505
+ end
506
+
507
+ ##
508
+ # @!method get_intent(workspace_id:, intent:, export: nil, include_audit: nil)
509
+ # Get intent.
510
+ # Get information about an intent, optionally including all intent content.
511
+ #
512
+ # With **export**=`false`, this operation is limited to 6000 requests per 5 minutes.
513
+ # With **export**=`true`, the limit is 400 requests per 30 minutes. For more
514
+ # information, see **Rate limiting**.
515
+ # @param workspace_id [String] Unique identifier of the workspace.
516
+ # @param intent [String] The intent name.
517
+ # @param export [Boolean] Whether to include all element content in the returned data. If
518
+ # **export**=`false`, the returned data includes only information about the element
519
+ # itself. If **export**=`true`, all content, including subelements, is included.
520
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
521
+ # the response.
522
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
523
+ def get_intent(workspace_id:, intent:, export: nil, include_audit: nil)
524
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
525
+ raise ArgumentError("intent must be provided") if intent.nil?
526
+ headers = {
527
+ }
528
+ params = {
529
+ "version" => @version,
530
+ "export" => export,
531
+ "include_audit" => include_audit
532
+ }
533
+ method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
534
+ response = request(
535
+ method: "GET",
536
+ url: method_url,
537
+ headers: headers,
538
+ params: params,
539
+ accept_json: true
540
+ )
541
+ response
542
+ end
543
+
544
+ ##
545
+ # @!method update_intent(workspace_id:, intent:, new_intent: nil, new_description: nil, new_examples: nil)
546
+ # Update intent.
547
+ # Update an existing intent with new or modified data. You must provide component
548
+ # objects defining the content of the updated intent.
549
+ #
550
+ # This operation is limited to 2000 requests per 30 minutes. For more information,
551
+ # see **Rate limiting**.
552
+ # @param workspace_id [String] Unique identifier of the workspace.
553
+ # @param intent [String] The intent name.
554
+ # @param new_intent [String] The name of the intent. This string must conform to the following restrictions:
555
+ # - It can contain only Unicode alphanumeric, underscore, hyphen, and dot
556
+ # characters.
557
+ # - It cannot begin with the reserved prefix `sys-`.
558
+ # - It must be no longer than 128 characters.
559
+ # @param new_description [String] The description of the intent.
560
+ # @param new_examples [Array[CreateExample]] An array of user input examples for the intent.
561
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
562
+ def update_intent(workspace_id:, intent:, new_intent: nil, new_description: nil, new_examples: nil)
563
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
564
+ raise ArgumentError("intent must be provided") if intent.nil?
565
+ headers = {
566
+ }
567
+ params = {
568
+ "version" => @version
569
+ }
570
+ data = {
571
+ "intent" => new_intent,
572
+ "description" => new_description,
573
+ "examples" => new_examples
574
+ }
575
+ method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
576
+ response = request(
577
+ method: "POST",
578
+ url: method_url,
579
+ headers: headers,
580
+ params: params,
581
+ json: data,
582
+ accept_json: true
583
+ )
584
+ response
585
+ end
586
+
587
+ ##
588
+ # @!method delete_intent(workspace_id:, intent:)
589
+ # Delete intent.
590
+ # Delete an intent from a workspace.
591
+ #
592
+ # This operation is limited to 2000 requests per 30 minutes. For more information,
593
+ # see **Rate limiting**.
594
+ # @param workspace_id [String] Unique identifier of the workspace.
595
+ # @param intent [String] The intent name.
596
+ # @return [nil]
597
+ def delete_intent(workspace_id:, intent:)
598
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
599
+ raise ArgumentError("intent must be provided") if intent.nil?
600
+ headers = {
601
+ }
602
+ params = {
603
+ "version" => @version
604
+ }
605
+ method_url = "/v1/workspaces/%s/intents/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
606
+ request(
607
+ method: "DELETE",
608
+ url: method_url,
609
+ headers: headers,
610
+ params: params,
611
+ accept_json: true
612
+ )
613
+ nil
614
+ end
615
+ #########################
616
+ # Examples
617
+ #########################
618
+
619
+ ##
620
+ # @!method list_examples(workspace_id:, intent:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
621
+ # List user input examples.
622
+ # List the user input examples for an intent.
623
+ #
624
+ # This operation is limited to 2500 requests per 30 minutes. For more information,
625
+ # see **Rate limiting**.
626
+ # @param workspace_id [String] Unique identifier of the workspace.
627
+ # @param intent [String] The intent name.
628
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
629
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
630
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
631
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
632
+ # and `workspace_id`.
633
+ # @param cursor [String] A token identifying the page of results to retrieve.
634
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
635
+ # the response.
636
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
637
+ def list_examples(workspace_id:, intent:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
638
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
639
+ raise ArgumentError("intent must be provided") if intent.nil?
640
+ headers = {
641
+ }
642
+ params = {
643
+ "version" => @version,
644
+ "page_limit" => page_limit,
645
+ "include_count" => include_count,
646
+ "sort" => sort,
647
+ "cursor" => cursor,
648
+ "include_audit" => include_audit
649
+ }
650
+ method_url = "/v1/workspaces/%s/intents/%s/examples" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
651
+ response = request(
652
+ method: "GET",
653
+ url: method_url,
654
+ headers: headers,
655
+ params: params,
656
+ accept_json: true
657
+ )
658
+ response
659
+ end
660
+
661
+ ##
662
+ # @!method create_example(workspace_id:, intent:, text:)
663
+ # Create user input example.
664
+ # Add a new user input example to an intent.
665
+ #
666
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
667
+ # see **Rate limiting**.
668
+ # @param workspace_id [String] Unique identifier of the workspace.
669
+ # @param intent [String] The intent name.
670
+ # @param text [String] The text of a user input example. This string must conform to the following
671
+ # restrictions:
672
+ # - It cannot contain carriage return, newline, or tab characters.
673
+ # - It cannot consist of only whitespace characters.
674
+ # - It must be no longer than 1024 characters.
675
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
676
+ def create_example(workspace_id:, intent:, text:)
677
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
678
+ raise ArgumentError("intent must be provided") if intent.nil?
679
+ raise ArgumentError("text must be provided") if text.nil?
680
+ headers = {
681
+ }
682
+ params = {
683
+ "version" => @version
684
+ }
685
+ data = {
686
+ "text" => text
687
+ }
688
+ method_url = "/v1/workspaces/%s/intents/%s/examples" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent)]
689
+ response = request(
690
+ method: "POST",
691
+ url: method_url,
692
+ headers: headers,
693
+ params: params,
694
+ json: data,
695
+ accept_json: true
696
+ )
697
+ response
698
+ end
699
+
700
+ ##
701
+ # @!method get_example(workspace_id:, intent:, text:, include_audit: nil)
702
+ # Get user input example.
703
+ # Get information about a user input example.
704
+ #
705
+ # This operation is limited to 6000 requests per 5 minutes. For more information,
706
+ # see **Rate limiting**.
707
+ # @param workspace_id [String] Unique identifier of the workspace.
708
+ # @param intent [String] The intent name.
709
+ # @param text [String] The text of the user input example.
710
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
711
+ # the response.
712
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
713
+ def get_example(workspace_id:, intent:, text:, include_audit: nil)
714
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
715
+ raise ArgumentError("intent must be provided") if intent.nil?
716
+ raise ArgumentError("text must be provided") if text.nil?
717
+ headers = {
718
+ }
719
+ params = {
720
+ "version" => @version,
721
+ "include_audit" => include_audit
722
+ }
723
+ method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
724
+ response = request(
725
+ method: "GET",
726
+ url: method_url,
727
+ headers: headers,
728
+ params: params,
729
+ accept_json: true
730
+ )
731
+ response
732
+ end
733
+
734
+ ##
735
+ # @!method update_example(workspace_id:, intent:, text:, new_text: nil)
736
+ # Update user input example.
737
+ # Update the text of a user input example.
738
+ #
739
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
740
+ # see **Rate limiting**.
741
+ # @param workspace_id [String] Unique identifier of the workspace.
742
+ # @param intent [String] The intent name.
743
+ # @param text [String] The text of the user input example.
744
+ # @param new_text [String] The text of the user input example. This string must conform to the following
745
+ # restrictions:
746
+ # - It cannot contain carriage return, newline, or tab characters.
747
+ # - It cannot consist of only whitespace characters.
748
+ # - It must be no longer than 1024 characters.
749
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
750
+ def update_example(workspace_id:, intent:, text:, new_text: nil)
751
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
752
+ raise ArgumentError("intent must be provided") if intent.nil?
753
+ raise ArgumentError("text must be provided") if text.nil?
754
+ headers = {
755
+ }
756
+ params = {
757
+ "version" => @version
758
+ }
759
+ data = {
760
+ "text" => new_text
761
+ }
762
+ method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
763
+ response = request(
764
+ method: "POST",
765
+ url: method_url,
766
+ headers: headers,
767
+ params: params,
768
+ json: data,
769
+ accept_json: true
770
+ )
771
+ response
772
+ end
773
+
774
+ ##
775
+ # @!method delete_example(workspace_id:, intent:, text:)
776
+ # Delete user input example.
777
+ # Delete a user input example from an intent.
778
+ #
779
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
780
+ # see **Rate limiting**.
781
+ # @param workspace_id [String] Unique identifier of the workspace.
782
+ # @param intent [String] The intent name.
783
+ # @param text [String] The text of the user input example.
784
+ # @return [nil]
785
+ def delete_example(workspace_id:, intent:, text:)
786
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
787
+ raise ArgumentError("intent must be provided") if intent.nil?
788
+ raise ArgumentError("text must be provided") if text.nil?
789
+ headers = {
790
+ }
791
+ params = {
792
+ "version" => @version
793
+ }
794
+ method_url = "/v1/workspaces/%s/intents/%s/examples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(intent), ERB::Util.url_encode(text)]
795
+ request(
796
+ method: "DELETE",
797
+ url: method_url,
798
+ headers: headers,
799
+ params: params,
800
+ accept_json: true
801
+ )
802
+ nil
803
+ end
804
+ #########################
805
+ # Counterexamples
806
+ #########################
807
+
808
+ ##
809
+ # @!method list_counterexamples(workspace_id:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
810
+ # List counterexamples.
811
+ # List the counterexamples for a workspace. Counterexamples are examples that have
812
+ # been marked as irrelevant input.
813
+ #
814
+ # This operation is limited to 2500 requests per 30 minutes. For more information,
815
+ # see **Rate limiting**.
816
+ # @param workspace_id [String] Unique identifier of the workspace.
817
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
818
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
819
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
820
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
821
+ # and `workspace_id`.
822
+ # @param cursor [String] A token identifying the page of results to retrieve.
823
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
824
+ # the response.
825
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
826
+ def list_counterexamples(workspace_id:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
827
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
828
+ headers = {
829
+ }
830
+ params = {
831
+ "version" => @version,
832
+ "page_limit" => page_limit,
833
+ "include_count" => include_count,
834
+ "sort" => sort,
835
+ "cursor" => cursor,
836
+ "include_audit" => include_audit
837
+ }
838
+ method_url = "/v1/workspaces/%s/counterexamples" % [ERB::Util.url_encode(workspace_id)]
839
+ response = request(
840
+ method: "GET",
841
+ url: method_url,
842
+ headers: headers,
843
+ params: params,
844
+ accept_json: true
845
+ )
846
+ response
847
+ end
848
+
849
+ ##
850
+ # @!method create_counterexample(workspace_id:, text:)
851
+ # Create counterexample.
852
+ # Add a new counterexample to a workspace. Counterexamples are examples that have
853
+ # been marked as irrelevant input.
854
+ #
855
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
856
+ # see **Rate limiting**.
857
+ # @param workspace_id [String] Unique identifier of the workspace.
858
+ # @param text [String] The text of a user input marked as irrelevant input. This string must conform to
859
+ # the following restrictions:
860
+ # - It cannot contain carriage return, newline, or tab characters
861
+ # - It cannot consist of only whitespace characters
862
+ # - It must be no longer than 1024 characters.
863
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
864
+ def create_counterexample(workspace_id:, text:)
865
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
866
+ raise ArgumentError("text must be provided") if text.nil?
867
+ headers = {
868
+ }
869
+ params = {
870
+ "version" => @version
871
+ }
872
+ data = {
873
+ "text" => text
874
+ }
875
+ method_url = "/v1/workspaces/%s/counterexamples" % [ERB::Util.url_encode(workspace_id)]
876
+ response = request(
877
+ method: "POST",
878
+ url: method_url,
879
+ headers: headers,
880
+ params: params,
881
+ json: data,
882
+ accept_json: true
883
+ )
884
+ response
885
+ end
886
+
887
+ ##
888
+ # @!method get_counterexample(workspace_id:, text:, include_audit: nil)
889
+ # Get counterexample.
890
+ # Get information about a counterexample. Counterexamples are examples that have
891
+ # been marked as irrelevant input.
892
+ #
893
+ # This operation is limited to 6000 requests per 5 minutes. For more information,
894
+ # see **Rate limiting**.
895
+ # @param workspace_id [String] Unique identifier of the workspace.
896
+ # @param text [String] The text of a user input counterexample (for example, `What are you wearing?`).
897
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
898
+ # the response.
899
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
900
+ def get_counterexample(workspace_id:, text:, include_audit: nil)
901
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
902
+ raise ArgumentError("text must be provided") if text.nil?
903
+ headers = {
904
+ }
905
+ params = {
906
+ "version" => @version,
907
+ "include_audit" => include_audit
908
+ }
909
+ method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
910
+ response = request(
911
+ method: "GET",
912
+ url: method_url,
913
+ headers: headers,
914
+ params: params,
915
+ accept_json: true
916
+ )
917
+ response
918
+ end
919
+
920
+ ##
921
+ # @!method update_counterexample(workspace_id:, text:, new_text: nil)
922
+ # Update counterexample.
923
+ # Update the text of a counterexample. Counterexamples are examples that have been
924
+ # marked as irrelevant input.
925
+ #
926
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
927
+ # see **Rate limiting**.
928
+ # @param workspace_id [String] Unique identifier of the workspace.
929
+ # @param text [String] The text of a user input counterexample (for example, `What are you wearing?`).
930
+ # @param new_text [String] The text of a user input counterexample.
931
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
932
+ def update_counterexample(workspace_id:, text:, new_text: nil)
933
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
934
+ raise ArgumentError("text must be provided") if text.nil?
935
+ headers = {
936
+ }
937
+ params = {
938
+ "version" => @version
939
+ }
940
+ data = {
941
+ "text" => new_text
942
+ }
943
+ method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
944
+ response = request(
945
+ method: "POST",
946
+ url: method_url,
947
+ headers: headers,
948
+ params: params,
949
+ json: data,
950
+ accept_json: true
951
+ )
952
+ response
953
+ end
954
+
955
+ ##
956
+ # @!method delete_counterexample(workspace_id:, text:)
957
+ # Delete counterexample.
958
+ # Delete a counterexample from a workspace. Counterexamples are examples that have
959
+ # been marked as irrelevant input.
960
+ #
961
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
962
+ # see **Rate limiting**.
963
+ # @param workspace_id [String] Unique identifier of the workspace.
964
+ # @param text [String] The text of a user input counterexample (for example, `What are you wearing?`).
965
+ # @return [nil]
966
+ def delete_counterexample(workspace_id:, text:)
967
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
968
+ raise ArgumentError("text must be provided") if text.nil?
969
+ headers = {
970
+ }
971
+ params = {
972
+ "version" => @version
973
+ }
974
+ method_url = "/v1/workspaces/%s/counterexamples/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(text)]
975
+ request(
976
+ method: "DELETE",
977
+ url: method_url,
978
+ headers: headers,
979
+ params: params,
980
+ accept_json: true
981
+ )
982
+ nil
983
+ end
984
+ #########################
985
+ # Entities
986
+ #########################
987
+
988
+ ##
989
+ # @!method list_entities(workspace_id:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
990
+ # List entities.
991
+ # List the entities for a workspace.
992
+ #
993
+ # With **export**=`false`, this operation is limited to 1000 requests per 30
994
+ # minutes. With **export**=`true`, the limit is 200 requests per 30 minutes. For
995
+ # more information, see **Rate limiting**.
996
+ # @param workspace_id [String] Unique identifier of the workspace.
997
+ # @param export [Boolean] Whether to include all element content in the returned data. If
998
+ # **export**=`false`, the returned data includes only information about the element
999
+ # itself. If **export**=`true`, all content, including subelements, is included.
1000
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1001
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
1002
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1003
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1004
+ # and `workspace_id`.
1005
+ # @param cursor [String] A token identifying the page of results to retrieve.
1006
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1007
+ # the response.
1008
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1009
+ def list_entities(workspace_id:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1010
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1011
+ headers = {
1012
+ }
1013
+ params = {
1014
+ "version" => @version,
1015
+ "export" => export,
1016
+ "page_limit" => page_limit,
1017
+ "include_count" => include_count,
1018
+ "sort" => sort,
1019
+ "cursor" => cursor,
1020
+ "include_audit" => include_audit
1021
+ }
1022
+ method_url = "/v1/workspaces/%s/entities" % [ERB::Util.url_encode(workspace_id)]
1023
+ response = request(
1024
+ method: "GET",
1025
+ url: method_url,
1026
+ headers: headers,
1027
+ params: params,
1028
+ accept_json: true
1029
+ )
1030
+ response
1031
+ end
1032
+
1033
+ ##
1034
+ # @!method create_entity(workspace_id:, entity:, description: nil, metadata: nil, values: nil, fuzzy_match: nil)
1035
+ # Create entity.
1036
+ # Create a new entity.
1037
+ #
1038
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1039
+ # see **Rate limiting**.
1040
+ # @param workspace_id [String] Unique identifier of the workspace.
1041
+ # @param entity [String] The name of the entity. This string must conform to the following restrictions:
1042
+ # - It can contain only Unicode alphanumeric, underscore, and hyphen characters.
1043
+ # - It cannot begin with the reserved prefix `sys-`.
1044
+ # - It must be no longer than 64 characters.
1045
+ # @param description [String] The description of the entity. This string cannot contain carriage return,
1046
+ # newline, or tab characters, and it must be no longer than 128 characters.
1047
+ # @param metadata [Object] Any metadata related to the value.
1048
+ # @param values [Array[CreateValue]] An array of objects describing the entity values.
1049
+ # @param fuzzy_match [Boolean] Whether to use fuzzy matching for the entity.
1050
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1051
+ def create_entity(workspace_id:, entity:, description: nil, metadata: nil, values: nil, fuzzy_match: nil)
1052
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1053
+ raise ArgumentError("entity must be provided") if entity.nil?
1054
+ headers = {
1055
+ }
1056
+ params = {
1057
+ "version" => @version
1058
+ }
1059
+ data = {
1060
+ "entity" => entity,
1061
+ "description" => description,
1062
+ "metadata" => metadata,
1063
+ "values" => values,
1064
+ "fuzzy_match" => fuzzy_match
1065
+ }
1066
+ method_url = "/v1/workspaces/%s/entities" % [ERB::Util.url_encode(workspace_id)]
1067
+ response = request(
1068
+ method: "POST",
1069
+ url: method_url,
1070
+ headers: headers,
1071
+ params: params,
1072
+ json: data,
1073
+ accept_json: true
1074
+ )
1075
+ response
1076
+ end
1077
+
1078
+ ##
1079
+ # @!method get_entity(workspace_id:, entity:, export: nil, include_audit: nil)
1080
+ # Get entity.
1081
+ # Get information about an entity, optionally including all entity content.
1082
+ #
1083
+ # With **export**=`false`, this operation is limited to 6000 requests per 5 minutes.
1084
+ # With **export**=`true`, the limit is 200 requests per 30 minutes. For more
1085
+ # information, see **Rate limiting**.
1086
+ # @param workspace_id [String] Unique identifier of the workspace.
1087
+ # @param entity [String] The name of the entity.
1088
+ # @param export [Boolean] Whether to include all element content in the returned data. If
1089
+ # **export**=`false`, the returned data includes only information about the element
1090
+ # itself. If **export**=`true`, all content, including subelements, is included.
1091
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1092
+ # the response.
1093
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1094
+ def get_entity(workspace_id:, entity:, export: nil, include_audit: nil)
1095
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1096
+ raise ArgumentError("entity must be provided") if entity.nil?
1097
+ headers = {
1098
+ }
1099
+ params = {
1100
+ "version" => @version,
1101
+ "export" => export,
1102
+ "include_audit" => include_audit
1103
+ }
1104
+ method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1105
+ response = request(
1106
+ method: "GET",
1107
+ url: method_url,
1108
+ headers: headers,
1109
+ params: params,
1110
+ accept_json: true
1111
+ )
1112
+ response
1113
+ end
1114
+
1115
+ ##
1116
+ # @!method update_entity(workspace_id:, entity:, new_entity: nil, new_description: nil, new_metadata: nil, new_fuzzy_match: nil, new_values: nil)
1117
+ # Update entity.
1118
+ # Update an existing entity with new or modified data. You must provide component
1119
+ # objects defining the content of the updated entity.
1120
+ #
1121
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1122
+ # see **Rate limiting**.
1123
+ # @param workspace_id [String] Unique identifier of the workspace.
1124
+ # @param entity [String] The name of the entity.
1125
+ # @param new_entity [String] The name of the entity. This string must conform to the following restrictions:
1126
+ # - It can contain only Unicode alphanumeric, underscore, and hyphen characters.
1127
+ # - It cannot begin with the reserved prefix `sys-`.
1128
+ # - It must be no longer than 64 characters.
1129
+ # @param new_description [String] The description of the entity. This string cannot contain carriage return,
1130
+ # newline, or tab characters, and it must be no longer than 128 characters.
1131
+ # @param new_metadata [Object] Any metadata related to the entity.
1132
+ # @param new_fuzzy_match [Boolean] Whether to use fuzzy matching for the entity.
1133
+ # @param new_values [Array[CreateValue]] An array of entity values.
1134
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1135
+ def update_entity(workspace_id:, entity:, new_entity: nil, new_description: nil, new_metadata: nil, new_fuzzy_match: nil, new_values: nil)
1136
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1137
+ raise ArgumentError("entity must be provided") if entity.nil?
1138
+ headers = {
1139
+ }
1140
+ params = {
1141
+ "version" => @version
1142
+ }
1143
+ data = {
1144
+ "entity" => new_entity,
1145
+ "description" => new_description,
1146
+ "metadata" => new_metadata,
1147
+ "fuzzy_match" => new_fuzzy_match,
1148
+ "values" => new_values
1149
+ }
1150
+ method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1151
+ response = request(
1152
+ method: "POST",
1153
+ url: method_url,
1154
+ headers: headers,
1155
+ params: params,
1156
+ json: data,
1157
+ accept_json: true
1158
+ )
1159
+ response
1160
+ end
1161
+
1162
+ ##
1163
+ # @!method delete_entity(workspace_id:, entity:)
1164
+ # Delete entity.
1165
+ # Delete an entity from a workspace.
1166
+ #
1167
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1168
+ # see **Rate limiting**.
1169
+ # @param workspace_id [String] Unique identifier of the workspace.
1170
+ # @param entity [String] The name of the entity.
1171
+ # @return [nil]
1172
+ def delete_entity(workspace_id:, entity:)
1173
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1174
+ raise ArgumentError("entity must be provided") if entity.nil?
1175
+ headers = {
1176
+ }
1177
+ params = {
1178
+ "version" => @version
1179
+ }
1180
+ method_url = "/v1/workspaces/%s/entities/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1181
+ request(
1182
+ method: "DELETE",
1183
+ url: method_url,
1184
+ headers: headers,
1185
+ params: params,
1186
+ accept_json: true
1187
+ )
1188
+ nil
1189
+ end
1190
+ #########################
1191
+ # Values
1192
+ #########################
1193
+
1194
+ ##
1195
+ # @!method list_values(workspace_id:, entity:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1196
+ # List entity values.
1197
+ # List the values for an entity.
1198
+ #
1199
+ # This operation is limited to 2500 requests per 30 minutes. For more information,
1200
+ # see **Rate limiting**.
1201
+ # @param workspace_id [String] Unique identifier of the workspace.
1202
+ # @param entity [String] The name of the entity.
1203
+ # @param export [Boolean] Whether to include all element content in the returned data. If
1204
+ # **export**=`false`, the returned data includes only information about the element
1205
+ # itself. If **export**=`true`, all content, including subelements, is included.
1206
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1207
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
1208
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1209
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1210
+ # and `workspace_id`.
1211
+ # @param cursor [String] A token identifying the page of results to retrieve.
1212
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1213
+ # the response.
1214
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1215
+ def list_values(workspace_id:, entity:, export: nil, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1216
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1217
+ raise ArgumentError("entity must be provided") if entity.nil?
1218
+ headers = {
1219
+ }
1220
+ params = {
1221
+ "version" => @version,
1222
+ "export" => export,
1223
+ "page_limit" => page_limit,
1224
+ "include_count" => include_count,
1225
+ "sort" => sort,
1226
+ "cursor" => cursor,
1227
+ "include_audit" => include_audit
1228
+ }
1229
+ method_url = "/v1/workspaces/%s/entities/%s/values" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1230
+ response = request(
1231
+ method: "GET",
1232
+ url: method_url,
1233
+ headers: headers,
1234
+ params: params,
1235
+ accept_json: true
1236
+ )
1237
+ response
1238
+ end
1239
+
1240
+ ##
1241
+ # @!method create_value(workspace_id:, entity:, value:, metadata: nil, synonyms: nil, patterns: nil, value_type: nil)
1242
+ # Add entity value.
1243
+ # Create a new value for an entity.
1244
+ #
1245
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1246
+ # see **Rate limiting**.
1247
+ # @param workspace_id [String] Unique identifier of the workspace.
1248
+ # @param entity [String] The name of the entity.
1249
+ # @param value [String] The text of the entity value. This string must conform to the following
1250
+ # restrictions:
1251
+ # - It cannot contain carriage return, newline, or tab characters.
1252
+ # - It cannot consist of only whitespace characters.
1253
+ # - It must be no longer than 64 characters.
1254
+ # @param metadata [Object] Any metadata related to the entity value.
1255
+ # @param synonyms [Array[String]] An array containing any synonyms for the entity value. You can provide either
1256
+ # synonyms or patterns (as indicated by **type**), but not both. A synonym must
1257
+ # conform to the following restrictions:
1258
+ # - It cannot contain carriage return, newline, or tab characters.
1259
+ # - It cannot consist of only whitespace characters.
1260
+ # - It must be no longer than 64 characters.
1261
+ # @param patterns [Array[String]] An array of patterns for the entity value. You can provide either synonyms or
1262
+ # patterns (as indicated by **type**), but not both. A pattern is a regular
1263
+ # expression no longer than 512 characters. For more information about how to
1264
+ # specify a pattern, see the
1265
+ # [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities).
1266
+ # @param value_type [String] Specifies the type of value.
1267
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1268
+ def create_value(workspace_id:, entity:, value:, metadata: nil, synonyms: nil, patterns: nil, value_type: nil)
1269
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1270
+ raise ArgumentError("entity must be provided") if entity.nil?
1271
+ raise ArgumentError("value must be provided") if value.nil?
1272
+ headers = {
1273
+ }
1274
+ params = {
1275
+ "version" => @version
1276
+ }
1277
+ data = {
1278
+ "value" => value,
1279
+ "metadata" => metadata,
1280
+ "synonyms" => synonyms,
1281
+ "patterns" => patterns,
1282
+ "type" => value_type
1283
+ }
1284
+ method_url = "/v1/workspaces/%s/entities/%s/values" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity)]
1285
+ response = request(
1286
+ method: "POST",
1287
+ url: method_url,
1288
+ headers: headers,
1289
+ params: params,
1290
+ json: data,
1291
+ accept_json: true
1292
+ )
1293
+ response
1294
+ end
1295
+
1296
+ ##
1297
+ # @!method get_value(workspace_id:, entity:, value:, export: nil, include_audit: nil)
1298
+ # Get entity value.
1299
+ # Get information about an entity value.
1300
+ #
1301
+ # This operation is limited to 6000 requests per 5 minutes. For more information,
1302
+ # see **Rate limiting**.
1303
+ # @param workspace_id [String] Unique identifier of the workspace.
1304
+ # @param entity [String] The name of the entity.
1305
+ # @param value [String] The text of the entity value.
1306
+ # @param export [Boolean] Whether to include all element content in the returned data. If
1307
+ # **export**=`false`, the returned data includes only information about the element
1308
+ # itself. If **export**=`true`, all content, including subelements, is included.
1309
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1310
+ # the response.
1311
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1312
+ def get_value(workspace_id:, entity:, value:, export: nil, include_audit: nil)
1313
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1314
+ raise ArgumentError("entity must be provided") if entity.nil?
1315
+ raise ArgumentError("value must be provided") if value.nil?
1316
+ headers = {
1317
+ }
1318
+ params = {
1319
+ "version" => @version,
1320
+ "export" => export,
1321
+ "include_audit" => include_audit
1322
+ }
1323
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1324
+ response = request(
1325
+ method: "GET",
1326
+ url: method_url,
1327
+ headers: headers,
1328
+ params: params,
1329
+ accept_json: true
1330
+ )
1331
+ response
1332
+ end
1333
+
1334
+ ##
1335
+ # @!method update_value(workspace_id:, entity:, value:, new_value: nil, new_metadata: nil, new_type: nil, new_synonyms: nil, new_patterns: nil)
1336
+ # Update entity value.
1337
+ # Update an existing entity value with new or modified data. You must provide
1338
+ # component objects defining the content of the updated entity value.
1339
+ #
1340
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1341
+ # see **Rate limiting**.
1342
+ # @param workspace_id [String] Unique identifier of the workspace.
1343
+ # @param entity [String] The name of the entity.
1344
+ # @param value [String] The text of the entity value.
1345
+ # @param new_value [String] The text of the entity value. This string must conform to the following
1346
+ # restrictions:
1347
+ # - It cannot contain carriage return, newline, or tab characters.
1348
+ # - It cannot consist of only whitespace characters.
1349
+ # - It must be no longer than 64 characters.
1350
+ # @param new_metadata [Object] Any metadata related to the entity value.
1351
+ # @param new_type [String] Specifies the type of value.
1352
+ # @param new_synonyms [Array[String]] An array of synonyms for the entity value. You can provide either synonyms or
1353
+ # patterns (as indicated by **type**), but not both. A synonym must conform to the
1354
+ # following resrictions:
1355
+ # - It cannot contain carriage return, newline, or tab characters.
1356
+ # - It cannot consist of only whitespace characters.
1357
+ # - It must be no longer than 64 characters.
1358
+ # @param new_patterns [Array[String]] An array of patterns for the entity value. You can provide either synonyms or
1359
+ # patterns (as indicated by **type**), but not both. A pattern is a regular
1360
+ # expression no longer than 512 characters. For more information about how to
1361
+ # specify a pattern, see the
1362
+ # [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities).
1363
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1364
+ def update_value(workspace_id:, entity:, value:, new_value: nil, new_metadata: nil, new_type: nil, new_synonyms: nil, new_patterns: nil)
1365
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1366
+ raise ArgumentError("entity must be provided") if entity.nil?
1367
+ raise ArgumentError("value must be provided") if value.nil?
1368
+ headers = {
1369
+ }
1370
+ params = {
1371
+ "version" => @version
1372
+ }
1373
+ data = {
1374
+ "value" => new_value,
1375
+ "metadata" => new_metadata,
1376
+ "type" => new_type,
1377
+ "synonyms" => new_synonyms,
1378
+ "patterns" => new_patterns
1379
+ }
1380
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1381
+ response = request(
1382
+ method: "POST",
1383
+ url: method_url,
1384
+ headers: headers,
1385
+ params: params,
1386
+ json: data,
1387
+ accept_json: true
1388
+ )
1389
+ response
1390
+ end
1391
+
1392
+ ##
1393
+ # @!method delete_value(workspace_id:, entity:, value:)
1394
+ # Delete entity value.
1395
+ # Delete a value from an entity.
1396
+ #
1397
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1398
+ # see **Rate limiting**.
1399
+ # @param workspace_id [String] Unique identifier of the workspace.
1400
+ # @param entity [String] The name of the entity.
1401
+ # @param value [String] The text of the entity value.
1402
+ # @return [nil]
1403
+ def delete_value(workspace_id:, entity:, value:)
1404
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1405
+ raise ArgumentError("entity must be provided") if entity.nil?
1406
+ raise ArgumentError("value must be provided") if value.nil?
1407
+ headers = {
1408
+ }
1409
+ params = {
1410
+ "version" => @version
1411
+ }
1412
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1413
+ request(
1414
+ method: "DELETE",
1415
+ url: method_url,
1416
+ headers: headers,
1417
+ params: params,
1418
+ accept_json: true
1419
+ )
1420
+ nil
1421
+ end
1422
+ #########################
1423
+ # Synonyms
1424
+ #########################
1425
+
1426
+ ##
1427
+ # @!method list_synonyms(workspace_id:, entity:, value:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1428
+ # List entity value synonyms.
1429
+ # List the synonyms for an entity value.
1430
+ #
1431
+ # This operation is limited to 2500 requests per 30 minutes. For more information,
1432
+ # see **Rate limiting**.
1433
+ # @param workspace_id [String] Unique identifier of the workspace.
1434
+ # @param entity [String] The name of the entity.
1435
+ # @param value [String] The text of the entity value.
1436
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1437
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
1438
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1439
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1440
+ # and `workspace_id`.
1441
+ # @param cursor [String] A token identifying the page of results to retrieve.
1442
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1443
+ # the response.
1444
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1445
+ def list_synonyms(workspace_id:, entity:, value:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1446
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1447
+ raise ArgumentError("entity must be provided") if entity.nil?
1448
+ raise ArgumentError("value must be provided") if value.nil?
1449
+ headers = {
1450
+ }
1451
+ params = {
1452
+ "version" => @version,
1453
+ "page_limit" => page_limit,
1454
+ "include_count" => include_count,
1455
+ "sort" => sort,
1456
+ "cursor" => cursor,
1457
+ "include_audit" => include_audit
1458
+ }
1459
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1460
+ response = request(
1461
+ method: "GET",
1462
+ url: method_url,
1463
+ headers: headers,
1464
+ params: params,
1465
+ accept_json: true
1466
+ )
1467
+ response
1468
+ end
1469
+
1470
+ ##
1471
+ # @!method create_synonym(workspace_id:, entity:, value:, synonym:)
1472
+ # Add entity value synonym.
1473
+ # Add a new synonym to an entity value.
1474
+ #
1475
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1476
+ # see **Rate limiting**.
1477
+ # @param workspace_id [String] Unique identifier of the workspace.
1478
+ # @param entity [String] The name of the entity.
1479
+ # @param value [String] The text of the entity value.
1480
+ # @param synonym [String] The text of the synonym. This string must conform to the following restrictions:
1481
+ # - It cannot contain carriage return, newline, or tab characters.
1482
+ # - It cannot consist of only whitespace characters.
1483
+ # - It must be no longer than 64 characters.
1484
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1485
+ def create_synonym(workspace_id:, entity:, value:, synonym:)
1486
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1487
+ raise ArgumentError("entity must be provided") if entity.nil?
1488
+ raise ArgumentError("value must be provided") if value.nil?
1489
+ raise ArgumentError("synonym must be provided") if synonym.nil?
1490
+ headers = {
1491
+ }
1492
+ params = {
1493
+ "version" => @version
1494
+ }
1495
+ data = {
1496
+ "synonym" => synonym
1497
+ }
1498
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value)]
1499
+ response = request(
1500
+ method: "POST",
1501
+ url: method_url,
1502
+ headers: headers,
1503
+ params: params,
1504
+ json: data,
1505
+ accept_json: true
1506
+ )
1507
+ response
1508
+ end
1509
+
1510
+ ##
1511
+ # @!method get_synonym(workspace_id:, entity:, value:, synonym:, include_audit: nil)
1512
+ # Get entity value synonym.
1513
+ # Get information about a synonym of an entity value.
1514
+ #
1515
+ # This operation is limited to 6000 requests per 5 minutes. For more information,
1516
+ # see **Rate limiting**.
1517
+ # @param workspace_id [String] Unique identifier of the workspace.
1518
+ # @param entity [String] The name of the entity.
1519
+ # @param value [String] The text of the entity value.
1520
+ # @param synonym [String] The text of the synonym.
1521
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1522
+ # the response.
1523
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1524
+ def get_synonym(workspace_id:, entity:, value:, synonym:, include_audit: nil)
1525
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1526
+ raise ArgumentError("entity must be provided") if entity.nil?
1527
+ raise ArgumentError("value must be provided") if value.nil?
1528
+ raise ArgumentError("synonym must be provided") if synonym.nil?
1529
+ headers = {
1530
+ }
1531
+ params = {
1532
+ "version" => @version,
1533
+ "include_audit" => include_audit
1534
+ }
1535
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1536
+ response = request(
1537
+ method: "GET",
1538
+ url: method_url,
1539
+ headers: headers,
1540
+ params: params,
1541
+ accept_json: true
1542
+ )
1543
+ response
1544
+ end
1545
+
1546
+ ##
1547
+ # @!method update_synonym(workspace_id:, entity:, value:, synonym:, new_synonym: nil)
1548
+ # Update entity value synonym.
1549
+ # Update an existing entity value synonym with new text.
1550
+ #
1551
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1552
+ # see **Rate limiting**.
1553
+ # @param workspace_id [String] Unique identifier of the workspace.
1554
+ # @param entity [String] The name of the entity.
1555
+ # @param value [String] The text of the entity value.
1556
+ # @param synonym [String] The text of the synonym.
1557
+ # @param new_synonym [String] The text of the synonym. This string must conform to the following restrictions:
1558
+ # - It cannot contain carriage return, newline, or tab characters.
1559
+ # - It cannot consist of only whitespace characters.
1560
+ # - It must be no longer than 64 characters.
1561
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1562
+ def update_synonym(workspace_id:, entity:, value:, synonym:, new_synonym: nil)
1563
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1564
+ raise ArgumentError("entity must be provided") if entity.nil?
1565
+ raise ArgumentError("value must be provided") if value.nil?
1566
+ raise ArgumentError("synonym must be provided") if synonym.nil?
1567
+ headers = {
1568
+ }
1569
+ params = {
1570
+ "version" => @version
1571
+ }
1572
+ data = {
1573
+ "synonym" => new_synonym
1574
+ }
1575
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1576
+ response = request(
1577
+ method: "POST",
1578
+ url: method_url,
1579
+ headers: headers,
1580
+ params: params,
1581
+ json: data,
1582
+ accept_json: true
1583
+ )
1584
+ response
1585
+ end
1586
+
1587
+ ##
1588
+ # @!method delete_synonym(workspace_id:, entity:, value:, synonym:)
1589
+ # Delete entity value synonym.
1590
+ # Delete a synonym from an entity value.
1591
+ #
1592
+ # This operation is limited to 1000 requests per 30 minutes. For more information,
1593
+ # see **Rate limiting**.
1594
+ # @param workspace_id [String] Unique identifier of the workspace.
1595
+ # @param entity [String] The name of the entity.
1596
+ # @param value [String] The text of the entity value.
1597
+ # @param synonym [String] The text of the synonym.
1598
+ # @return [nil]
1599
+ def delete_synonym(workspace_id:, entity:, value:, synonym:)
1600
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1601
+ raise ArgumentError("entity must be provided") if entity.nil?
1602
+ raise ArgumentError("value must be provided") if value.nil?
1603
+ raise ArgumentError("synonym must be provided") if synonym.nil?
1604
+ headers = {
1605
+ }
1606
+ params = {
1607
+ "version" => @version
1608
+ }
1609
+ method_url = "/v1/workspaces/%s/entities/%s/values/%s/synonyms/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(entity), ERB::Util.url_encode(value), ERB::Util.url_encode(synonym)]
1610
+ request(
1611
+ method: "DELETE",
1612
+ url: method_url,
1613
+ headers: headers,
1614
+ params: params,
1615
+ accept_json: true
1616
+ )
1617
+ nil
1618
+ end
1619
+ #########################
1620
+ # Dialog nodes
1621
+ #########################
1622
+
1623
+ ##
1624
+ # @!method list_dialog_nodes(workspace_id:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1625
+ # List dialog nodes.
1626
+ # List the dialog nodes for a workspace.
1627
+ #
1628
+ # This operation is limited to 2500 requests per 30 minutes. For more information,
1629
+ # see **Rate limiting**.
1630
+ # @param workspace_id [String] Unique identifier of the workspace.
1631
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1632
+ # @param include_count [Boolean] Whether to include information about the number of records returned.
1633
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1634
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1635
+ # and `workspace_id`.
1636
+ # @param cursor [String] A token identifying the page of results to retrieve.
1637
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1638
+ # the response.
1639
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1640
+ def list_dialog_nodes(workspace_id:, page_limit: nil, include_count: nil, sort: nil, cursor: nil, include_audit: nil)
1641
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1642
+ headers = {
1643
+ }
1644
+ params = {
1645
+ "version" => @version,
1646
+ "page_limit" => page_limit,
1647
+ "include_count" => include_count,
1648
+ "sort" => sort,
1649
+ "cursor" => cursor,
1650
+ "include_audit" => include_audit
1651
+ }
1652
+ method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
1653
+ response = request(
1654
+ method: "GET",
1655
+ url: method_url,
1656
+ headers: headers,
1657
+ params: params,
1658
+ accept_json: true
1659
+ )
1660
+ response
1661
+ end
1662
+
1663
+ ##
1664
+ # @!method create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil)
1665
+ # Create dialog node.
1666
+ # Create a new dialog node.
1667
+ #
1668
+ # This operation is limited to 500 requests per 30 minutes. For more information,
1669
+ # see **Rate limiting**.
1670
+ # @param workspace_id [String] Unique identifier of the workspace.
1671
+ # @param dialog_node [String] The dialog node ID. This string must conform to the following restrictions:
1672
+ # - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot
1673
+ # characters.
1674
+ # - It must be no longer than 1024 characters.
1675
+ # @param description [String] The description of the dialog node. This string cannot contain carriage return,
1676
+ # newline, or tab characters, and it must be no longer than 128 characters.
1677
+ # @param conditions [String] The condition that will trigger the dialog node. This string cannot contain
1678
+ # carriage return, newline, or tab characters, and it must be no longer than 2048
1679
+ # characters.
1680
+ # @param parent [String] The ID of the parent dialog node.
1681
+ # @param previous_sibling [String] The ID of the previous dialog node.
1682
+ # @param output [Object] The output of the dialog node. For more information about how to specify dialog
1683
+ # node output, see the
1684
+ # [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex).
1685
+ # @param context [Object] The context for the dialog node.
1686
+ # @param metadata [Object] The metadata for the dialog node.
1687
+ # @param next_step [DialogNodeNextStep] The next step to be executed in dialog processing.
1688
+ # @param actions [Array[DialogNodeAction]] An array of objects describing any actions to be invoked by the dialog node.
1689
+ # @param title [String] The alias used to identify the dialog node. This string must conform to the
1690
+ # following restrictions:
1691
+ # - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot
1692
+ # characters.
1693
+ # - It must be no longer than 64 characters.
1694
+ # @param node_type [String] How the dialog node is processed.
1695
+ # @param event_name [String] How an `event_handler` node is processed.
1696
+ # @param variable [String] The location in the dialog context where output is stored.
1697
+ # @param digress_in [String] Whether this top-level dialog node can be digressed into.
1698
+ # @param digress_out [String] Whether this dialog node can be returned to after a digression.
1699
+ # @param digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
1700
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1701
+ def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions: nil, parent: nil, previous_sibling: nil, output: nil, context: nil, metadata: nil, next_step: nil, actions: nil, title: nil, node_type: nil, event_name: nil, variable: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil)
1702
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1703
+ raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
1704
+ headers = {
1705
+ }
1706
+ params = {
1707
+ "version" => @version
1708
+ }
1709
+ data = {
1710
+ "dialog_node" => dialog_node,
1711
+ "description" => description,
1712
+ "conditions" => conditions,
1713
+ "parent" => parent,
1714
+ "previous_sibling" => previous_sibling,
1715
+ "output" => output,
1716
+ "context" => context,
1717
+ "metadata" => metadata,
1718
+ "next_step" => next_step,
1719
+ "actions" => actions,
1720
+ "title" => title,
1721
+ "type" => node_type,
1722
+ "event_name" => event_name,
1723
+ "variable" => variable,
1724
+ "digress_in" => digress_in,
1725
+ "digress_out" => digress_out,
1726
+ "digress_out_slots" => digress_out_slots
1727
+ }
1728
+ method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
1729
+ response = request(
1730
+ method: "POST",
1731
+ url: method_url,
1732
+ headers: headers,
1733
+ params: params,
1734
+ json: data,
1735
+ accept_json: true
1736
+ )
1737
+ response
1738
+ end
1739
+
1740
+ ##
1741
+ # @!method get_dialog_node(workspace_id:, dialog_node:, include_audit: nil)
1742
+ # Get dialog node.
1743
+ # Get information about a dialog node.
1744
+ #
1745
+ # This operation is limited to 6000 requests per 5 minutes. For more information,
1746
+ # see **Rate limiting**.
1747
+ # @param workspace_id [String] Unique identifier of the workspace.
1748
+ # @param dialog_node [String] The dialog node ID (for example, `get_order`).
1749
+ # @param include_audit [Boolean] Whether to include the audit properties (`created` and `updated` timestamps) in
1750
+ # the response.
1751
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1752
+ def get_dialog_node(workspace_id:, dialog_node:, include_audit: nil)
1753
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1754
+ raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
1755
+ headers = {
1756
+ }
1757
+ params = {
1758
+ "version" => @version,
1759
+ "include_audit" => include_audit
1760
+ }
1761
+ method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
1762
+ response = request(
1763
+ method: "GET",
1764
+ url: method_url,
1765
+ headers: headers,
1766
+ params: params,
1767
+ accept_json: true
1768
+ )
1769
+ response
1770
+ end
1771
+
1772
+ ##
1773
+ # @!method update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil)
1774
+ # Update dialog node.
1775
+ # Update an existing dialog node with new or modified data.
1776
+ #
1777
+ # This operation is limited to 500 requests per 30 minutes. For more information,
1778
+ # see **Rate limiting**.
1779
+ # @param workspace_id [String] Unique identifier of the workspace.
1780
+ # @param dialog_node [String] The dialog node ID (for example, `get_order`).
1781
+ # @param new_dialog_node [String] The dialog node ID. This string must conform to the following restrictions:
1782
+ # - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot
1783
+ # characters.
1784
+ # - It must be no longer than 1024 characters.
1785
+ # @param new_description [String] The description of the dialog node. This string cannot contain carriage return,
1786
+ # newline, or tab characters, and it must be no longer than 128 characters.
1787
+ # @param new_conditions [String] The condition that will trigger the dialog node. This string cannot contain
1788
+ # carriage return, newline, or tab characters, and it must be no longer than 2048
1789
+ # characters.
1790
+ # @param new_parent [String] The ID of the parent dialog node.
1791
+ # @param new_previous_sibling [String] The ID of the previous sibling dialog node.
1792
+ # @param new_output [Object] The output of the dialog node. For more information about how to specify dialog
1793
+ # node output, see the
1794
+ # [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex).
1795
+ # @param new_context [Object] The context for the dialog node.
1796
+ # @param new_metadata [Object] The metadata for the dialog node.
1797
+ # @param new_next_step [DialogNodeNextStep] The next step to be executed in dialog processing.
1798
+ # @param new_title [String] The alias used to identify the dialog node. This string must conform to the
1799
+ # following restrictions:
1800
+ # - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot
1801
+ # characters.
1802
+ # - It must be no longer than 64 characters.
1803
+ # @param new_type [String] How the dialog node is processed.
1804
+ # @param new_event_name [String] How an `event_handler` node is processed.
1805
+ # @param new_variable [String] The location in the dialog context where output is stored.
1806
+ # @param new_actions [Array[DialogNodeAction]] An array of objects describing any actions to be invoked by the dialog node.
1807
+ # @param new_digress_in [String] Whether this top-level dialog node can be digressed into.
1808
+ # @param new_digress_out [String] Whether this dialog node can be returned to after a digression.
1809
+ # @param new_digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
1810
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1811
+ def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_description: nil, new_conditions: nil, new_parent: nil, new_previous_sibling: nil, new_output: nil, new_context: nil, new_metadata: nil, new_next_step: nil, new_title: nil, new_type: nil, new_event_name: nil, new_variable: nil, new_actions: nil, new_digress_in: nil, new_digress_out: nil, new_digress_out_slots: nil)
1812
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1813
+ raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
1814
+ headers = {
1815
+ }
1816
+ params = {
1817
+ "version" => @version
1818
+ }
1819
+ data = {
1820
+ "dialog_node" => new_dialog_node,
1821
+ "description" => new_description,
1822
+ "conditions" => new_conditions,
1823
+ "parent" => new_parent,
1824
+ "previous_sibling" => new_previous_sibling,
1825
+ "output" => new_output,
1826
+ "context" => new_context,
1827
+ "metadata" => new_metadata,
1828
+ "next_step" => new_next_step,
1829
+ "title" => new_title,
1830
+ "type" => new_type,
1831
+ "event_name" => new_event_name,
1832
+ "variable" => new_variable,
1833
+ "actions" => new_actions,
1834
+ "digress_in" => new_digress_in,
1835
+ "digress_out" => new_digress_out,
1836
+ "digress_out_slots" => new_digress_out_slots
1837
+ }
1838
+ method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
1839
+ response = request(
1840
+ method: "POST",
1841
+ url: method_url,
1842
+ headers: headers,
1843
+ params: params,
1844
+ json: data,
1845
+ accept_json: true
1846
+ )
1847
+ response
1848
+ end
1849
+
1850
+ ##
1851
+ # @!method delete_dialog_node(workspace_id:, dialog_node:)
1852
+ # Delete dialog node.
1853
+ # Delete a dialog node from a workspace.
1854
+ #
1855
+ # This operation is limited to 500 requests per 30 minutes. For more information,
1856
+ # see **Rate limiting**.
1857
+ # @param workspace_id [String] Unique identifier of the workspace.
1858
+ # @param dialog_node [String] The dialog node ID (for example, `get_order`).
1859
+ # @return [nil]
1860
+ def delete_dialog_node(workspace_id:, dialog_node:)
1861
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1862
+ raise ArgumentError("dialog_node must be provided") if dialog_node.nil?
1863
+ headers = {
1864
+ }
1865
+ params = {
1866
+ "version" => @version
1867
+ }
1868
+ method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
1869
+ request(
1870
+ method: "DELETE",
1871
+ url: method_url,
1872
+ headers: headers,
1873
+ params: params,
1874
+ accept_json: true
1875
+ )
1876
+ nil
1877
+ end
1878
+ #########################
1879
+ # Logs
1880
+ #########################
1881
+
1882
+ ##
1883
+ # @!method list_logs(workspace_id:, sort: nil, filter: nil, page_limit: nil, cursor: nil)
1884
+ # List log events in a workspace.
1885
+ # List the events from the log of a specific workspace.
1886
+ #
1887
+ # If **cursor** is not specified, this operation is limited to 40 requests per 30
1888
+ # minutes. If **cursor** is specified, the limit is 120 requests per minute. For
1889
+ # more information, see **Rate limiting**.
1890
+ # @param workspace_id [String] Unique identifier of the workspace.
1891
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1892
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1893
+ # and `workspace_id`.
1894
+ # @param filter [String] A cacheable parameter that limits the results to those matching the specified
1895
+ # filter. For more information, see the
1896
+ # [documentation](https://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax).
1897
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1898
+ # @param cursor [String] A token identifying the page of results to retrieve.
1899
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1900
+ def list_logs(workspace_id:, sort: nil, filter: nil, page_limit: nil, cursor: nil)
1901
+ raise ArgumentError("workspace_id must be provided") if workspace_id.nil?
1902
+ headers = {
1903
+ }
1904
+ params = {
1905
+ "version" => @version,
1906
+ "sort" => sort,
1907
+ "filter" => filter,
1908
+ "page_limit" => page_limit,
1909
+ "cursor" => cursor
1910
+ }
1911
+ method_url = "/v1/workspaces/%s/logs" % [ERB::Util.url_encode(workspace_id)]
1912
+ response = request(
1913
+ method: "GET",
1914
+ url: method_url,
1915
+ headers: headers,
1916
+ params: params,
1917
+ accept_json: true
1918
+ )
1919
+ response
1920
+ end
1921
+
1922
+ ##
1923
+ # @!method list_all_logs(filter:, sort: nil, page_limit: nil, cursor: nil)
1924
+ # List log events in all workspaces.
1925
+ # List the events from the logs of all workspaces in the service instance.
1926
+ #
1927
+ # If **cursor** is not specified, this operation is limited to 40 requests per 30
1928
+ # minutes. If **cursor** is specified, the limit is 120 requests per minute. For
1929
+ # more information, see **Rate limiting**.
1930
+ # @param filter [String] A cacheable parameter that limits the results to those matching the specified
1931
+ # filter. You must specify a filter query that includes a value for `language`, as
1932
+ # well as a value for `workspace_id` or `request.context.metadata.deployment`. For
1933
+ # more information, see the
1934
+ # [documentation](https://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax).
1935
+ # @param sort [String] The attribute by which returned results will be sorted. To reverse the sort order,
1936
+ # prefix the value with a minus sign (`-`). Supported values are `name`, `updated`,
1937
+ # and `workspace_id`.
1938
+ # @param page_limit [Fixnum] The number of records to return in each page of results.
1939
+ # @param cursor [String] A token identifying the page of results to retrieve.
1940
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1941
+ def list_all_logs(filter:, sort: nil, page_limit: nil, cursor: nil)
1942
+ raise ArgumentError("filter must be provided") if filter.nil?
1943
+ headers = {
1944
+ }
1945
+ params = {
1946
+ "version" => @version,
1947
+ "filter" => filter,
1948
+ "sort" => sort,
1949
+ "page_limit" => page_limit,
1950
+ "cursor" => cursor
1951
+ }
1952
+ method_url = "/v1/logs"
1953
+ response = request(
1954
+ method: "GET",
1955
+ url: method_url,
1956
+ headers: headers,
1957
+ params: params,
1958
+ accept_json: true
1959
+ )
1960
+ response
1961
+ end
1962
+ #########################
1963
+ # User data
1964
+ #########################
1965
+
1966
+ ##
1967
+ # @!method delete_user_data(customer_id:)
1968
+ # Delete labeled data.
1969
+ # Deletes all data associated with a specified customer ID. The method has no effect
1970
+ # if no data is associated with the customer ID.
1971
+ #
1972
+ # You associate a customer ID with data by passing the `X-Watson-Metadata` header
1973
+ # with a request that passes data. For more information about personal data and
1974
+ # customer IDs, see [Information
1975
+ # security](https://console.bluemix.net/docs/services/conversation/information-security.html).
1976
+ # @param customer_id [String] The customer ID for which all data is to be deleted.
1977
+ # @return [nil]
1978
+ def delete_user_data(customer_id:)
1979
+ raise ArgumentError("customer_id must be provided") if customer_id.nil?
1980
+ headers = {
1981
+ }
1982
+ params = {
1983
+ "version" => @version,
1984
+ "customer_id" => customer_id
1985
+ }
1986
+ method_url = "/v1/user_data"
1987
+ request(
1988
+ method: "DELETE",
1989
+ url: method_url,
1990
+ headers: headers,
1991
+ params: params,
1992
+ accept_json: true
1993
+ )
1994
+ nil
1995
+ end
1996
+ end
1997
+ end