| | 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 SubnetsRestOperations |
| | 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 SubnetsRestOperations. </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 |
| 84 | 32 | | public SubnetsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, |
| | 33 | | { |
| 84 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 84 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 84 | 40 | | this.subscriptionId = subscriptionId; |
| 84 | 41 | | this.endpoint = endpoint; |
| 84 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 84 | 43 | | _pipeline = pipeline; |
| 84 | 44 | | } |
| | 45 | |
|
| | 46 | | internal HttpMessage CreateDeleteRequest(string resourceGroupName, string virtualNetworkName, string subnetName) |
| | 47 | | { |
| 8 | 48 | | var message = _pipeline.CreateMessage(); |
| 8 | 49 | | var request = message.Request; |
| 8 | 50 | | request.Method = RequestMethod.Delete; |
| 8 | 51 | | var uri = new RawRequestUriBuilder(); |
| 8 | 52 | | uri.Reset(endpoint); |
| 8 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 54 | | uri.AppendPath(subscriptionId, true); |
| 8 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 57 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 8 | 58 | | uri.AppendPath(virtualNetworkName, true); |
| 8 | 59 | | uri.AppendPath("/subnets/", false); |
| 8 | 60 | | uri.AppendPath(subnetName, true); |
| 8 | 61 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 62 | | request.Uri = uri; |
| 8 | 63 | | return message; |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> Deletes the specified subnet. </summary> |
| | 67 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 68 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 69 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 70 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 71 | | public async Task<Response> DeleteAsync(string resourceGroupName, string virtualNetworkName, string subnetName, |
| | 72 | | { |
| 2 | 73 | | if (resourceGroupName == null) |
| | 74 | | { |
| 0 | 75 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 76 | | } |
| 2 | 77 | | if (virtualNetworkName == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 80 | | } |
| 2 | 81 | | if (subnetName == null) |
| | 82 | | { |
| 0 | 83 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 84 | | } |
| | 85 | |
|
| 2 | 86 | | using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName, subnetName); |
| 2 | 87 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 88 | | switch (message.Response.Status) |
| | 89 | | { |
| | 90 | | case 200: |
| | 91 | | case 202: |
| | 92 | | case 204: |
| 2 | 93 | | return message.Response; |
| | 94 | | default: |
| 0 | 95 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 96 | | } |
| 2 | 97 | | } |
| | 98 | |
|
| | 99 | | /// <summary> Deletes the specified subnet. </summary> |
| | 100 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 101 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 102 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 103 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 104 | | public Response Delete(string resourceGroupName, string virtualNetworkName, string subnetName, CancellationToken |
| | 105 | | { |
| 2 | 106 | | if (resourceGroupName == null) |
| | 107 | | { |
| 0 | 108 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 109 | | } |
| 2 | 110 | | if (virtualNetworkName == null) |
| | 111 | | { |
| 0 | 112 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 113 | | } |
| 2 | 114 | | if (subnetName == null) |
| | 115 | | { |
| 0 | 116 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 117 | | } |
| | 118 | |
|
| 2 | 119 | | using var message = CreateDeleteRequest(resourceGroupName, virtualNetworkName, subnetName); |
| 2 | 120 | | _pipeline.Send(message, cancellationToken); |
| 2 | 121 | | switch (message.Response.Status) |
| | 122 | | { |
| | 123 | | case 200: |
| | 124 | | case 202: |
| | 125 | | case 204: |
| 2 | 126 | | return message.Response; |
| | 127 | | default: |
| 0 | 128 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 129 | | } |
| 2 | 130 | | } |
| | 131 | |
|
| | 132 | | internal HttpMessage CreateGetRequest(string resourceGroupName, string virtualNetworkName, string subnetName, st |
| | 133 | | { |
| 68 | 134 | | var message = _pipeline.CreateMessage(); |
| 68 | 135 | | var request = message.Request; |
| 68 | 136 | | request.Method = RequestMethod.Get; |
| 68 | 137 | | var uri = new RawRequestUriBuilder(); |
| 68 | 138 | | uri.Reset(endpoint); |
| 68 | 139 | | uri.AppendPath("/subscriptions/", false); |
| 68 | 140 | | uri.AppendPath(subscriptionId, true); |
| 68 | 141 | | uri.AppendPath("/resourceGroups/", false); |
| 68 | 142 | | uri.AppendPath(resourceGroupName, true); |
| 68 | 143 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 68 | 144 | | uri.AppendPath(virtualNetworkName, true); |
| 68 | 145 | | uri.AppendPath("/subnets/", false); |
| 68 | 146 | | uri.AppendPath(subnetName, true); |
| 68 | 147 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 68 | 148 | | if (expand != null) |
| | 149 | | { |
| 4 | 150 | | uri.AppendQuery("$expand", expand, true); |
| | 151 | | } |
| 68 | 152 | | request.Uri = uri; |
| 68 | 153 | | return message; |
| | 154 | | } |
| | 155 | |
|
| | 156 | | /// <summary> Gets the specified subnet by virtual network and resource group. </summary> |
| | 157 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 158 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 159 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 160 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 161 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 162 | | public async Task<Response<Subnet>> GetAsync(string resourceGroupName, string virtualNetworkName, string subnetN |
| | 163 | | { |
| 34 | 164 | | if (resourceGroupName == null) |
| | 165 | | { |
| 0 | 166 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 167 | | } |
| 34 | 168 | | if (virtualNetworkName == null) |
| | 169 | | { |
| 0 | 170 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 171 | | } |
| 34 | 172 | | if (subnetName == null) |
| | 173 | | { |
| 0 | 174 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 175 | | } |
| | 176 | |
|
| 34 | 177 | | using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, subnetName, expand); |
| 34 | 178 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 34 | 179 | | switch (message.Response.Status) |
| | 180 | | { |
| | 181 | | case 200: |
| | 182 | | { |
| 34 | 183 | | Subnet value = default; |
| 34 | 184 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 34 | 185 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 186 | | { |
| 0 | 187 | | value = null; |
| | 188 | | } |
| | 189 | | else |
| | 190 | | { |
| 34 | 191 | | value = Subnet.DeserializeSubnet(document.RootElement); |
| | 192 | | } |
| 34 | 193 | | return Response.FromValue(value, message.Response); |
| | 194 | | } |
| | 195 | | default: |
| 0 | 196 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 197 | | } |
| 34 | 198 | | } |
| | 199 | |
|
| | 200 | | /// <summary> Gets the specified subnet by virtual network and resource group. </summary> |
| | 201 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 202 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 203 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 204 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 205 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 206 | | public Response<Subnet> Get(string resourceGroupName, string virtualNetworkName, string subnetName, string expan |
| | 207 | | { |
| 34 | 208 | | if (resourceGroupName == null) |
| | 209 | | { |
| 0 | 210 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 211 | | } |
| 34 | 212 | | if (virtualNetworkName == null) |
| | 213 | | { |
| 0 | 214 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 215 | | } |
| 34 | 216 | | if (subnetName == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 219 | | } |
| | 220 | |
|
| 34 | 221 | | using var message = CreateGetRequest(resourceGroupName, virtualNetworkName, subnetName, expand); |
| 34 | 222 | | _pipeline.Send(message, cancellationToken); |
| 34 | 223 | | switch (message.Response.Status) |
| | 224 | | { |
| | 225 | | case 200: |
| | 226 | | { |
| 34 | 227 | | Subnet value = default; |
| 34 | 228 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 34 | 229 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 230 | | { |
| 0 | 231 | | value = null; |
| | 232 | | } |
| | 233 | | else |
| | 234 | | { |
| 34 | 235 | | value = Subnet.DeserializeSubnet(document.RootElement); |
| | 236 | | } |
| 34 | 237 | | return Response.FromValue(value, message.Response); |
| | 238 | | } |
| | 239 | | default: |
| 0 | 240 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 241 | | } |
| 34 | 242 | | } |
| | 243 | |
|
| | 244 | | internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string virtualNetworkName, string sub |
| | 245 | | { |
| 8 | 246 | | var message = _pipeline.CreateMessage(); |
| 8 | 247 | | var request = message.Request; |
| 8 | 248 | | request.Method = RequestMethod.Put; |
| 8 | 249 | | var uri = new RawRequestUriBuilder(); |
| 8 | 250 | | uri.Reset(endpoint); |
| 8 | 251 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 252 | | uri.AppendPath(subscriptionId, true); |
| 8 | 253 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 254 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 255 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 8 | 256 | | uri.AppendPath(virtualNetworkName, true); |
| 8 | 257 | | uri.AppendPath("/subnets/", false); |
| 8 | 258 | | uri.AppendPath(subnetName, true); |
| 8 | 259 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 260 | | request.Uri = uri; |
| 8 | 261 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 262 | | var content = new Utf8JsonRequestContent(); |
| 8 | 263 | | content.JsonWriter.WriteObjectValue(subnetParameters); |
| 8 | 264 | | request.Content = content; |
| 8 | 265 | | return message; |
| | 266 | | } |
| | 267 | |
|
| | 268 | | /// <summary> Creates or updates a subnet in the specified virtual network. </summary> |
| | 269 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 270 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 271 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 272 | | /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param> |
| | 273 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 274 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string virtualNetworkName, string subn |
| | 275 | | { |
| 2 | 276 | | if (resourceGroupName == null) |
| | 277 | | { |
| 0 | 278 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 279 | | } |
| 2 | 280 | | if (virtualNetworkName == null) |
| | 281 | | { |
| 0 | 282 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 283 | | } |
| 2 | 284 | | if (subnetName == null) |
| | 285 | | { |
| 0 | 286 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 287 | | } |
| 2 | 288 | | if (subnetParameters == null) |
| | 289 | | { |
| 0 | 290 | | throw new ArgumentNullException(nameof(subnetParameters)); |
| | 291 | | } |
| | 292 | |
|
| 2 | 293 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, subnetName, subnetPar |
| 2 | 294 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 295 | | switch (message.Response.Status) |
| | 296 | | { |
| | 297 | | case 200: |
| | 298 | | case 201: |
| 2 | 299 | | return message.Response; |
| | 300 | | default: |
| 0 | 301 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 302 | | } |
| 2 | 303 | | } |
| | 304 | |
|
| | 305 | | /// <summary> Creates or updates a subnet in the specified virtual network. </summary> |
| | 306 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 307 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 308 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 309 | | /// <param name="subnetParameters"> Parameters supplied to the create or update subnet operation. </param> |
| | 310 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 311 | | public Response CreateOrUpdate(string resourceGroupName, string virtualNetworkName, string subnetName, Subnet su |
| | 312 | | { |
| 2 | 313 | | if (resourceGroupName == null) |
| | 314 | | { |
| 0 | 315 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 316 | | } |
| 2 | 317 | | if (virtualNetworkName == null) |
| | 318 | | { |
| 0 | 319 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 320 | | } |
| 2 | 321 | | if (subnetName == null) |
| | 322 | | { |
| 0 | 323 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 324 | | } |
| 2 | 325 | | if (subnetParameters == null) |
| | 326 | | { |
| 0 | 327 | | throw new ArgumentNullException(nameof(subnetParameters)); |
| | 328 | | } |
| | 329 | |
|
| 2 | 330 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualNetworkName, subnetName, subnetPar |
| 2 | 331 | | _pipeline.Send(message, cancellationToken); |
| 2 | 332 | | switch (message.Response.Status) |
| | 333 | | { |
| | 334 | | case 200: |
| | 335 | | case 201: |
| 2 | 336 | | return message.Response; |
| | 337 | | default: |
| 0 | 338 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 339 | | } |
| 2 | 340 | | } |
| | 341 | |
|
| | 342 | | internal HttpMessage CreatePrepareNetworkPoliciesRequest(string resourceGroupName, string virtualNetworkName, st |
| | 343 | | { |
| 0 | 344 | | var message = _pipeline.CreateMessage(); |
| 0 | 345 | | var request = message.Request; |
| 0 | 346 | | request.Method = RequestMethod.Post; |
| 0 | 347 | | var uri = new RawRequestUriBuilder(); |
| 0 | 348 | | uri.Reset(endpoint); |
| 0 | 349 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 350 | | uri.AppendPath(subscriptionId, true); |
| 0 | 351 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 352 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 353 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 0 | 354 | | uri.AppendPath(virtualNetworkName, true); |
| 0 | 355 | | uri.AppendPath("/subnets/", false); |
| 0 | 356 | | uri.AppendPath(subnetName, true); |
| 0 | 357 | | uri.AppendPath("/PrepareNetworkPolicies", false); |
| 0 | 358 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 359 | | request.Uri = uri; |
| 0 | 360 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 361 | | var content = new Utf8JsonRequestContent(); |
| 0 | 362 | | content.JsonWriter.WriteObjectValue(prepareNetworkPoliciesRequestParameters); |
| 0 | 363 | | request.Content = content; |
| 0 | 364 | | return message; |
| | 365 | | } |
| | 366 | |
|
| | 367 | | /// <summary> Prepares a subnet by applying network intent policies. </summary> |
| | 368 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 369 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 370 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 371 | | /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net |
| | 372 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 373 | | public async Task<Response> PrepareNetworkPoliciesAsync(string resourceGroupName, string virtualNetworkName, str |
| | 374 | | { |
| 0 | 375 | | if (resourceGroupName == null) |
| | 376 | | { |
| 0 | 377 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 378 | | } |
| 0 | 379 | | if (virtualNetworkName == null) |
| | 380 | | { |
| 0 | 381 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 382 | | } |
| 0 | 383 | | if (subnetName == null) |
| | 384 | | { |
| 0 | 385 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 386 | | } |
| 0 | 387 | | if (prepareNetworkPoliciesRequestParameters == null) |
| | 388 | | { |
| 0 | 389 | | throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters)); |
| | 390 | | } |
| | 391 | |
|
| 0 | 392 | | using var message = CreatePrepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, p |
| 0 | 393 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 394 | | switch (message.Response.Status) |
| | 395 | | { |
| | 396 | | case 200: |
| | 397 | | case 202: |
| 0 | 398 | | return message.Response; |
| | 399 | | default: |
| 0 | 400 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 401 | | } |
| 0 | 402 | | } |
| | 403 | |
|
| | 404 | | /// <summary> Prepares a subnet by applying network intent policies. </summary> |
| | 405 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 406 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 407 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 408 | | /// <param name="prepareNetworkPoliciesRequestParameters"> Parameters supplied to prepare subnet by applying net |
| | 409 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 410 | | public Response PrepareNetworkPolicies(string resourceGroupName, string virtualNetworkName, string subnetName, P |
| | 411 | | { |
| 0 | 412 | | if (resourceGroupName == null) |
| | 413 | | { |
| 0 | 414 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 415 | | } |
| 0 | 416 | | if (virtualNetworkName == null) |
| | 417 | | { |
| 0 | 418 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 419 | | } |
| 0 | 420 | | if (subnetName == null) |
| | 421 | | { |
| 0 | 422 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 423 | | } |
| 0 | 424 | | if (prepareNetworkPoliciesRequestParameters == null) |
| | 425 | | { |
| 0 | 426 | | throw new ArgumentNullException(nameof(prepareNetworkPoliciesRequestParameters)); |
| | 427 | | } |
| | 428 | |
|
| 0 | 429 | | using var message = CreatePrepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, p |
| 0 | 430 | | _pipeline.Send(message, cancellationToken); |
| 0 | 431 | | switch (message.Response.Status) |
| | 432 | | { |
| | 433 | | case 200: |
| | 434 | | case 202: |
| 0 | 435 | | return message.Response; |
| | 436 | | default: |
| 0 | 437 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 438 | | } |
| 0 | 439 | | } |
| | 440 | |
|
| | 441 | | internal HttpMessage CreateUnprepareNetworkPoliciesRequest(string resourceGroupName, string virtualNetworkName, |
| | 442 | | { |
| 0 | 443 | | var message = _pipeline.CreateMessage(); |
| 0 | 444 | | var request = message.Request; |
| 0 | 445 | | request.Method = RequestMethod.Post; |
| 0 | 446 | | var uri = new RawRequestUriBuilder(); |
| 0 | 447 | | uri.Reset(endpoint); |
| 0 | 448 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 449 | | uri.AppendPath(subscriptionId, true); |
| 0 | 450 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 451 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 452 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 0 | 453 | | uri.AppendPath(virtualNetworkName, true); |
| 0 | 454 | | uri.AppendPath("/subnets/", false); |
| 0 | 455 | | uri.AppendPath(subnetName, true); |
| 0 | 456 | | uri.AppendPath("/UnprepareNetworkPolicies", false); |
| 0 | 457 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 0 | 458 | | request.Uri = uri; |
| 0 | 459 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 460 | | var content = new Utf8JsonRequestContent(); |
| 0 | 461 | | content.JsonWriter.WriteObjectValue(unprepareNetworkPoliciesRequestParameters); |
| 0 | 462 | | request.Content = content; |
| 0 | 463 | | return message; |
| | 464 | | } |
| | 465 | |
|
| | 466 | | /// <summary> Unprepares a subnet by removing network intent policies. </summary> |
| | 467 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 468 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 469 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 470 | | /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n |
| | 471 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 472 | | public async Task<Response> UnprepareNetworkPoliciesAsync(string resourceGroupName, string virtualNetworkName, s |
| | 473 | | { |
| 0 | 474 | | if (resourceGroupName == null) |
| | 475 | | { |
| 0 | 476 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 477 | | } |
| 0 | 478 | | if (virtualNetworkName == null) |
| | 479 | | { |
| 0 | 480 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 481 | | } |
| 0 | 482 | | if (subnetName == null) |
| | 483 | | { |
| 0 | 484 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 485 | | } |
| 0 | 486 | | if (unprepareNetworkPoliciesRequestParameters == null) |
| | 487 | | { |
| 0 | 488 | | throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters)); |
| | 489 | | } |
| | 490 | |
|
| 0 | 491 | | using var message = CreateUnprepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, |
| 0 | 492 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 493 | | switch (message.Response.Status) |
| | 494 | | { |
| | 495 | | case 200: |
| | 496 | | case 202: |
| 0 | 497 | | return message.Response; |
| | 498 | | default: |
| 0 | 499 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 500 | | } |
| 0 | 501 | | } |
| | 502 | |
|
| | 503 | | /// <summary> Unprepares a subnet by removing network intent policies. </summary> |
| | 504 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 505 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 506 | | /// <param name="subnetName"> The name of the subnet. </param> |
| | 507 | | /// <param name="unprepareNetworkPoliciesRequestParameters"> Parameters supplied to unprepare subnet to remove n |
| | 508 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 509 | | public Response UnprepareNetworkPolicies(string resourceGroupName, string virtualNetworkName, string subnetName, |
| | 510 | | { |
| 0 | 511 | | if (resourceGroupName == null) |
| | 512 | | { |
| 0 | 513 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 514 | | } |
| 0 | 515 | | if (virtualNetworkName == null) |
| | 516 | | { |
| 0 | 517 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 518 | | } |
| 0 | 519 | | if (subnetName == null) |
| | 520 | | { |
| 0 | 521 | | throw new ArgumentNullException(nameof(subnetName)); |
| | 522 | | } |
| 0 | 523 | | if (unprepareNetworkPoliciesRequestParameters == null) |
| | 524 | | { |
| 0 | 525 | | throw new ArgumentNullException(nameof(unprepareNetworkPoliciesRequestParameters)); |
| | 526 | | } |
| | 527 | |
|
| 0 | 528 | | using var message = CreateUnprepareNetworkPoliciesRequest(resourceGroupName, virtualNetworkName, subnetName, |
| 0 | 529 | | _pipeline.Send(message, cancellationToken); |
| 0 | 530 | | switch (message.Response.Status) |
| | 531 | | { |
| | 532 | | case 200: |
| | 533 | | case 202: |
| 0 | 534 | | return message.Response; |
| | 535 | | default: |
| 0 | 536 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 537 | | } |
| 0 | 538 | | } |
| | 539 | |
|
| | 540 | | internal HttpMessage CreateListRequest(string resourceGroupName, string virtualNetworkName) |
| | 541 | | { |
| 8 | 542 | | var message = _pipeline.CreateMessage(); |
| 8 | 543 | | var request = message.Request; |
| 8 | 544 | | request.Method = RequestMethod.Get; |
| 8 | 545 | | var uri = new RawRequestUriBuilder(); |
| 8 | 546 | | uri.Reset(endpoint); |
| 8 | 547 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 548 | | uri.AppendPath(subscriptionId, true); |
| 8 | 549 | | uri.AppendPath("/resourceGroups/", false); |
| 8 | 550 | | uri.AppendPath(resourceGroupName, true); |
| 8 | 551 | | uri.AppendPath("/providers/Microsoft.Network/virtualNetworks/", false); |
| 8 | 552 | | uri.AppendPath(virtualNetworkName, true); |
| 8 | 553 | | uri.AppendPath("/subnets", false); |
| 8 | 554 | | uri.AppendQuery("api-version", "2020-04-01", true); |
| 8 | 555 | | request.Uri = uri; |
| 8 | 556 | | return message; |
| | 557 | | } |
| | 558 | |
|
| | 559 | | /// <summary> Gets all subnets in a virtual network. </summary> |
| | 560 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 561 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 562 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 563 | | public async Task<Response<SubnetListResult>> ListAsync(string resourceGroupName, string virtualNetworkName, Can |
| | 564 | | { |
| 4 | 565 | | if (resourceGroupName == null) |
| | 566 | | { |
| 0 | 567 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 568 | | } |
| 4 | 569 | | if (virtualNetworkName == null) |
| | 570 | | { |
| 0 | 571 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 572 | | } |
| | 573 | |
|
| 4 | 574 | | using var message = CreateListRequest(resourceGroupName, virtualNetworkName); |
| 4 | 575 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 576 | | switch (message.Response.Status) |
| | 577 | | { |
| | 578 | | case 200: |
| | 579 | | { |
| 4 | 580 | | SubnetListResult value = default; |
| 4 | 581 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 4 | 582 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 583 | | { |
| 0 | 584 | | value = null; |
| | 585 | | } |
| | 586 | | else |
| | 587 | | { |
| 4 | 588 | | value = SubnetListResult.DeserializeSubnetListResult(document.RootElement); |
| | 589 | | } |
| 4 | 590 | | return Response.FromValue(value, message.Response); |
| | 591 | | } |
| | 592 | | default: |
| 0 | 593 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 594 | | } |
| 4 | 595 | | } |
| | 596 | |
|
| | 597 | | /// <summary> Gets all subnets in a virtual network. </summary> |
| | 598 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 599 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 600 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 601 | | public Response<SubnetListResult> List(string resourceGroupName, string virtualNetworkName, CancellationToken ca |
| | 602 | | { |
| 4 | 603 | | if (resourceGroupName == null) |
| | 604 | | { |
| 0 | 605 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 606 | | } |
| 4 | 607 | | if (virtualNetworkName == null) |
| | 608 | | { |
| 0 | 609 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 610 | | } |
| | 611 | |
|
| 4 | 612 | | using var message = CreateListRequest(resourceGroupName, virtualNetworkName); |
| 4 | 613 | | _pipeline.Send(message, cancellationToken); |
| 4 | 614 | | switch (message.Response.Status) |
| | 615 | | { |
| | 616 | | case 200: |
| | 617 | | { |
| 4 | 618 | | SubnetListResult value = default; |
| 4 | 619 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 4 | 620 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 621 | | { |
| 0 | 622 | | value = null; |
| | 623 | | } |
| | 624 | | else |
| | 625 | | { |
| 4 | 626 | | value = SubnetListResult.DeserializeSubnetListResult(document.RootElement); |
| | 627 | | } |
| 4 | 628 | | return Response.FromValue(value, message.Response); |
| | 629 | | } |
| | 630 | | default: |
| 0 | 631 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 632 | | } |
| 4 | 633 | | } |
| | 634 | |
|
| | 635 | | internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string virtualNetworkN |
| | 636 | | { |
| 0 | 637 | | var message = _pipeline.CreateMessage(); |
| 0 | 638 | | var request = message.Request; |
| 0 | 639 | | request.Method = RequestMethod.Get; |
| 0 | 640 | | var uri = new RawRequestUriBuilder(); |
| 0 | 641 | | uri.Reset(endpoint); |
| 0 | 642 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 643 | | request.Uri = uri; |
| 0 | 644 | | return message; |
| | 645 | | } |
| | 646 | |
|
| | 647 | | /// <summary> Gets all subnets in a virtual network. </summary> |
| | 648 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 649 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 650 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 651 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 652 | | public async Task<Response<SubnetListResult>> ListNextPageAsync(string nextLink, string resourceGroupName, strin |
| | 653 | | { |
| 0 | 654 | | if (nextLink == null) |
| | 655 | | { |
| 0 | 656 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 657 | | } |
| 0 | 658 | | if (resourceGroupName == null) |
| | 659 | | { |
| 0 | 660 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 661 | | } |
| 0 | 662 | | if (virtualNetworkName == null) |
| | 663 | | { |
| 0 | 664 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 665 | | } |
| | 666 | |
|
| 0 | 667 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualNetworkName); |
| 0 | 668 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 669 | | switch (message.Response.Status) |
| | 670 | | { |
| | 671 | | case 200: |
| | 672 | | { |
| 0 | 673 | | SubnetListResult value = default; |
| 0 | 674 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 675 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 676 | | { |
| 0 | 677 | | value = null; |
| | 678 | | } |
| | 679 | | else |
| | 680 | | { |
| 0 | 681 | | value = SubnetListResult.DeserializeSubnetListResult(document.RootElement); |
| | 682 | | } |
| 0 | 683 | | return Response.FromValue(value, message.Response); |
| | 684 | | } |
| | 685 | | default: |
| 0 | 686 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 687 | | } |
| 0 | 688 | | } |
| | 689 | |
|
| | 690 | | /// <summary> Gets all subnets in a virtual network. </summary> |
| | 691 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 692 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 693 | | /// <param name="virtualNetworkName"> The name of the virtual network. </param> |
| | 694 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 695 | | public Response<SubnetListResult> ListNextPage(string nextLink, string resourceGroupName, string virtualNetworkN |
| | 696 | | { |
| 0 | 697 | | if (nextLink == null) |
| | 698 | | { |
| 0 | 699 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 700 | | } |
| 0 | 701 | | if (resourceGroupName == null) |
| | 702 | | { |
| 0 | 703 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 704 | | } |
| 0 | 705 | | if (virtualNetworkName == null) |
| | 706 | | { |
| 0 | 707 | | throw new ArgumentNullException(nameof(virtualNetworkName)); |
| | 708 | | } |
| | 709 | |
|
| 0 | 710 | | using var message = CreateListNextPageRequest(nextLink, resourceGroupName, virtualNetworkName); |
| 0 | 711 | | _pipeline.Send(message, cancellationToken); |
| 0 | 712 | | switch (message.Response.Status) |
| | 713 | | { |
| | 714 | | case 200: |
| | 715 | | { |
| 0 | 716 | | SubnetListResult value = default; |
| 0 | 717 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 718 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 719 | | { |
| 0 | 720 | | value = null; |
| | 721 | | } |
| | 722 | | else |
| | 723 | | { |
| 0 | 724 | | value = SubnetListResult.DeserializeSubnetListResult(document.RootElement); |
| | 725 | | } |
| 0 | 726 | | return Response.FromValue(value, message.Response); |
| | 727 | | } |
| | 728 | | default: |
| 0 | 729 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 730 | | } |
| 0 | 731 | | } |
| | 732 | | } |
| | 733 | | } |