Skip to content

Commit 2b8a2fc

Browse files
committed
feat(assistant-v1): update models and add new methods
NEW methods: createWorkspaceAsync, updateWorkspaceAsync, exportWorkspaceAsync
1 parent ea6cc46 commit 2b8a2fc

File tree

9 files changed

+619
-17
lines changed

9 files changed

+619
-17
lines changed

src/IBM.Watson.Assistant.v1/AssistantService.cs

Lines changed: 364 additions & 2 deletions
Large diffs are not rendered by default.

src/IBM.Watson.Assistant.v1/IAssistantService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2021.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,9 @@ public partial interface IAssistantService
3030
DetailedResponse<Workspace> GetWorkspace(string workspaceId, bool? export = null, bool? includeAudit = null, string sort = null);
3131
DetailedResponse<Workspace> UpdateWorkspace(string workspaceId, string name = null, string description = null, string language = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<Webhook> webhooks = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, bool? append = null, bool? includeAudit = null);
3232
DetailedResponse<object> DeleteWorkspace(string workspaceId);
33+
DetailedResponse<Workspace> CreateWorkspaceAsync(string name = null, string description = null, string language = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<Webhook> webhooks = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null);
34+
DetailedResponse<Workspace> UpdateWorkspaceAsync(string workspaceId, string name = null, string description = null, string language = null, List<DialogNode> dialogNodes = null, List<Counterexample> counterexamples = null, Dictionary<string, object> metadata = null, bool? learningOptOut = null, WorkspaceSystemSettings systemSettings = null, List<Webhook> webhooks = null, List<CreateIntent> intents = null, List<CreateEntity> entities = null, bool? append = null);
35+
DetailedResponse<Workspace> ExportWorkspaceAsync(string workspaceId, bool? includeAudit = null, string sort = null, bool? verbose = null);
3336
DetailedResponse<IntentCollection> ListIntents(string workspaceId, bool? export = null, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null);
3437
DetailedResponse<Intent> CreateIntent(string workspaceId, string intent, string description = null, List<Example> examples = null, bool? includeAudit = null);
3538
DetailedResponse<Intent> GetIntent(string workspaceId, string intent, bool? export = null, bool? includeAudit = null);

src/IBM.Watson.Assistant.v1/Model/RuntimeIntent.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2019.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,8 @@ public class RuntimeIntent
3030
[JsonProperty("intent", NullValueHandling = NullValueHandling.Ignore)]
3131
public string Intent { get; set; }
3232
/// <summary>
33-
/// A decimal percentage that represents Watson's confidence in the intent.
33+
/// A decimal percentage that represents Watson's confidence in the intent. If you are specifying an intent as
34+
/// part of a request, but you do not have a calculated confidence value, specify `1`.
3435
/// </summary>
3536
[JsonProperty("confidence", NullValueHandling = NullValueHandling.Ignore)]
3637
public double? Confidence { get; set; }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
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+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.Assistant.v1.Model
21+
{
22+
/// <summary>
23+
/// An object describing an error that occurred during processing of an asynchronous operation.
24+
/// </summary>
25+
public class StatusError
26+
{
27+
/// <summary>
28+
/// The text of the error message.
29+
/// </summary>
30+
[JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)]
31+
public string Message { get; set; }
32+
}
33+
34+
}

