Skip to content

Commit eb60765

Browse files
JoyerJinNoriZC
andauthored
[Maintenance] Migrate SDK generation from autorest C# to autorest PowerShell (#27145)
* migrate Maintenance SDK from autorest csharp to autorest powershell * Migrated the Maintenance SDK for Autorest from C# to PowerShell * Add autorest reset command to README * Update ChangeLog for SDK migration --------- Co-authored-by: NoriZC <[email protected]>
1 parent bff9fc1 commit eb60765

File tree

65 files changed

+4957
-5143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4957
-5143
lines changed
Lines changed: 67 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
// <auto-generated>
21
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
// Licensed under the MIT License. See License.txt in the project root for
4-
// license information.
5-
//
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
63
// Code generated by Microsoft (R) AutoRest Code Generator.
7-
// Changes may cause incorrect behavior and will be lost if the code is
8-
// regenerated.
9-
// </auto-generated>
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
105

116
namespace Microsoft.Azure.Management.Maintenance
127
{
8+
using System.Linq;
139
using Microsoft.Rest;
1410
using Microsoft.Rest.Azure;
1511
using Models;
16-
using Newtonsoft.Json;
17-
using System.Collections;
18-
using System.Collections.Generic;
19-
using System.Linq;
20-
using System.Net;
21-
using System.Net.Http;
22-
using System.Threading;
23-
using System.Threading.Tasks;
2412

2513
/// <summary>
2614
/// ApplyUpdateForResourceGroupOperations operations.
2715
/// </summary>
28-
internal partial class ApplyUpdateForResourceGroupOperations : IServiceOperations<MaintenanceManagementClient>, IApplyUpdateForResourceGroupOperations
16+
internal partial class ApplyUpdateForResourceGroupOperations : Microsoft.Rest.IServiceOperations<MaintenanceManagementClient>, IApplyUpdateForResourceGroupOperations
2917
{
3018
/// <summary>
3119
/// Initializes a new instance of the ApplyUpdateForResourceGroupOperations class.
@@ -36,13 +24,13 @@ internal partial class ApplyUpdateForResourceGroupOperations : IServiceOperation
3624
/// <exception cref="System.ArgumentNullException">
3725
/// Thrown when a required parameter is null
3826
/// </exception>
39-
internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient client)
27+
internal ApplyUpdateForResourceGroupOperations (MaintenanceManagementClient client)
4028
{
41-
if (client == null)
29+
if (client == null)
4230
{
4331
throw new System.ArgumentNullException("client");
4432
}
45-
Client = client;
33+
this.Client = client;
4634
}
4735

4836
/// <summary>
@@ -62,13 +50,13 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
6250
/// <param name='cancellationToken'>
6351
/// The cancellation token.
6452
/// </param>
65-
/// <exception cref="MaintenanceErrorException">
53+
/// <exception cref="Microsoft.Rest.Azure.CloudException">
6654
/// Thrown when the operation returned an invalid status code
6755
/// </exception>
68-
/// <exception cref="SerializationException">
56+
/// <exception cref="Microsoft.Rest.SerializationException">
6957
/// Thrown when unable to deserialize the response
7058
/// </exception>
71-
/// <exception cref="ValidationException">
59+
/// <exception cref="Microsoft.Rest.ValidationException">
7260
/// Thrown when a required parameter is null
7361
/// </exception>
7462
/// <exception cref="System.ArgumentNullException">
@@ -77,65 +65,75 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
7765
/// <return>
7866
/// A response object containing the response body and response headers.
7967
/// </return>
80-
public async Task<AzureOperationResponse<IEnumerable<ApplyUpdate>>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
68+
public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<System.Collections.Generic.IEnumerable<ApplyUpdate>>> ListWithHttpMessagesAsync(string resourceGroupName, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
8169
{
82-
if (Client.SubscriptionId == null)
70+
71+
72+
73+
74+
if (this.Client.SubscriptionId == null)
8375
{
84-
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
76+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
8577
}
78+
8679
if (resourceGroupName == null)
8780
{
88-
throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
81+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName");
8982
}
90-
if (Client.ApiVersion == null)
83+
84+
if (this.Client.ApiVersion == null)
9185
{
92-
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
86+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion");
9387
}
88+
9489
// Tracing
95-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
90+
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
9691
string _invocationId = null;
9792
if (_shouldTrace)
9893
{
99-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
100-
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
94+
_invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
95+
System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
10196
tracingParameters.Add("resourceGroupName", resourceGroupName);
97+
98+
10299
tracingParameters.Add("cancellationToken", cancellationToken);
103-
ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
100+
Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
104101
}
105102
// Construct URL
106-
var _baseUrl = Client.BaseUri.AbsoluteUri;
103+
104+
var _baseUrl = this.Client.BaseUri.AbsoluteUri;
107105
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates").ToString();
108-
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
106+
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId));
109107
_url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
110-
List<string> _queryParameters = new List<string>();
111-
if (Client.ApiVersion != null)
108+
109+
System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
110+
if (this.Client.ApiVersion != null)
112111
{
113-
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
112+
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion)));
114113
}
115114
if (_queryParameters.Count > 0)
116115
{
117116
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
118117
}
119118
// Create HTTP transport objects
120-
var _httpRequest = new HttpRequestMessage();
121-
HttpResponseMessage _httpResponse = null;
122-
_httpRequest.Method = new HttpMethod("GET");
119+
var _httpRequest = new System.Net.Http.HttpRequestMessage();
120+
System.Net.Http.HttpResponseMessage _httpResponse = null;
121+
_httpRequest.Method = new System.Net.Http.HttpMethod("GET");
123122
_httpRequest.RequestUri = new System.Uri(_url);
124123
// Set Headers
125-
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
124+
if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
126125
{
127126
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
128127
}
129-
if (Client.AcceptLanguage != null)
128+
if (this.Client.AcceptLanguage != null)
130129
{
131130
if (_httpRequest.Headers.Contains("accept-language"))
132131
{
133132
_httpRequest.Headers.Remove("accept-language");
134133
}
135-
_httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
134+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
136135
}
137136

