Skip to content

Commit 0973958

Browse files
authored
Migrate RedisCache SDK from autorest.csharp to autorest.powershell (#22870)
1 parent e701422 commit 0973958

File tree

108 files changed

+29671
-17024
lines changed

Some content is hidden

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

108 files changed

+29671
-17024
lines changed
Lines changed: 69 additions & 64 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.RedisCache
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
/// AsyncOperationStatusOperations operations.
2715
/// </summary>
28-
internal partial class AsyncOperationStatusOperations : IServiceOperations<RedisManagementClient>, IAsyncOperationStatusOperations
16+
internal partial class AsyncOperationStatusOperations : Microsoft.Rest.IServiceOperations<RedisManagementClient>, IAsyncOperationStatusOperations
2917
{
3018
/// <summary>
3119
/// Initializes a new instance of the AsyncOperationStatusOperations class.
@@ -36,13 +24,13 @@ internal partial class AsyncOperationStatusOperations : IServiceOperations<Redis
3624
/// <exception cref="System.ArgumentNullException">
3725
/// Thrown when a required parameter is null
3826
/// </exception>
39-
internal AsyncOperationStatusOperations(RedisManagementClient client)
27+
internal AsyncOperationStatusOperations (RedisManagementClient 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>
@@ -65,13 +53,13 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
6553
/// <param name='cancellationToken'>
6654
/// The cancellation token.
6755
/// </param>
68-
/// <exception cref="ErrorResponseException">
56+
/// <exception cref="Microsoft.Rest.Azure.CloudException">
6957
/// Thrown when the operation returned an invalid status code
7058
/// </exception>
71-
/// <exception cref="SerializationException">
59+
/// <exception cref="Microsoft.Rest.SerializationException">
7260
/// Thrown when unable to deserialize the response
7361
/// </exception>
74-
/// <exception cref="ValidationException">
62+
/// <exception cref="Microsoft.Rest.ValidationException">
7563
/// Thrown when a required parameter is null
7664
/// </exception>
7765
/// <exception cref="System.ArgumentNullException">
@@ -80,71 +68,82 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
8068
/// <return>
8169
/// A response object containing the response body and response headers.
8270
/// </return>
83-
public async Task<AzureOperationResponse<OperationStatus>> GetWithHttpMessagesAsync(string location, string operationId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
71+
public async System.Threading.Tasks.Task<Microsoft.Rest.Azure.AzureOperationResponse<OperationStatus>> GetWithHttpMessagesAsync(string location, string operationId, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
8472
{
73+
74+
75+
76+
8577
if (location == null)
8678
{
87-
throw new ValidationException(ValidationRules.CannotBeNull, "location");
79+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "location");
8880
}
81+
8982
if (operationId == null)
9083
{
91-
throw new ValidationException(ValidationRules.CannotBeNull, "operationId");
84+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "operationId");
9285
}
93-
if (Client.ApiVersion == null)
86+
87+
if (this.Client.ApiVersion == null)
9488
{
95-
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
89+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion");
9690
}
97-
if (Client.SubscriptionId == null)
91+
92+
if (this.Client.SubscriptionId == null)
9893
{
99-
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
94+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
10095
}
96+
10197
// Tracing
102-
bool _shouldTrace = ServiceClientTracing.IsEnabled;
98+
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
10399
string _invocationId = null;
104100
if (_shouldTrace)
105101
{
106-
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
107-
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
102+
_invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString();
103+
System.Collections.Generic.Dictionary<string, object> tracingParameters = new System.Collections.Generic.Dictionary<string, object>();
108104
tracingParameters.Add("location", location);
109105
tracingParameters.Add("operationId", operationId);
106+
107+
110108
tracingParameters.Add("cancellationToken", cancellationToken);
111-
ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
109+
Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
112110
}
113111
// Construct URL
114-
var _baseUrl = Client.BaseUri.AbsoluteUri;
112+
113+
var _baseUrl = this.Client.BaseUri.AbsoluteUri;
115114
var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/asyncOperations/{operationId}").ToString();
116115
_url = _url.Replace("{location}", System.Uri.EscapeDataString(location));
117116
_url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId));
118-
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
119-
List<string> _queryParameters = new List<string>();
120-
if (Client.ApiVersion != null)
117+
_url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId));
118+
119+
System.Collections.Generic.List<string> _queryParameters = new System.Collections.Generic.List<string>();
120+
if (this.Client.ApiVersion != null)
121121
{
122-
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
122+
_queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion)));
123123
}
124124
if (_queryParameters.Count > 0)
125125
{
126126
_url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
127127
}
128128
// Create HTTP transport objects
129-
var _httpRequest = new HttpRequestMessage();
130-
HttpResponseMessage _httpResponse = null;
131-
_httpRequest.Method = new HttpMethod("GET");
129+
var _httpRequest = new System.Net.Http.HttpRequestMessage();
130+
System.Net.Http.HttpResponseMessage _httpResponse = null;
131+
_httpRequest.Method = new System.Net.Http.HttpMethod("GET");
132132
_httpRequest.RequestUri = new System.Uri(_url);
133133
// Set Headers
134-
if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
134+
if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value)
135135
{
136136
_httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
137137
}
138-
if (Client.AcceptLanguage != null)
138+
if (this.Client.AcceptLanguage != null)
139139
{
140140
if (_httpRequest.Headers.Contains("accept-language"))
141141
{
142142
_httpRequest.Headers.Remove("accept-language");
143143
}
144-
_httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
144+
_httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage);
145145
}
146146