src/IBM.Watson.Assistant.v1/Model/Workspace.cs

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,26 +27,37 @@ namespace IBM.Watson.Assistant.v1.Model
2727
public class Workspace
2828
{
2929
/// <summary>
30-
/// The current status of the workspace.
30+
/// The current status of the workspace:
31+
/// - **Available**: The workspace is available and ready to process messages.
32+
/// - **Failed**: An asynchronous operation has failed. See the **status_errors** property for more information
33+
/// about the cause of the failure. Returned only by the **Export workspace asynchronously** method.
34+
/// - **Non Existent**: The workspace does not exist.
35+
/// - **Processing**: An asynchronous operation has not yet completed. Returned only by the **Export workspace
36+
/// asynchronously** method.
37+
/// - **Training**: The workspace is training based on new data such as intents or examples.
3138
/// </summary>
3239
public class StatusEnumValue
3340
{
3441
/// <summary>
35-
/// Constant NON_EXISTENT for Non Existent
36-
/// </summary>
37-
public const string NON_EXISTENT = "Non Existent";
38-
/// <summary>
39-
/// Constant TRAINING for Training
42+
/// Constant AVAILABLE for Available
4043
/// </summary>
41-
public const string TRAINING = "Training";
44+
public const string AVAILABLE = "Available";
4245
/// <summary>
4346
/// Constant FAILED for Failed
4447
/// </summary>
4548
public const string FAILED = "Failed";
4649
/// <summary>
47-
/// Constant AVAILABLE for Available
50+
/// Constant NON_EXISTENT for Non Existent
4851
/// </summary>
49-
public const string AVAILABLE = "Available";
52+
public const string NON_EXISTENT = "Non Existent";
53+
/// <summary>
54+
/// Constant PROCESSING for Processing
55+
/// </summary>
56+
public const string PROCESSING = "Processing";
57+
/// <summary>
58+
/// Constant TRAINING for Training
59+
/// </summary>
60+
public const string TRAINING = "Training";
5061
/// <summary>
5162
/// Constant UNAVAILABLE for Unavailable
5263
/// </summary>
@@ -55,7 +66,14 @@ public class StatusEnumValue
5566
}
5667

5768
/// <summary>
58-
/// The current status of the workspace.
69+
/// The current status of the workspace:
70+
/// - **Available**: The workspace is available and ready to process messages.
71+
/// - **Failed**: An asynchronous operation has failed. See the **status_errors** property for more information
72+
/// about the cause of the failure. Returned only by the **Export workspace asynchronously** method.
73+
/// - **Non Existent**: The workspace does not exist.
74+
/// - **Processing**: An asynchronous operation has not yet completed. Returned only by the **Export workspace
75+
/// asynchronously** method.
76+
/// - **Training**: The workspace is training based on new data such as intents or examples.
5977
/// Constants for possible values can be found using Workspace.StatusEnumValue
6078
/// </summary>
6179
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
@@ -117,6 +135,11 @@ public class StatusEnumValue
117135
[JsonProperty("system_settings", NullValueHandling = NullValueHandling.Ignore)]
118136
public WorkspaceSystemSettings SystemSettings { get; set; }
119137
/// <summary>
138+
/// An array of messages about errors that caused an asynchronous operation to fail.
139+
/// </summary>
140+
[JsonProperty("status_errors", NullValueHandling = NullValueHandling.Ignore)]
141+
public virtual List<StatusError> StatusErrors { get; private set; }
142+
/// <summary>
120143
/// Gets or Sets Webhooks
121144
/// </summary>
122145
[JsonProperty("webhooks", NullValueHandling = NullValueHandling.Ignore)]
@@ -131,6 +154,13 @@ public class StatusEnumValue
131154
/// </summary>
132155
[JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)]
133156
public List<Entity> Entities { get; set; }
157+
/// <summary>
158+
/// An object containing properties that indicate how many intents, entities, and dialog nodes are defined in
159+
/// the workspace. This property is included only in responses from the **Export workspace asynchronously**
160+
/// method, and only when the **verbose** query parameter is set to `true`.
161+
/// </summary>
162+
[JsonProperty("counts", NullValueHandling = NullValueHandling.Ignore)]
163+
public WorkspaceCounts Counts { get; set; }
134164
}
135165

136166
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
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+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.Assistant.v1.Model
21+
{
22+
/// <summary>
23+
/// An object containing properties that indicate how many intents, entities, and dialog nodes are defined in the
24+
/// workspace. This property is included only in responses from the **Export workspace asynchronously** method, and
25+
/// only when the **verbose** query parameter is set to `true`.
26+
/// </summary>
27+
public class WorkspaceCounts
28+
{
29+
/// <summary>
30+
/// The number of intents defined in the workspace.
31+
/// </summary>
32+
[JsonProperty("intent", NullValueHandling = NullValueHandling.Ignore)]
33+
public long? Intent { get; set; }
34+
/// <summary>
35+
/// The number of entities defined in the workspace.
36+
/// </summary>
37+
[JsonProperty("entity", NullValueHandling = NullValueHandling.Ignore)]
38+
public long? Entity { get; set; }
39+
/// <summary>
40+
/// The number of nodes defined in the workspace.
41+
/// </summary>
42+
[JsonProperty("node", NullValueHandling = NullValueHandling.Ignore)]
43+
public long? Node { get; set; }
44+
}
45+
46+
}

src/IBM.Watson.Assistant.v1/Model/WorkspaceSystemSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2022.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,6 +64,11 @@ public class WorkspaceSystemSettings : DynamicModel<object>
6464
/// </summary>
6565
[JsonProperty("off_topic", NullValueHandling = NullValueHandling.Ignore)]
6666
public WorkspaceSystemSettingsOffTopic OffTopic { get; set; }
67+
/// <summary>
68+
/// Workspace settings related to the version of the training algorithms currently used by the skill.
69+
/// </summary>
70+
[JsonProperty("nlp", NullValueHandling = NullValueHandling.Ignore)]
71+
public WorkspaceSystemSettingsNlp Nlp { get; set; }
6772
}
6873

