| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Resources.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Resources |
| | 18 | | { |
| | 19 | | internal partial class FeaturesRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of FeaturesRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 16 | 32 | | public FeaturesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, |
| | 33 | | { |
| 16 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 16 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 16 | 40 | | this.subscriptionId = subscriptionId; |
| 16 | 41 | | this.endpoint = endpoint; |
| 16 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 16 | 43 | | _pipeline = pipeline; |
| 16 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateListAllRequest() |
| | 47 | | { |
| 4 | 48 | | var message = _pipeline.CreateMessage(); |
| 4 | 49 | | var request = message.Request; |
| 4 | 50 | | request.Method = RequestMethod.Get; |
| 4 | 51 | | var uri = new RawRequestUriBuilder(); |
| 4 | 52 | | uri.Reset(endpoint); |
| 4 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 54 | | uri.AppendPath(subscriptionId, true); |
| 4 | 55 | | uri.AppendPath("/providers/Microsoft.Features/features", false); |
| 4 | 56 | | uri.AppendQuery("api-version", "2015-12-01", true); |
| 4 | 57 | | request.Uri = uri; |
| 4 | 58 | | return message; |
| | 59 | | } |
| | 60 | |
|
| | 61 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public async Task<Response<FeatureOperationsListResult>> ListAllAsync(CancellationToken cancellationToken = defa |
| | 64 | | { |
| 2 | 65 | | using var message = CreateListAllRequest(); |
| 2 | 66 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 67 | | switch (message.Response.Status) |
| | 68 | | { |
| | 69 | | case 200: |
| | 70 | | { |
| 2 | 71 | | FeatureOperationsListResult value = default; |
| 2 | 72 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 73 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 74 | | { |
| 0 | 75 | | value = null; |
| | 76 | | } |
| | 77 | | else |
| | 78 | | { |
| 2 | 79 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 80 | | } |
| 2 | 81 | | return Response.FromValue(value, message.Response); |
| | 82 | | } |
| | 83 | | default: |
| 0 | 84 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 85 | | } |
| 2 | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 89 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 90 | | public Response<FeatureOperationsListResult> ListAll(CancellationToken cancellationToken = default) |
| | 91 | | { |
| 2 | 92 | | using var message = CreateListAllRequest(); |
| 2 | 93 | | _pipeline.Send(message, cancellationToken); |
| 2 | 94 | | switch (message.Response.Status) |
| | 95 | | { |
| | 96 | | case 200: |
| | 97 | | { |
| 2 | 98 | | FeatureOperationsListResult value = default; |
| 2 | 99 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 100 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 101 | | { |
| 0 | 102 | | value = null; |
| | 103 | | } |
| | 104 | | else |
| | 105 | | { |
| 2 | 106 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 107 | | } |
| 2 | 108 | | return Response.FromValue(value, message.Response); |
| | 109 | | } |
| | 110 | | default: |
| 0 | 111 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 112 | | } |
| 2 | 113 | | } |
| | 114 | |
|
| | 115 | | internal Core.HttpMessage CreateListRequest(string resourceProviderNamespace) |
| | 116 | | { |
| 4 | 117 | | var message = _pipeline.CreateMessage(); |
| 4 | 118 | | var request = message.Request; |
| 4 | 119 | | request.Method = RequestMethod.Get; |
| 4 | 120 | | var uri = new RawRequestUriBuilder(); |
| 4 | 121 | | uri.Reset(endpoint); |
| 4 | 122 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 123 | | uri.AppendPath(subscriptionId, true); |
| 4 | 124 | | uri.AppendPath("/providers/Microsoft.Features/providers/", false); |
| 4 | 125 | | uri.AppendPath(resourceProviderNamespace, true); |
| 4 | 126 | | uri.AppendPath("/features", false); |
| 4 | 127 | | uri.AppendQuery("api-version", "2015-12-01", true); |
| 4 | 128 | | request.Uri = uri; |
| 4 | 129 | | return message; |
| | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 133 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 134 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 135 | | public async Task<Response<FeatureOperationsListResult>> ListAsync(string resourceProviderNamespace, Cancellatio |
| | 136 | | { |
| 2 | 137 | | if (resourceProviderNamespace == null) |
| | 138 | | { |
| 0 | 139 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 140 | | } |
| | 141 | |
|
| 2 | 142 | | using var message = CreateListRequest(resourceProviderNamespace); |
| 2 | 143 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 144 | | switch (message.Response.Status) |
| | 145 | | { |
| | 146 | | case 200: |
| | 147 | | { |
| 2 | 148 | | FeatureOperationsListResult value = default; |
| 2 | 149 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 150 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 151 | | { |
| 0 | 152 | | value = null; |
| | 153 | | } |
| | 154 | | else |
| | 155 | | { |
| 2 | 156 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 157 | | } |
| 2 | 158 | | return Response.FromValue(value, message.Response); |
| | 159 | | } |
| | 160 | | default: |
| 0 | 161 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 162 | | } |
| 2 | 163 | | } |
| | 164 | |
|
| | 165 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 166 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 167 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 168 | | public Response<FeatureOperationsListResult> List(string resourceProviderNamespace, CancellationToken cancellati |
| | 169 | | { |
| 2 | 170 | | if (resourceProviderNamespace == null) |
| | 171 | | { |
| 0 | 172 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 173 | | } |
| | 174 | |
|
| 2 | 175 | | using var message = CreateListRequest(resourceProviderNamespace); |
| 2 | 176 | | _pipeline.Send(message, cancellationToken); |
| 2 | 177 | | switch (message.Response.Status) |
| | 178 | | { |
| | 179 | | case 200: |
| | 180 | | { |
| 2 | 181 | | FeatureOperationsListResult value = default; |
| 2 | 182 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 183 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 184 | | { |
| 0 | 185 | | value = null; |
| | 186 | | } |
| | 187 | | else |
| | 188 | | { |
| 2 | 189 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 190 | | } |
| 2 | 191 | | return Response.FromValue(value, message.Response); |
| | 192 | | } |
| | 193 | | default: |
| 0 | 194 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 195 | | } |
| 2 | 196 | | } |
| | 197 | |
|
| | 198 | | internal Core.HttpMessage CreateGetRequest(string resourceProviderNamespace, string featureName) |
| | 199 | | { |
| 4 | 200 | | var message = _pipeline.CreateMessage(); |
| 4 | 201 | | var request = message.Request; |
| 4 | 202 | | request.Method = RequestMethod.Get; |
| 4 | 203 | | var uri = new RawRequestUriBuilder(); |
| 4 | 204 | | uri.Reset(endpoint); |
| 4 | 205 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 206 | | uri.AppendPath(subscriptionId, true); |
| 4 | 207 | | uri.AppendPath("/providers/Microsoft.Features/providers/", false); |
| 4 | 208 | | uri.AppendPath(resourceProviderNamespace, true); |
| 4 | 209 | | uri.AppendPath("/features/", false); |
| 4 | 210 | | uri.AppendPath(featureName, true); |
| 4 | 211 | | uri.AppendQuery("api-version", "2015-12-01", true); |
| 4 | 212 | | request.Uri = uri; |
| 4 | 213 | | return message; |
| | 214 | | } |
| | 215 | |
|
| | 216 | | /// <summary> Gets the preview feature with the specified name. </summary> |
| | 217 | | /// <param name="resourceProviderNamespace"> The resource provider namespace for the feature. </param> |
| | 218 | | /// <param name="featureName"> The name of the feature to get. </param> |
| | 219 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 220 | | public async Task<Response<FeatureResult>> GetAsync(string resourceProviderNamespace, string featureName, Cancel |
| | 221 | | { |
| 2 | 222 | | if (resourceProviderNamespace == null) |
| | 223 | | { |
| 0 | 224 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 225 | | } |
| 2 | 226 | | if (featureName == null) |
| | 227 | | { |
| 0 | 228 | | throw new ArgumentNullException(nameof(featureName)); |
| | 229 | | } |
| | 230 | |
|
| 2 | 231 | | using var message = CreateGetRequest(resourceProviderNamespace, featureName); |
| 2 | 232 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 233 | | switch (message.Response.Status) |
| | 234 | | { |
| | 235 | | case 200: |
| | 236 | | { |
| 2 | 237 | | FeatureResult value = default; |
| 2 | 238 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 239 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 240 | | { |
| 0 | 241 | | value = null; |
| | 242 | | } |
| | 243 | | else |
| | 244 | | { |
| 2 | 245 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 246 | | } |
| 2 | 247 | | return Response.FromValue(value, message.Response); |
| | 248 | | } |
| | 249 | | default: |
| 0 | 250 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 251 | | } |
| 2 | 252 | | } |
| | 253 | |
|
| | 254 | | /// <summary> Gets the preview feature with the specified name. </summary> |
| | 255 | | /// <param name="resourceProviderNamespace"> The resource provider namespace for the feature. </param> |
| | 256 | | /// <param name="featureName"> The name of the feature to get. </param> |
| | 257 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 258 | | public Response<FeatureResult> Get(string resourceProviderNamespace, string featureName, CancellationToken cance |
| | 259 | | { |
| 2 | 260 | | if (resourceProviderNamespace == null) |
| | 261 | | { |
| 0 | 262 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 263 | | } |
| 2 | 264 | | if (featureName == null) |
| | 265 | | { |
| 0 | 266 | | throw new ArgumentNullException(nameof(featureName)); |
| | 267 | | } |
| | 268 | |
|
| 2 | 269 | | using var message = CreateGetRequest(resourceProviderNamespace, featureName); |
| 2 | 270 | | _pipeline.Send(message, cancellationToken); |
| 2 | 271 | | switch (message.Response.Status) |
| | 272 | | { |
| | 273 | | case 200: |
| | 274 | | { |
| 2 | 275 | | FeatureResult value = default; |
| 2 | 276 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 277 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 278 | | { |
| 0 | 279 | | value = null; |
| | 280 | | } |
| | 281 | | else |
| | 282 | | { |
| 2 | 283 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 284 | | } |
| 2 | 285 | | return Response.FromValue(value, message.Response); |
| | 286 | | } |
| | 287 | | default: |
| 0 | 288 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 289 | | } |
| 2 | 290 | | } |
| | 291 | |
|
| | 292 | | internal Core.HttpMessage CreateRegisterRequest(string resourceProviderNamespace, string featureName) |
| | 293 | | { |
| 4 | 294 | | var message = _pipeline.CreateMessage(); |
| 4 | 295 | | var request = message.Request; |
| 4 | 296 | | request.Method = RequestMethod.Post; |
| 4 | 297 | | var uri = new RawRequestUriBuilder(); |
| 4 | 298 | | uri.Reset(endpoint); |
| 4 | 299 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 300 | | uri.AppendPath(subscriptionId, true); |
| 4 | 301 | | uri.AppendPath("/providers/Microsoft.Features/providers/", false); |
| 4 | 302 | | uri.AppendPath(resourceProviderNamespace, true); |
| 4 | 303 | | uri.AppendPath("/features/", false); |
| 4 | 304 | | uri.AppendPath(featureName, true); |
| 4 | 305 | | uri.AppendPath("/register", false); |
| 4 | 306 | | uri.AppendQuery("api-version", "2015-12-01", true); |
| 4 | 307 | | request.Uri = uri; |
| 4 | 308 | | return message; |
| | 309 | | } |
| | 310 | |
|
| | 311 | | /// <summary> Registers the preview feature for the subscription. </summary> |
| | 312 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 313 | | /// <param name="featureName"> The name of the feature to register. </param> |
| | 314 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 315 | | public async Task<Response<FeatureResult>> RegisterAsync(string resourceProviderNamespace, string featureName, C |
| | 316 | | { |
| 2 | 317 | | if (resourceProviderNamespace == null) |
| | 318 | | { |
| 0 | 319 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 320 | | } |
| 2 | 321 | | if (featureName == null) |
| | 322 | | { |
| 0 | 323 | | throw new ArgumentNullException(nameof(featureName)); |
| | 324 | | } |
| | 325 | |
|
| 2 | 326 | | using var message = CreateRegisterRequest(resourceProviderNamespace, featureName); |
| 2 | 327 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 328 | | switch (message.Response.Status) |
| | 329 | | { |
| | 330 | | case 200: |
| | 331 | | { |
| 2 | 332 | | FeatureResult value = default; |
| 2 | 333 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 334 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 335 | | { |
| 0 | 336 | | value = null; |
| | 337 | | } |
| | 338 | | else |
| | 339 | | { |
| 2 | 340 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 341 | | } |
| 2 | 342 | | return Response.FromValue(value, message.Response); |
| | 343 | | } |
| | 344 | | default: |
| 0 | 345 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 346 | | } |
| 2 | 347 | | } |
| | 348 | |
|
| | 349 | | /// <summary> Registers the preview feature for the subscription. </summary> |
| | 350 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 351 | | /// <param name="featureName"> The name of the feature to register. </param> |
| | 352 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 353 | | public Response<FeatureResult> Register(string resourceProviderNamespace, string featureName, CancellationToken |
| | 354 | | { |
| 2 | 355 | | if (resourceProviderNamespace == null) |
| | 356 | | { |
| 0 | 357 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 358 | | } |
| 2 | 359 | | if (featureName == null) |
| | 360 | | { |
| 0 | 361 | | throw new ArgumentNullException(nameof(featureName)); |
| | 362 | | } |
| | 363 | |
|
| 2 | 364 | | using var message = CreateRegisterRequest(resourceProviderNamespace, featureName); |
| 2 | 365 | | _pipeline.Send(message, cancellationToken); |
| 2 | 366 | | switch (message.Response.Status) |
| | 367 | | { |
| | 368 | | case 200: |
| | 369 | | { |
| 2 | 370 | | FeatureResult value = default; |
| 2 | 371 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 372 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 373 | | { |
| 0 | 374 | | value = null; |
| | 375 | | } |
| | 376 | | else |
| | 377 | | { |
| 2 | 378 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 379 | | } |
| 2 | 380 | | return Response.FromValue(value, message.Response); |
| | 381 | | } |
| | 382 | | default: |
| 0 | 383 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 384 | | } |
| 2 | 385 | | } |
| | 386 | |
|
| | 387 | | internal Core.HttpMessage CreateUnregisterRequest(string resourceProviderNamespace, string featureName) |
| | 388 | | { |
| 0 | 389 | | var message = _pipeline.CreateMessage(); |
| 0 | 390 | | var request = message.Request; |
| 0 | 391 | | request.Method = RequestMethod.Post; |
| 0 | 392 | | var uri = new RawRequestUriBuilder(); |
| 0 | 393 | | uri.Reset(endpoint); |
| 0 | 394 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 395 | | uri.AppendPath(subscriptionId, true); |
| 0 | 396 | | uri.AppendPath("/providers/Microsoft.Features/providers/", false); |
| 0 | 397 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 398 | | uri.AppendPath("/features/", false); |
| 0 | 399 | | uri.AppendPath(featureName, true); |
| 0 | 400 | | uri.AppendPath("/unregister", false); |
| 0 | 401 | | uri.AppendQuery("api-version", "2015-12-01", true); |
| 0 | 402 | | request.Uri = uri; |
| 0 | 403 | | return message; |
| | 404 | | } |
| | 405 | |
|
| | 406 | | /// <summary> Unregisters the preview feature for the subscription. </summary> |
| | 407 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 408 | | /// <param name="featureName"> The name of the feature to unregister. </param> |
| | 409 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 410 | | public async Task<Response<FeatureResult>> UnregisterAsync(string resourceProviderNamespace, string featureName, |
| | 411 | | { |
| 0 | 412 | | if (resourceProviderNamespace == null) |
| | 413 | | { |
| 0 | 414 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 415 | | } |
| 0 | 416 | | if (featureName == null) |
| | 417 | | { |
| 0 | 418 | | throw new ArgumentNullException(nameof(featureName)); |
| | 419 | | } |
| | 420 | |
|
| 0 | 421 | | using var message = CreateUnregisterRequest(resourceProviderNamespace, featureName); |
| 0 | 422 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 423 | | switch (message.Response.Status) |
| | 424 | | { |
| | 425 | | case 200: |
| | 426 | | { |
| 0 | 427 | | FeatureResult value = default; |
| 0 | 428 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 429 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 430 | | { |
| 0 | 431 | | value = null; |
| | 432 | | } |
| | 433 | | else |
| | 434 | | { |
| 0 | 435 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 436 | | } |
| 0 | 437 | | return Response.FromValue(value, message.Response); |
| | 438 | | } |
| | 439 | | default: |
| 0 | 440 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 441 | | } |
| 0 | 442 | | } |
| | 443 | |
|
| | 444 | | /// <summary> Unregisters the preview feature for the subscription. </summary> |
| | 445 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 446 | | /// <param name="featureName"> The name of the feature to unregister. </param> |
| | 447 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 448 | | public Response<FeatureResult> Unregister(string resourceProviderNamespace, string featureName, CancellationToke |
| | 449 | | { |
| 0 | 450 | | if (resourceProviderNamespace == null) |
| | 451 | | { |
| 0 | 452 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 453 | | } |
| 0 | 454 | | if (featureName == null) |
| | 455 | | { |
| 0 | 456 | | throw new ArgumentNullException(nameof(featureName)); |
| | 457 | | } |
| | 458 | |
|
| 0 | 459 | | using var message = CreateUnregisterRequest(resourceProviderNamespace, featureName); |
| 0 | 460 | | _pipeline.Send(message, cancellationToken); |
| 0 | 461 | | switch (message.Response.Status) |
| | 462 | | { |
| | 463 | | case 200: |
| | 464 | | { |
| 0 | 465 | | FeatureResult value = default; |
| 0 | 466 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 467 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 468 | | { |
| 0 | 469 | | value = null; |
| | 470 | | } |
| | 471 | | else |
| | 472 | | { |
| 0 | 473 | | value = FeatureResult.DeserializeFeatureResult(document.RootElement); |
| | 474 | | } |
| 0 | 475 | | return Response.FromValue(value, message.Response); |
| | 476 | | } |
| | 477 | | default: |
| 0 | 478 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 479 | | } |
| 0 | 480 | | } |
| | 481 | |
|
| | 482 | | internal Core.HttpMessage CreateListAllNextPageRequest(string nextLink) |
| | 483 | | { |
| 0 | 484 | | var message = _pipeline.CreateMessage(); |
| 0 | 485 | | var request = message.Request; |
| 0 | 486 | | request.Method = RequestMethod.Get; |
| 0 | 487 | | var uri = new RawRequestUriBuilder(); |
| 0 | 488 | | uri.Reset(endpoint); |
| 0 | 489 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 490 | | request.Uri = uri; |
| 0 | 491 | | return message; |
| | 492 | | } |
| | 493 | |
|
| | 494 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 495 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 496 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 497 | | public async Task<Response<FeatureOperationsListResult>> ListAllNextPageAsync(string nextLink, CancellationToken |
| | 498 | | { |
| 0 | 499 | | if (nextLink == null) |
| | 500 | | { |
| 0 | 501 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 502 | | } |
| | 503 | |
|
| 0 | 504 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 505 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 506 | | switch (message.Response.Status) |
| | 507 | | { |
| | 508 | | case 200: |
| | 509 | | { |
| 0 | 510 | | FeatureOperationsListResult value = default; |
| 0 | 511 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 512 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 513 | | { |
| 0 | 514 | | value = null; |
| | 515 | | } |
| | 516 | | else |
| | 517 | | { |
| 0 | 518 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 519 | | } |
| 0 | 520 | | return Response.FromValue(value, message.Response); |
| | 521 | | } |
| | 522 | | default: |
| 0 | 523 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 524 | | } |
| 0 | 525 | | } |
| | 526 | |
|
| | 527 | | /// <summary> Gets all the preview features that are available through AFEC for the subscription. </summary> |
| | 528 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 529 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 530 | | public Response<FeatureOperationsListResult> ListAllNextPage(string nextLink, CancellationToken cancellationToke |
| | 531 | | { |
| 0 | 532 | | if (nextLink == null) |
| | 533 | | { |
| 0 | 534 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 535 | | } |
| | 536 | |
|
| 0 | 537 | | using var message = CreateListAllNextPageRequest(nextLink); |
| 0 | 538 | | _pipeline.Send(message, cancellationToken); |
| 0 | 539 | | switch (message.Response.Status) |
| | 540 | | { |
| | 541 | | case 200: |
| | 542 | | { |
| 0 | 543 | | FeatureOperationsListResult value = default; |
| 0 | 544 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 545 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 546 | | { |
| 0 | 547 | | value = null; |
| | 548 | | } |
| | 549 | | else |
| | 550 | | { |
| 0 | 551 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 552 | | } |
| 0 | 553 | | return Response.FromValue(value, message.Response); |
| | 554 | | } |
| | 555 | | default: |
| 0 | 556 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 557 | | } |
| 0 | 558 | | } |
| | 559 | |
|
| | 560 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string resourceProviderNamespace) |
| | 561 | | { |
| 0 | 562 | | var message = _pipeline.CreateMessage(); |
| 0 | 563 | | var request = message.Request; |
| 0 | 564 | | request.Method = RequestMethod.Get; |
| 0 | 565 | | var uri = new RawRequestUriBuilder(); |
| 0 | 566 | | uri.Reset(endpoint); |
| 0 | 567 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 568 | | request.Uri = uri; |
| 0 | 569 | | return message; |
| | 570 | | } |
| | 571 | |
|
| | 572 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 573 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 574 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 575 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 576 | | public async Task<Response<FeatureOperationsListResult>> ListNextPageAsync(string nextLink, string resourceProvi |
| | 577 | | { |
| 0 | 578 | | if (nextLink == null) |
| | 579 | | { |
| 0 | 580 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 581 | | } |
| 0 | 582 | | if (resourceProviderNamespace == null) |
| | 583 | | { |
| 0 | 584 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 585 | | } |
| | 586 | |
|
| 0 | 587 | | using var message = CreateListNextPageRequest(nextLink, resourceProviderNamespace); |
| 0 | 588 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 589 | | switch (message.Response.Status) |
| | 590 | | { |
| | 591 | | case 200: |
| | 592 | | { |
| 0 | 593 | | FeatureOperationsListResult value = default; |
| 0 | 594 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 595 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 596 | | { |
| 0 | 597 | | value = null; |
| | 598 | | } |
| | 599 | | else |
| | 600 | | { |
| 0 | 601 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 602 | | } |
| 0 | 603 | | return Response.FromValue(value, message.Response); |
| | 604 | | } |
| | 605 | | default: |
| 0 | 606 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 607 | | } |
| 0 | 608 | | } |
| | 609 | |
|
| | 610 | | /// <summary> Gets all the preview features in a provider namespace that are available through AFEC for the subs |
| | 611 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 612 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider for getting features. </para |
| | 613 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 614 | | public Response<FeatureOperationsListResult> ListNextPage(string nextLink, string resourceProviderNamespace, Can |
| | 615 | | { |
| 0 | 616 | | if (nextLink == null) |
| | 617 | | { |
| 0 | 618 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 619 | | } |
| 0 | 620 | | if (resourceProviderNamespace == null) |
| | 621 | | { |
| 0 | 622 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 623 | | } |
| | 624 | |
|
| 0 | 625 | | using var message = CreateListNextPageRequest(nextLink, resourceProviderNamespace); |
| 0 | 626 | | _pipeline.Send(message, cancellationToken); |
| 0 | 627 | | switch (message.Response.Status) |
| | 628 | | { |
| | 629 | | case 200: |
| | 630 | | { |
| 0 | 631 | | FeatureOperationsListResult value = default; |
| 0 | 632 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 633 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 634 | | { |
| 0 | 635 | | value = null; |
| | 636 | | } |
| | 637 | | else |
| | 638 | | { |
| 0 | 639 | | value = FeatureOperationsListResult.DeserializeFeatureOperationsListResult(document.RootElem |
| | 640 | | } |
| 0 | 641 | | return Response.FromValue(value, message.Response); |
| | 642 | | } |
| | 643 | | default: |
| 0 | 644 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 645 | | } |
| 0 | 646 | | } |
| | 647 | | } |
| | 648 | | } |