138-
139137
if (customHeaders != null)
140138
{
141139
foreach(var _header in customHeaders)
@@ -147,50 +145,51 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
147145
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
148146
}
149147
}
150-
151148
// Serialize Request
152149
string _requestContent = null;
153150
// Set Credentials
154-
if (Client.Credentials != null)
151+
if (this.Client.Credentials != null)
155152
{
156153
cancellationToken.ThrowIfCancellationRequested();
157-
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
154+
await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
158155
}
159156
// Send Request
160157
if (_shouldTrace)
161158
{
162-
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
159+
Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
163160
}
164161
cancellationToken.ThrowIfCancellationRequested();
165-
_httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
162+
_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
166163
if (_shouldTrace)
167164
{
168-
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
165+
Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
169166
}
170-
HttpStatusCode _statusCode = _httpResponse.StatusCode;
167+
168+
System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
171169
cancellationToken.ThrowIfCancellationRequested();
172170
string _responseContent = null;
171+
173172
if ((int)_statusCode != 200)
174173
{
175174
var ex = new MaintenanceErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
176175
try
177176
{
178177
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
179-
MaintenanceError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<MaintenanceError>(_responseContent, Client.DeserializationSettings);
178+
MaintenanceError _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<MaintenanceError>(_responseContent, this.Client.DeserializationSettings);
180179
if (_errorBody != null)
181180
{
182181
ex.Body = _errorBody;
183182
}
184183
}
185-
catch (JsonException)
184+
catch (Newtonsoft.Json.JsonException)
186185
{
187186
// Ignore the exception
188187
}
189-
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
190-
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
188+
ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
189+
ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
191190
if (_shouldTrace)
192191
{
193-
ServiceClientTracing.Error(_invocationId, ex);
192+
Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
194193
}
195194
_httpRequest.Dispose();
196195
if (_httpResponse != null)
@@ -200,9 +199,10 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
200199
throw ex;
201200
}
202201
// Create Result
203-
var _result = new AzureOperationResponse<IEnumerable<ApplyUpdate>>();
202+
var _result = new Microsoft.Rest.Azure.AzureOperationResponse<System.Collections.Generic.IEnumerable<ApplyUpdate>>();
204203
_result.Request = _httpRequest;
205204
_result.Response = _httpResponse;
205+
206206
if (_httpResponse.Headers.Contains("x-ms-request-id"))
207207
{
208208
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
@@ -213,24 +213,28 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
213213
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
214214
try
215215
{
216-
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ApplyUpdate>>(_responseContent, Client.DeserializationSettings);
216+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<ApplyUpdate>>(_responseContent, this.Client.DeserializationSettings);
217217
}
218-
catch (JsonException ex)
218+
catch (Newtonsoft.Json.JsonException ex)
219219
{
220220
_httpRequest.Dispose();
221221
if (_httpResponse != null)
222222
{
223223
_httpResponse.Dispose();
224224
}
225-
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
225+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
226226
}
227227
}
228228
if (_shouldTrace)
229229
{
230-
ServiceClientTracing.Exit(_invocationId, _result);
230+
Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
231231
}
232232
return _result;
233-
}
234233

