1
- // <auto-generated>
2
1
// 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.
6
3
// 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.
10
5
11
6
namespace Microsoft . Azure . Management . RedisCache
12
7
{
8
+ using System . Linq ;
13
9
using Microsoft . Rest ;
14
10
using Microsoft . Rest . Azure ;
15
11
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 ;
24
12
25
13
/// <summary>
26
14
/// AsyncOperationStatusOperations operations.
27
15
/// </summary>
28
- internal partial class AsyncOperationStatusOperations : IServiceOperations < RedisManagementClient > , IAsyncOperationStatusOperations
16
+ internal partial class AsyncOperationStatusOperations : Microsoft . Rest . IServiceOperations < RedisManagementClient > , IAsyncOperationStatusOperations
29
17
{
30
18
/// <summary>
31
19
/// Initializes a new instance of the AsyncOperationStatusOperations class.
@@ -36,13 +24,13 @@ internal partial class AsyncOperationStatusOperations : IServiceOperations<Redis
36
24
/// <exception cref="System.ArgumentNullException">
37
25
/// Thrown when a required parameter is null
38
26
/// </exception>
39
- internal AsyncOperationStatusOperations ( RedisManagementClient client )
27
+ internal AsyncOperationStatusOperations ( RedisManagementClient client )
40
28
{
41
- if ( client == null )
29
+ if ( client == null )
42
30
{
43
31
throw new System . ArgumentNullException ( "client" ) ;
44
32
}
45
- Client = client ;
33
+ this . Client = client ;
46
34
}
47
35
48
36
/// <summary>
@@ -65,13 +53,13 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
65
53
/// <param name='cancellationToken'>
66
54
/// The cancellation token.
67
55
/// </param>
68
- /// <exception cref="ErrorResponseException ">
56
+ /// <exception cref="Microsoft.Rest.Azure.CloudException ">
69
57
/// Thrown when the operation returned an invalid status code
70
58
/// </exception>
71
- /// <exception cref="SerializationException">
59
+ /// <exception cref="Microsoft.Rest. SerializationException">
72
60
/// Thrown when unable to deserialize the response
73
61
/// </exception>
74
- /// <exception cref="ValidationException">
62
+ /// <exception cref="Microsoft.Rest. ValidationException">
75
63
/// Thrown when a required parameter is null
76
64
/// </exception>
77
65
/// <exception cref="System.ArgumentNullException">
@@ -80,71 +68,82 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
80
68
/// <return>
81
69
/// A response object containing the response body and response headers.
82
70
/// </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 ) )
84
72
{
73
+
74
+
75
+
76
+
85
77
if ( location == null )
86
78
{
87
- throw new ValidationException ( ValidationRules . CannotBeNull , "location" ) ;
79
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "location" ) ;
88
80
}
81
+
89
82
if ( operationId == null )
90
83
{
91
- throw new ValidationException ( ValidationRules . CannotBeNull , "operationId" ) ;
84
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "operationId" ) ;
92
85
}
93
- if ( Client . ApiVersion == null )
86
+
87
+ if ( this . Client . ApiVersion == null )
94
88
{
95
- throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
89
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
96
90
}
97
- if ( Client . SubscriptionId == null )
91
+
92
+ if ( this . Client . SubscriptionId == null )
98
93
{
99
- throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
94
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
100
95
}
96
+
101
97
// Tracing
102
- bool _shouldTrace = ServiceClientTracing . IsEnabled ;
98
+ bool _shouldTrace = Microsoft . Rest . ServiceClientTracing . IsEnabled ;
103
99
string _invocationId = null ;
104
100
if ( _shouldTrace )
105
101
{
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 > ( ) ;
108
104
tracingParameters . Add ( "location" , location ) ;
109
105
tracingParameters . Add ( "operationId" , operationId ) ;
106
+
107
+
110
108
tracingParameters . Add ( "cancellationToken" , cancellationToken ) ;
111
- ServiceClientTracing . Enter ( _invocationId , this , "Get" , tracingParameters ) ;
109
+ Microsoft . Rest . ServiceClientTracing . Enter ( _invocationId , this , "Get" , tracingParameters ) ;
112
110
}
113
111
// Construct URL
114
- var _baseUrl = Client . BaseUri . AbsoluteUri ;
112
+
113
+ var _baseUrl = this . Client . BaseUri . AbsoluteUri ;
115
114
var _url = new System . Uri ( new System . Uri ( _baseUrl + ( _baseUrl . EndsWith ( "/" ) ? "" : "/" ) ) , "subscriptions/{subscriptionId}/providers/Microsoft.Cache/locations/{location}/asyncOperations/{operationId}" ) . ToString ( ) ;
116
115
_url = _url . Replace ( "{location}" , System . Uri . EscapeDataString ( location ) ) ;
117
116
_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 )
121
121
{
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 ) ) ) ;
123
123
}
124
124
if ( _queryParameters . Count > 0 )
125
125
{
126
126
_url += ( _url . Contains ( "?" ) ? "&" : "?" ) + string . Join ( "&" , _queryParameters ) ;
127
127
}
128
128
// 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" ) ;
132
132
_httpRequest . RequestUri = new System . Uri ( _url ) ;
133
133
// Set Headers
134
- if ( Client . GenerateClientRequestId != null && Client . GenerateClientRequestId . Value )
134
+ if ( this . Client . GenerateClientRequestId != null && this . Client . GenerateClientRequestId . Value )
135
135
{
136
136
_httpRequest . Headers . TryAddWithoutValidation ( "x-ms-client-request-id" , System . Guid . NewGuid ( ) . ToString ( ) ) ;
137
137
}
138
- if ( Client . AcceptLanguage != null )
138
+ if ( this . Client . AcceptLanguage != null )
139
139
{
140
140
if ( _httpRequest . Headers . Contains ( "accept-language" ) )
141
141
{
142
142
_httpRequest . Headers . Remove ( "accept-language" ) ;
143
143
}
144
- _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , Client . AcceptLanguage ) ;
144
+ _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , this . Client . AcceptLanguage ) ;
145
145
}
146
146
147
-
148
147
if ( customHeaders != null )
149
148
{
150
149
foreach ( var _header in customHeaders )
@@ -156,50 +155,51 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
156
155
_httpRequest . Headers . TryAddWithoutValidation ( _header . Key , _header . Value ) ;
157
156
}
158
157
}
159
-
160
158
// Serialize Request
161
159
string _requestContent = null ;
162
160
// Set Credentials
163
- if ( Client . Credentials != null )
161
+ if ( this . Client . Credentials != null )
164
162
{
165
163
cancellationToken . ThrowIfCancellationRequested ( ) ;
166
- await Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
164
+ await this . Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
167
165
}
168
166
// Send Request
169
167
if ( _shouldTrace )
170
168
{
171
- ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
169
+ Microsoft . Rest . ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
172
170
}
173
171
cancellationToken . ThrowIfCancellationRequested ( ) ;
174
- _httpResponse = await Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
172
+ _httpResponse = await this . Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
175
173
if ( _shouldTrace )
176
174
{
177
- ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
175
+ Microsoft . Rest . ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
178
176
}
179
- HttpStatusCode _statusCode = _httpResponse . StatusCode ;
177
+
178
+ System . Net . HttpStatusCode _statusCode = _httpResponse . StatusCode ;
180
179
cancellationToken . ThrowIfCancellationRequested ( ) ;
181
180
string _responseContent = null ;
181
+
182
182
if ( ( int ) _statusCode != 200 )
183
183
{
184
184
var ex = new ErrorResponseException ( string . Format ( "Operation returned an invalid status code '{0}'" , _statusCode ) ) ;
185
185
try
186
186
{
187
187
_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 ) ;
189
189
if ( _errorBody != null )
190
190
{
191
191
ex . Body = _errorBody ;
192
192
}
193
193
}
194
- catch ( JsonException )
194
+ catch ( Newtonsoft . Json . JsonException )
195
195
{
196
196
// Ignore the exception
197
197
}
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 ) ;
200
200
if ( _shouldTrace )
201
201
{
202
- ServiceClientTracing . Error ( _invocationId , ex ) ;
202
+ Microsoft . Rest . ServiceClientTracing . Error ( _invocationId , ex ) ;
203
203
}
204
204
_httpRequest . Dispose ( ) ;
205
205
if ( _httpResponse != null )
@@ -209,9 +209,10 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
209
209
throw ex ;
210
210
}
211
211
// Create Result
212
- var _result = new AzureOperationResponse < OperationStatus > ( ) ;
212
+ var _result = new Microsoft . Rest . Azure . AzureOperationResponse < OperationStatus > ( ) ;
213
213
_result . Request = _httpRequest ;
214
214
_result . Response = _httpResponse ;
215
+
215
216
if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
216
217
{
217
218
_result . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
@@ -222,24 +223,28 @@ internal AsyncOperationStatusOperations(RedisManagementClient client)
222
223
_responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
223
224
try
224
225
{
225
- _result . Body = Rest . Serialization . SafeJsonConvert . DeserializeObject < OperationStatus > ( _responseContent , Client . DeserializationSettings ) ;
226
+ _result . Body = Microsoft . Rest . Serialization . SafeJsonConvert . DeserializeObject < OperationStatus > ( _responseContent , this . Client . DeserializationSettings ) ;
226
227
}
227
- catch ( JsonException ex )
228
+ catch ( Newtonsoft . Json . JsonException ex )
228
229
{
229
230
_httpRequest . Dispose ( ) ;
230
231
if ( _httpResponse != null )
231
232
{
232
233
_httpResponse . Dispose ( ) ;
233
234
}
234
- throw new SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
235
+ throw new Microsoft . Rest . SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
235
236
}
236
237
}
237
238
if ( _shouldTrace )
238
239
{
239
- ServiceClientTracing . Exit ( _invocationId , _result ) ;
240
+ Microsoft . Rest . ServiceClientTracing . Exit ( _invocationId , _result ) ;
240
241
}
241
242
return _result ;
242
- }
243
243
244
+
245
+
246
+
247
+
248
+ }
244
249
}
245
- }
250
+ }
0 commit comments