| | 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.Compute.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Compute |
| | 17 | | { |
| | 18 | | /// <summary> The AvailabilitySets service client. </summary> |
| | 19 | | public partial class AvailabilitySetsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 228 | 23 | | internal AvailabilitySetsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of AvailabilitySetsOperations for mocking. </summary> |
| 396 | 25 | | protected AvailabilitySetsOperations() |
| | 26 | | { |
| 396 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of AvailabilitySetsOperations. </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"> Subscription credentials which uniquely identify Microsoft Azure subscription. |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 396 | 33 | | internal AvailabilitySetsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript |
| | 34 | | { |
| 396 | 35 | | RestClient = new AvailabilitySetsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 396 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 396 | 37 | | _pipeline = pipeline; |
| 396 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Create or update an availability set. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 42 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 43 | | /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param> |
| | 44 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 45 | | public virtual async Task<Response<AvailabilitySet>> CreateOrUpdateAsync(string resourceGroupName, string availa |
| | 46 | | { |
| 74 | 47 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.CreateOrUpdate"); |
| 74 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 74 | 51 | | return await RestClient.CreateOrUpdateAsync(resourceGroupName, availabilitySetName, parameters, cancella |
| | 52 | | } |
| 8 | 53 | | catch (Exception e) |
| | 54 | | { |
| 8 | 55 | | scope.Failed(e); |
| 8 | 56 | | throw; |
| | 57 | | } |
| 66 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Create or update an availability set. </summary> |
| | 61 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 62 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 63 | | /// <param name="parameters"> Parameters supplied to the Create Availability Set operation. </param> |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public virtual Response<AvailabilitySet> CreateOrUpdate(string resourceGroupName, string availabilitySetName, Av |
| | 66 | | { |
| 74 | 67 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.CreateOrUpdate"); |
| 74 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 74 | 71 | | return RestClient.CreateOrUpdate(resourceGroupName, availabilitySetName, parameters, cancellationToken); |
| | 72 | | } |
| 8 | 73 | | catch (Exception e) |
| | 74 | | { |
| 8 | 75 | | scope.Failed(e); |
| 8 | 76 | | throw; |
| | 77 | | } |
| 66 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> Update an availability set. </summary> |
| | 81 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 82 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 83 | | /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param> |
| | 84 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 85 | | public virtual async Task<Response<AvailabilitySet>> UpdateAsync(string resourceGroupName, string availabilitySe |
| | 86 | | { |
| 2 | 87 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Update"); |
| 2 | 88 | | scope.Start(); |
| | 89 | | try |
| | 90 | | { |
| 2 | 91 | | return await RestClient.UpdateAsync(resourceGroupName, availabilitySetName, parameters, cancellationToke |
| | 92 | | } |
| 0 | 93 | | catch (Exception e) |
| | 94 | | { |
| 0 | 95 | | scope.Failed(e); |
| 0 | 96 | | throw; |
| | 97 | | } |
| 2 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Update an availability set. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 102 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 103 | | /// <param name="parameters"> Parameters supplied to the Update Availability Set operation. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public virtual Response<AvailabilitySet> Update(string resourceGroupName, string availabilitySetName, Availabili |
| | 106 | | { |
| 2 | 107 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Update"); |
| 2 | 108 | | scope.Start(); |
| | 109 | | try |
| | 110 | | { |
| 2 | 111 | | return RestClient.Update(resourceGroupName, availabilitySetName, parameters, cancellationToken); |
| | 112 | | } |
| 0 | 113 | | catch (Exception e) |
| | 114 | | { |
| 0 | 115 | | scope.Failed(e); |
| 0 | 116 | | throw; |
| | 117 | | } |
| 2 | 118 | | } |
| | 119 | |
|
| | 120 | | /// <summary> Delete an availability set. </summary> |
| | 121 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 122 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 123 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 124 | | public virtual async Task<Response> DeleteAsync(string resourceGroupName, string availabilitySetName, Cancellati |
| | 125 | | { |
| 8 | 126 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Delete"); |
| 8 | 127 | | scope.Start(); |
| | 128 | | try |
| | 129 | | { |
| 8 | 130 | | return await RestClient.DeleteAsync(resourceGroupName, availabilitySetName, cancellationToken).Configure |
| | 131 | | } |
| 0 | 132 | | catch (Exception e) |
| | 133 | | { |
| 0 | 134 | | scope.Failed(e); |
| 0 | 135 | | throw; |
| | 136 | | } |
| 8 | 137 | | } |
| | 138 | |
|
| | 139 | | /// <summary> Delete an availability set. </summary> |
| | 140 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 141 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 142 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 143 | | public virtual Response Delete(string resourceGroupName, string availabilitySetName, CancellationToken cancellat |
| | 144 | | { |
| 8 | 145 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Delete"); |
| 8 | 146 | | scope.Start(); |
| | 147 | | try |
| | 148 | | { |
| 8 | 149 | | return RestClient.Delete(resourceGroupName, availabilitySetName, cancellationToken); |
| | 150 | | } |
| 0 | 151 | | catch (Exception e) |
| | 152 | | { |
| 0 | 153 | | scope.Failed(e); |
| 0 | 154 | | throw; |
| | 155 | | } |
| 8 | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> Retrieves information about an availability set. </summary> |
| | 159 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 160 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 161 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 162 | | public virtual async Task<Response<AvailabilitySet>> GetAsync(string resourceGroupName, string availabilitySetNa |
| | 163 | | { |
| 8 | 164 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Get"); |
| 8 | 165 | | scope.Start(); |
| | 166 | | try |
| | 167 | | { |
| 8 | 168 | | return await RestClient.GetAsync(resourceGroupName, availabilitySetName, cancellationToken).ConfigureAwa |
| | 169 | | } |
| 0 | 170 | | catch (Exception e) |
| | 171 | | { |
| 0 | 172 | | scope.Failed(e); |
| 0 | 173 | | throw; |
| | 174 | | } |
| 8 | 175 | | } |
| | 176 | |
|
| | 177 | | /// <summary> Retrieves information about an availability set. </summary> |
| | 178 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 179 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 180 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 181 | | public virtual Response<AvailabilitySet> Get(string resourceGroupName, string availabilitySetName, CancellationT |
| | 182 | | { |
| 8 | 183 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Get"); |
| 8 | 184 | | scope.Start(); |
| | 185 | | try |
| | 186 | | { |
| 8 | 187 | | return RestClient.Get(resourceGroupName, availabilitySetName, cancellationToken); |
| | 188 | | } |
| 0 | 189 | | catch (Exception e) |
| | 190 | | { |
| 0 | 191 | | scope.Failed(e); |
| 0 | 192 | | throw; |
| | 193 | | } |
| 8 | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> Lists all availability sets in a subscription. </summary> |
| | 197 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 198 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 199 | | public virtual AsyncPageable<AvailabilitySet> ListBySubscriptionAsync(string expand = null, CancellationToken ca |
| | 200 | | { |
| | 201 | | async Task<Page<AvailabilitySet>> FirstPageFunc(int? pageSizeHint) |
| | 202 | | { |
| 4 | 203 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription"); |
| 4 | 204 | | scope.Start(); |
| | 205 | | try |
| | 206 | | { |
| 4 | 207 | | var response = await RestClient.ListBySubscriptionAsync(expand, cancellationToken).ConfigureAwait(fa |
| 4 | 208 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 209 | | } |
| 0 | 210 | | catch (Exception e) |
| | 211 | | { |
| 0 | 212 | | scope.Failed(e); |
| 0 | 213 | | throw; |
| | 214 | | } |
| 4 | 215 | | } |
| | 216 | | async Task<Page<AvailabilitySet>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 217 | | { |
| 0 | 218 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription"); |
| 0 | 219 | | scope.Start(); |
| | 220 | | try |
| | 221 | | { |
| 0 | 222 | | var response = await RestClient.ListBySubscriptionNextPageAsync(nextLink, expand, cancellationToken) |
| 0 | 223 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 224 | | } |
| 0 | 225 | | catch (Exception e) |
| | 226 | | { |
| 0 | 227 | | scope.Failed(e); |
| 0 | 228 | | throw; |
| | 229 | | } |
| 0 | 230 | | } |
| 4 | 231 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Lists all availability sets in a subscription. </summary> |
| | 235 | | /// <param name="expand"> The expand expression to apply to the operation. </param> |
| | 236 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 237 | | public virtual Pageable<AvailabilitySet> ListBySubscription(string expand = null, CancellationToken cancellation |
| | 238 | | { |
| | 239 | | Page<AvailabilitySet> FirstPageFunc(int? pageSizeHint) |
| | 240 | | { |
| 4 | 241 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription"); |
| 4 | 242 | | scope.Start(); |
| | 243 | | try |
| | 244 | | { |
| 4 | 245 | | var response = RestClient.ListBySubscription(expand, cancellationToken); |
| 4 | 246 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 247 | | } |
| 0 | 248 | | catch (Exception e) |
| | 249 | | { |
| 0 | 250 | | scope.Failed(e); |
| 0 | 251 | | throw; |
| | 252 | | } |
| 4 | 253 | | } |
| | 254 | | Page<AvailabilitySet> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 255 | | { |
| 0 | 256 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListBySubscription"); |
| 0 | 257 | | scope.Start(); |
| | 258 | | try |
| | 259 | | { |
| 0 | 260 | | var response = RestClient.ListBySubscriptionNextPage(nextLink, expand, cancellationToken); |
| 0 | 261 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 262 | | } |
| 0 | 263 | | catch (Exception e) |
| | 264 | | { |
| 0 | 265 | | scope.Failed(e); |
| 0 | 266 | | throw; |
| | 267 | | } |
| 0 | 268 | | } |
| 4 | 269 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 270 | | } |
| | 271 | |
|
| | 272 | | /// <summary> Lists all availability sets in a resource group. </summary> |
| | 273 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 274 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 275 | | public virtual AsyncPageable<AvailabilitySet> ListAsync(string resourceGroupName, CancellationToken cancellation |
| | 276 | | { |
| 2 | 277 | | if (resourceGroupName == null) |
| | 278 | | { |
| 0 | 279 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 280 | | } |
| | 281 | |
|
| | 282 | | async Task<Page<AvailabilitySet>> FirstPageFunc(int? pageSizeHint) |
| | 283 | | { |
| 2 | 284 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List"); |
| 2 | 285 | | scope.Start(); |
| | 286 | | try |
| | 287 | | { |
| 2 | 288 | | var response = await RestClient.ListAsync(resourceGroupName, cancellationToken).ConfigureAwait(false |
| 2 | 289 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 290 | | } |
| 0 | 291 | | catch (Exception e) |
| | 292 | | { |
| 0 | 293 | | scope.Failed(e); |
| 0 | 294 | | throw; |
| | 295 | | } |
| 2 | 296 | | } |
| | 297 | | async Task<Page<AvailabilitySet>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 298 | | { |
| 0 | 299 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List"); |
| 0 | 300 | | scope.Start(); |
| | 301 | | try |
| | 302 | | { |
| 0 | 303 | | var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, cancellationToken).Co |
| 0 | 304 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 305 | | } |
| 0 | 306 | | catch (Exception e) |
| | 307 | | { |
| 0 | 308 | | scope.Failed(e); |
| 0 | 309 | | throw; |
| | 310 | | } |
| 0 | 311 | | } |
| 2 | 312 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 313 | | } |
| | 314 | |
|
| | 315 | | /// <summary> Lists all availability sets in a resource group. </summary> |
| | 316 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 317 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 318 | | public virtual Pageable<AvailabilitySet> List(string resourceGroupName, CancellationToken cancellationToken = de |
| | 319 | | { |
| 2 | 320 | | if (resourceGroupName == null) |
| | 321 | | { |
| 0 | 322 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 323 | | } |
| | 324 | |
|
| | 325 | | Page<AvailabilitySet> FirstPageFunc(int? pageSizeHint) |
| | 326 | | { |
| 2 | 327 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List"); |
| 2 | 328 | | scope.Start(); |
| | 329 | | try |
| | 330 | | { |
| 2 | 331 | | var response = RestClient.List(resourceGroupName, cancellationToken); |
| 2 | 332 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 333 | | } |
| 0 | 334 | | catch (Exception e) |
| | 335 | | { |
| 0 | 336 | | scope.Failed(e); |
| 0 | 337 | | throw; |
| | 338 | | } |
| 2 | 339 | | } |
| | 340 | | Page<AvailabilitySet> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 341 | | { |
| 0 | 342 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.List"); |
| 0 | 343 | | scope.Start(); |
| | 344 | | try |
| | 345 | | { |
| 0 | 346 | | var response = RestClient.ListNextPage(nextLink, resourceGroupName, cancellationToken); |
| 0 | 347 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 348 | | } |
| 0 | 349 | | catch (Exception e) |
| | 350 | | { |
| 0 | 351 | | scope.Failed(e); |
| 0 | 352 | | throw; |
| | 353 | | } |
| 0 | 354 | | } |
| 2 | 355 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 356 | | } |
| | 357 | |
|
| | 358 | | /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e |
| | 359 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 360 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 361 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 362 | | public virtual AsyncPageable<VirtualMachineSize> ListAvailableSizesAsync(string resourceGroupName, string availa |
| | 363 | | { |
| 16 | 364 | | if (resourceGroupName == null) |
| | 365 | | { |
| 0 | 366 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 367 | | } |
| 16 | 368 | | if (availabilitySetName == null) |
| | 369 | | { |
| 0 | 370 | | throw new ArgumentNullException(nameof(availabilitySetName)); |
| | 371 | | } |
| | 372 | |
|
| | 373 | | async Task<Page<VirtualMachineSize>> FirstPageFunc(int? pageSizeHint) |
| | 374 | | { |
| 16 | 375 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListAvailableSizes"); |
| 16 | 376 | | scope.Start(); |
| | 377 | | try |
| | 378 | | { |
| 16 | 379 | | var response = await RestClient.ListAvailableSizesAsync(resourceGroupName, availabilitySetName, canc |
| 16 | 380 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 381 | | } |
| 0 | 382 | | catch (Exception e) |
| | 383 | | { |
| 0 | 384 | | scope.Failed(e); |
| 0 | 385 | | throw; |
| | 386 | | } |
| 16 | 387 | | } |
| 16 | 388 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null); |
| | 389 | | } |
| | 390 | |
|
| | 391 | | /// <summary> Lists all available virtual machine sizes that can be used to create a new virtual machine in an e |
| | 392 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 393 | | /// <param name="availabilitySetName"> The name of the availability set. </param> |
| | 394 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 395 | | public virtual Pageable<VirtualMachineSize> ListAvailableSizes(string resourceGroupName, string availabilitySetN |
| | 396 | | { |
| 16 | 397 | | if (resourceGroupName == null) |
| | 398 | | { |
| 0 | 399 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 400 | | } |
| 16 | 401 | | if (availabilitySetName == null) |
| | 402 | | { |
| 0 | 403 | | throw new ArgumentNullException(nameof(availabilitySetName)); |
| | 404 | | } |
| | 405 | |
|
| | 406 | | Page<VirtualMachineSize> FirstPageFunc(int? pageSizeHint) |
| | 407 | | { |
| 16 | 408 | | using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.ListAvailableSizes"); |
| 16 | 409 | | scope.Start(); |
| | 410 | | try |
| | 411 | | { |
| 16 | 412 | | var response = RestClient.ListAvailableSizes(resourceGroupName, availabilitySetName, cancellationTok |
| 16 | 413 | | return Page.FromValues(response.Value.Value, null, response.GetRawResponse()); |
| | 414 | | } |
| 0 | 415 | | catch (Exception e) |
| | 416 | | { |
| 0 | 417 | | scope.Failed(e); |
| 0 | 418 | | throw; |
| | 419 | | } |
| 16 | 420 | | } |
| 16 | 421 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, null); |
| | 422 | | } |
| | 423 | | } |
| | 424 | | } |