147-
148147
if (customHeaders != null)
149148
{
150149
foreach(var _header in customHeaders)
@@ -156,50 +155,51 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
156155
_httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
157156
}
158157
}
159-
160158
// Serialize Request
161159
string _requestContent = null;
162160
// Set Credentials
163-
if (Client.Credentials != null)
161+
if (this.Client.Credentials != null)
164162
{
165163
cancellationToken.ThrowIfCancellationRequested();
166-
await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
164+
await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
167165
}
168166
// Send Request
169167
if (_shouldTrace)
170168
{
171-
ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
169+
Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
172170
}
173171
cancellationToken.ThrowIfCancellationRequested();
174-
_httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
172+
_httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
175173
if (_shouldTrace)
176174
{
177-
ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
175+
Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
178176
}
179-
HttpStatusCode _statusCode = _httpResponse.StatusCode;
177+
178+
System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode;
180179
cancellationToken.ThrowIfCancellationRequested();
181180
string _responseContent = null;
181+
182182
if ((int)_statusCode != 200)
183183
{
184184
var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
185185
try
186186
{
187187
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
188-
ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_responseContent, Client.DeserializationSettings);
188+
ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_responseContent, this.Client.DeserializationSettings);
189189
if (_errorBody != null)
190190
{
191191
ex.Body = _errorBody;
192192
}
193193
}
194-
catch (JsonException)
194+
catch (Newtonsoft.Json.JsonException)
195195
{
196196
// Ignore the exception
197197
}
198-
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
199-
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
198+
ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent);
199+
ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent);
200200
if (_shouldTrace)
201201
{
202-
ServiceClientTracing.Error(_invocationId, ex);
202+
Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex);
203203
}
204204
_httpRequest.Dispose();
205205
if (_httpResponse != null)
@@ -209,9 +209,10 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
209209
throw ex;
210210
}
211211
// Create Result
212-
var _result = new AzureOperationResponse<OperationStatus>();
212+
var _result = new Microsoft.Rest.Azure.AzureOperationResponse<OperationStatus>();
213213
_result.Request = _httpRequest;
214214
_result.Response = _httpResponse;
215+
215216
if (_httpResponse.Headers.Contains("x-ms-request-id"))
216217
{
217218
_result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
@@ -222,24 +223,28 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
222223
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
223224
try
224225
{
225-
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseContent, Client.DeserializationSettings);
226+
_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseContent, this.Client.DeserializationSettings);
226227
}
227-
catch (JsonException ex)
228+
catch (Newtonsoft.Json.JsonException ex)
228229
{
229230
_httpRequest.Dispose();
230231
if (_httpResponse != null)
231232
{
232233
_httpResponse.Dispose();
233234
}
234-
throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
235+
throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex);
235236
}
236237
}
237238
if (_shouldTrace)
238239
{
239-
ServiceClientTracing.Exit(_invocationId, _result);
240+
Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result);
240241
}
241242
return _result;
242-
}
243243