6974
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
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+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.Assistant.v1.Model
21+
{
22+
/// <summary>
23+
/// Workspace settings related to the version of the training algorithms currently used by the skill.
24+
/// </summary>
25+
public class WorkspaceSystemSettingsNlp
26+
{
27+
/// <summary>
28+
/// The policy the skill follows for selecting the algorithm version to use:
29+
///
30+
/// - `baseline`: the latest mature version
31+
/// - `beta`: the latest beta version.
32+
/// </summary>
33+
public class ModelEnumValue
34+
{
35+
/// <summary>
36+
/// Constant BASELINE for baseline
37+
/// </summary>
38+
public const string BASELINE = "baseline";
39+
/// <summary>
40+
/// Constant BETA for beta
41+
/// </summary>
42+
public const string BETA = "beta";
43+
44+
}
45+
46+
/// <summary>
47+
/// The policy the skill follows for selecting the algorithm version to use:
48+
///
49+
/// - `baseline`: the latest mature version
50+
/// - `beta`: the latest beta version.
51+
/// Constants for possible values can be found using WorkspaceSystemSettingsNlp.ModelEnumValue
52+
/// </summary>
53+
[JsonProperty("model", NullValueHandling = NullValueHandling.Ignore)]
54+
public string Model { get; set; }
55+
}
56+
57+
}

src/IBM.Watson.Assistant.v1/Test/Integration/AssistantServiceIntegrationTests.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
using System.Collections.Generic;
2525
using IBM.Cloud.SDK.Core.Util;
2626
using IBM.Cloud.SDK.Core.Authentication.Iam;
27+
using System.Threading;
28+
using IBM.Cloud.SDK.Core.Http;
2729

2830
namespace IBM.Watson.Assistant.v1.IntegrationTests
2931
{
@@ -1104,6 +1106,68 @@ public void TestRuntimeResponseGeneric()
11041106
Assert.IsTrue(response.Result.Output.Generic[0].ResponseType.Contains(inputMessage));
11051107
}
11061108
}
1109+
1110+
[TestMethod]
1111+
public void TestWorkspaceAsync()
1112+
{
1113+
service.WithHeader("X-Watson-Test", "1");
1114+
var createWorkspaceAsyncResult = service.CreateWorkspaceAsync(
1115+
name: createdWorkspaceName,
1116+
description: createdWorkspaceDescription,
1117+
language: createdWorkspaceLanguage
1118+
);
1119+
var workspaceId = createWorkspaceAsyncResult.Result.WorkspaceId;
1120+
1121+
DetailedResponse<Workspace> getWorkspaceResult = null;
1122+
var workspaceStatus = createWorkspaceAsyncResult.Result.Status;
1123+
while (workspaceStatus == Workspace.StatusEnumValue.PROCESSING)
1124+
{
1125+
Thread.Sleep(10000);
1126+
getWorkspaceResult = service.GetWorkspace(
1127+
workspaceId: workspaceId
1128+
);
1129+
workspaceStatus = getWorkspaceResult.Result.Status;
1130+
}
1131+
1132+
Assert.IsTrue(workspaceStatus == Workspace.StatusEnumValue.AVAILABLE);
1133+
1134+
var updateWorkspaceAsyncResult = service.UpdateWorkspaceAsync(
1135+
workspaceId: workspaceId,
1136+
name: createdWorkspaceName,
1137+
description: createdWorkspaceDescription + "-updated",
1138+
language: createdWorkspaceLanguage,
1139+
learningOptOut: true
1140+
);
1141+
1142+
workspaceStatus = Workspace.StatusEnumValue.PROCESSING;
1143+
while (workspaceStatus == Workspace.StatusEnumValue.PROCESSING)
1144+
{
1145+
Thread.Sleep(10000);
1146+
getWorkspaceResult = service.GetWorkspace(
1147+
workspaceId: workspaceId
1148+
);
1149+
workspaceStatus = getWorkspaceResult.Result.Status;
1150+
}
1151+
Assert.IsTrue(workspaceStatus == Workspace.StatusEnumValue.AVAILABLE);
1152+
Assert.IsTrue(getWorkspaceResult.Result.Description == createdWorkspaceDescription + "-updated");
1153+
1154+
var exportWorkspaceAsyncResult = service.ExportWorkspaceAsync(
1155+
workspaceId: workspaceId
1156+
);
1157+
workspaceStatus = Workspace.StatusEnumValue.PROCESSING;
1158+
1159+
while(workspaceStatus == Workspace.StatusEnumValue.PROCESSING)
1160+
{
1161+
Thread.Sleep(10000);
1162+
exportWorkspaceAsyncResult = service.ExportWorkspaceAsync(
1163+
workspaceId: workspaceId
1164+
);
1165+
workspaceStatus = getWorkspaceResult.Result.Status;
1166+
}
1167+
1168+
Assert.IsTrue(workspaceStatus == Workspace.StatusEnumValue.AVAILABLE);
1169+
Assert.IsTrue(exportWorkspaceAsyncResult.Result.Description == createdWorkspaceDescription + "-updated");
1170+
}
11071171
#endregion
11081172
}
11091173
}

0 commit comments

Comments
 (0)