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