| | 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.Network.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Network |
| | 18 | | { |
| | 19 | | internal partial class ServiceTagsRestOperations |
| | 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 ServiceTagsRestOperations. </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 subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 0 | 32 | | public ServiceTagsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateListRequest(string location) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Get; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/providers/Microsoft.Network/locations/", false); |
| 0 | 56 | | uri.AppendPath(location, true); |
| 0 | 57 | | uri.AppendPath("/serviceTags", false); |
| 0 | 58 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 59 | | request.Uri = uri; |
| 0 | 60 | | return message; |
| | 61 | | } |
| | 62 | |
|
| | 63 | | /// <summary> Gets a list of service tag information resources. </summary> |
| | 64 | | /// <param name="location"> The location that will be used as a reference for version (not as a filter based on |
| | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 66 | | public async Task<Response<ServiceTagsListResult>> ListAsync(string location, CancellationToken cancellationToke |
| | 67 | | { |
| 0 | 68 | | if (location == null) |
| | 69 | | { |
| 0 | 70 | | throw new ArgumentNullException(nameof(location)); |
| | 71 | | } |
| | 72 | |
|
| 0 | 73 | | using var message = CreateListRequest(location); |
| 0 | 74 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 75 | | switch (message.Response.Status) |
| | 76 | | { |
| | 77 | | case 200: |
| | 78 | | { |
| 0 | 79 | | ServiceTagsListResult value = default; |
| 0 | 80 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 81 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 82 | | { |
| 0 | 83 | | value = null; |
| | 84 | | } |
| | 85 | | else |
| | 86 | | { |
| 0 | 87 | | value = ServiceTagsListResult.DeserializeServiceTagsListResult(document.RootElement); |
| | 88 | | } |
| 0 | 89 | | return Response.FromValue(value, message.Response); |
| | 90 | | } |
| | 91 | | default: |
| 0 | 92 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 93 | | } |
| 0 | 94 | | } |
| | 95 | |
|
| | 96 | | /// <summary> Gets a list of service tag information resources. </summary> |
| | 97 | | /// <param name="location"> The location that will be used as a reference for version (not as a filter based on |
| | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 99 | | public Response<ServiceTagsListResult> List(string location, CancellationToken cancellationToken = default) |
| | 100 | | { |
| 0 | 101 | | if (location == null) |
| | 102 | | { |
| 0 | 103 | | throw new ArgumentNullException(nameof(location)); |
| | 104 | | } |
| | 105 | |
|
| 0 | 106 | | using var message = CreateListRequest(location); |
| 0 | 107 | | _pipeline.Send(message, cancellationToken); |
| 0 | 108 | | switch (message.Response.Status) |
| | 109 | | { |
| | 110 | | case 200: |
| | 111 | | { |
| 0 | 112 | | ServiceTagsListResult value = default; |
| 0 | 113 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 114 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 115 | | { |
| 0 | 116 | | value = null; |
| | 117 | | } |
| | 118 | | else |
| | 119 | | { |
| 0 | 120 | | value = ServiceTagsListResult.DeserializeServiceTagsListResult(document.RootElement); |
| | 121 | | } |
| 0 | 122 | | return Response.FromValue(value, message.Response); |
| | 123 | | } |
| | 124 | | default: |
| 0 | 125 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 126 | | } |
| 0 | 127 | | } |
| | 128 | | } |
| | 129 | | } |