| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Network.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Network |
| | 17 | | { |
| | 18 | | /// <summary> The VirtualRouters service client. </summary> |
| | 19 | | public partial class VirtualRoutersOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 0 | 23 | | internal VirtualRoutersRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of VirtualRoutersOperations for mocking. </summary> |
| 0 | 25 | | protected VirtualRoutersOperations() |
| | 26 | | { |
| 0 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of VirtualRoutersOperations. </summary> |
| | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="subscriptionId"> The subscription credentials which uniquely identify the Microsoft Azure subsc |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 0 | 33 | | internal VirtualRoutersOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 34 | | { |
| 0 | 35 | | RestClient = new VirtualRoutersRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 0 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 37 | | _pipeline = pipeline; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Gets the specified Virtual Router. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 42 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 43 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 44 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 45 | | public virtual async Task<Response<VirtualRouter>> GetAsync(string resourceGroupName, string virtualRouterName, |
| | 46 | | { |
| 0 | 47 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.Get"); |
| 0 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 0 | 51 | | return await RestClient.GetAsync(resourceGroupName, virtualRouterName, expand, cancellationToken).Config |
| | 52 | | } |
| 0 | 53 | | catch (Exception e) |
| | 54 | | { |
| 0 | 55 | | scope.Failed(e); |
| 0 | 56 | | throw; |
| | 57 | | } |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Gets the specified Virtual Router. </summary> |
| | 61 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 62 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 63 | | /// <param name="expand"> Expands referenced resources. </param> |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public virtual Response<VirtualRouter> Get(string resourceGroupName, string virtualRouterName, string expand = n |
| | 66 | | { |
| 0 | 67 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.Get"); |
| 0 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 0 | 71 | | return RestClient.Get(resourceGroupName, virtualRouterName, expand, cancellationToken); |
| | 72 | | } |
| 0 | 73 | | catch (Exception e) |
| | 74 | | { |
| 0 | 75 | | scope.Failed(e); |
| 0 | 76 | | throw; |
| | 77 | | } |
| 0 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> Lists all Virtual Routers in a resource group. </summary> |
| | 81 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 82 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 83 | | public virtual AsyncPageable<VirtualRouter> ListByResourceGroupAsync(string resourceGroupName, CancellationToken |
| | 84 | | { |
| 0 | 85 | | if (resourceGroupName == null) |
| | 86 | | { |
| 0 | 87 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 88 | | } |
| | 89 | |
|
| | 90 | | async Task<Page<VirtualRouter>> FirstPageFunc(int? pageSizeHint) |
| | 91 | | { |
| 0 | 92 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.ListByResourceGroup"); |
| 0 | 93 | | scope.Start(); |
| | 94 | | try |
| | 95 | | { |
| 0 | 96 | | var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi |
| 0 | 97 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 98 | | } |
| 0 | 99 | | catch (Exception e) |
| | 100 | | { |
| 0 | 101 | | scope.Failed(e); |
| 0 | 102 | | throw; |
| | 103 | | } |
| 0 | 104 | | } |
| | 105 | | async Task<Page<VirtualRouter>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 106 | | { |
| 0 | 107 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.ListByResourceGroup"); |
| 0 | 108 | | scope.Start(); |
| | 109 | | try |
| | 110 | | { |
| 0 | 111 | | var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel |
| 0 | 112 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 113 | | } |
| 0 | 114 | | catch (Exception e) |
| | 115 | | { |
| 0 | 116 | | scope.Failed(e); |
| 0 | 117 | | throw; |
| | 118 | | } |
| 0 | 119 | | } |
| 0 | 120 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 121 | | } |
| | 122 | |
|
| | 123 | | /// <summary> Lists all Virtual Routers in a resource group. </summary> |
| | 124 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 125 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 126 | | public virtual Pageable<VirtualRouter> ListByResourceGroup(string resourceGroupName, CancellationToken cancellat |
| | 127 | | { |
| 0 | 128 | | if (resourceGroupName == null) |
| | 129 | | { |
| 0 | 130 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 131 | | } |
| | 132 | |
|
| | 133 | | Page<VirtualRouter> FirstPageFunc(int? pageSizeHint) |
| | 134 | | { |
| 0 | 135 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.ListByResourceGroup"); |
| 0 | 136 | | scope.Start(); |
| | 137 | | try |
| | 138 | | { |
| 0 | 139 | | var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); |
| 0 | 140 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 141 | | } |
| 0 | 142 | | catch (Exception e) |
| | 143 | | { |
| 0 | 144 | | scope.Failed(e); |
| 0 | 145 | | throw; |
| | 146 | | } |
| 0 | 147 | | } |
| | 148 | | Page<VirtualRouter> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 149 | | { |
| 0 | 150 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.ListByResourceGroup"); |
| 0 | 151 | | scope.Start(); |
| | 152 | | try |
| | 153 | | { |
| 0 | 154 | | var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken |
| 0 | 155 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 156 | | } |
| 0 | 157 | | catch (Exception e) |
| | 158 | | { |
| 0 | 159 | | scope.Failed(e); |
| 0 | 160 | | throw; |
| | 161 | | } |
| 0 | 162 | | } |
| 0 | 163 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 164 | | } |
| | 165 | |
|
| | 166 | | /// <summary> Gets all the Virtual Routers in a subscription. </summary> |
| | 167 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 168 | | public virtual AsyncPageable<VirtualRouter> ListAsync(CancellationToken cancellationToken = default) |
| | 169 | | { |
| | 170 | | async Task<Page<VirtualRouter>> FirstPageFunc(int? pageSizeHint) |
| | 171 | | { |
| 0 | 172 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.List"); |
| 0 | 173 | | scope.Start(); |
| | 174 | | try |
| | 175 | | { |
| 0 | 176 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 0 | 177 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 178 | | } |
| 0 | 179 | | catch (Exception e) |
| | 180 | | { |
| 0 | 181 | | scope.Failed(e); |
| 0 | 182 | | throw; |
| | 183 | | } |
| 0 | 184 | | } |
| | 185 | | async Task<Page<VirtualRouter>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 186 | | { |
| 0 | 187 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.List"); |
| 0 | 188 | | scope.Start(); |
| | 189 | | try |
| | 190 | | { |
| 0 | 191 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 192 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 193 | | } |
| 0 | 194 | | catch (Exception e) |
| | 195 | | { |
| 0 | 196 | | scope.Failed(e); |
| 0 | 197 | | throw; |
| | 198 | | } |
| 0 | 199 | | } |
| 0 | 200 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 201 | | } |
| | 202 | |
|
| | 203 | | /// <summary> Gets all the Virtual Routers in a subscription. </summary> |
| | 204 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 205 | | public virtual Pageable<VirtualRouter> List(CancellationToken cancellationToken = default) |
| | 206 | | { |
| | 207 | | Page<VirtualRouter> FirstPageFunc(int? pageSizeHint) |
| | 208 | | { |
| 0 | 209 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.List"); |
| 0 | 210 | | scope.Start(); |
| | 211 | | try |
| | 212 | | { |
| 0 | 213 | | var response = RestClient.List(cancellationToken); |
| 0 | 214 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 215 | | } |
| 0 | 216 | | catch (Exception e) |
| | 217 | | { |
| 0 | 218 | | scope.Failed(e); |
| 0 | 219 | | throw; |
| | 220 | | } |
| 0 | 221 | | } |
| | 222 | | Page<VirtualRouter> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 223 | | { |
| 0 | 224 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.List"); |
| 0 | 225 | | scope.Start(); |
| | 226 | | try |
| | 227 | | { |
| 0 | 228 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 229 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 230 | | } |
| 0 | 231 | | catch (Exception e) |
| | 232 | | { |
| 0 | 233 | | scope.Failed(e); |
| 0 | 234 | | throw; |
| | 235 | | } |
| 0 | 236 | | } |
| 0 | 237 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 238 | | } |
| | 239 | |
|
| | 240 | | /// <summary> Deletes the specified Virtual Router. </summary> |
| | 241 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 242 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 243 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 244 | | public virtual async Task<VirtualRoutersDeleteOperation> StartDeleteAsync(string resourceGroupName, string virtu |
| | 245 | | { |
| 0 | 246 | | if (resourceGroupName == null) |
| | 247 | | { |
| 0 | 248 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 249 | | } |
| 0 | 250 | | if (virtualRouterName == null) |
| | 251 | | { |
| 0 | 252 | | throw new ArgumentNullException(nameof(virtualRouterName)); |
| | 253 | | } |
| | 254 | |
|
| 0 | 255 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.StartDelete"); |
| 0 | 256 | | scope.Start(); |
| | 257 | | try |
| | 258 | | { |
| 0 | 259 | | var originalResponse = await RestClient.DeleteAsync(resourceGroupName, virtualRouterName, cancellationTo |
| 0 | 260 | | return new VirtualRoutersDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r |
| | 261 | | } |
| 0 | 262 | | catch (Exception e) |
| | 263 | | { |
| 0 | 264 | | scope.Failed(e); |
| 0 | 265 | | throw; |
| | 266 | | } |
| 0 | 267 | | } |
| | 268 | |
|
| | 269 | | /// <summary> Deletes the specified Virtual Router. </summary> |
| | 270 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 271 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 273 | | public virtual VirtualRoutersDeleteOperation StartDelete(string resourceGroupName, string virtualRouterName, Can |
| | 274 | | { |
| 0 | 275 | | if (resourceGroupName == null) |
| | 276 | | { |
| 0 | 277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 278 | | } |
| 0 | 279 | | if (virtualRouterName == null) |
| | 280 | | { |
| 0 | 281 | | throw new ArgumentNullException(nameof(virtualRouterName)); |
| | 282 | | } |
| | 283 | |
|
| 0 | 284 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.StartDelete"); |
| 0 | 285 | | scope.Start(); |
| | 286 | | try |
| | 287 | | { |
| 0 | 288 | | var originalResponse = RestClient.Delete(resourceGroupName, virtualRouterName, cancellationToken); |
| 0 | 289 | | return new VirtualRoutersDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r |
| | 290 | | } |
| 0 | 291 | | catch (Exception e) |
| | 292 | | { |
| 0 | 293 | | scope.Failed(e); |
| 0 | 294 | | throw; |
| | 295 | | } |
| 0 | 296 | | } |
| | 297 | |
|
| | 298 | | /// <summary> Creates or updates the specified Virtual Router. </summary> |
| | 299 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 300 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 301 | | /// <param name="parameters"> Parameters supplied to the create or update Virtual Router. </param> |
| | 302 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 303 | | public virtual async Task<VirtualRoutersCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupNa |
| | 304 | | { |
| 0 | 305 | | if (resourceGroupName == null) |
| | 306 | | { |
| 0 | 307 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 308 | | } |
| 0 | 309 | | if (virtualRouterName == null) |
| | 310 | | { |
| 0 | 311 | | throw new ArgumentNullException(nameof(virtualRouterName)); |
| | 312 | | } |
| 0 | 313 | | if (parameters == null) |
| | 314 | | { |
| 0 | 315 | | throw new ArgumentNullException(nameof(parameters)); |
| | 316 | | } |
| | 317 | |
|
| 0 | 318 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.StartCreateOrUpdate"); |
| 0 | 319 | | scope.Start(); |
| | 320 | | try |
| | 321 | | { |
| 0 | 322 | | var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, virtualRouterName, parame |
| 0 | 323 | | return new VirtualRoutersCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateO |
| | 324 | | } |
| 0 | 325 | | catch (Exception e) |
| | 326 | | { |
| 0 | 327 | | scope.Failed(e); |
| 0 | 328 | | throw; |
| | 329 | | } |
| 0 | 330 | | } |
| | 331 | |
|
| | 332 | | /// <summary> Creates or updates the specified Virtual Router. </summary> |
| | 333 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 334 | | /// <param name="virtualRouterName"> The name of the Virtual Router. </param> |
| | 335 | | /// <param name="parameters"> Parameters supplied to the create or update Virtual Router. </param> |
| | 336 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 337 | | public virtual VirtualRoutersCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string virtua |
| | 338 | | { |
| 0 | 339 | | if (resourceGroupName == null) |
| | 340 | | { |
| 0 | 341 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 342 | | } |
| 0 | 343 | | if (virtualRouterName == null) |
| | 344 | | { |
| 0 | 345 | | throw new ArgumentNullException(nameof(virtualRouterName)); |
| | 346 | | } |
| 0 | 347 | | if (parameters == null) |
| | 348 | | { |
| 0 | 349 | | throw new ArgumentNullException(nameof(parameters)); |
| | 350 | | } |
| | 351 | |
|
| 0 | 352 | | using var scope = _clientDiagnostics.CreateScope("VirtualRoutersOperations.StartCreateOrUpdate"); |
| 0 | 353 | | scope.Start(); |
| | 354 | | try |
| | 355 | | { |
| 0 | 356 | | var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, virtualRouterName, parameters, cance |
| 0 | 357 | | return new VirtualRoutersCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateO |
| | 358 | | } |
| 0 | 359 | | catch (Exception e) |
| | 360 | | { |
| 0 | 361 | | scope.Failed(e); |
| 0 | 362 | | throw; |
| | 363 | | } |
| 0 | 364 | | } |
| | 365 | | } |
| | 366 | | } |