Skip to content

Commit 3b5b490

Browse files
authored
Merge pull request #82 from watson-developer-cloud/release-5-2019
v1.1
2 parents e2bc3db + 5181c91 commit 3b5b490

20 files changed

+1420
-1084
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Ruby gem to quickly get started with the various [IBM Watson][wdc] services.
1616
* [Before you begin](#before-you-begin)
1717
* [Installation](#installation)
1818
* [Examples](#examples)
19+
* [Discovery v2 only on CP4D](#discovery-v2-only-on-cp4d)
1920
* [Running in IBM Cloud](#running-in-ibm-cloud)
2021
* [Authentication](#authentication)
2122
* [Getting credentials](#getting-credentials)
@@ -61,6 +62,10 @@ require "ibm_watson"
6162

6263
The [examples][examples] folder has basic and advanced examples. The examples within each service assume that you already have [service credentials](#getting-credentials).
6364

65+
## Discovery v2 only on CP4D
66+
67+
Discovery v2 is only available on Cloud Pak for Data.
68+
6469
## Running in IBM Cloud
6570

6671
If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVICES`][vcap_services] environment variable.
@@ -350,7 +355,7 @@ The SDK will manage the token for the user
350355

351356
```ruby
352357

353-
authenticator = IBMWatson::Authenticators::CLoudPakForDataAuthenticator.new(
358+
authenticator = IBMWatson::Authenticators::CloudPakForDataAuthenticator.new(
354359
username: "<username>",
355360
password: "<password>",
356361
url: "<authentication url>",
@@ -360,7 +365,7 @@ assistant = IBMWatson::AssistantV1.new(
360365
version: "<version>",
361366
authenticator: authenticator
362367
)
363-
assistant.configure_http_client(disable_ssl_verification: true) # MAKE SURE SSL VERIFICATION IS DISABLED
368+
364369
```
365370

366371
## Ruby version

examples/discovery_v2.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# frozen_string_literal: true
2+
3+
require "json"
4+
require "ibm_watson/authenticators"
5+
require "ibm_watson/discovery_v2"
6+
7+
## Important: Discovery v2 is only available on Cloud Pak for Data. ##
8+
9+
## Authentication ##
10+
## Option 1: username/password
11+
# authenticator = IBMWatson::Authenticators::CloudPakForDataAuthenticator.new(
12+
# username: "{username}",
13+
# password: "{password}",
14+
# url: "{authentication_url}",
15+
# disable_ssl: true
16+
# )
17+
18+
## Option 2: bearer token
19+
authenticator = IBMWatson::Authenticators::BearerTokenAuthenticator.new(
20+
bearer_token: "{token}"
21+
)
22+
23+
discovery = IBMWatson::DiscoveryV2.new(
24+
authenticator: authenticator,
25+
version: "2019-11-21"
26+
)
27+
discovery.service_url = "{service_url}"
28+
discovery.configure_http_client(disable_ssl_verification: true)
29+
30+
collections = discovery.list_collections(
31+
project_id: "{project_id}"
32+
).result
33+
34+
puts JSON.pretty_generate(collections)
35+
36+
query_response = discovery.query(
37+
project_id: "{project_id}",
38+
count: 10
39+
).result
40+
puts JSON.pretty_generate(query_response)
41+
42+
autocomplete_response = discovery.get_autocompletion(
43+
project_id: "{project_id}",
44+
prefix: "hi how are "
45+
)
46+
puts JSON.pretty_generate(autocomplete_response)

ibm_watson.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
3636
spec.add_runtime_dependency "eventmachine", "~> 1.2"
3737
spec.add_runtime_dependency "faye-websocket", "~> 0.10"
3838
spec.add_runtime_dependency "http", "~> 4.1.0"
39-
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.0"
39+
spec.add_runtime_dependency "ibm_cloud_sdk_core", "~> 1.1"
4040
spec.add_runtime_dependency "jwt", "~> 2.2.1"
4141

4242
spec.add_development_dependency "bundler", "~> 1.16"

lib/ibm_watson.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module IBMWatson
1313
require_relative("./ibm_watson/assistant_v2.rb")
1414
require_relative("./ibm_watson/text_to_speech_v1.rb")
1515
require_relative("./ibm_watson/discovery_v1.rb")
16+
require_relative("./ibm_watson/discovery_v2.rb")
1617
require_relative("./ibm_watson/natural_language_understanding_v1.rb")
1718
require_relative("./ibm_watson/speech_to_text_v1.rb")
1819
require_relative("./ibm_watson/visual_recognition_v3.rb")

lib/ibm_watson/assistant_v1.rb

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def list_workspaces(page_limit: nil, sort: nil, cursor: nil, include_audit: nil)
177177
end
178178

179179
##
180-
# @!method create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil)
180+
# @!method create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil)
181181
# Create workspace.
182182
# Create a workspace based on component objects. You must provide workspace
183183
# components defining the content of the new workspace.
@@ -199,8 +199,9 @@ def list_workspaces(page_limit: nil, sort: nil, cursor: nil, include_audit: nil)
199199
# @param dialog_nodes [Array[DialogNode]] An array of objects describing the dialog nodes in the workspace.
200200
# @param counterexamples [Array[Counterexample]] An array of objects defining input examples that have been marked as irrelevant
201201
# input.
202+
# @param webhooks [Array[Webhook]]
202203
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
203-
def create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil)
204+
def create_workspace(name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil)
204205
headers = {
205206
}
206207
sdk_headers = Common.new.get_sdk_headers("conversation", "V1", "create_workspace")
@@ -220,7 +221,8 @@ def create_workspace(name: nil, description: nil, language: nil, metadata: nil,
220221
"intents" => intents,
221222
"entities" => entities,
222223
"dialog_nodes" => dialog_nodes,
223-
"counterexamples" => counterexamples
224+
"counterexamples" => counterexamples,
225+
"webhooks" => webhooks
224226
}
225227

226228
method_url = "/v1/workspaces"
@@ -282,7 +284,7 @@ def get_workspace(workspace_id:, export: nil, include_audit: nil, sort: nil)
282284
end
283285

284286
##
285-
# @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, append: nil)
287+
# @!method update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil, append: nil)
286288
# Update workspace.
287289
# Update an existing workspace with new or modified data. You must provide component
288290
# objects defining the content of the updated workspace.
@@ -305,6 +307,7 @@ def get_workspace(workspace_id:, export: nil, include_audit: nil, sort: nil)
305307
# @param dialog_nodes [Array[DialogNode]] An array of objects describing the dialog nodes in the workspace.
306308
# @param counterexamples [Array[Counterexample]] An array of objects defining input examples that have been marked as irrelevant
307309
# input.
310+
# @param webhooks [Array[Webhook]]
308311
# @param append [Boolean] Whether the new data is to be appended to the existing data in the workspace. If
309312
# **append**=`false`, elements included in the new data completely replace the
310313
# corresponding existing elements, including all subelements. For example, if the
@@ -315,7 +318,7 @@ def get_workspace(workspace_id:, export: nil, include_audit: nil, sort: nil)
315318
# added. If any elements in the new data collide with existing elements, the update
316319
# request fails.
317320
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
318-
def update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, append: nil)
321+
def update_workspace(workspace_id:, name: nil, description: nil, language: nil, metadata: nil, learning_opt_out: nil, system_settings: nil, intents: nil, entities: nil, dialog_nodes: nil, counterexamples: nil, webhooks: nil, append: nil)
319322
raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
320323

321324
headers = {
@@ -338,7 +341,8 @@ def update_workspace(workspace_id:, name: nil, description: nil, language: nil,
338341
"intents" => intents,
339342
"entities" => entities,
340343
"dialog_nodes" => dialog_nodes,
341-
"counterexamples" => counterexamples
344+
"counterexamples" => counterexamples,
345+
"webhooks" => webhooks
342346
}
343347

344348
method_url = "/v1/workspaces/%s" % [ERB::Util.url_encode(workspace_id)]
@@ -1936,7 +1940,7 @@ def list_dialog_nodes(workspace_id:, page_limit: nil, sort: nil, cursor: nil, in
19361940
end
19371941

19381942
##
1939-
# @!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, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
1943+
# @!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, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil, disambiguation_opt_out: nil)
19401944
# Create dialog node.
19411945
# Create a new dialog node.
19421946
#
@@ -1976,8 +1980,9 @@ def list_dialog_nodes(workspace_id:, page_limit: nil, sort: nil, cursor: nil, in
19761980
# @param digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
19771981
# @param user_label [String] A label that can be displayed externally to describe the purpose of the node to
19781982
# users.
1983+
# @param disambiguation_opt_out [Boolean] Whether the dialog node should be excluded from disambiguation suggestions.
19791984
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
1980-
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, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil)
1985+
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, title: nil, type: nil, event_name: nil, variable: nil, actions: nil, digress_in: nil, digress_out: nil, digress_out_slots: nil, user_label: nil, disambiguation_opt_out: nil)
19811986
raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
19821987

19831988
raise ArgumentError.new("dialog_node must be provided") if dialog_node.nil?
@@ -2009,7 +2014,8 @@ def create_dialog_node(workspace_id:, dialog_node:, description: nil, conditions
20092014
"digress_in" => digress_in,
20102015
"digress_out" => digress_out,
20112016
"digress_out_slots" => digress_out_slots,
2012-
"user_label" => user_label
2017+
"user_label" => user_label,
2018+
"disambiguation_opt_out" => disambiguation_opt_out
20132019
}
20142020

20152021
method_url = "/v1/workspaces/%s/dialog_nodes" % [ERB::Util.url_encode(workspace_id)]
@@ -2065,7 +2071,7 @@ def get_dialog_node(workspace_id:, dialog_node:, include_audit: nil)
20652071
end
20662072

20672073
##
2068-
# @!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, new_user_label: nil)
2074+
# @!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, new_user_label: nil, new_disambiguation_opt_out: nil)
20692075
# Update dialog node.
20702076
# Update an existing dialog node with new or modified data.
20712077
#
@@ -2106,8 +2112,9 @@ def get_dialog_node(workspace_id:, dialog_node:, include_audit: nil)
21062112
# @param new_digress_out_slots [String] Whether the user can digress to top-level nodes while filling out slots.
21072113
# @param new_user_label [String] A label that can be displayed externally to describe the purpose of the node to
21082114
# users.
2115+
# @param new_disambiguation_opt_out [Boolean] Whether the dialog node should be excluded from disambiguation suggestions.
21092116
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
2110-
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, new_user_label: nil)
2117+
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, new_user_label: nil, new_disambiguation_opt_out: nil)
21112118
raise ArgumentError.new("workspace_id must be provided") if workspace_id.nil?
21122119

21132120
raise ArgumentError.new("dialog_node must be provided") if dialog_node.nil?
@@ -2139,7 +2146,8 @@ def update_dialog_node(workspace_id:, dialog_node:, new_dialog_node: nil, new_de
21392146
"digress_in" => new_digress_in,
21402147
"digress_out" => new_digress_out,
21412148
"digress_out_slots" => new_digress_out_slots,
2142-
"user_label" => new_user_label
2149+
"user_label" => new_user_label,
2150+
"disambiguation_opt_out" => new_disambiguation_opt_out
21432151
}
21442152

21452153
method_url = "/v1/workspaces/%s/dialog_nodes/%s" % [ERB::Util.url_encode(workspace_id), ERB::Util.url_encode(dialog_node)]
@@ -2249,8 +2257,8 @@ def list_logs(workspace_id:, sort: nil, filter: nil, page_limit: nil, cursor: ni
22492257
# more information, see **Rate limiting**.
22502258
# @param filter [String] A cacheable parameter that limits the results to those matching the specified
22512259
# filter. You must specify a filter query that includes a value for `language`, as
2252-
# well as a value for `workspace_id` or `request.context.metadata.deployment`. For
2253-
# more information, see the
2260+
# well as a value for `request.context.system.assistant_id`, `workspace_id`, or
2261+
# `request.context.metadata.deployment`. For more information, see the
22542262
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-filter-reference#filter-reference).
22552263
# @param sort [String] How to sort the returned log events. You can sort by **request_timestamp**. To
22562264
# reverse the sort order, prefix the parameter value with a minus sign (`-`).

lib/ibm_watson/assistant_v2.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def initialize(args = {})
7474
# @!method create_session(assistant_id:)
7575
# Create a session.
7676
# Create a new session. A session is used to send user input to a skill and receive
77-
# responses. It also maintains the state of the conversation.
77+
# responses. It also maintains the state of the conversation. A session persists
78+
# until it is deleted, or until it times out because of inactivity. (For more
79+
# information, see the
80+
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings).
7881
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
7982
# Assistant user interface, open the assistant settings and click **API Details**.
8083
# For information about creating assistants, see the
@@ -109,7 +112,9 @@ def create_session(assistant_id:)
109112
##
110113
# @!method delete_session(assistant_id:, session_id:)
111114
# Delete session.
112-
# Deletes a session explicitly before it times out.
115+
# Deletes a session explicitly before it times out. (For more information about the
116+
# session inactivity timeout, see the
117+
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings)).
113118
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
114119
# Assistant user interface, open the assistant settings and click **API Details**.
115120
# For information about creating assistants, see the

0 commit comments

Comments
 (0)