| | 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.Resources.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Resources |
| | 17 | | { |
| | 18 | | /// <summary> The ResourceGroups service client. </summary> |
| | 19 | | public partial class ResourceGroupsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 212 | 23 | | internal ResourceGroupsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of ResourceGroupsOperations for mocking. </summary> |
| 312 | 25 | | protected ResourceGroupsOperations() |
| | 26 | | { |
| 312 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of ResourceGroupsOperations. </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 ID of the target subscription. </param> |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 312 | 33 | | internal ResourceGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 34 | | { |
| 312 | 35 | | RestClient = new ResourceGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 312 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 312 | 37 | | _pipeline = pipeline; |
| 312 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Checks whether a resource group exists. </summary> |
| | 41 | | /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa |
| | 42 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 43 | | public virtual async Task<Response> CheckExistenceAsync(string resourceGroupName, CancellationToken cancellation |
| | 44 | | { |
| 10 | 45 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CheckExistence"); |
| 10 | 46 | | scope.Start(); |
| | 47 | | try |
| | 48 | | { |
| 10 | 49 | | return await RestClient.CheckExistenceAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); |
| | 50 | | } |
| 2 | 51 | | catch (Exception e) |
| | 52 | | { |
| 2 | 53 | | scope.Failed(e); |
| 2 | 54 | | throw; |
| | 55 | | } |
| 8 | 56 | | } |
| | 57 | |
|
| | 58 | | /// <summary> Checks whether a resource group exists. </summary> |
| | 59 | | /// <param name="resourceGroupName"> The name of the resource group to check. The name is case insensitive. </pa |
| | 60 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 61 | | public virtual Response CheckExistence(string resourceGroupName, CancellationToken cancellationToken = default) |
| | 62 | | { |
| 10 | 63 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CheckExistence"); |
| 10 | 64 | | scope.Start(); |
| | 65 | | try |
| | 66 | | { |
| 10 | 67 | | return RestClient.CheckExistence(resourceGroupName, cancellationToken); |
| | 68 | | } |
| 2 | 69 | | catch (Exception e) |
| | 70 | | { |
| 2 | 71 | | scope.Failed(e); |
| 2 | 72 | | throw; |
| | 73 | | } |
| 8 | 74 | | } |
| | 75 | |
|
| | 76 | | /// <summary> Creates or updates a resource group. </summary> |
| | 77 | | /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri |
| | 78 | | /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param> |
| | 79 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 80 | | public virtual async Task<Response<ResourceGroup>> CreateOrUpdateAsync(string resourceGroupName, ResourceGroup p |
| | 81 | | { |
| 60 | 82 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CreateOrUpdate"); |
| 60 | 83 | | scope.Start(); |
| | 84 | | try |
| | 85 | | { |
| 60 | 86 | | return await RestClient.CreateOrUpdateAsync(resourceGroupName, parameters, cancellationToken).ConfigureA |
| | 87 | | } |
| 4 | 88 | | catch (Exception e) |
| | 89 | | { |
| 4 | 90 | | scope.Failed(e); |
| 4 | 91 | | throw; |
| | 92 | | } |
| 56 | 93 | | } |
| | 94 | |
|
| | 95 | | /// <summary> Creates or updates a resource group. </summary> |
| | 96 | | /// <param name="resourceGroupName"> The name of the resource group to create or update. Can include alphanumeri |
| | 97 | | /// <param name="parameters"> Parameters supplied to the create or update a resource group. </param> |
| | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 99 | | public virtual Response<ResourceGroup> CreateOrUpdate(string resourceGroupName, ResourceGroup parameters, Cancel |
| | 100 | | { |
| 60 | 101 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.CreateOrUpdate"); |
| 60 | 102 | | scope.Start(); |
| | 103 | | try |
| | 104 | | { |
| 60 | 105 | | return RestClient.CreateOrUpdate(resourceGroupName, parameters, cancellationToken); |
| | 106 | | } |
| 4 | 107 | | catch (Exception e) |
| | 108 | | { |
| 4 | 109 | | scope.Failed(e); |
| 4 | 110 | | throw; |
| | 111 | | } |
| 56 | 112 | | } |
| | 113 | |
|
| | 114 | | /// <summary> Gets a resource group. </summary> |
| | 115 | | /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para |
| | 116 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 117 | | public virtual async Task<Response<ResourceGroup>> GetAsync(string resourceGroupName, CancellationToken cancella |
| | 118 | | { |
| 8 | 119 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Get"); |
| 8 | 120 | | scope.Start(); |
| | 121 | | try |
| | 122 | | { |
| 8 | 123 | | return await RestClient.GetAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); |
| | 124 | | } |
| 0 | 125 | | catch (Exception e) |
| | 126 | | { |
| 0 | 127 | | scope.Failed(e); |
| 0 | 128 | | throw; |
| | 129 | | } |
| 8 | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> Gets a resource group. </summary> |
| | 133 | | /// <param name="resourceGroupName"> The name of the resource group to get. The name is case insensitive. </para |
| | 134 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 135 | | public virtual Response<ResourceGroup> Get(string resourceGroupName, CancellationToken cancellationToken = defau |
| | 136 | | { |
| 8 | 137 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Get"); |
| 8 | 138 | | scope.Start(); |
| | 139 | | try |
| | 140 | | { |
| 8 | 141 | | return RestClient.Get(resourceGroupName, cancellationToken); |
| | 142 | | } |
| 0 | 143 | | catch (Exception e) |
| | 144 | | { |
| 0 | 145 | | scope.Failed(e); |
| 0 | 146 | | throw; |
| | 147 | | } |
| 8 | 148 | | } |
| | 149 | |
|
| | 150 | | /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of |
| | 151 | | /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p |
| | 152 | | /// <param name="parameters"> Parameters supplied to update a resource group. </param> |
| | 153 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 154 | | public virtual async Task<Response<ResourceGroup>> UpdateAsync(string resourceGroupName, ResourceGroupPatchable |
| | 155 | | { |
| 2 | 156 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Update"); |
| 2 | 157 | | scope.Start(); |
| | 158 | | try |
| | 159 | | { |
| 2 | 160 | | return await RestClient.UpdateAsync(resourceGroupName, parameters, cancellationToken).ConfigureAwait(fal |
| | 161 | | } |
| 0 | 162 | | catch (Exception e) |
| | 163 | | { |
| 0 | 164 | | scope.Failed(e); |
| 0 | 165 | | throw; |
| | 166 | | } |
| 2 | 167 | | } |
| | 168 | |
|
| | 169 | | /// <summary> Resource groups can be updated through a simple PATCH operation to a group address. The format of |
| | 170 | | /// <param name="resourceGroupName"> The name of the resource group to update. The name is case insensitive. </p |
| | 171 | | /// <param name="parameters"> Parameters supplied to update a resource group. </param> |
| | 172 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 173 | | public virtual Response<ResourceGroup> Update(string resourceGroupName, ResourceGroupPatchable parameters, Cance |
| | 174 | | { |
| 2 | 175 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.Update"); |
| 2 | 176 | | scope.Start(); |
| | 177 | | try |
| | 178 | | { |
| 2 | 179 | | return RestClient.Update(resourceGroupName, parameters, cancellationToken); |
| | 180 | | } |
| 0 | 181 | | catch (Exception e) |
| | 182 | | { |
| 0 | 183 | | scope.Failed(e); |
| 0 | 184 | | throw; |
| | 185 | | } |
| 2 | 186 | | } |
| | 187 | |
|
| | 188 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 189 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 190 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 191 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 192 | | public virtual AsyncPageable<ResourceGroup> ListAsync(string filter = null, int? top = null, CancellationToken c |
| | 193 | | { |
| | 194 | | async Task<Page<ResourceGroup>> FirstPageFunc(int? pageSizeHint) |
| | 195 | | { |
| 10 | 196 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List"); |
| 10 | 197 | | scope.Start(); |
| | 198 | | try |
| | 199 | | { |
| 10 | 200 | | var response = await RestClient.ListAsync(filter, top, cancellationToken).ConfigureAwait(false); |
| 10 | 201 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 202 | | } |
| 0 | 203 | | catch (Exception e) |
| | 204 | | { |
| 0 | 205 | | scope.Failed(e); |
| 0 | 206 | | throw; |
| | 207 | | } |
| 10 | 208 | | } |
| | 209 | | async Task<Page<ResourceGroup>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 210 | | { |
| 0 | 211 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List"); |
| 0 | 212 | | scope.Start(); |
| | 213 | | try |
| | 214 | | { |
| 0 | 215 | | var response = await RestClient.ListNextPageAsync(nextLink, filter, top, cancellationToken).Configur |
| 0 | 216 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 217 | | } |
| 0 | 218 | | catch (Exception e) |
| | 219 | | { |
| 0 | 220 | | scope.Failed(e); |
| 0 | 221 | | throw; |
| | 222 | | } |
| 0 | 223 | | } |
| 10 | 224 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 225 | | } |
| | 226 | |
|
| | 227 | | /// <summary> Gets all the resource groups for a subscription. </summary> |
| | 228 | | /// <param name="filter"> The filter to apply on the operation.<br><br>You can filter by tag names a |
| | 229 | | /// <param name="top"> The number of results to return. If null is passed, returns all resource groups. </param> |
| | 230 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 231 | | public virtual Pageable<ResourceGroup> List(string filter = null, int? top = null, CancellationToken cancellatio |
| | 232 | | { |
| | 233 | | Page<ResourceGroup> FirstPageFunc(int? pageSizeHint) |
| | 234 | | { |
| 10 | 235 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List"); |
| 10 | 236 | | scope.Start(); |
| | 237 | | try |
| | 238 | | { |
| 10 | 239 | | var response = RestClient.List(filter, top, cancellationToken); |
| 10 | 240 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 241 | | } |
| 0 | 242 | | catch (Exception e) |
| | 243 | | { |
| 0 | 244 | | scope.Failed(e); |
| 0 | 245 | | throw; |
| | 246 | | } |
| 10 | 247 | | } |
| | 248 | | Page<ResourceGroup> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 249 | | { |
| 0 | 250 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.List"); |
| 0 | 251 | | scope.Start(); |
| | 252 | | try |
| | 253 | | { |
| 0 | 254 | | var response = RestClient.ListNextPage(nextLink, filter, top, cancellationToken); |
| 0 | 255 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 256 | | } |
| 0 | 257 | | catch (Exception e) |
| | 258 | | { |
| 0 | 259 | | scope.Failed(e); |
| 0 | 260 | | throw; |
| | 261 | | } |
| 0 | 262 | | } |
| 10 | 263 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 264 | | } |
| | 265 | |
|
| | 266 | | /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group |
| | 267 | | /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p |
| | 268 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 269 | | public virtual async Task<ResourceGroupsDeleteOperation> StartDeleteAsync(string resourceGroupName, Cancellation |
| | 270 | | { |
| 10 | 271 | | if (resourceGroupName == null) |
| | 272 | | { |
| 2 | 273 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 274 | | } |
| | 275 | |
|
| 8 | 276 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartDelete"); |
| 8 | 277 | | scope.Start(); |
| | 278 | | try |
| | 279 | | { |
| 8 | 280 | | var originalResponse = await RestClient.DeleteAsync(resourceGroupName, cancellationToken).ConfigureAwait |
| 8 | 281 | | return new ResourceGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r |
| | 282 | | } |
| 0 | 283 | | catch (Exception e) |
| | 284 | | { |
| 0 | 285 | | scope.Failed(e); |
| 0 | 286 | | throw; |
| | 287 | | } |
| 8 | 288 | | } |
| | 289 | |
|
| | 290 | | /// <summary> When you delete a resource group, all of its resources are also deleted. Deleting a resource group |
| | 291 | | /// <param name="resourceGroupName"> The name of the resource group to delete. The name is case insensitive. </p |
| | 292 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 293 | | public virtual ResourceGroupsDeleteOperation StartDelete(string resourceGroupName, CancellationToken cancellatio |
| | 294 | | { |
| 10 | 295 | | if (resourceGroupName == null) |
| | 296 | | { |
| 2 | 297 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 298 | | } |
| | 299 | |
|
| 8 | 300 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartDelete"); |
| 8 | 301 | | scope.Start(); |
| | 302 | | try |
| | 303 | | { |
| 8 | 304 | | var originalResponse = RestClient.Delete(resourceGroupName, cancellationToken); |
| 8 | 305 | | return new ResourceGroupsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(r |
| | 306 | | } |
| 0 | 307 | | catch (Exception e) |
| | 308 | | { |
| 0 | 309 | | scope.Failed(e); |
| 0 | 310 | | throw; |
| | 311 | | } |
| 8 | 312 | | } |
| | 313 | |
|
| | 314 | | /// <summary> Captures the specified resource group as a template. </summary> |
| | 315 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 316 | | /// <param name="parameters"> Parameters for exporting the template. </param> |
| | 317 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 318 | | public virtual async Task<ResourceGroupsExportTemplateOperation> StartExportTemplateAsync(string resourceGroupNa |
| | 319 | | { |
| 0 | 320 | | if (resourceGroupName == null) |
| | 321 | | { |
| 0 | 322 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 323 | | } |
| 0 | 324 | | if (parameters == null) |
| | 325 | | { |
| 0 | 326 | | throw new ArgumentNullException(nameof(parameters)); |
| | 327 | | } |
| | 328 | |
|
| 0 | 329 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartExportTemplate"); |
| 0 | 330 | | scope.Start(); |
| | 331 | | try |
| | 332 | | { |
| 0 | 333 | | var originalResponse = await RestClient.ExportTemplateAsync(resourceGroupName, parameters, cancellationT |
| 0 | 334 | | return new ResourceGroupsExportTemplateOperation(_clientDiagnostics, _pipeline, RestClient.CreateExportT |
| | 335 | | } |
| 0 | 336 | | catch (Exception e) |
| | 337 | | { |
| 0 | 338 | | scope.Failed(e); |
| 0 | 339 | | throw; |
| | 340 | | } |
| 0 | 341 | | } |
| | 342 | |
|
| | 343 | | /// <summary> Captures the specified resource group as a template. </summary> |
| | 344 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 345 | | /// <param name="parameters"> Parameters for exporting the template. </param> |
| | 346 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 347 | | public virtual ResourceGroupsExportTemplateOperation StartExportTemplate(string resourceGroupName, ExportTemplat |
| | 348 | | { |
| 0 | 349 | | if (resourceGroupName == null) |
| | 350 | | { |
| 0 | 351 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 352 | | } |
| 0 | 353 | | if (parameters == null) |
| | 354 | | { |
| 0 | 355 | | throw new ArgumentNullException(nameof(parameters)); |
| | 356 | | } |
| | 357 | |
|
| 0 | 358 | | using var scope = _clientDiagnostics.CreateScope("ResourceGroupsOperations.StartExportTemplate"); |
| 0 | 359 | | scope.Start(); |
| | 360 | | try |
| | 361 | | { |
| 0 | 362 | | var originalResponse = RestClient.ExportTemplate(resourceGroupName, parameters, cancellationToken); |
| 0 | 363 | | return new ResourceGroupsExportTemplateOperation(_clientDiagnostics, _pipeline, RestClient.CreateExportT |
| | 364 | | } |
| 0 | 365 | | catch (Exception e) |
| | 366 | | { |
| 0 | 367 | | scope.Failed(e); |
| 0 | 368 | | throw; |
| | 369 | | } |
| 0 | 370 | | } |
| | 371 | | } |
| | 372 | | } |