Skip to content

Commit 5595caa

Browse files
authored
Merge pull request #1042 from watson-developer-cloud/update-schemas
fix(assistant): adjust agent availability schema
2 parents f58b90e + 69e7da4 commit 5595caa

13 files changed

Lines changed: 369 additions & 218 deletions

Sources/AssistantV1/Assistant.swift

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
**/
1616

1717
/**
18-
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-36b26b63-20201028-122900
18+
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-be3b4618-20201221-123327
1919
**/
2020

2121
// swiftlint:disable file_length
@@ -263,6 +263,90 @@ public class Assistant {
263263
// swiftlint:enable identifier_name
264264
}
265265

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+
266350
/**
267351
List workspaces.
268352

@@ -4076,88 +4160,4 @@ public class Assistant {
40764160
request.response(completionHandler: completionHandler)
40774161
}
40784162

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-
41634163
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2020.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
import Foundation
18+
19+
/**
20+
AgentAvailabilityMessage.
21+
*/
22+
public struct AgentAvailabilityMessage: Codable, Equatable {
23+
24+
/**
25+
The text of the message.
26+
*/
27+
public var message: String?
28+
29+
// Map each property name to the key that shall be used for encoding/decoding.
30+
private enum CodingKeys: String, CodingKey {
31+
case message = "message"
32+
}
33+
34+
/**
35+
Initialize a `AgentAvailabilityMessage` with member variables.
36+
37+
- parameter message: The text of the message.
38+
39+
- returns: An initialized `AgentAvailabilityMessage`.
40+
*/
41+
public init(
42+
message: String? = nil
43+
)
44+
{
45+
self.message = message
46+
}
47+
48+
}

Sources/AssistantV1/Models/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public struct DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent:
4747
An optional message to be displayed to the user to indicate that the conversation will be transferred to the next
4848
available agent.
4949
*/
50-
public var agentAvailable: String?
50+
public var agentAvailable: AgentAvailabilityMessage?
5151

5252
/**
5353
An optional message to be displayed to the user to indicate that no online agent is available to take over the
5454
conversation.
5555
*/
56-
public var agentUnavailable: String?
56+
public var agentUnavailable: AgentAvailabilityMessage?
5757

5858
/**
5959
Routing or other contextual information to be used by target service desk systems.
@@ -87,8 +87,8 @@ public struct DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent:
8787
public init(
8888
responseType: String,
8989
messageToHumanAgent: String? = nil,
90-
agentAvailable: String? = nil,
91-
agentUnavailable: String? = nil,
90+
agentAvailable: AgentAvailabilityMessage? = nil,
91+
agentUnavailable: AgentAvailabilityMessage? = nil,
9292
transferInfo: DialogNodeOutputConnectToAgentTransferInfo? = nil
9393
)
9494
{

Sources/AssistantV1/Models/RuntimeEntity.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ public struct RuntimeEntity: Codable, Equatable {
5454
public var groups: [CaptureGroup]?
5555

5656
/**
57-
An object containing detailed information about the entity recognized in the user input. This property is included
58-
only if the new system entities are enabled for the workspace.
59-
For more information about how the new system entities are interpreted, see the
60-
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
57+
An object containing detailed information about the entity recognized in the user input.
58+
For more information about how system entities are interpreted, see the
59+
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
6160
*/
6261
public var interpretation: RuntimeEntityInterpretation?
6362

@@ -100,9 +99,9 @@ public struct RuntimeEntity: Codable, Equatable {
10099
- parameter metadata: Any metadata for the entity.
101100
- parameter groups: The recognized capture groups for the entity, as defined by the entity pattern.
102101
- parameter interpretation: An object containing detailed information about the entity recognized in the user
103-
input. This property is included only if the new system entities are enabled for the workspace.
104-
For more information about how the new system entities are interpreted, see the
105-
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities).
102+
input.
103+
For more information about how system entities are interpreted, see the
104+
[documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities).
106105
- parameter alternatives: An array of possible alternative values that the user might have intended instead of
107106
the value returned in the **value** property. This property is returned only for `@sys-time` and `@sys-date`
108107
entities when the user's input is ambiguous.

Sources/AssistantV1/Models/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public struct RuntimeResponseGenericRuntimeResponseTypeConnectToAgent: Codable,
4747
An optional message to be displayed to the user to indicate that the conversation will be transferred to the next
4848
available agent.
4949
*/
50-
public var agentAvailable: String?
50+
public var agentAvailable: AgentAvailabilityMessage?
5151

5252
/**
5353
An optional message to be displayed to the user to indicate that no online agent is available to take over the
5454
conversation.
5555
*/
56-
public var agentUnavailable: String?
56+
public var agentUnavailable: AgentAvailabilityMessage?
5757

5858
/**
5959
Routing or other contextual information to be used by target service desk systems.
@@ -105,8 +105,8 @@ public struct RuntimeResponseGenericRuntimeResponseTypeConnectToAgent: Codable,
105105
public init(
106106
responseType: String,
107107
messageToHumanAgent: String? = nil,
108-
agentAvailable: String? = nil,
109-
agentUnavailable: String? = nil,
108+
agentAvailable: AgentAvailabilityMessage? = nil,
109+
agentUnavailable: AgentAvailabilityMessage? = nil,
110110
transferInfo: DialogNodeOutputConnectToAgentTransferInfo? = nil,
111111
topic: String? = nil,
112112
dialogNode: String? = nil

0 commit comments

Comments
 (0)