ibm_watson 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e5beca0130db02ef8d574f58ebe96eef6cb879a7b656146405a03854f972b56
4
- data.tar.gz: 7a1c2370c981076c0ad4be3d00123facac33bd9975fc675095f27a2730bac005
3
+ metadata.gz: 02b9a374cec465603fa4b16fed7dafdc2a2282fa928c4f3609ded4ad7b37f9d7
4
+ data.tar.gz: aa3773cedacb514da7f7ecc838e5d1263f55649b23b872049b95a697d73e928d
5
5
  SHA512:
6
- metadata.gz: 728c141e67558420faf66cb1b204893309d73dbfa65bd5c16620c40657ec9101706168a13d404c2961e36a29992e4360125e9b59988138fec1c2e28ecd84f01f
7
- data.tar.gz: 5d4d8fa466ee58d68dd5275bfb0f0ef9d113f7b05d1cf26c017b1132b81ab92b9a1a4b97c50dfe907ca345a075780d0deef375ded62f6b45bc5a0a1e7173103c
6
+ metadata.gz: 4d88024b3b18c0e91b6d36014832b14eba4c6a716a924a6dc3843fa91516dff028486984428c141376ff615995feb0e198425363aebd25633a18508984e1cb4f
7
+ data.tar.gz: 5d943c0f6509a7beeb16cd417f3cab1203687a0be47d00fb8271eaeec38f4498d4f428c31cf2f9acbbe0b1aa2da722afa3c2dbf7bb3abbb3f16536388245c49b
data/README.md CHANGED
@@ -72,10 +72,9 @@ Watson services are migrating to token-based Identity and Access Management (IAM
72
72
  ### Getting credentials
73
73
  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:
74
74
 
75
- 1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page.
76
- 2. Either click an existing Watson service instance or click **Create**.
77
- 3. Click **Show** to view your service credentials.
78
- 4. Copy the `url` and either `apikey` or `username` and `password`.
75
+ 1. Go to the IBM Cloud [Dashboard][watson-dashboard] page.
76
+ 1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance.
77
+ 1. Copy the `url` and either `apikey` or `username` and `password`. Click **Show** if the credentials are masked.
79
78
 
80
79
  ### IAM
81
80
 
@@ -290,7 +289,7 @@ This library is licensed under the [Apache 2.0 license][license].
290
289
 
291
290
  [wdc]: http://www.ibm.com/watson/developercloud/
292
291
  [ibm_cloud]: https://console.bluemix.net
293
- [watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=watson
292
+ [watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=ai
294
293
  [examples]: https://github.com/watson-developer-cloud/ruby-sdk/tree/master/examples
295
294
  [CONTRIBUTING]: https://github.com/watson-developer-cloud/ruby-sdk/blob/master/CONTRIBUTING.md
296
295
  [license]: http://www.apache.org/licenses/LICENSE-2.0
@@ -174,7 +174,7 @@ module IBMWatson
174
174
  # instance. An attempt to create another environment results in an error.
175
175
  # @param name [String] Name that identifies the environment.
176
176
  # @param description [String] Description of the environment.
177
- # @param size [Fixnum] **Deprecated**: Size of the environment.
177
+ # @param size [String] Size of the environment.
178
178
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
179
179
  def create_environment(name:, description: nil, size: nil)
180
180
  raise ArgumentError("name must be provided") if name.nil?
@@ -1094,7 +1094,7 @@ module IBMWatson
1094
1094
  # exact answer. Aggregations are useful for building applications, because you can
1095
1095
  # use them to build lists, tables, and time series. For a full list of possible
1096
1096
  # aggregrations, see the Query reference.
1097
- # @param count [Fixnum] Number of documents to return.
1097
+ # @param count [Fixnum] Number of results to return.
1098
1098
  # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1099
1099
  # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1100
1100
  # number of results that are returned is 10, and the offset is 8, it returns the
@@ -1195,7 +1195,7 @@ module IBMWatson
1195
1195
  # exact answer. Aggregations are useful for building applications, because you can
1196
1196
  # use them to build lists, tables, and time series. For a full list of possible
1197
1197
  # aggregrations, see the Query reference.
1198
- # @param count [Fixnum] Number of documents to return.
1198
+ # @param count [Fixnum] Number of results to return.
1199
1199
  # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1200
1200
  # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1201
1201
  # number of results that are returned is 10, and the offset is 8, it returns the
@@ -1286,7 +1286,7 @@ module IBMWatson
1286
1286
  # exact answer. Aggregations are useful for building applications, because you can
1287
1287
  # use them to build lists, tables, and time series. For a full list of possible
1288
1288
  # aggregrations, see the Query reference.
1289
- # @param count [Fixnum] Number of documents to return.
1289
+ # @param count [Fixnum] Number of results to return.
1290
1290
  # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1291
1291
  # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1292
1292
  # number of results that are returned is 10, and the offset is 8, it returns the
@@ -1386,7 +1386,7 @@ module IBMWatson
1386
1386
  # exact answer. Aggregations are useful for building applications, because you can
1387
1387
  # use them to build lists, tables, and time series. For a full list of possible
1388
1388
  # aggregrations, see the Query reference.
1389
- # @param count [Fixnum] Number of documents to return.
1389
+ # @param count [Fixnum] Number of results to return.
1390
1390
  # @param return_fields [Array[String]] A comma separated list of the portion of the document hierarchy to return.
1391
1391
  # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1392
1392
  # number of results that are returned is 10, and the offset is 8, it returns the
@@ -1884,6 +1884,239 @@ module IBMWatson
1884
1884
  nil
1885
1885
  end
1886
1886
  #########################
1887
+ # Events and feedback
1888
+ #########################
1889
+
1890
+ ##
1891
+ # @!method create_event(type:, data:)
1892
+ # Create event.
1893
+ # The **Events** API can be used to create log entries that are associated with
1894
+ # specific queries. For example, you can record which documents in the results set
1895
+ # were \"clicked\" by a user and when that click occured.
1896
+ # @param type [String] The event type to be created.
1897
+ # @param data [EventData] Data object used to create a query event.
1898
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1899
+ def create_event(type:, data:)
1900
+ raise ArgumentError("type must be provided") if type.nil?
1901
+ raise ArgumentError("data must be provided") if data.nil?
1902
+ headers = {
1903
+ }
1904
+ params = {
1905
+ "version" => @version
1906
+ }
1907
+ data = {
1908
+ "type" => type,
1909
+ "data" => data
1910
+ }
1911
+ method_url = "/v1/events"
1912
+ response = request(
1913
+ method: "POST",
1914
+ url: method_url,
1915
+ headers: headers,
1916
+ params: params,
1917
+ json: data,
1918
+ accept_json: true
1919
+ )
1920
+ response
1921
+ end
1922
+
1923
+ ##
1924
+ # @!method query_log(filter: nil, query: nil, count: nil, offset: nil, sort: nil)
1925
+ # Search the query and event log.
1926
+ # Searches the query and event log to find query sessions that match the specified
1927
+ # criteria. Searching the **logs** endpoint uses the standard Discovery query syntax
1928
+ # for the parameters that are supported.
1929
+ # @param filter [String] A cacheable query that limits the documents returned to exclude any documents that
1930
+ # don't mention the query content. Filter searches are better for metadata type
1931
+ # searches and when you are trying to get a sense of concepts in the data set.
1932
+ # @param query [String] A query search returns all documents in your data set with full enrichments and
1933
+ # full text, but with the most relevant documents listed first. Use a query search
1934
+ # when you want to find the most relevant search results. You cannot use
1935
+ # **natural_language_query** and **query** at the same time.
1936
+ # @param count [Fixnum] Number of results to return.
1937
+ # @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
1938
+ # number of results that are returned is 10, and the offset is 8, it returns the
1939
+ # last two results.
1940
+ # @param sort [Array[String]] A comma separated list of fields in the document to sort on. You can optionally
1941
+ # specify a sort direction by prefixing the field with `-` for descending or `+` for
1942
+ # ascending. Ascending is the default sort direction if no prefix is specified.
1943
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1944
+ def query_log(filter: nil, query: nil, count: nil, offset: nil, sort: nil)
1945
+ headers = {
1946
+ }
1947
+ params = {
1948
+ "version" => @version,
1949
+ "filter" => filter,
1950
+ "query" => query,
1951
+ "count" => count,
1952
+ "offset" => offset,
1953
+ "sort" => sort.to_a
1954
+ }
1955
+ method_url = "/v1/logs"
1956
+ response = request(
1957
+ method: "GET",
1958
+ url: method_url,
1959
+ headers: headers,
1960
+ params: params,
1961
+ accept_json: true
1962
+ )
1963
+ response
1964
+ end
1965
+
1966
+ ##
1967
+ # @!method get_metrics_query(start_time: nil, end_time: nil, result_type: nil)
1968
+ # Number of queries over time.
1969
+ # Total number of queries using the **natural_language_query** parameter over a
1970
+ # specific time window.
1971
+ # @param start_time [Time] Metric is computed from data recorded after this timestamp; must be in
1972
+ # `YYYY-MM-DDThh:mm:ssZ` format.
1973
+ # @param end_time [Time] Metric is computed from data recorded before this timestamp; must be in
1974
+ # `YYYY-MM-DDThh:mm:ssZ` format.
1975
+ # @param result_type [String] The type of result to consider when calculating the metric.
1976
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1977
+ def get_metrics_query(start_time: nil, end_time: nil, result_type: nil)
1978
+ headers = {
1979
+ }
1980
+ params = {
1981
+ "version" => @version,
1982
+ "start_time" => start_time,
1983
+ "end_time" => end_time,
1984
+ "result_type" => result_type
1985
+ }
1986
+ method_url = "/v1/metrics/number_of_queries"
1987
+ response = request(
1988
+ method: "GET",
1989
+ url: method_url,
1990
+ headers: headers,
1991
+ params: params,
1992
+ accept_json: true
1993
+ )
1994
+ response
1995
+ end
1996
+
1997
+ ##
1998
+ # @!method get_metrics_query_event(start_time: nil, end_time: nil, result_type: nil)
1999
+ # Number of queries with an event over time.
2000
+ # Total number of queries using the **natural_language_query** parameter that have a
2001
+ # corresponding \"click\" event over a specified time window. This metric requires
2002
+ # having integrated event tracking in your application using the **Events** API.
2003
+ # @param start_time [Time] Metric is computed from data recorded after this timestamp; must be in
2004
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2005
+ # @param end_time [Time] Metric is computed from data recorded before this timestamp; must be in
2006
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2007
+ # @param result_type [String] The type of result to consider when calculating the metric.
2008
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2009
+ def get_metrics_query_event(start_time: nil, end_time: nil, result_type: nil)
2010
+ headers = {
2011
+ }
2012
+ params = {
2013
+ "version" => @version,
2014
+ "start_time" => start_time,
2015
+ "end_time" => end_time,
2016
+ "result_type" => result_type
2017
+ }
2018
+ method_url = "/v1/metrics/number_of_queries_with_event"
2019
+ response = request(
2020
+ method: "GET",
2021
+ url: method_url,
2022
+ headers: headers,
2023
+ params: params,
2024
+ accept_json: true
2025
+ )
2026
+ response
2027
+ end
2028
+
2029
+ ##
2030
+ # @!method get_metrics_query_no_results(start_time: nil, end_time: nil, result_type: nil)
2031
+ # Number of queries with no search results over time.
2032
+ # Total number of queries using the **natural_language_query** parameter that have
2033
+ # no results returned over a specified time window.
2034
+ # @param start_time [Time] Metric is computed from data recorded after this timestamp; must be in
2035
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2036
+ # @param end_time [Time] Metric is computed from data recorded before this timestamp; must be in
2037
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2038
+ # @param result_type [String] The type of result to consider when calculating the metric.
2039
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2040
+ def get_metrics_query_no_results(start_time: nil, end_time: nil, result_type: nil)
2041
+ headers = {
2042
+ }
2043
+ params = {
2044
+ "version" => @version,
2045
+ "start_time" => start_time,
2046
+ "end_time" => end_time,
2047
+ "result_type" => result_type
2048
+ }
2049
+ method_url = "/v1/metrics/number_of_queries_with_no_search_results"
2050
+ response = request(
2051
+ method: "GET",
2052
+ url: method_url,
2053
+ headers: headers,
2054
+ params: params,
2055
+ accept_json: true
2056
+ )
2057
+ response
2058
+ end
2059
+
2060
+ ##
2061
+ # @!method get_metrics_event_rate(start_time: nil, end_time: nil, result_type: nil)
2062
+ # Percentage of queries with an associated event.
2063
+ # The percentage of queries using the **natural_language_query** parameter that have
2064
+ # a corresponding \"click\" event over a specified time window. This metric
2065
+ # requires having integrated event tracking in your application using the **Events**
2066
+ # API.
2067
+ # @param start_time [Time] Metric is computed from data recorded after this timestamp; must be in
2068
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2069
+ # @param end_time [Time] Metric is computed from data recorded before this timestamp; must be in
2070
+ # `YYYY-MM-DDThh:mm:ssZ` format.
2071
+ # @param result_type [String] The type of result to consider when calculating the metric.
2072
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2073
+ def get_metrics_event_rate(start_time: nil, end_time: nil, result_type: nil)
2074
+ headers = {
2075
+ }
2076
+ params = {
2077
+ "version" => @version,
2078
+ "start_time" => start_time,
2079
+ "end_time" => end_time,
2080
+ "result_type" => result_type
2081
+ }
2082
+ method_url = "/v1/metrics/event_rate"
2083
+ response = request(
2084
+ method: "GET",
2085
+ url: method_url,
2086
+ headers: headers,
2087
+ params: params,
2088
+ accept_json: true
2089
+ )
2090
+ response
2091
+ end
2092
+
2093
+ ##
2094
+ # @!method get_metrics_query_token_event(count: nil)
2095
+ # Most frequent query tokens with an event.
2096
+ # The most frequent query tokens parsed from the **natural_language_query**
2097
+ # parameter and their corresponding \"click\" event rate within the recording period
2098
+ # (queries and events are stored for 30 days). A query token is an individual word
2099
+ # or unigram within the query string.
2100
+ # @param count [Fixnum] Number of results to return.
2101
+ # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2102
+ def get_metrics_query_token_event(count: nil)
2103
+ headers = {
2104
+ }
2105
+ params = {
2106
+ "version" => @version,
2107
+ "count" => count
2108
+ }
2109
+ method_url = "/v1/metrics/top_query_tokens_with_event_rate"
2110
+ response = request(
2111
+ method: "GET",
2112
+ url: method_url,
2113
+ headers: headers,
2114
+ params: params,
2115
+ accept_json: true
2116
+ )
2117
+ response
2118
+ end
2119
+ #########################
1887
2120
  # Credentials
1888
2121
  #########################
1889
2122
 
@@ -157,7 +157,7 @@ module IBMWatson
157
157
  # Returns label information for the input. The status must be `Available` before you
158
158
  # can use the classifier to classify text.
159
159
  # @param classifier_id [String] Classifier ID to use.
160
- # @param text [String] The submitted phrase.
160
+ # @param text [String] The submitted phrase. The maximum length is 2048 characters.
161
161
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
162
162
  def classify(classifier_id:, text:)
163
163
  raise ArgumentError("classifier_id must be provided") if classifier_id.nil?
@@ -34,6 +34,12 @@
34
34
  # HTTP REST interface](https://console.bluemix.net/docs/services/speech-to-text/http.html)
35
35
  # and [The asynchronous HTTP
36
36
  # interface](https://console.bluemix.net/docs/services/speech-to-text/async.html).
37
+ #
38
+ # **Important:** The session-based interface is deprecated as of August 8, 2018, and
39
+ # will be removed from service on September 7, 2018. Use the sessionless, asynchronous, or
40
+ # WebSocket interface instead. For more information, see the August 8 service update in
41
+ # the [Release
42
+ # notes](https://console.bluemix.net/docs/services/speech-to-text/release-notes.html#August2018).
37
43
  # * **WebSocket interface:** The service also offers a WebSocket interface for speech
38
44
  # recognition. The WebSocket interface provides a full-duplex, low-latency communication
39
45
  # channel. Clients send requests and audio to the service and receive results over a
@@ -2069,7 +2075,7 @@ module IBMWatson
2069
2075
  # @param audio_name [String] The name of the audio resource for the custom acoustic model. When adding an audio
2070
2076
  # resource, do not include spaces in the name; use a localized name that matches the
2071
2077
  # language of the custom model.
2072
- # @param audio_resource [Array[String]] The audio resource that is to be added to the custom acoustic model, an individual
2078
+ # @param audio_resource [String] The audio resource that is to be added to the custom acoustic model, an individual
2073
2079
  # audio file or an archive file.
2074
2080
  # @param content_type [String] The type of the input.
2075
2081
  # @param contained_content_type [String] For an archive-type resource, specifies the format of the audio files contained in
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IBMWatson
4
- VERSION = "0.4.2"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -190,8 +190,8 @@ module IBMWatson
190
190
  #
191
191
  # The following built-in classifier IDs require no training:
192
192
  # - `default`: Returns classes from thousands of general tags.
193
- # - `food`: (Beta) Enhances specificity and accuracy for images of food items.
194
- # - `explicit`: (Beta) Evaluates whether the image might be pornographic.
193
+ # - `food`: Enhances specificity and accuracy for images of food items.
194
+ # - `explicit`: Evaluates whether the image might be pornographic.
195
195
  # @param images_file_content_type [String] The content type of images_file.
196
196
  # @param images_filename [String] The filename for images_file.
197
197
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
@@ -1010,6 +1010,171 @@ class DiscoveryV1Test < Minitest::Test
1010
1010
  assert_equal({ "received" => "true" }, service_response.result)
1011
1011
  end
1012
1012
 
1013
+ def test_create_event
1014
+ data_create_event = {
1015
+ environment_id: "envid",
1016
+ session_token: "token",
1017
+ collection_id: "collid",
1018
+ document_id: "docid"
1019
+ }
1020
+ mock_response = {
1021
+ "type" => "click",
1022
+ "data" => "data"
1023
+ }
1024
+ service = IBMWatson::DiscoveryV1.new(
1025
+ username: "username",
1026
+ password: "password",
1027
+ version: "2018-05-23"
1028
+ )
1029
+ stub_request(:post, "https://gateway.watsonplatform.net/discovery/api/v1/events?version=2018-05-23")
1030
+ .with(
1031
+ body: "{\"type\":\"click\",\"data\":{\"environment_id\":\"envid\",\"session_token\":\"token\",\"collection_id\":\"collid\",\"document_id\":\"docid\"}}",
1032
+ headers: {
1033
+ "Accept" => "application/json",
1034
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1035
+ "Content-Type" => "application/json",
1036
+ "Host" => "gateway.watsonplatform.net"
1037
+ }
1038
+ )
1039
+ .to_return(status: 201, body: mock_response.to_json, headers: { "Content-Type" => "application/json" })
1040
+ service_response = service.create_event(
1041
+ type: "click",
1042
+ data: data_create_event
1043
+ )
1044
+ assert_equal(mock_response, service_response.result)
1045
+ end
1046
+
1047
+ def test_query_log
1048
+ service = IBMWatson::DiscoveryV1.new(
1049
+ username: "username",
1050
+ password: "password",
1051
+ version: "2018-05-23"
1052
+ )
1053
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/logs?count=10&query=test&version=2018-05-23")
1054
+ .with(
1055
+ headers: {
1056
+ "Accept" => "application/json",
1057
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1058
+ "Host" => "gateway.watsonplatform.net"
1059
+ }
1060
+ )
1061
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1062
+ service_response = service.query_log(
1063
+ query: "test",
1064
+ count: 10
1065
+ )
1066
+ assert_equal({ "received" => "true" }, service_response.result)
1067
+ end
1068
+
1069
+ def test_metrics_query
1070
+ service = IBMWatson::DiscoveryV1.new(
1071
+ username: "username",
1072
+ password: "password",
1073
+ version: "2018-05-23"
1074
+ )
1075
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/metrics/number_of_queries?end_time=2018-01-01T00:10:00Z&start_time=2018-01-01T00:00:00Z&version=2018-05-23")
1076
+ .with(
1077
+ headers: {
1078
+ "Accept" => "application/json",
1079
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1080
+ "Host" => "gateway.watsonplatform.net"
1081
+ }
1082
+ )
1083
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1084
+ service_response = service.get_metrics_query(
1085
+ start_time: "2018-01-01T00:00:00Z",
1086
+ end_time: "2018-01-01T00:10:00Z"
1087
+ )
1088
+ assert_equal({ "received" => "true" }, service_response.result)
1089
+ end
1090
+
1091
+ def test_metrics_query_event
1092
+ service = IBMWatson::DiscoveryV1.new(
1093
+ username: "username",
1094
+ password: "password",
1095
+ version: "2018-05-23"
1096
+ )
1097
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/metrics/number_of_queries_with_event?end_time=2018-01-01T00:10:00Z&start_time=2018-01-01T00:00:00Z&version=2018-05-23")
1098
+ .with(
1099
+ headers: {
1100
+ "Accept" => "application/json",
1101
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1102
+ "Host" => "gateway.watsonplatform.net"
1103
+ }
1104
+ )
1105
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1106
+ service_response = service.get_metrics_query_event(
1107
+ start_time: "2018-01-01T00:00:00Z",
1108
+ end_time: "2018-01-01T00:10:00Z"
1109
+ )
1110
+ assert_equal({ "received" => "true" }, service_response.result)
1111
+ end
1112
+
1113
+ def test_metrics_query_token_event
1114
+ service = IBMWatson::DiscoveryV1.new(
1115
+ username: "username",
1116
+ password: "password",
1117
+ version: "2018-05-23"
1118
+ )
1119
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/metrics/top_query_tokens_with_event_rate?count=10&version=2018-05-23")
1120
+ .with(
1121
+ headers: {
1122
+ "Accept" => "application/json",
1123
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1124
+ "Host" => "gateway.watsonplatform.net"
1125
+ }
1126
+ )
1127
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1128
+ service_response = service.get_metrics_query_token_event(
1129
+ count: 10
1130
+ )
1131
+ assert_equal({ "received" => "true" }, service_response.result)
1132
+ end
1133
+
1134
+ def test_metrics_event_rate
1135
+ service = IBMWatson::DiscoveryV1.new(
1136
+ username: "username",
1137
+ password: "password",
1138
+ version: "2018-05-23"
1139
+ )
1140
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/metrics/event_rate?end_time=2018-01-01T00:10:00Z&start_time=2018-01-01T00:00:00Z&version=2018-05-23")
1141
+ .with(
1142
+ headers: {
1143
+ "Accept" => "application/json",
1144
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1145
+ "Host" => "gateway.watsonplatform.net"
1146
+ }
1147
+ )
1148
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1149
+ service_response = service.get_metrics_event_rate(
1150
+ start_time: "2018-01-01T00:00:00Z",
1151
+ end_time: "2018-01-01T00:10:00Z"
1152
+ )
1153
+ assert_equal({ "received" => "true" }, service_response.result)
1154
+ end
1155
+
1156
+ def test_metrics_query_no_results
1157
+ service = IBMWatson::DiscoveryV1.new(
1158
+ username: "username",
1159
+ password: "password",
1160
+ version: "2018-05-23"
1161
+ )
1162
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/metrics/number_of_queries_with_no_search_results?end_time=2018-01-01T00:10:00Z&start_time=2018-01-01T00:00:00Z&version=2018-05-23")
1163
+ .with(
1164
+ headers: {
1165
+ "Accept" => "application/json",
1166
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1167
+ "Host" => "gateway.watsonplatform.net"
1168
+ }
1169
+ )
1170
+ .to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1171
+ service_response = service.get_metrics_query_no_results(
1172
+ start_time: "2018-01-01T00:00:00Z",
1173
+ end_time: "2018-01-01T00:10:00Z"
1174
+ )
1175
+ assert_equal({ "received" => "true" }, service_response.result)
1176
+ end
1177
+
1013
1178
  def test_list_credentials
1014
1179
  service = IBMWatson::DiscoveryV1.new(
1015
1180
  username: "username",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_watson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-10 00:00:00.000000000 Z
11
+ date: 2018-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby