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 . Maintenance
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
/// ApplyUpdateForResourceGroupOperations operations.
27
15
/// </summary>
28
- internal partial class ApplyUpdateForResourceGroupOperations : IServiceOperations < MaintenanceManagementClient > , IApplyUpdateForResourceGroupOperations
16
+ internal partial class ApplyUpdateForResourceGroupOperations : Microsoft . Rest . IServiceOperations < MaintenanceManagementClient > , IApplyUpdateForResourceGroupOperations
29
17
{
30
18
/// <summary>
31
19
/// Initializes a new instance of the ApplyUpdateForResourceGroupOperations class.
@@ -36,13 +24,13 @@ internal partial class ApplyUpdateForResourceGroupOperations : IServiceOperation
36
24
/// <exception cref="System.ArgumentNullException">
37
25
/// Thrown when a required parameter is null
38
26
/// </exception>
39
- internal ApplyUpdateForResourceGroupOperations ( MaintenanceManagementClient client )
27
+ internal ApplyUpdateForResourceGroupOperations ( MaintenanceManagementClient 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>
@@ -62,13 +50,13 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
62
50
/// <param name='cancellationToken'>
63
51
/// The cancellation token.
64
52
/// </param>
65
- /// <exception cref="MaintenanceErrorException ">
53
+ /// <exception cref="Microsoft.Rest.Azure.CloudException ">
66
54
/// Thrown when the operation returned an invalid status code
67
55
/// </exception>
68
- /// <exception cref="SerializationException">
56
+ /// <exception cref="Microsoft.Rest. SerializationException">
69
57
/// Thrown when unable to deserialize the response
70
58
/// </exception>
71
- /// <exception cref="ValidationException">
59
+ /// <exception cref="Microsoft.Rest. ValidationException">
72
60
/// Thrown when a required parameter is null
73
61
/// </exception>
74
62
/// <exception cref="System.ArgumentNullException">
@@ -77,65 +65,75 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
77
65
/// <return>
78
66
/// A response object containing the response body and response headers.
79
67
/// </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 ) )
81
69
{
82
- if ( Client . SubscriptionId == null )
70
+
71
+
72
+
73
+
74
+ if ( this . Client . SubscriptionId == null )
83
75
{
84
- throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
76
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
85
77
}
78
+
86
79
if ( resourceGroupName == null )
87
80
{
88
- throw new ValidationException ( ValidationRules . CannotBeNull , "resourceGroupName" ) ;
81
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "resourceGroupName" ) ;
89
82
}
90
- if ( Client . ApiVersion == null )
83
+
84
+ if ( this . Client . ApiVersion == null )
91
85
{
92
- throw new ValidationException ( ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
86
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.ApiVersion" ) ;
93
87
}
88
+
94
89
// Tracing
95
- bool _shouldTrace = ServiceClientTracing . IsEnabled ;
90
+ bool _shouldTrace = Microsoft . Rest . ServiceClientTracing . IsEnabled ;
96
91
string _invocationId = null ;
97
92
if ( _shouldTrace )
98
93
{
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 > ( ) ;
101
96
tracingParameters . Add ( "resourceGroupName" , resourceGroupName ) ;
97
+
98
+
102
99
tracingParameters . Add ( "cancellationToken" , cancellationToken ) ;
103
- ServiceClientTracing . Enter ( _invocationId , this , "List" , tracingParameters ) ;
100
+ Microsoft . Rest . ServiceClientTracing . Enter ( _invocationId , this , "List" , tracingParameters ) ;
104
101
}
105
102
// Construct URL
106
- var _baseUrl = Client . BaseUri . AbsoluteUri ;
103
+
104
+ var _baseUrl = this . Client . BaseUri . AbsoluteUri ;
107
105
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 ) ) ;
109
107
_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 )
112
111
{
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 ) ) ) ;
114
113
}
115
114
if ( _queryParameters . Count > 0 )
116
115
{
117
116
_url += ( _url . Contains ( "?" ) ? "&" : "?" ) + string . Join ( "&" , _queryParameters ) ;
118
117
}
119
118
// 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" ) ;
123
122
_httpRequest . RequestUri = new System . Uri ( _url ) ;
124
123
// Set Headers
125
- if ( Client . GenerateClientRequestId != null && Client . GenerateClientRequestId . Value )
124
+ if ( this . Client . GenerateClientRequestId != null && this . Client . GenerateClientRequestId . Value )
126
125
{
127
126
_httpRequest . Headers . TryAddWithoutValidation ( "x-ms-client-request-id" , System . Guid . NewGuid ( ) . ToString ( ) ) ;
128
127
}
129
- if ( Client . AcceptLanguage != null )
128
+ if ( this . Client . AcceptLanguage != null )
130
129
{
131
130
if ( _httpRequest . Headers . Contains ( "accept-language" ) )
132
131
{
133
132
_httpRequest . Headers . Remove ( "accept-language" ) ;
134
133
}
135
- _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , Client . AcceptLanguage ) ;
134
+ _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , this . Client . AcceptLanguage ) ;
136
135
}
137
136
138
-
139
137
if ( customHeaders != null )
140
138
{
141
139
foreach ( var _header in customHeaders )
@@ -147,50 +145,51 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
147
145
_httpRequest . Headers . TryAddWithoutValidation ( _header . Key , _header . Value ) ;
148
146
}
149
147
}
150
-
151
148
// Serialize Request
152
149
string _requestContent = null ;
153
150
// Set Credentials
154
- if ( Client . Credentials != null )
151
+ if ( this . Client . Credentials != null )
155
152
{
156
153
cancellationToken . ThrowIfCancellationRequested ( ) ;
157
- await Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
154
+ await this . Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
158
155
}
159
156
// Send Request
160
157
if ( _shouldTrace )
161
158
{
162
- ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
159
+ Microsoft . Rest . ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
163
160
}
164
161
cancellationToken . ThrowIfCancellationRequested ( ) ;
165
- _httpResponse = await Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
162
+ _httpResponse = await this . Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
166
163
if ( _shouldTrace )
167
164
{
168
- ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
165
+ Microsoft . Rest . ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
169
166
}
170
- HttpStatusCode _statusCode = _httpResponse . StatusCode ;
167
+
168
+ System . Net . HttpStatusCode _statusCode = _httpResponse . StatusCode ;
171
169
cancellationToken . ThrowIfCancellationRequested ( ) ;
172
170
string _responseContent = null ;
171
+
173
172
if ( ( int ) _statusCode != 200 )
174
173
{
175
174
var ex = new MaintenanceErrorException ( string . Format ( "Operation returned an invalid status code '{0}'" , _statusCode ) ) ;
176
175
try
177
176
{
178
177
_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 ) ;
180
179
if ( _errorBody != null )
181
180
{
182
181
ex . Body = _errorBody ;
183
182
}
184
183
}
185
- catch ( JsonException )
184
+ catch ( Newtonsoft . Json . JsonException )
186
185
{
187
186
// Ignore the exception
188
187
}
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 ) ;
191
190
if ( _shouldTrace )
192
191
{
193
- ServiceClientTracing . Error ( _invocationId , ex ) ;
192
+ Microsoft . Rest . ServiceClientTracing . Error ( _invocationId , ex ) ;
194
193
}
195
194
_httpRequest . Dispose ( ) ;
196
195
if ( _httpResponse != null )
@@ -200,9 +199,10 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
200
199
throw ex ;
201
200
}
202
201
// Create Result
203
- var _result = new AzureOperationResponse < IEnumerable < ApplyUpdate > > ( ) ;
202
+ var _result = new Microsoft . Rest . Azure . AzureOperationResponse < System . Collections . Generic . IEnumerable < ApplyUpdate > > ( ) ;
204
203
_result . Request = _httpRequest ;
205
204
_result . Response = _httpResponse ;
205
+
206
206
if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
207
207
{
208
208
_result . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
@@ -213,24 +213,28 @@ internal ApplyUpdateForResourceGroupOperations(MaintenanceManagementClient clien
213
213
_responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
214
214
try
215
215
{
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 ) ;
217
217
}
218
- catch ( JsonException ex )
218
+ catch ( Newtonsoft . Json . JsonException ex )
219
219
{
220
220
_httpRequest . Dispose ( ) ;
221
221
if ( _httpResponse != null )
222
222
{
223
223
_httpResponse . Dispose ( ) ;
224
224
}
225
- throw new SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
225
+ throw new Microsoft . Rest . SerializationException ( "Unable to deserialize the response." , _responseContent , ex ) ;
226
226
}
227
227
}
228
228
if ( _shouldTrace )
229
229
{
230
- ServiceClientTracing . Exit ( _invocationId , _result ) ;
230
+ Microsoft . Rest . ServiceClientTracing . Exit ( _invocationId , _result ) ;
231
231
}
232
232
return _result ;
233
- }
234
233
234
+
235
+
236
+
237
+
238
+ }
235
239
}
236
- }
240
+ }
0 commit comments