-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathTspClientUpdateResponse.cs
More file actions
107 lines (99 loc) · 3.56 KB
/
TspClientUpdateResponse.cs
File metadata and controls
107 lines (99 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Text;
using System.Text.Json.Serialization;
namespace Azure.Sdk.Tools.Cli.Models;
/// <summary>
/// Response payload for TspClientUpdateTool MCP / CLI operations.
/// </summary>
public class TspClientUpdateResponse : Response
{
[JsonPropertyName("session")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ClientUpdateSessionState? Session { get; set; }
[JsonPropertyName("message")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Message { get; set; }
[JsonPropertyName("errorCode")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ErrorCode { get; set; }
public override string ToString()
{
var sb = new StringBuilder();
if (!string.IsNullOrEmpty(Message))
{
sb.AppendLine(Message);
}
if (Session != null)
{
sb.AppendLine($"Session: {Session.SessionId} Stage: {Session.LastStage} Manual?: {Session.RequiresManualIntervention}");
}
if (!string.IsNullOrWhiteSpace(ErrorCode))
{
sb.AppendLine($"ErrorCode: {ErrorCode}");
}
return ToString(sb);
}
}
public enum UpdateStage
{
/// <summary>
/// Session object created; no work performed yet.
/// </summary>
Initialized,
/// <summary>
/// TypeSpec (or language) client re-generated into <see cref="ClientUpdateSessionState.NewGeneratedPath"/>.
/// </summary>
Regenerated,
/// <summary>
/// A diff between old and new generations has been produced and API changes collected.
/// </summary>
Diffed,
/// <summary>
/// Customization files analyzed and mapped to impacted API changes.
/// </summary>
Mapped,
/// <summary>
/// Patch proposals created for impacted customizations (but not yet applied).
/// </summary>
PatchesProposed,
/// <summary>
/// Proposed patches applied to the customization sources.
/// </summary>
Applied,
/// <summary>
/// Post-apply validation (build / tests / lint) executed and results captured.
/// </summary>
Validated,
/// <summary>
/// Update failed due to an unknown error.
/// </summary>
Failed
}
public class ClientUpdateSessionState
{
/// <summary>
/// Stable id to correlate multi-step invocations.
/// </summary>
[JsonPropertyName("sessionId")] public string SessionId { get; set; } = Guid.NewGuid().ToString("n");
/// <summary>
/// Path to the source spec (.tsp) used for regeneration.
/// </summary>
[JsonPropertyName("specPath")] public string SpecPath { get; set; } = string.Empty;
/// <summary>
/// Path containing (or destined to contain) the latest regenerated output; also used for validation.
/// </summary>
[JsonPropertyName("newGeneratedPath")] public string NewGeneratedPath { get; set; } = string.Empty;
/// <summary>
/// Root folder of user customizations (may be null when none exist).
/// </summary>
[JsonPropertyName("customizationRoot")] public string? CustomizationRoot { get; set; }
/// <summary>
/// Latest completed pipeline stage for progress / resumability.
/// </summary>
[JsonPropertyName("lastStage")] public UpdateStage LastStage { get; set; } = UpdateStage.Initialized;
/// <summary>
/// True when automation halted and requires user action.
/// </summary>
[JsonPropertyName("requiresManualIntervention")] public bool RequiresManualIntervention { get; set; } = false;
}