234+
235+
236+
237+
238+
}
235239
}
236-
}
240+
}
Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,49 @@
1-
// <auto-generated>
21
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
// Licensed under the MIT License. See License.txt in the project root for
4-
// license information.
5-
//
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
63
// Code generated by Microsoft (R) AutoRest Code Generator.
7-
// Changes may cause incorrect behavior and will be lost if the code is
8-
// regenerated.
9-
// </auto-generated>
10-
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
115
namespace Microsoft.Azure.Management.Maintenance
126
{
13-
using Microsoft.Rest;
147
using Microsoft.Rest.Azure;
158
using Models;
16-
using System.Collections;
17-
using System.Collections.Generic;
18-
using System.Threading;
19-
using System.Threading.Tasks;
209

2110
/// <summary>
22-
/// Extension methods for ApplyUpdateForResourceGroupOperations.
11+
/// Extension methods for ApplyUpdateForResourceGroupOperations
2312
/// </summary>
2413
public static partial class ApplyUpdateForResourceGroupOperationsExtensions
2514
{
26-
/// <summary>
27-
/// Get Configuration records within a subscription and resource group
28-
/// </summary>
29-
/// <param name='operations'>
30-
/// The operations group for this extension method.
31-
/// </param>
32-
/// <param name='resourceGroupName'>
33-
/// Resource Group Name
34-
/// </param>
35-
public static IEnumerable<ApplyUpdate> List(this IApplyUpdateForResourceGroupOperations operations, string resourceGroupName)
36-
{
37-
return operations.ListAsync(resourceGroupName).GetAwaiter().GetResult();
38-
}
15+
/// <summary>
16+
/// Get Configuration records within a subscription and resource group
17+
/// </summary>
18+
/// <param name='operations'>
19+
/// The operations group for this extension method.
20+
/// </param>
21+
/// <param name='resourceGroupName'>
22+
/// Resource Group Name
23+
/// </param>
24+
public static System.Collections.Generic.IEnumerable<ApplyUpdate> List(this IApplyUpdateForResourceGroupOperations operations, string resourceGroupName)
25+
{
26+
return ((IApplyUpdateForResourceGroupOperations)operations).ListAsync(resourceGroupName).GetAwaiter().GetResult();
27+
}
3928

40-
/// <summary>
41-
/// Get Configuration records within a subscription and resource group
42-
/// </summary>
43-
/// <param name='operations'>
44-
/// The operations group for this extension method.
45-
/// </param>
46-
/// <param name='resourceGroupName'>
47-
/// Resource Group Name
48-
/// </param>
49-
/// <param name='cancellationToken'>
50-
/// The cancellation token.
51-
/// </param>
52-
public static async Task<IEnumerable<ApplyUpdate>> ListAsync(this IApplyUpdateForResourceGroupOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken))
29+
/// <summary>
30+
/// Get Configuration records within a subscription and resource group
31+
/// </summary>
32+
/// <param name='operations'>
33+
/// The operations group for this extension method.
34+
/// </param>
35+
/// <param name='resourceGroupName'>
36+
/// Resource Group Name
37+
/// </param>
38+
/// <param name='cancellationToken'>
39+
/// The cancellation token.
40+
/// </param>
41+
public static async System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ApplyUpdate>> ListAsync(this IApplyUpdateForResourceGroupOperations operations, string resourceGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
42+
{
43+
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false))
5344
{
54-
using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false))
55-
{
56-
return _result.Body;
57-
}
45+
return _result.Body;
5846
}
59-
47+
}
6048
}
6149
}

0 commit comments

Comments
 (0)