|
15 | 15 | **/ |
16 | 16 |
|
17 | 17 | /** |
18 | | - * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-36b26b63-20201028-122900 |
| 18 | + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-be3b4618-20201221-123327 |
19 | 19 | **/ |
20 | 20 |
|
21 | 21 | // swiftlint:disable file_length |
@@ -263,6 +263,90 @@ public class Assistant { |
263 | 263 | // swiftlint:enable identifier_name |
264 | 264 | } |
265 | 265 |
|
| 266 | + /** |
| 267 | + Identify intents and entities in multiple user utterances. |
| 268 | + |
| 269 | + Send multiple user inputs to a workspace in a single request and receive information about the intents and entities |
| 270 | + recognized in each input. This method is useful for testing and comparing the performance of different workspaces. |
| 271 | + This method is available only with Premium plans. |
| 272 | + |
| 273 | + - parameter workspaceID: Unique identifier of the workspace. |
| 274 | + - parameter input: An array of input utterances to classify. |
| 275 | + - parameter headers: A dictionary of request headers to be sent with this request. |
| 276 | + - parameter completionHandler: A function executed when the request completes with a successful result or error |
| 277 | + */ |
| 278 | + public func bulkClassify( |
| 279 | + workspaceID: String, |
| 280 | + input: [BulkClassifyUtterance]? = nil, |
| 281 | + headers: [String: String]? = nil, |
| 282 | + completionHandler: @escaping (WatsonResponse<BulkClassifyResponse>?, WatsonError?) -> Void) |
| 283 | + { |
| 284 | + // construct body |
| 285 | + let bulkClassifyRequest = BulkClassifyRequest( |
| 286 | + input: input) |
| 287 | + let body: Data? |
| 288 | + do { |
| 289 | + body = try JSON.encoder.encodeIfPresent(bulkClassifyRequest) |
| 290 | + } catch { |
| 291 | + completionHandler(nil, RestError.serialization(values: "request body")) |
| 292 | + return |
| 293 | + } |
| 294 | + |
| 295 | + // construct header parameters |
| 296 | + var headerParameters = defaultHeaders |
| 297 | + let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "bulkClassify") |
| 298 | + headerParameters.merge(sdkHeaders) { (_, new) in new } |
| 299 | + headerParameters["Accept"] = "application/json" |
| 300 | + headerParameters["Content-Type"] = "application/json" |
| 301 | + if let headers = headers { |
| 302 | + headerParameters.merge(headers) { (_, new) in new } |
| 303 | + } |
| 304 | + |
| 305 | + // construct query parameters |
| 306 | + var queryParameters = [URLQueryItem]() |
| 307 | + queryParameters.append(URLQueryItem(name: "version", value: version)) |
| 308 | + |
| 309 | + // construct REST request |
| 310 | + let path = "/v1/workspaces/\(workspaceID)/bulk_classify" |
| 311 | + guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { |
| 312 | + completionHandler(nil, RestError.urlEncoding(path: path)) |
| 313 | + return |
| 314 | + } |
| 315 | + |
| 316 | + // ensure that serviceURL is set |
| 317 | + guard let serviceEndpoint = serviceURL else { |
| 318 | + completionHandler(nil, RestError.noEndpoint) |
| 319 | + return |
| 320 | + } |
| 321 | + |
| 322 | + let request = RestRequest( |
| 323 | + session: session, |
| 324 | + authenticator: authenticator, |
| 325 | + errorResponseDecoder: errorResponseDecoder, |
| 326 | + method: "POST", |
| 327 | + url: serviceEndpoint + encodedPath, |
| 328 | + headerParameters: headerParameters, |
| 329 | + queryItems: queryParameters, |
| 330 | + messageBody: body |
| 331 | + ) |
| 332 | + |
| 333 | + // execute REST request |
| 334 | + request.responseObject(completionHandler: completionHandler) |
| 335 | + } |
| 336 | + |
| 337 | + // Private struct for the bulkClassify request body |
| 338 | + private struct BulkClassifyRequest: Encodable { |
| 339 | + // swiftlint:disable identifier_name |
| 340 | + let input: [BulkClassifyUtterance]? |
| 341 | + init? (input: [BulkClassifyUtterance]? = nil) { |
| 342 | + if input == nil { |
| 343 | + return nil |
| 344 | + } |
| 345 | + self.input = input |
| 346 | + } |
| 347 | + // swiftlint:enable identifier_name |
| 348 | + } |
| 349 | + |
266 | 350 | /** |
267 | 351 | List workspaces. |
268 | 352 |
|
@@ -4076,88 +4160,4 @@ public class Assistant { |
4076 | 4160 | request.response(completionHandler: completionHandler) |
4077 | 4161 | } |
4078 | 4162 |
|
4079 | | - /** |
4080 | | - Identify intents and entities in multiple user utterances. |
4081 | | - |
4082 | | - Send multiple user inputs to a workspace in a single request and receive information about the intents and entities |
4083 | | - recognized in each input. This method is useful for testing and comparing the performance of different workspaces. |
4084 | | - This method is available only with Premium plans. |
4085 | | - |
4086 | | - - parameter workspaceID: Unique identifier of the workspace. |
4087 | | - - parameter input: An array of input utterances to classify. |
4088 | | - - parameter headers: A dictionary of request headers to be sent with this request. |
4089 | | - - parameter completionHandler: A function executed when the request completes with a successful result or error |
4090 | | - */ |
4091 | | - public func bulkClassify( |
4092 | | - workspaceID: String, |
4093 | | - input: [BulkClassifyUtterance]? = nil, |
4094 | | - headers: [String: String]? = nil, |
4095 | | - completionHandler: @escaping (WatsonResponse<BulkClassifyResponse>?, WatsonError?) -> Void) |
4096 | | - { |
4097 | | - // construct body |
4098 | | - let bulkClassifyRequest = BulkClassifyRequest( |
4099 | | - input: input) |
4100 | | - let body: Data? |
4101 | | - do { |
4102 | | - body = try JSON.encoder.encodeIfPresent(bulkClassifyRequest) |
4103 | | - } catch { |
4104 | | - completionHandler(nil, RestError.serialization(values: "request body")) |
4105 | | - return |
4106 | | - } |
4107 | | - |
4108 | | - // construct header parameters |
4109 | | - var headerParameters = defaultHeaders |
4110 | | - let sdkHeaders = Shared.getSDKHeaders(serviceName: serviceName, serviceVersion: serviceVersion, methodName: "bulkClassify") |
4111 | | - headerParameters.merge(sdkHeaders) { (_, new) in new } |
4112 | | - headerParameters["Accept"] = "application/json" |
4113 | | - headerParameters["Content-Type"] = "application/json" |
4114 | | - if let headers = headers { |
4115 | | - headerParameters.merge(headers) { (_, new) in new } |
4116 | | - } |
4117 | | - |
4118 | | - // construct query parameters |
4119 | | - var queryParameters = [URLQueryItem]() |
4120 | | - queryParameters.append(URLQueryItem(name: "version", value: version)) |
4121 | | - |
4122 | | - // construct REST request |
4123 | | - let path = "/v1/workspaces/\(workspaceID)/bulk_classify" |
4124 | | - guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { |
4125 | | - completionHandler(nil, RestError.urlEncoding(path: path)) |
4126 | | - return |
4127 | | - } |
4128 | | - |
4129 | | - // ensure that serviceURL is set |
4130 | | - guard let serviceEndpoint = serviceURL else { |
4131 | | - completionHandler(nil, RestError.noEndpoint) |
4132 | | - return |
4133 | | - } |
4134 | | - |
4135 | | - let request = RestRequest( |
4136 | | - session: session, |
4137 | | - authenticator: authenticator, |
4138 | | - errorResponseDecoder: errorResponseDecoder, |
4139 | | - method: "POST", |
4140 | | - url: serviceEndpoint + encodedPath, |
4141 | | - headerParameters: headerParameters, |
4142 | | - queryItems: queryParameters, |
4143 | | - messageBody: body |
4144 | | - ) |
4145 | | - |
4146 | | - // execute REST request |
4147 | | - request.responseObject(completionHandler: completionHandler) |
4148 | | - } |
4149 | | - |
4150 | | - // Private struct for the bulkClassify request body |
4151 | | - private struct BulkClassifyRequest: Encodable { |
4152 | | - // swiftlint:disable identifier_name |
4153 | | - let input: [BulkClassifyUtterance]? |
4154 | | - init? (input: [BulkClassifyUtterance]? = nil) { |
4155 | | - if input == nil { |
4156 | | - return nil |
4157 | | - } |
4158 | | - self.input = input |
4159 | | - } |
4160 | | - // swiftlint:enable identifier_name |
4161 | | - } |
4162 | | - |
4163 | 4163 | } |
0 commit comments