244+
245+
246+
247+
248+
}
244249
}
245-
}
250+
}
Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,55 @@
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.RedisCache
126
{
13-
using Microsoft.Rest;
147
using Microsoft.Rest.Azure;
158
using Models;
16-
using System.Threading;
17-
using System.Threading.Tasks;
189

1910
/// <summary>
20-
/// Extension methods for AsyncOperationStatusOperations.
11+
/// Extension methods for AsyncOperationStatusOperations
2112
/// </summary>
2213
public static partial class AsyncOperationStatusOperationsExtensions
2314
{
24-
/// <summary>
25-
/// For checking the ongoing status of an operation
26-
/// </summary>
27-
/// <param name='operations'>
28-
/// The operations group for this extension method.
29-
/// </param>
30-
/// <param name='location'>
31-
/// The location at which operation was triggered
32-
/// </param>
33-
/// <param name='operationId'>
34-
/// The ID of asynchronous operation
35-
/// </param>
36-
public static OperationStatus Get(this IAsyncOperationStatusOperations operations, string location, string operationId)
37-
{
38-
return operations.GetAsync(location, operationId).GetAwaiter().GetResult();
39-
}
15+
/// <summary>
16+
/// For checking the ongoing status of an operation
17+
/// </summary>
18+
/// <param name='operations'>
19+
/// The operations group for this extension method.
20+
/// </param>
21+
/// <param name='location'>
22+
/// The location at which operation was triggered
23+
/// </param>
24+
/// <param name='operationId'>
25+
/// The ID of asynchronous operation
26+
/// </param>
27+
public static OperationStatus Get(this IAsyncOperationStatusOperations operations, string location, string operationId)
28+
{
29+
return ((IAsyncOperationStatusOperations)operations).GetAsync(location, operationId).GetAwaiter().GetResult();
30+
}
4031

41-
/// <summary>
42-
/// For checking the ongoing status of an operation
43-
/// </summary>
44-
/// <param name='operations'>
45-
/// The operations group for this extension method.
46-
/// </param>
47-
/// <param name='location'>
48-
/// The location at which operation was triggered
49-
/// </param>
50-
/// <param name='operationId'>
51-
/// The ID of asynchronous operation
52-
/// </param>
53-
/// <param name='cancellationToken'>
54-
/// The cancellation token.
55-
/// </param>
56-
public static async Task<OperationStatus> GetAsync(this IAsyncOperationStatusOperations operations, string location, string operationId, CancellationToken cancellationToken = default(CancellationToken))
32+
/// <summary>
33+
/// For checking the ongoing status of an operation
34+
/// </summary>
35+
/// <param name='operations'>
36+
/// The operations group for this extension method.
37+
/// </param>
38+
/// <param name='location'>
39+
/// The location at which operation was triggered
40+
/// </param>
41+
/// <param name='operationId'>
42+
/// The ID of asynchronous operation
43+
/// </param>
44+
/// <param name='cancellationToken'>
45+
/// The cancellation token.
46+
/// </param>
47+
public static async System.Threading.Tasks.Task<OperationStatus> GetAsync(this IAsyncOperationStatusOperations operations, string location, string operationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
48+
{
49+
using (var _result = await operations.GetWithHttpMessagesAsync(location, operationId, null, cancellationToken).ConfigureAwait(false))
5750
{
58-
using (var _result = await operations.GetWithHttpMessagesAsync(location, operationId, null, cancellationToken).ConfigureAwait(false))
59-
{
60-
return _result.Body;
61-
}
51+
return _result.Body;
6252
}
63-
53+
}
6454
}
6555
}

0 commit comments

Comments
 (0)