| | 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 SshPublicKeys service client. </summary> |
| | 19 | | public partial class SshPublicKeysOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 0 | 23 | | internal SshPublicKeysRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of SshPublicKeysOperations for mocking. </summary> |
| 0 | 25 | | protected SshPublicKeysOperations() |
| | 26 | | { |
| 0 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of SshPublicKeysOperations. </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> |
| 0 | 33 | | internal SshPublicKeysOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription |
| | 34 | | { |
| 0 | 35 | | RestClient = new SshPublicKeysRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 0 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 37 | | _pipeline = pipeline; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Creates a new SSH public key resource. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 42 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 43 | | /// <param name="parameters"> Parameters supplied to create the SSH public key. </param> |
| | 44 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 45 | | public virtual async Task<Response<SshPublicKeyResource>> CreateAsync(string resourceGroupName, string sshPublic |
| | 46 | | { |
| 0 | 47 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Create"); |
| 0 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 0 | 51 | | return await RestClient.CreateAsync(resourceGroupName, sshPublicKeyName, parameters, cancellationToken). |
| | 52 | | } |
| 0 | 53 | | catch (Exception e) |
| | 54 | | { |
| 0 | 55 | | scope.Failed(e); |
| 0 | 56 | | throw; |
| | 57 | | } |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Creates a new SSH public key resource. </summary> |
| | 61 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 62 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 63 | | /// <param name="parameters"> Parameters supplied to create the SSH public key. </param> |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public virtual Response<SshPublicKeyResource> Create(string resourceGroupName, string sshPublicKeyName, SshPubli |
| | 66 | | { |
| 0 | 67 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Create"); |
| 0 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 0 | 71 | | return RestClient.Create(resourceGroupName, sshPublicKeyName, parameters, cancellationToken); |
| | 72 | | } |
| 0 | 73 | | catch (Exception e) |
| | 74 | | { |
| 0 | 75 | | scope.Failed(e); |
| 0 | 76 | | throw; |
| | 77 | | } |
| 0 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> Updates a new SSH public key resource. </summary> |
| | 81 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 82 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 83 | | /// <param name="parameters"> Parameters supplied to update the SSH public key. </param> |
| | 84 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 85 | | public virtual async Task<Response<SshPublicKeyResource>> UpdateAsync(string resourceGroupName, string sshPublic |
| | 86 | | { |
| 0 | 87 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Update"); |
| 0 | 88 | | scope.Start(); |
| | 89 | | try |
| | 90 | | { |
| 0 | 91 | | return await RestClient.UpdateAsync(resourceGroupName, sshPublicKeyName, parameters, cancellationToken). |
| | 92 | | } |
| 0 | 93 | | catch (Exception e) |
| | 94 | | { |
| 0 | 95 | | scope.Failed(e); |
| 0 | 96 | | throw; |
| | 97 | | } |
| 0 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> Updates a new SSH public key resource. </summary> |
| | 101 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 102 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 103 | | /// <param name="parameters"> Parameters supplied to update the SSH public key. </param> |
| | 104 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 105 | | public virtual Response<SshPublicKeyResource> Update(string resourceGroupName, string sshPublicKeyName, SshPubli |
| | 106 | | { |
| 0 | 107 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Update"); |
| 0 | 108 | | scope.Start(); |
| | 109 | | try |
| | 110 | | { |
| 0 | 111 | | return RestClient.Update(resourceGroupName, sshPublicKeyName, parameters, cancellationToken); |
| | 112 | | } |
| 0 | 113 | | catch (Exception e) |
| | 114 | | { |
| 0 | 115 | | scope.Failed(e); |
| 0 | 116 | | throw; |
| | 117 | | } |
| 0 | 118 | | } |
| | 119 | |
|
| | 120 | | /// <summary> Delete an SSH public key. </summary> |
| | 121 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 122 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 123 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 124 | | public virtual async Task<Response> DeleteAsync(string resourceGroupName, string sshPublicKeyName, CancellationT |
| | 125 | | { |
| 0 | 126 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Delete"); |
| 0 | 127 | | scope.Start(); |
| | 128 | | try |
| | 129 | | { |
| 0 | 130 | | return await RestClient.DeleteAsync(resourceGroupName, sshPublicKeyName, cancellationToken).ConfigureAwa |
| | 131 | | } |
| 0 | 132 | | catch (Exception e) |
| | 133 | | { |
| 0 | 134 | | scope.Failed(e); |
| 0 | 135 | | throw; |
| | 136 | | } |
| 0 | 137 | | } |
| | 138 | |
|
| | 139 | | /// <summary> Delete an SSH public key. </summary> |
| | 140 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 141 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 142 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 143 | | public virtual Response Delete(string resourceGroupName, string sshPublicKeyName, CancellationToken cancellation |
| | 144 | | { |
| 0 | 145 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Delete"); |
| 0 | 146 | | scope.Start(); |
| | 147 | | try |
| | 148 | | { |
| 0 | 149 | | return RestClient.Delete(resourceGroupName, sshPublicKeyName, cancellationToken); |
| | 150 | | } |
| 0 | 151 | | catch (Exception e) |
| | 152 | | { |
| 0 | 153 | | scope.Failed(e); |
| 0 | 154 | | throw; |
| | 155 | | } |
| 0 | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> Retrieves information about an SSH public key. </summary> |
| | 159 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 160 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 161 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 162 | | public virtual async Task<Response<SshPublicKeyResource>> GetAsync(string resourceGroupName, string sshPublicKey |
| | 163 | | { |
| 0 | 164 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Get"); |
| 0 | 165 | | scope.Start(); |
| | 166 | | try |
| | 167 | | { |
| 0 | 168 | | return await RestClient.GetAsync(resourceGroupName, sshPublicKeyName, cancellationToken).ConfigureAwait( |
| | 169 | | } |
| 0 | 170 | | catch (Exception e) |
| | 171 | | { |
| 0 | 172 | | scope.Failed(e); |
| 0 | 173 | | throw; |
| | 174 | | } |
| 0 | 175 | | } |
| | 176 | |
|
| | 177 | | /// <summary> Retrieves information about an SSH public key. </summary> |
| | 178 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 179 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 180 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 181 | | public virtual Response<SshPublicKeyResource> Get(string resourceGroupName, string sshPublicKeyName, Cancellatio |
| | 182 | | { |
| 0 | 183 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.Get"); |
| 0 | 184 | | scope.Start(); |
| | 185 | | try |
| | 186 | | { |
| 0 | 187 | | return RestClient.Get(resourceGroupName, sshPublicKeyName, cancellationToken); |
| | 188 | | } |
| 0 | 189 | | catch (Exception e) |
| | 190 | | { |
| 0 | 191 | | scope.Failed(e); |
| 0 | 192 | | throw; |
| | 193 | | } |
| 0 | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> Generates and returns a public/private key pair and populates the SSH public key resource with the |
| | 197 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 198 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 199 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 200 | | public virtual async Task<Response<SshPublicKeyGenerateKeyPairResult>> GenerateKeyPairAsync(string resourceGroup |
| | 201 | | { |
| 0 | 202 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.GenerateKeyPair"); |
| 0 | 203 | | scope.Start(); |
| | 204 | | try |
| | 205 | | { |
| 0 | 206 | | return await RestClient.GenerateKeyPairAsync(resourceGroupName, sshPublicKeyName, cancellationToken).Con |
| | 207 | | } |
| 0 | 208 | | catch (Exception e) |
| | 209 | | { |
| 0 | 210 | | scope.Failed(e); |
| 0 | 211 | | throw; |
| | 212 | | } |
| 0 | 213 | | } |
| | 214 | |
|
| | 215 | | /// <summary> Generates and returns a public/private key pair and populates the SSH public key resource with the |
| | 216 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 217 | | /// <param name="sshPublicKeyName"> The name of the SSH public key. </param> |
| | 218 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 219 | | public virtual Response<SshPublicKeyGenerateKeyPairResult> GenerateKeyPair(string resourceGroupName, string sshP |
| | 220 | | { |
| 0 | 221 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.GenerateKeyPair"); |
| 0 | 222 | | scope.Start(); |
| | 223 | | try |
| | 224 | | { |
| 0 | 225 | | return RestClient.GenerateKeyPair(resourceGroupName, sshPublicKeyName, cancellationToken); |
| | 226 | | } |
| 0 | 227 | | catch (Exception e) |
| | 228 | | { |
| 0 | 229 | | scope.Failed(e); |
| 0 | 230 | | throw; |
| | 231 | | } |
| 0 | 232 | | } |
| | 233 | |
|
| | 234 | | /// <summary> Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to |
| | 235 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 236 | | public virtual AsyncPageable<SshPublicKeyResource> ListBySubscriptionAsync(CancellationToken cancellationToken = |
| | 237 | | { |
| | 238 | | async Task<Page<SshPublicKeyResource>> FirstPageFunc(int? pageSizeHint) |
| | 239 | | { |
| 0 | 240 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListBySubscription"); |
| 0 | 241 | | scope.Start(); |
| | 242 | | try |
| | 243 | | { |
| 0 | 244 | | var response = await RestClient.ListBySubscriptionAsync(cancellationToken).ConfigureAwait(false); |
| 0 | 245 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 246 | | } |
| 0 | 247 | | catch (Exception e) |
| | 248 | | { |
| 0 | 249 | | scope.Failed(e); |
| 0 | 250 | | throw; |
| | 251 | | } |
| 0 | 252 | | } |
| | 253 | | async Task<Page<SshPublicKeyResource>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 254 | | { |
| 0 | 255 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListBySubscription"); |
| 0 | 256 | | scope.Start(); |
| | 257 | | try |
| | 258 | | { |
| 0 | 259 | | var response = await RestClient.ListBySubscriptionNextPageAsync(nextLink, cancellationToken).Configu |
| 0 | 260 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 261 | | } |
| 0 | 262 | | catch (Exception e) |
| | 263 | | { |
| 0 | 264 | | scope.Failed(e); |
| 0 | 265 | | throw; |
| | 266 | | } |
| 0 | 267 | | } |
| 0 | 268 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 269 | | } |
| | 270 | |
|
| | 271 | | /// <summary> Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to |
| | 272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 273 | | public virtual Pageable<SshPublicKeyResource> ListBySubscription(CancellationToken cancellationToken = default) |
| | 274 | | { |
| | 275 | | Page<SshPublicKeyResource> FirstPageFunc(int? pageSizeHint) |
| | 276 | | { |
| 0 | 277 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListBySubscription"); |
| 0 | 278 | | scope.Start(); |
| | 279 | | try |
| | 280 | | { |
| 0 | 281 | | var response = RestClient.ListBySubscription(cancellationToken); |
| 0 | 282 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 283 | | } |
| 0 | 284 | | catch (Exception e) |
| | 285 | | { |
| 0 | 286 | | scope.Failed(e); |
| 0 | 287 | | throw; |
| | 288 | | } |
| 0 | 289 | | } |
| | 290 | | Page<SshPublicKeyResource> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 291 | | { |
| 0 | 292 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListBySubscription"); |
| 0 | 293 | | scope.Start(); |
| | 294 | | try |
| | 295 | | { |
| 0 | 296 | | var response = RestClient.ListBySubscriptionNextPage(nextLink, cancellationToken); |
| 0 | 297 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 298 | | } |
| 0 | 299 | | catch (Exception e) |
| | 300 | | { |
| 0 | 301 | | scope.Failed(e); |
| 0 | 302 | | throw; |
| | 303 | | } |
| 0 | 304 | | } |
| 0 | 305 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 306 | | } |
| | 307 | |
|
| | 308 | | /// <summary> Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the |
| | 309 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 310 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 311 | | public virtual AsyncPageable<SshPublicKeyResource> ListByResourceGroupAsync(string resourceGroupName, Cancellati |
| | 312 | | { |
| 0 | 313 | | if (resourceGroupName == null) |
| | 314 | | { |
| 0 | 315 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 316 | | } |
| | 317 | |
|
| | 318 | | async Task<Page<SshPublicKeyResource>> FirstPageFunc(int? pageSizeHint) |
| | 319 | | { |
| 0 | 320 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListByResourceGroup"); |
| 0 | 321 | | scope.Start(); |
| | 322 | | try |
| | 323 | | { |
| 0 | 324 | | var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi |
| 0 | 325 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 326 | | } |
| 0 | 327 | | catch (Exception e) |
| | 328 | | { |
| 0 | 329 | | scope.Failed(e); |
| 0 | 330 | | throw; |
| | 331 | | } |
| 0 | 332 | | } |
| | 333 | | async Task<Page<SshPublicKeyResource>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 334 | | { |
| 0 | 335 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListByResourceGroup"); |
| 0 | 336 | | scope.Start(); |
| | 337 | | try |
| | 338 | | { |
| 0 | 339 | | var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel |
| 0 | 340 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 341 | | } |
| 0 | 342 | | catch (Exception e) |
| | 343 | | { |
| 0 | 344 | | scope.Failed(e); |
| 0 | 345 | | throw; |
| | 346 | | } |
| 0 | 347 | | } |
| 0 | 348 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 349 | | } |
| | 350 | |
|
| | 351 | | /// <summary> Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the |
| | 352 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 353 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 354 | | public virtual Pageable<SshPublicKeyResource> ListByResourceGroup(string resourceGroupName, CancellationToken ca |
| | 355 | | { |
| 0 | 356 | | if (resourceGroupName == null) |
| | 357 | | { |
| 0 | 358 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 359 | | } |
| | 360 | |
|
| | 361 | | Page<SshPublicKeyResource> FirstPageFunc(int? pageSizeHint) |
| | 362 | | { |
| 0 | 363 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListByResourceGroup"); |
| 0 | 364 | | scope.Start(); |
| | 365 | | try |
| | 366 | | { |
| 0 | 367 | | var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken); |
| 0 | 368 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 369 | | } |
| 0 | 370 | | catch (Exception e) |
| | 371 | | { |
| 0 | 372 | | scope.Failed(e); |
| 0 | 373 | | throw; |
| | 374 | | } |
| 0 | 375 | | } |
| | 376 | | Page<SshPublicKeyResource> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 377 | | { |
| 0 | 378 | | using var scope = _clientDiagnostics.CreateScope("SshPublicKeysOperations.ListByResourceGroup"); |
| 0 | 379 | | scope.Start(); |
| | 380 | | try |
| | 381 | | { |
| 0 | 382 | | var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken |
| 0 | 383 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 384 | | } |
| 0 | 385 | | catch (Exception e) |
| | 386 | | { |
| 0 | 387 | | scope.Failed(e); |
| 0 | 388 | | throw; |
| | 389 | | } |
| 0 | 390 | | } |
| 0 | 391 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 392 | | } |
| | 393 | | } |
| | 394 | | } |