ibm_watson 1.6.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -4
- data/lib/ibm_watson/assistant_v1.rb +277 -81
- data/lib/ibm_watson/assistant_v2.rb +100 -22
- data/lib/ibm_watson/compare_comply_v1.rb +44 -23
- data/lib/ibm_watson/discovery_v1.rb +132 -14
- data/lib/ibm_watson/discovery_v2.rb +234 -18
- data/lib/ibm_watson/language_translator_v3.rb +59 -27
- data/lib/ibm_watson/natural_language_classifier_v1.rb +3 -2
- data/lib/ibm_watson/natural_language_understanding_v1.rb +705 -14
- data/lib/ibm_watson/personality_insights_v3.rb +29 -18
- data/lib/ibm_watson/speech_to_text_v1.rb +278 -121
- data/lib/ibm_watson/text_to_speech_v1.rb +689 -130
- data/lib/ibm_watson/tone_analyzer_v3.rb +11 -13
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +32 -16
- data/lib/ibm_watson/visual_recognition_v4.rb +67 -23
- data/test/integration/test_assistant_v1.rb +9 -0
- data/test/integration/test_assistant_v2.rb +9 -0
- data/test/integration/test_discovery_v2.rb +29 -0
- data/test/integration/test_natural_language_understanding_v1.rb +134 -1
- data/test/integration/test_text_to_speech_v1.rb +60 -3
- data/test/unit/test_assistant_v1.rb +52 -1
- data/test/unit/test_assistant_v2.rb +51 -0
- data/test/unit/test_discovery_v2.rb +30 -1
- data/test/unit/test_natural_language_understanding_v1.rb +231 -0
- data/test/unit/test_text_to_speech_v1.rb +152 -7
- metadata +12 -11
@@ -13,7 +13,9 @@
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
|
-
|
16
|
+
#
|
17
|
+
# IBM OpenAPI SDK Code Generator Version: 3.31.0-902c9336-20210504-161156
|
18
|
+
#
|
17
19
|
# IBM Watson™ Discovery is a cognitive search and content analytics engine that
|
18
20
|
# you can add to applications to identify patterns, trends and actionable insights to
|
19
21
|
# drive better decision-making. Securely unify structured and unstructured data with
|
@@ -26,7 +28,6 @@ require "json"
|
|
26
28
|
require "ibm_cloud_sdk_core"
|
27
29
|
require_relative "./common.rb"
|
28
30
|
|
29
|
-
# Module for the Watson APIs
|
30
31
|
module IBMWatson
|
31
32
|
##
|
32
33
|
# The Discovery V2 service.
|
@@ -34,21 +35,14 @@ module IBMWatson
|
|
34
35
|
include Concurrent::Async
|
35
36
|
DEFAULT_SERVICE_NAME = "discovery"
|
36
37
|
DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"
|
38
|
+
attr_accessor :version
|
37
39
|
##
|
38
40
|
# @!method initialize(args)
|
39
41
|
# Construct a new client for the Discovery service.
|
40
42
|
#
|
41
43
|
# @param args [Hash] The args to initialize with
|
42
|
-
# @option args version [String]
|
43
|
-
#
|
44
|
-
# incompatible way, a new minor version of the API is released.
|
45
|
-
# The service uses the API version for the date you specify, or
|
46
|
-
# the most recent version before that date. Note that you should
|
47
|
-
# not programmatically specify the current date at runtime, in
|
48
|
-
# case the API has been updated since your application's release.
|
49
|
-
# Instead, specify a version date that is compatible with your
|
50
|
-
# application, and don't change it until your application is
|
51
|
-
# ready for a later version.
|
44
|
+
# @option args version [String] Release date of the version of the API you want to use. Specify dates in
|
45
|
+
# YYYY-MM-DD format. The current version is `2019-11-22`.
|
52
46
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
53
47
|
# The base service_url may differ between IBM Cloud regions.
|
54
48
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
@@ -57,10 +51,10 @@ module IBMWatson
|
|
57
51
|
def initialize(args = {})
|
58
52
|
@__async_initialized__ = false
|
59
53
|
defaults = {}
|
60
|
-
defaults[:version] = nil
|
61
54
|
defaults[:service_url] = DEFAULT_SERVICE_URL
|
62
55
|
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
63
56
|
defaults[:authenticator] = nil
|
57
|
+
defaults[:version] = nil
|
64
58
|
user_service_url = args[:service_url] unless args[:service_url].nil?
|
65
59
|
args = defaults.merge(args)
|
66
60
|
@version = args[:version]
|
@@ -85,6 +79,8 @@ module IBMWatson
|
|
85
79
|
def list_collections(project_id:)
|
86
80
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
87
81
|
|
82
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
83
|
+
|
88
84
|
headers = {
|
89
85
|
}
|
90
86
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_collections")
|
@@ -118,6 +114,8 @@ module IBMWatson
|
|
118
114
|
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
119
115
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
120
116
|
def create_collection(project_id:, name:, description: nil, language: nil, enrichments: nil)
|
117
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
118
|
+
|
121
119
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
122
120
|
|
123
121
|
raise ArgumentError.new("name must be provided") if name.nil?
|
@@ -160,6 +158,8 @@ module IBMWatson
|
|
160
158
|
# @param collection_id [String] The ID of the collection.
|
161
159
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
162
160
|
def get_collection(project_id:, collection_id:)
|
161
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
162
|
+
|
163
163
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
164
164
|
|
165
165
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -197,6 +197,8 @@ module IBMWatson
|
|
197
197
|
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
198
198
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
199
199
|
def update_collection(project_id:, collection_id:, name: nil, description: nil, enrichments: nil)
|
200
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
201
|
+
|
200
202
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
201
203
|
|
202
204
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -239,6 +241,8 @@ module IBMWatson
|
|
239
241
|
# @param collection_id [String] The ID of the collection.
|
240
242
|
# @return [nil]
|
241
243
|
def delete_collection(project_id:, collection_id:)
|
244
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
245
|
+
|
242
246
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
243
247
|
|
244
248
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -315,6 +319,8 @@ module IBMWatson
|
|
315
319
|
def query(project_id:, collection_ids: nil, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, _return: nil, offset: nil, sort: nil, highlight: nil, spelling_suggestions: nil, table_results: nil, suggested_refinements: nil, passages: nil)
|
316
320
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
317
321
|
|
322
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
323
|
+
|
318
324
|
headers = {
|
319
325
|
}
|
320
326
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query")
|
@@ -371,6 +377,8 @@ module IBMWatson
|
|
371
377
|
def get_autocompletion(project_id:, prefix:, collection_ids: nil, field: nil, count: nil)
|
372
378
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
373
379
|
|
380
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
381
|
+
|
374
382
|
raise ArgumentError.new("prefix must be provided") if prefix.nil?
|
375
383
|
|
376
384
|
headers = {
|
@@ -399,12 +407,66 @@ module IBMWatson
|
|
399
407
|
response
|
400
408
|
end
|
401
409
|
|
410
|
+
##
|
411
|
+
# @!method query_collection_notices(project_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
|
412
|
+
# Query collection notices.
|
413
|
+
# Finds collection-level notices (errors and warnings) that are generated when
|
414
|
+
# documents are ingested.
|
415
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
416
|
+
# Discovery administrative tooling.
|
417
|
+
# @param collection_id [String] The ID of the collection.
|
418
|
+
# @param filter [String] A cacheable query that excludes documents that don't mention the query content.
|
419
|
+
# Filter searches are better for metadata-type searches and for assessing the
|
420
|
+
# concepts in the data set.
|
421
|
+
# @param query [String] A query search returns all documents in your data set with full enrichments and
|
422
|
+
# full text, but with the most relevant documents listed first.
|
423
|
+
# @param natural_language_query [String] A natural language query that returns relevant documents by utilizing training
|
424
|
+
# data and natural language understanding.
|
425
|
+
# @param count [Fixnum] Number of results to return. The maximum for the **count** and **offset** values
|
426
|
+
# together in any one query is **10000**.
|
427
|
+
# @param offset [Fixnum] The number of query results to skip at the beginning. For example, if the total
|
428
|
+
# number of results that are returned is 10 and the offset is 8, it returns the last
|
429
|
+
# two results. The maximum for the **count** and **offset** values together in any
|
430
|
+
# one query is **10000**.
|
431
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
432
|
+
def query_collection_notices(project_id:, collection_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
|
433
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
434
|
+
|
435
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
436
|
+
|
437
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
438
|
+
|
439
|
+
headers = {
|
440
|
+
}
|
441
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query_collection_notices")
|
442
|
+
headers.merge!(sdk_headers)
|
443
|
+
|
444
|
+
params = {
|
445
|
+
"version" => @version,
|
446
|
+
"filter" => filter,
|
447
|
+
"query" => query,
|
448
|
+
"natural_language_query" => natural_language_query,
|
449
|
+
"count" => count,
|
450
|
+
"offset" => offset
|
451
|
+
}
|
452
|
+
|
453
|
+
method_url = "/v2/projects/%s/collections/%s/notices" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
454
|
+
|
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
|
+
|
402
465
|
##
|
403
466
|
# @!method query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
|
404
|
-
# Query
|
405
|
-
#
|
406
|
-
#
|
407
|
-
# training.
|
467
|
+
# Query project notices.
|
468
|
+
# Finds project-level notices (errors and warnings). Currently, project-level
|
469
|
+
# notices are generated by relevancy training.
|
408
470
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
409
471
|
# Discovery administrative tooling.
|
410
472
|
# @param filter [String] A cacheable query that excludes documents that don't mention the query content.
|
@@ -422,6 +484,8 @@ module IBMWatson
|
|
422
484
|
# one query is **10000**.
|
423
485
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
424
486
|
def query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
|
487
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
488
|
+
|
425
489
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
426
490
|
|
427
491
|
headers = {
|
@@ -461,6 +525,8 @@ module IBMWatson
|
|
461
525
|
# all collections in the project are used.
|
462
526
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
463
527
|
def list_fields(project_id:, collection_ids: nil)
|
528
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
529
|
+
|
464
530
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
465
531
|
|
466
532
|
headers = {
|
@@ -499,6 +565,8 @@ module IBMWatson
|
|
499
565
|
def get_component_settings(project_id:)
|
500
566
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
501
567
|
|
568
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
569
|
+
|
502
570
|
headers = {
|
503
571
|
}
|
504
572
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_component_settings")
|
@@ -580,6 +648,8 @@ module IBMWatson
|
|
580
648
|
# that collection is shared with other collections.
|
581
649
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
582
650
|
def add_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
|
651
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
652
|
+
|
583
653
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
584
654
|
|
585
655
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -659,6 +729,8 @@ module IBMWatson
|
|
659
729
|
# that collection is shared with other collections.
|
660
730
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
661
731
|
def update_document(project_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
|
732
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
733
|
+
|
662
734
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
663
735
|
|
664
736
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -721,6 +793,8 @@ module IBMWatson
|
|
721
793
|
# that collection is shared with other collections.
|
722
794
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
723
795
|
def delete_document(project_id:, collection_id:, document_id:, x_watson_discovery_force: nil)
|
796
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
797
|
+
|
724
798
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
725
799
|
|
726
800
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -760,6 +834,8 @@ module IBMWatson
|
|
760
834
|
# Discovery administrative tooling.
|
761
835
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
762
836
|
def list_training_queries(project_id:)
|
837
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
838
|
+
|
763
839
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
764
840
|
|
765
841
|
headers = {
|
@@ -791,6 +867,8 @@ module IBMWatson
|
|
791
867
|
# Discovery administrative tooling.
|
792
868
|
# @return [nil]
|
793
869
|
def delete_training_queries(project_id:)
|
870
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
871
|
+
|
794
872
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
795
873
|
|
796
874
|
headers = {
|
@@ -827,6 +905,8 @@ module IBMWatson
|
|
827
905
|
# applied.
|
828
906
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
829
907
|
def create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
|
908
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
909
|
+
|
830
910
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
831
911
|
|
832
912
|
raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?
|
@@ -871,6 +951,8 @@ module IBMWatson
|
|
871
951
|
# @param query_id [String] The ID of the query used for training.
|
872
952
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
873
953
|
def get_training_query(project_id:, query_id:)
|
954
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
955
|
+
|
874
956
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
875
957
|
|
876
958
|
raise ArgumentError.new("query_id must be provided") if query_id.nil?
|
@@ -909,6 +991,8 @@ module IBMWatson
|
|
909
991
|
# applied.
|
910
992
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
911
993
|
def update_training_query(project_id:, query_id:, natural_language_query:, examples:, filter: nil)
|
994
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
995
|
+
|
912
996
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
913
997
|
|
914
998
|
raise ArgumentError.new("query_id must be provided") if query_id.nil?
|
@@ -944,6 +1028,116 @@ module IBMWatson
|
|
944
1028
|
)
|
945
1029
|
response
|
946
1030
|
end
|
1031
|
+
|
1032
|
+
##
|
1033
|
+
# @!method delete_training_query(project_id:, query_id:)
|
1034
|
+
# Delete a training data query.
|
1035
|
+
# Removes details from a training data query, including the query string and all
|
1036
|
+
# examples.
|
1037
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1038
|
+
# Discovery administrative tooling.
|
1039
|
+
# @param query_id [String] The ID of the query used for training.
|
1040
|
+
# @return [nil]
|
1041
|
+
def delete_training_query(project_id:, query_id:)
|
1042
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1043
|
+
|
1044
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1045
|
+
|
1046
|
+
raise ArgumentError.new("query_id must be provided") if query_id.nil?
|
1047
|
+
|
1048
|
+
headers = {
|
1049
|
+
}
|
1050
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "delete_training_query")
|
1051
|
+
headers.merge!(sdk_headers)
|
1052
|
+
|
1053
|
+
params = {
|
1054
|
+
"version" => @version
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
method_url = "/v2/projects/%s/training_data/queries/%s" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(query_id)]
|
1058
|
+
|
1059
|
+
request(
|
1060
|
+
method: "DELETE",
|
1061
|
+
url: method_url,
|
1062
|
+
headers: headers,
|
1063
|
+
params: params,
|
1064
|
+
accept_json: false
|
1065
|
+
)
|
1066
|
+
nil
|
1067
|
+
end
|
1068
|
+
#########################
|
1069
|
+
# analyze
|
1070
|
+
#########################
|
1071
|
+
|
1072
|
+
##
|
1073
|
+
# @!method analyze_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
|
1074
|
+
# Analyze a Document.
|
1075
|
+
# Process a document using the specified collection's settings and return it for
|
1076
|
+
# realtime use.
|
1077
|
+
#
|
1078
|
+
# **Note:** Documents processed using this method are not added to the specified
|
1079
|
+
# collection.
|
1080
|
+
#
|
1081
|
+
# **Note:** This method is only supported on IBM Cloud Pak for Data instances of
|
1082
|
+
# Discovery.
|
1083
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
1084
|
+
# Discovery administrative tooling.
|
1085
|
+
# @param collection_id [String] The ID of the collection.
|
1086
|
+
# @param file [File] The content of the document to ingest. The maximum supported file size when adding
|
1087
|
+
# a file to a collection is 50 megabytes, the maximum supported file size when
|
1088
|
+
# testing a configuration is 1 megabyte. Files larger than the supported size are
|
1089
|
+
# rejected.
|
1090
|
+
# @param filename [String] The filename for file.
|
1091
|
+
# @param file_content_type [String] The content type of file.
|
1092
|
+
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
1093
|
+
# are rejected.
|
1094
|
+
#
|
1095
|
+
#
|
1096
|
+
# Example: ``` {
|
1097
|
+
# "Creator": "Johnny Appleseed",
|
1098
|
+
# "Subject": "Apples"
|
1099
|
+
# } ```.
|
1100
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1101
|
+
def analyze_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
|
1102
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1103
|
+
|
1104
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1105
|
+
|
1106
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
1107
|
+
|
1108
|
+
headers = {
|
1109
|
+
}
|
1110
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "analyze_document")
|
1111
|
+
headers.merge!(sdk_headers)
|
1112
|
+
|
1113
|
+
params = {
|
1114
|
+
"version" => @version
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
form_data = {}
|
1118
|
+
|
1119
|
+
unless file.nil?
|
1120
|
+
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
1121
|
+
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
1122
|
+
end
|
1123
|
+
filename = file.path if filename.nil? && file.respond_to?(:path)
|
1124
|
+
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
|
1128
|
+
|
1129
|
+
method_url = "/v2/projects/%s/collections/%s/analyze" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
1130
|
+
|
1131
|
+
response = request(
|
1132
|
+
method: "POST",
|
1133
|
+
url: method_url,
|
1134
|
+
headers: headers,
|
1135
|
+
params: params,
|
1136
|
+
form: form_data,
|
1137
|
+
accept_json: true
|
1138
|
+
)
|
1139
|
+
response
|
1140
|
+
end
|
947
1141
|
#########################
|
948
1142
|
# enrichments
|
949
1143
|
#########################
|
@@ -956,6 +1150,8 @@ module IBMWatson
|
|
956
1150
|
# Discovery administrative tooling.
|
957
1151
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
958
1152
|
def list_enrichments(project_id:)
|
1153
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1154
|
+
|
959
1155
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
960
1156
|
|
961
1157
|
headers = {
|
@@ -985,10 +1181,12 @@ module IBMWatson
|
|
985
1181
|
# Create an enrichment for use with the specified project/.
|
986
1182
|
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
987
1183
|
# Discovery administrative tooling.
|
988
|
-
# @param enrichment [CreateEnrichment]
|
1184
|
+
# @param enrichment [CreateEnrichment] Information about a specific enrichment.
|
989
1185
|
# @param file [File] The enrichment file to upload.
|
990
1186
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
991
1187
|
def create_enrichment(project_id:, enrichment:, file: nil)
|
1188
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1189
|
+
|
992
1190
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
993
1191
|
|
994
1192
|
raise ArgumentError.new("enrichment must be provided") if enrichment.nil?
|
@@ -1035,6 +1233,8 @@ module IBMWatson
|
|
1035
1233
|
# @param enrichment_id [String] The ID of the enrichment.
|
1036
1234
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1037
1235
|
def get_enrichment(project_id:, enrichment_id:)
|
1236
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1237
|
+
|
1038
1238
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1039
1239
|
|
1040
1240
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1071,6 +1271,8 @@ module IBMWatson
|
|
1071
1271
|
# @param description [String] A new description for the enrichment.
|
1072
1272
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1073
1273
|
def update_enrichment(project_id:, enrichment_id:, name:, description: nil)
|
1274
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1275
|
+
|
1074
1276
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1075
1277
|
|
1076
1278
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1115,6 +1317,8 @@ module IBMWatson
|
|
1115
1317
|
# @param enrichment_id [String] The ID of the enrichment.
|
1116
1318
|
# @return [nil]
|
1117
1319
|
def delete_enrichment(project_id:, enrichment_id:)
|
1320
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1321
|
+
|
1118
1322
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1119
1323
|
|
1120
1324
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1149,6 +1353,8 @@ module IBMWatson
|
|
1149
1353
|
# Lists existing projects for this instance.
|
1150
1354
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1151
1355
|
def list_projects
|
1356
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1357
|
+
|
1152
1358
|
headers = {
|
1153
1359
|
}
|
1154
1360
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_projects")
|
@@ -1179,6 +1385,8 @@ module IBMWatson
|
|
1179
1385
|
# @param default_query_parameters [DefaultQueryParams] Default query parameters for this project.
|
1180
1386
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1181
1387
|
def create_project(name:, type:, default_query_parameters: nil)
|
1388
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1389
|
+
|
1182
1390
|
raise ArgumentError.new("name must be provided") if name.nil?
|
1183
1391
|
|
1184
1392
|
raise ArgumentError.new("type must be provided") if type.nil?
|
@@ -1219,6 +1427,8 @@ module IBMWatson
|
|
1219
1427
|
# Discovery administrative tooling.
|
1220
1428
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1221
1429
|
def get_project(project_id:)
|
1430
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1431
|
+
|
1222
1432
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1223
1433
|
|
1224
1434
|
headers = {
|
@@ -1251,6 +1461,8 @@ module IBMWatson
|
|
1251
1461
|
# @param name [String] The new name to give this project.
|
1252
1462
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1253
1463
|
def update_project(project_id:, name: nil)
|
1464
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1465
|
+
|
1254
1466
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1255
1467
|
|
1256
1468
|
headers = {
|
@@ -1290,6 +1502,8 @@ module IBMWatson
|
|
1290
1502
|
# Discovery administrative tooling.
|
1291
1503
|
# @return [nil]
|
1292
1504
|
def delete_project(project_id:)
|
1505
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1506
|
+
|
1293
1507
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1294
1508
|
|
1295
1509
|
headers = {
|
@@ -1332,6 +1546,8 @@ module IBMWatson
|
|
1332
1546
|
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
1333
1547
|
# @return [nil]
|
1334
1548
|
def delete_user_data(customer_id:)
|
1549
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1550
|
+
|
1335
1551
|
raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
|
1336
1552
|
|
1337
1553
|
headers = {
|