1
+ // Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected] )
2
+ // Changes may cause incorrect behavior and will be lost if the code is regenerated.
3
+
4
+ namespace Microsoft . Azure . Management . FrontDoor
5
+ {
6
+ using System . Linq ;
7
+ using Microsoft . Rest ;
8
+ using Microsoft . Rest . Azure ;
9
+ using Models ;
10
+
11
+ /// <summary>
12
+ /// EndpointsOperations operations.
13
+ /// </summary>
14
+ internal partial class EndpointsOperations : Microsoft . Rest . IServiceOperations < FrontDoor > , IEndpointsOperations
15
+ {
16
+ /// <summary>
17
+ /// Initializes a new instance of the EndpointsOperations class.
18
+ /// </summary>
19
+ /// <param name='client'>
20
+ /// Reference to the service client.
21
+ /// </param>
22
+ /// <exception cref="System.ArgumentNullException">
23
+ /// Thrown when a required parameter is null
24
+ /// </exception>
25
+ internal EndpointsOperations ( FrontDoor client )
26
+ {
27
+ if ( client == null )
28
+ {
29
+ throw new System . ArgumentNullException ( "client" ) ;
30
+ }
31
+ this . Client = client ;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Gets a reference to the FrontDoor
36
+ /// </summary>
37
+ public FrontDoor Client { get ; private set ; }
38
+
39
+ /// <summary>
40
+ /// Removes a content from Front Door.
41
+ /// </summary>
42
+ /// <param name='resourceGroupName'>
43
+ /// Name of the Resource group within the Azure subscription.
44
+ /// </param>
45
+ /// <param name='frontDoorName'>
46
+ /// Name of the Front Door which is globally unique.
47
+ /// </param>
48
+ /// <param name='contentFilePaths'>
49
+ /// The path to the content to be purged. Path can be a full URL, e.g.
50
+ /// '/pictures/city.png' which removes a single file, or a directory with a
51
+ /// wildcard, e.g. '/pictures/*' which removes all folders and files in the
52
+ /// directory.
53
+ /// </param>
54
+ /// <param name='customHeaders'>
55
+ /// Headers that will be added to request.
56
+ /// </param>
57
+ /// <param name='cancellationToken'>
58
+ /// The cancellation token.
59
+ /// </param>
60
+ public async System . Threading . Tasks . Task < Microsoft . Rest . Azure . AzureOperationResponse > PurgeContentWithHttpMessagesAsync ( string resourceGroupName , string frontDoorName , PurgeParameters contentFilePaths , System . Collections . Generic . Dictionary < string , System . Collections . Generic . List < string > > customHeaders = null , System . Threading . CancellationToken cancellationToken = default ( System . Threading . CancellationToken ) )
61
+ {
62
+ // Send Request
63
+ Microsoft . Rest . Azure . AzureOperationResponse _response = await BeginPurgeContentWithHttpMessagesAsync ( resourceGroupName , frontDoorName , contentFilePaths , customHeaders , cancellationToken ) . ConfigureAwait ( false ) ;
64
+ return await this . Client . GetPostOrDeleteOperationResultAsync ( _response , customHeaders , cancellationToken ) . ConfigureAwait ( false ) ;
65
+ }
66
+
67
+ /// <summary>
68
+ /// Removes a content from Front Door.
69
+ /// </summary>
70
+ /// <param name='resourceGroupName'>
71
+ /// Name of the Resource group within the Azure subscription.
72
+ /// </param>
73
+ /// <param name='frontDoorName'>
74
+ /// Name of the Front Door which is globally unique.
75
+ /// </param>
76
+ /// <param name='contentFilePaths'>
77
+ /// The path to the content to be purged. Path can be a full URL, e.g.
78
+ /// '/pictures/city.png' which removes a single file, or a directory with a
79
+ /// wildcard, e.g. '/pictures/*' which removes all folders and files in the
80
+ /// directory.
81
+ /// </param>
82
+ /// <param name='customHeaders'>
83
+ /// Headers that will be added to request.
84
+ /// </param>
85
+ /// <param name='cancellationToken'>
86
+ /// The cancellation token.
87
+ /// </param>
88
+ /// <exception cref="Microsoft.Rest.Azure.CloudException">
89
+ /// Thrown when the operation returned an invalid status code
90
+ /// </exception>
91
+ /// <exception cref="Microsoft.Rest.ValidationException">
92
+ /// Thrown when a required parameter is null
93
+ /// </exception>
94
+ /// <exception cref="System.ArgumentNullException">
95
+ /// Thrown when a required parameter is null
96
+ /// </exception>
97
+ /// <return>
98
+ /// A response object containing the response body and response headers.
99
+ /// </return>
100
+ public async System . Threading . Tasks . Task < Microsoft . Rest . Azure . AzureOperationResponse > BeginPurgeContentWithHttpMessagesAsync ( string resourceGroupName , string frontDoorName , PurgeParameters contentFilePaths , System . Collections . Generic . Dictionary < string , System . Collections . Generic . List < string > > customHeaders = null , System . Threading . CancellationToken cancellationToken = default ( System . Threading . CancellationToken ) )
101
+ {
102
+
103
+
104
+
105
+
106
+ if ( contentFilePaths == null )
107
+ {
108
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "contentFilePaths" ) ;
109
+ }
110
+ if ( contentFilePaths != null )
111
+ {
112
+ contentFilePaths . Validate ( ) ;
113
+ }
114
+ if ( this . Client . SubscriptionId == null )
115
+ {
116
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "this.Client.SubscriptionId" ) ;
117
+ }
118
+
119
+ if ( resourceGroupName == null )
120
+ {
121
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "resourceGroupName" ) ;
122
+ }
123
+ if ( resourceGroupName != null )
124
+ {
125
+ if ( resourceGroupName . Length > 80 )
126
+ {
127
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MaxLength , "resourceGroupName" , 80 ) ;
128
+ }
129
+ if ( resourceGroupName . Length < 1 )
130
+ {
131
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MinLength , "resourceGroupName" , 1 ) ;
132
+ }
133
+ if ( ! System . Text . RegularExpressions . Regex . IsMatch ( resourceGroupName , "^[a-zA-Z0-9_\\ -\\ (\\ )\\ .]*[^\\ .]$" ) )
134
+ {
135
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . Pattern , "resourceGroupName" , "^[a-zA-Z0-9_\\ -\\ (\\ )\\ .]*[^\\ .]$" ) ;
136
+ }
137
+ }
138
+ if ( frontDoorName == null )
139
+ {
140
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . CannotBeNull , "frontDoorName" ) ;
141
+ }
142
+ if ( frontDoorName != null )
143
+ {
144
+ if ( frontDoorName . Length > 64 )
145
+ {
146
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MaxLength , "frontDoorName" , 64 ) ;
147
+ }
148
+ if ( frontDoorName . Length < 5 )
149
+ {
150
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . MinLength , "frontDoorName" , 5 ) ;
151
+ }
152
+ if ( ! System . Text . RegularExpressions . Regex . IsMatch ( frontDoorName , "^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$" ) )
153
+ {
154
+ throw new Microsoft . Rest . ValidationException ( Microsoft . Rest . ValidationRules . Pattern , "frontDoorName" , "^[a-zA-Z0-9]+([-a-zA-Z0-9]?[a-zA-Z0-9])*$" ) ;
155
+ }
156
+ }
157
+ string apiVersion = "2021-06-01" ;
158
+ // Tracing
159
+ bool _shouldTrace = Microsoft . Rest . ServiceClientTracing . IsEnabled ;
160
+ string _invocationId = null ;
161
+ if ( _shouldTrace )
162
+ {
163
+ _invocationId = Microsoft . Rest . ServiceClientTracing . NextInvocationId . ToString ( ) ;
164
+ System . Collections . Generic . Dictionary < string , object > tracingParameters = new System . Collections . Generic . Dictionary < string , object > ( ) ;
165
+ tracingParameters . Add ( "resourceGroupName" , resourceGroupName ) ;
166
+ tracingParameters . Add ( "frontDoorName" , frontDoorName ) ;
167
+ tracingParameters . Add ( "apiVersion" , apiVersion ) ;
168
+
169
+ tracingParameters . Add ( "contentFilePaths" , contentFilePaths ) ;
170
+
171
+ tracingParameters . Add ( "cancellationToken" , cancellationToken ) ;
172
+ Microsoft . Rest . ServiceClientTracing . Enter ( _invocationId , this , "BeginPurgeContent" , tracingParameters ) ;
173
+ }
174
+ // Construct URL
175
+
176
+ var _baseUrl = this . Client . BaseUri . AbsoluteUri ;
177
+ var _url = new System . Uri ( new System . Uri ( _baseUrl + ( _baseUrl . EndsWith ( "/" ) ? "" : "/" ) ) , "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge" ) . ToString ( ) ;
178
+ _url = _url . Replace ( "{subscriptionId}" , System . Uri . EscapeDataString ( this . Client . SubscriptionId ) ) ;
179
+ _url = _url . Replace ( "{resourceGroupName}" , System . Uri . EscapeDataString ( resourceGroupName ) ) ;
180
+ _url = _url . Replace ( "{frontDoorName}" , System . Uri . EscapeDataString ( frontDoorName ) ) ;
181
+
182
+ System . Collections . Generic . List < string > _queryParameters = new System . Collections . Generic . List < string > ( ) ;
183
+ if ( apiVersion != null )
184
+ {
185
+ _queryParameters . Add ( string . Format ( "api-version={0}" , System . Uri . EscapeDataString ( apiVersion ) ) ) ;
186
+ }
187
+ if ( _queryParameters . Count > 0 )
188
+ {
189
+ _url += ( _url . Contains ( "?" ) ? "&" : "?" ) + string . Join ( "&" , _queryParameters ) ;
190
+ }
191
+ // Create HTTP transport objects
192
+ var _httpRequest = new System . Net . Http . HttpRequestMessage ( ) ;
193
+ System . Net . Http . HttpResponseMessage _httpResponse = null ;
194
+ _httpRequest . Method = new System . Net . Http . HttpMethod ( "POST" ) ;
195
+ _httpRequest . RequestUri = new System . Uri ( _url ) ;
196
+ // Set Headers
197
+ if ( this . Client . GenerateClientRequestId != null && this . Client . GenerateClientRequestId . Value )
198
+ {
199
+ _httpRequest . Headers . TryAddWithoutValidation ( "x-ms-client-request-id" , System . Guid . NewGuid ( ) . ToString ( ) ) ;
200
+ }
201
+ if ( this . Client . AcceptLanguage != null )
202
+ {
203
+ if ( _httpRequest . Headers . Contains ( "accept-language" ) )
204
+ {
205
+ _httpRequest . Headers . Remove ( "accept-language" ) ;
206
+ }
207
+ _httpRequest . Headers . TryAddWithoutValidation ( "accept-language" , this . Client . AcceptLanguage ) ;
208
+ }
209
+
210
+ if ( customHeaders != null )
211
+ {
212
+ foreach ( var _header in customHeaders )
213
+ {
214
+ if ( _httpRequest . Headers . Contains ( _header . Key ) )
215
+ {
216
+ _httpRequest . Headers . Remove ( _header . Key ) ;
217
+ }
218
+ _httpRequest . Headers . TryAddWithoutValidation ( _header . Key , _header . Value ) ;
219
+ }
220
+ }
221
+ // Serialize Request
222
+ string _requestContent = null ;
223
+ if ( contentFilePaths != null )
224
+ {
225
+ _requestContent = Microsoft . Rest . Serialization . SafeJsonConvert . SerializeObject ( contentFilePaths , this . Client . SerializationSettings ) ;
226
+ _httpRequest . Content = new System . Net . Http . StringContent ( _requestContent , System . Text . Encoding . UTF8 ) ;
227
+ _httpRequest . Content . Headers . ContentType = System . Net . Http . Headers . MediaTypeHeaderValue . Parse ( "application/json; charset=utf-8" ) ;
228
+ }
229
+ // Set Credentials
230
+ if ( this . Client . Credentials != null )
231
+ {
232
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
233
+ await this . Client . Credentials . ProcessHttpRequestAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
234
+ }
235
+ // Send Request
236
+ if ( _shouldTrace )
237
+ {
238
+ Microsoft . Rest . ServiceClientTracing . SendRequest ( _invocationId , _httpRequest ) ;
239
+ }
240
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
241
+ _httpResponse = await this . Client . HttpClient . SendAsync ( _httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
242
+ if ( _shouldTrace )
243
+ {
244
+ Microsoft . Rest . ServiceClientTracing . ReceiveResponse ( _invocationId , _httpResponse ) ;
245
+ }
246
+
247
+ System . Net . HttpStatusCode _statusCode = _httpResponse . StatusCode ;
248
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
249
+ string _responseContent = null ;
250
+
251
+ if ( ( int ) _statusCode != 200 && ( int ) _statusCode != 202 )
252
+ {
253
+ var ex = new ErrorResponseException ( string . Format ( "Operation returned an invalid status code '{0}'" , _statusCode ) ) ;
254
+ try
255
+ {
256
+ _responseContent = await _httpResponse . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
257
+ ErrorResponse _errorBody = Microsoft . Rest . Serialization . SafeJsonConvert . DeserializeObject < ErrorResponse > ( _responseContent , this . Client . DeserializationSettings ) ;
258
+ if ( _errorBody != null )
259
+ {
260
+ ex . Body = _errorBody ;
261
+ }
262
+ }
263
+ catch ( Newtonsoft . Json . JsonException )
264
+ {
265
+ // Ignore the exception
266
+ }
267
+ ex . Request = new Microsoft . Rest . HttpRequestMessageWrapper ( _httpRequest , _requestContent ) ;
268
+ ex . Response = new Microsoft . Rest . HttpResponseMessageWrapper ( _httpResponse , _responseContent ) ;
269
+ if ( _shouldTrace )
270
+ {
271
+ Microsoft . Rest . ServiceClientTracing . Error ( _invocationId , ex ) ;
272
+ }
273
+ _httpRequest . Dispose ( ) ;
274
+ if ( _httpResponse != null )
275
+ {
276
+ _httpResponse . Dispose ( ) ;
277
+ }
278
+ throw ex ;
279
+ }
280
+ // Create Result
281
+ var _result = new Microsoft . Rest . Azure . AzureOperationResponse ( ) ;
282
+ _result . Request = _httpRequest ;
283
+ _result . Response = _httpResponse ;
284
+
285
+ if ( _httpResponse . Headers . Contains ( "x-ms-request-id" ) )
286
+ {
287
+ _result . RequestId = _httpResponse . Headers . GetValues ( "x-ms-request-id" ) . FirstOrDefault ( ) ;
288
+ }
289
+ if ( _shouldTrace )
290
+ {
291
+ Microsoft . Rest . ServiceClientTracing . Exit ( _invocationId , _result ) ;
292
+ }
293
+ return _result ;
294
+
295
+
296
+
297
+
298
+
299
+ }
300
+ }
301
+ }
0 commit comments