Skip to content

Commit 0429822

Browse files
Add tool status in response (#12609)
* Add tool status in response * Update response test * Change to enum * Add serialize response as string * Updated response as status * Update to operation status
1 parent 003afa9 commit 0429822

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Helpers/OutputHelperTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public void TestTypedJsonOutput()
4040
""message"": ""message2""
4141
}
4242
],
43-
""suggested_fix"": ""a test suggested fix""
43+
""suggested_fix"": ""a test suggested fix"",
44+
""operation_status"": ""Succeeded""
4445
}";
4546

4647
var output = new OutputHelper(OutputHelper.OutputModes.Json);

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Models/Responses/CommandResponse.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
3-
using System.Text;
43
using System.Text.Json.Serialization;
54

65
namespace Azure.Sdk.Tools.Cli.Models;
76

7+
[JsonConverter(typeof(JsonStringEnumConverter))]
8+
public enum Status
9+
{
10+
Succeeded,
11+
Failed
12+
}
13+
814
public abstract class CommandResponse
915
{
1016
private int? exitCode = null;
@@ -44,6 +50,18 @@ public int ExitCode
4450
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4551
public List<string>? NextSteps { get; set; }
4652

53+
/// <summary>
54+
/// Status shows whether the command operation was successful.
55+
/// </summary>
56+
[JsonPropertyName("operation_status")]
57+
public Status OperationStatus
58+
{
59+
get
60+
{
61+
return string.IsNullOrEmpty(ResponseError) && (ResponseErrors == null || ResponseErrors.Count == 0)? Status.Succeeded : Status.Failed;
62+
}
63+
}
64+
4765
protected abstract string Format();
4866

4967
public override string ToString()

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Tools/Package/SdkReleaseTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task<SdkReleaseResponse> ReleasePackageAsync(string packageName, st
144144
PackageName = packageName,
145145
Language = language,
146146
ReleasePipelineStatus = "Failed",
147-
ReleaseStatusDetails = $"Error: {ex.Message}"
147+
ResponseError = $"Error: {ex.Message}"
148148
};
149149
return response;
150150
}

0 commit comments

Comments
 (0)