| | 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 AvailableEndpointServicesRestOperations |
| | 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 AvailableEndpointServicesRestOperations. </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 AvailableEndpointServicesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, strin |
| | 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("/virtualNetworkAvailableEndpointServices", false); |
| 0 | 58 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 59 | | request.Uri = uri; |
| 0 | 60 | | return message; |
| | 61 | | } |
| | 62 | |
|
| | 63 | | /// <summary> List what values of endpoint services are available for use. </summary> |
| | 64 | | /// <param name="location"> The location to check available endpoint services. </param> |
| | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 66 | | public async Task<Response<EndpointServicesListResult>> ListAsync(string location, CancellationToken cancellatio |
| | 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 | | EndpointServicesListResult 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 = EndpointServicesListResult.DeserializeEndpointServicesListResult(document.RootElemen |
| | 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> List what values of endpoint services are available for use. </summary> |
| | 97 | | /// <param name="location"> The location to check available endpoint services. </param> |
| | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 99 | | public Response<EndpointServicesListResult> 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 | | EndpointServicesListResult 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 = EndpointServicesListResult.DeserializeEndpointServicesListResult(document.RootElemen |
| | 121 | | } |
| 0 | 122 | | return Response.FromValue(value, message.Response); |
| | 123 | | } |
| | 124 | | default: |
| 0 | 125 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 126 | | } |
| 0 | 127 | | } |
| | 128 | |
|
| | 129 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string location) |
| | 130 | | { |
| 0 | 131 | | var message = _pipeline.CreateMessage(); |
| 0 | 132 | | var request = message.Request; |
| 0 | 133 | | request.Method = RequestMethod.Get; |
| 0 | 134 | | var uri = new RawRequestUriBuilder(); |
| 0 | 135 | | uri.Reset(endpoint); |
| 0 | 136 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 137 | | request.Uri = uri; |
| 0 | 138 | | return message; |
| | 139 | | } |
| | 140 | |
|
| | 141 | | /// <summary> List what values of endpoint services are available for use. </summary> |
| | 142 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 143 | | /// <param name="location"> The location to check available endpoint services. </param> |
| | 144 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 145 | | public async Task<Response<EndpointServicesListResult>> ListNextPageAsync(string nextLink, string location, Canc |
| | 146 | | { |
| 0 | 147 | | if (nextLink == null) |
| | 148 | | { |
| 0 | 149 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 150 | | } |
| 0 | 151 | | if (location == null) |
| | 152 | | { |
| 0 | 153 | | throw new ArgumentNullException(nameof(location)); |
| | 154 | | } |
| | 155 | |
|
| 0 | 156 | | using var message = CreateListNextPageRequest(nextLink, location); |
| 0 | 157 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 158 | | switch (message.Response.Status) |
| | 159 | | { |
| | 160 | | case 200: |
| | 161 | | { |
| 0 | 162 | | EndpointServicesListResult value = default; |
| 0 | 163 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 164 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 165 | | { |
| 0 | 166 | | value = null; |
| | 167 | | } |
| | 168 | | else |
| | 169 | | { |
| 0 | 170 | | value = EndpointServicesListResult.DeserializeEndpointServicesListResult(document.RootElemen |
| | 171 | | } |
| 0 | 172 | | return Response.FromValue(value, message.Response); |
| | 173 | | } |
| | 174 | | default: |
| 0 | 175 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 176 | | } |
| 0 | 177 | | } |
| | 178 | |
|
| | 179 | | /// <summary> List what values of endpoint services are available for use. </summary> |
| | 180 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 181 | | /// <param name="location"> The location to check available endpoint services. </param> |
| | 182 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 183 | | public Response<EndpointServicesListResult> ListNextPage(string nextLink, string location, CancellationToken can |
| | 184 | | { |
| 0 | 185 | | if (nextLink == null) |
| | 186 | | { |
| 0 | 187 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 188 | | } |
| 0 | 189 | | if (location == null) |
| | 190 | | { |
| 0 | 191 | | throw new ArgumentNullException(nameof(location)); |
| | 192 | | } |
| | 193 | |
|
| 0 | 194 | | using var message = CreateListNextPageRequest(nextLink, location); |
| 0 | 195 | | _pipeline.Send(message, cancellationToken); |
| 0 | 196 | | switch (message.Response.Status) |
| | 197 | | { |
| | 198 | | case 200: |
| | 199 | | { |
| 0 | 200 | | EndpointServicesListResult value = default; |
| 0 | 201 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 202 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 203 | | { |
| 0 | 204 | | value = null; |
| | 205 | | } |
| | 206 | | else |
| | 207 | | { |
| 0 | 208 | | value = EndpointServicesListResult.DeserializeEndpointServicesListResult(document.RootElemen |
| | 209 | | } |
| 0 | 210 | | return Response.FromValue(value, message.Response); |
| | 211 | | } |
| | 212 | | default: |
| 0 | 213 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 214 | | } |
| 0 | 215 | | } |
| | 216 | | } |
| | 217 | | } |