| | 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 PolicyDefinitions service client. </summary> |
| | 19 | | public partial class PolicyDefinitionsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 13632 | 23 | | internal PolicyDefinitionsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of PolicyDefinitionsOperations for mocking. </summary> |
| 256 | 25 | | protected PolicyDefinitionsOperations() |
| | 26 | | { |
| 256 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of PolicyDefinitionsOperations. </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> |
| 256 | 33 | | internal PolicyDefinitionsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip |
| | 34 | | { |
| 256 | 35 | | RestClient = new PolicyDefinitionsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 256 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 256 | 37 | | _pipeline = pipeline; |
| 256 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam |
| | 41 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 42 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual async Task<Response<PolicyDefinition>> CreateOrUpdateAsync(string policyDefinitionName, PolicyDef |
| | 45 | | { |
| 34 | 46 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdate"); |
| 34 | 47 | | scope.Start(); |
| | 48 | | try |
| | 49 | | { |
| 34 | 50 | | return await RestClient.CreateOrUpdateAsync(policyDefinitionName, parameters, cancellationToken).Configu |
| | 51 | | } |
| 8 | 52 | | catch (Exception e) |
| | 53 | | { |
| 8 | 54 | | scope.Failed(e); |
| 8 | 55 | | throw; |
| | 56 | | } |
| 26 | 57 | | } |
| | 58 | |
|
| | 59 | | /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam |
| | 60 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 61 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public virtual Response<PolicyDefinition> CreateOrUpdate(string policyDefinitionName, PolicyDefinition parameter |
| | 64 | | { |
| 34 | 65 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdate"); |
| 34 | 66 | | scope.Start(); |
| | 67 | | try |
| | 68 | | { |
| 34 | 69 | | return RestClient.CreateOrUpdate(policyDefinitionName, parameters, cancellationToken); |
| | 70 | | } |
| 8 | 71 | | catch (Exception e) |
| | 72 | | { |
| 8 | 73 | | scope.Failed(e); |
| 8 | 74 | | throw; |
| | 75 | | } |
| 26 | 76 | | } |
| | 77 | |
|
| | 78 | | /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ |
| | 79 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 80 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 81 | | public virtual async Task<Response> DeleteAsync(string policyDefinitionName, CancellationToken cancellationToken |
| | 82 | | { |
| 122 | 83 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Delete"); |
| 122 | 84 | | scope.Start(); |
| | 85 | | try |
| | 86 | | { |
| 122 | 87 | | return await RestClient.DeleteAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); |
| | 88 | | } |
| 0 | 89 | | catch (Exception e) |
| | 90 | | { |
| 0 | 91 | | scope.Failed(e); |
| 0 | 92 | | throw; |
| | 93 | | } |
| 122 | 94 | | } |
| | 95 | |
|
| | 96 | | /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ |
| | 97 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 98 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 99 | | public virtual Response Delete(string policyDefinitionName, CancellationToken cancellationToken = default) |
| | 100 | | { |
| 122 | 101 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Delete"); |
| 122 | 102 | | scope.Start(); |
| | 103 | | try |
| | 104 | | { |
| 122 | 105 | | return RestClient.Delete(policyDefinitionName, cancellationToken); |
| | 106 | | } |
| 0 | 107 | | catch (Exception e) |
| | 108 | | { |
| 0 | 109 | | scope.Failed(e); |
| 0 | 110 | | throw; |
| | 111 | | } |
| 122 | 112 | | } |
| | 113 | |
|
| | 114 | | /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su |
| | 115 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 116 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 117 | | public virtual async Task<Response<PolicyDefinition>> GetAsync(string policyDefinitionName, CancellationToken ca |
| | 118 | | { |
| 28 | 119 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Get"); |
| 28 | 120 | | scope.Start(); |
| | 121 | | try |
| | 122 | | { |
| 28 | 123 | | return await RestClient.GetAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); |
| | 124 | | } |
| 18 | 125 | | catch (Exception e) |
| | 126 | | { |
| 18 | 127 | | scope.Failed(e); |
| 18 | 128 | | throw; |
| | 129 | | } |
| 10 | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su |
| | 133 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 134 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 135 | | public virtual Response<PolicyDefinition> Get(string policyDefinitionName, CancellationToken cancellationToken = |
| | 136 | | { |
| 28 | 137 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.Get"); |
| 28 | 138 | | scope.Start(); |
| | 139 | | try |
| | 140 | | { |
| 28 | 141 | | return RestClient.Get(policyDefinitionName, cancellationToken); |
| | 142 | | } |
| 18 | 143 | | catch (Exception e) |
| | 144 | | { |
| 18 | 145 | | scope.Failed(e); |
| 18 | 146 | | throw; |
| | 147 | | } |
| 10 | 148 | | } |
| | 149 | |
|
| | 150 | | /// <summary> This operation retrieves the built-in policy definition with the given name. </summary> |
| | 151 | | /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param> |
| | 152 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 153 | | public virtual async Task<Response<PolicyDefinition>> GetBuiltInAsync(string policyDefinitionName, CancellationT |
| | 154 | | { |
| 6604 | 155 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetBuiltIn"); |
| 6604 | 156 | | scope.Start(); |
| | 157 | | try |
| | 158 | | { |
| 6604 | 159 | | return await RestClient.GetBuiltInAsync(policyDefinitionName, cancellationToken).ConfigureAwait(false); |
| | 160 | | } |
| 0 | 161 | | catch (Exception e) |
| | 162 | | { |
| 0 | 163 | | scope.Failed(e); |
| 0 | 164 | | throw; |
| | 165 | | } |
| 6604 | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> This operation retrieves the built-in policy definition with the given name. </summary> |
| | 169 | | /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param> |
| | 170 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 171 | | public virtual Response<PolicyDefinition> GetBuiltIn(string policyDefinitionName, CancellationToken cancellation |
| | 172 | | { |
| 6604 | 173 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetBuiltIn"); |
| 6604 | 174 | | scope.Start(); |
| | 175 | | try |
| | 176 | | { |
| 6604 | 177 | | return RestClient.GetBuiltIn(policyDefinitionName, cancellationToken); |
| | 178 | | } |
| 0 | 179 | | catch (Exception e) |
| | 180 | | { |
| 0 | 181 | | scope.Failed(e); |
| 0 | 182 | | throw; |
| | 183 | | } |
| 6604 | 184 | | } |
| | 185 | |
|
| | 186 | | /// <summary> This operation creates or updates a policy definition in the given management group with the given |
| | 187 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 188 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 189 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public virtual async Task<Response<PolicyDefinition>> CreateOrUpdateAtManagementGroupAsync(string policyDefiniti |
| | 192 | | { |
| 0 | 193 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdateAtManagementGrou |
| 0 | 194 | | scope.Start(); |
| | 195 | | try |
| | 196 | | { |
| 0 | 197 | | return await RestClient.CreateOrUpdateAtManagementGroupAsync(policyDefinitionName, managementGroupId, pa |
| | 198 | | } |
| 0 | 199 | | catch (Exception e) |
| | 200 | | { |
| 0 | 201 | | scope.Failed(e); |
| 0 | 202 | | throw; |
| | 203 | | } |
| 0 | 204 | | } |
| | 205 | |
|
| | 206 | | /// <summary> This operation creates or updates a policy definition in the given management group with the given |
| | 207 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 208 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 209 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 210 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 211 | | public virtual Response<PolicyDefinition> CreateOrUpdateAtManagementGroup(string policyDefinitionName, string ma |
| | 212 | | { |
| 0 | 213 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.CreateOrUpdateAtManagementGrou |
| 0 | 214 | | scope.Start(); |
| | 215 | | try |
| | 216 | | { |
| 0 | 217 | | return RestClient.CreateOrUpdateAtManagementGroup(policyDefinitionName, managementGroupId, parameters, c |
| | 218 | | } |
| 0 | 219 | | catch (Exception e) |
| | 220 | | { |
| 0 | 221 | | scope.Failed(e); |
| 0 | 222 | | throw; |
| | 223 | | } |
| 0 | 224 | | } |
| | 225 | |
|
| | 226 | | /// <summary> This operation deletes the policy definition in the given management group with the given name. </ |
| | 227 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 228 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 229 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 230 | | public virtual async Task<Response> DeleteAtManagementGroupAsync(string policyDefinitionName, string managementG |
| | 231 | | { |
| 0 | 232 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.DeleteAtManagementGroup"); |
| 0 | 233 | | scope.Start(); |
| | 234 | | try |
| | 235 | | { |
| 0 | 236 | | return await RestClient.DeleteAtManagementGroupAsync(policyDefinitionName, managementGroupId, cancellati |
| | 237 | | } |
| 0 | 238 | | catch (Exception e) |
| | 239 | | { |
| 0 | 240 | | scope.Failed(e); |
| 0 | 241 | | throw; |
| | 242 | | } |
| 0 | 243 | | } |
| | 244 | |
|
| | 245 | | /// <summary> This operation deletes the policy definition in the given management group with the given name. </ |
| | 246 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 247 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 248 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 249 | | public virtual Response DeleteAtManagementGroup(string policyDefinitionName, string managementGroupId, Cancellat |
| | 250 | | { |
| 0 | 251 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.DeleteAtManagementGroup"); |
| 0 | 252 | | scope.Start(); |
| | 253 | | try |
| | 254 | | { |
| 0 | 255 | | return RestClient.DeleteAtManagementGroup(policyDefinitionName, managementGroupId, cancellationToken); |
| | 256 | | } |
| 0 | 257 | | catch (Exception e) |
| | 258 | | { |
| 0 | 259 | | scope.Failed(e); |
| 0 | 260 | | throw; |
| | 261 | | } |
| 0 | 262 | | } |
| | 263 | |
|
| | 264 | | /// <summary> This operation retrieves the policy definition in the given management group with the given name. |
| | 265 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 266 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 267 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 268 | | public virtual async Task<Response<PolicyDefinition>> GetAtManagementGroupAsync(string policyDefinitionName, str |
| | 269 | | { |
| 0 | 270 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetAtManagementGroup"); |
| 0 | 271 | | scope.Start(); |
| | 272 | | try |
| | 273 | | { |
| 0 | 274 | | return await RestClient.GetAtManagementGroupAsync(policyDefinitionName, managementGroupId, cancellationT |
| | 275 | | } |
| 0 | 276 | | catch (Exception e) |
| | 277 | | { |
| 0 | 278 | | scope.Failed(e); |
| 0 | 279 | | throw; |
| | 280 | | } |
| 0 | 281 | | } |
| | 282 | |
|
| | 283 | | /// <summary> This operation retrieves the policy definition in the given management group with the given name. |
| | 284 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 285 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 286 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 287 | | public virtual Response<PolicyDefinition> GetAtManagementGroup(string policyDefinitionName, string managementGro |
| | 288 | | { |
| 0 | 289 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.GetAtManagementGroup"); |
| 0 | 290 | | scope.Start(); |
| | 291 | | try |
| | 292 | | { |
| 0 | 293 | | return RestClient.GetAtManagementGroup(policyDefinitionName, managementGroupId, cancellationToken); |
| | 294 | | } |
| 0 | 295 | | catch (Exception e) |
| | 296 | | { |
| 0 | 297 | | scope.Failed(e); |
| 0 | 298 | | throw; |
| | 299 | | } |
| 0 | 300 | | } |
| | 301 | |
|
| | 302 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 303 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 304 | | public virtual AsyncPageable<PolicyDefinition> ListAsync(CancellationToken cancellationToken = default) |
| | 305 | | { |
| | 306 | | async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint) |
| | 307 | | { |
| 22 | 308 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List"); |
| 22 | 309 | | scope.Start(); |
| | 310 | | try |
| | 311 | | { |
| 22 | 312 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 22 | 313 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 314 | | } |
| 0 | 315 | | catch (Exception e) |
| | 316 | | { |
| 0 | 317 | | scope.Failed(e); |
| 0 | 318 | | throw; |
| | 319 | | } |
| 22 | 320 | | } |
| | 321 | | async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 322 | | { |
| 0 | 323 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List"); |
| 0 | 324 | | scope.Start(); |
| | 325 | | try |
| | 326 | | { |
| 0 | 327 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 328 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 329 | | } |
| 0 | 330 | | catch (Exception e) |
| | 331 | | { |
| 0 | 332 | | scope.Failed(e); |
| 0 | 333 | | throw; |
| | 334 | | } |
| 0 | 335 | | } |
| 22 | 336 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 337 | | } |
| | 338 | |
|
| | 339 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 340 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 341 | | public virtual Pageable<PolicyDefinition> List(CancellationToken cancellationToken = default) |
| | 342 | | { |
| | 343 | | Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint) |
| | 344 | | { |
| 22 | 345 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List"); |
| 22 | 346 | | scope.Start(); |
| | 347 | | try |
| | 348 | | { |
| 22 | 349 | | var response = RestClient.List(cancellationToken); |
| 22 | 350 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 351 | | } |
| 0 | 352 | | catch (Exception e) |
| | 353 | | { |
| 0 | 354 | | scope.Failed(e); |
| 0 | 355 | | throw; |
| | 356 | | } |
| 22 | 357 | | } |
| | 358 | | Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 359 | | { |
| 0 | 360 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.List"); |
| 0 | 361 | | scope.Start(); |
| | 362 | | try |
| | 363 | | { |
| 0 | 364 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 365 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 366 | | } |
| 0 | 367 | | catch (Exception e) |
| | 368 | | { |
| 0 | 369 | | scope.Failed(e); |
| 0 | 370 | | throw; |
| | 371 | | } |
| 0 | 372 | | } |
| 22 | 373 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 374 | | } |
| | 375 | |
|
| | 376 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 377 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 378 | | public virtual AsyncPageable<PolicyDefinition> ListBuiltInAsync(CancellationToken cancellationToken = default) |
| | 379 | | { |
| | 380 | | async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint) |
| | 381 | | { |
| 6 | 382 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn"); |
| 6 | 383 | | scope.Start(); |
| | 384 | | try |
| | 385 | | { |
| 6 | 386 | | var response = await RestClient.ListBuiltInAsync(cancellationToken).ConfigureAwait(false); |
| 6 | 387 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 388 | | } |
| 0 | 389 | | catch (Exception e) |
| | 390 | | { |
| 0 | 391 | | scope.Failed(e); |
| 0 | 392 | | throw; |
| | 393 | | } |
| 6 | 394 | | } |
| | 395 | | async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 396 | | { |
| 0 | 397 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn"); |
| 0 | 398 | | scope.Start(); |
| | 399 | | try |
| | 400 | | { |
| 0 | 401 | | var response = await RestClient.ListBuiltInNextPageAsync(nextLink, cancellationToken).ConfigureAwait |
| 0 | 402 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 403 | | } |
| 0 | 404 | | catch (Exception e) |
| | 405 | | { |
| 0 | 406 | | scope.Failed(e); |
| 0 | 407 | | throw; |
| | 408 | | } |
| 0 | 409 | | } |
| 6 | 410 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 411 | | } |
| | 412 | |
|
| | 413 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 414 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 415 | | public virtual Pageable<PolicyDefinition> ListBuiltIn(CancellationToken cancellationToken = default) |
| | 416 | | { |
| | 417 | | Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint) |
| | 418 | | { |
| 6 | 419 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn"); |
| 6 | 420 | | scope.Start(); |
| | 421 | | try |
| | 422 | | { |
| 6 | 423 | | var response = RestClient.ListBuiltIn(cancellationToken); |
| 6 | 424 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 425 | | } |
| 0 | 426 | | catch (Exception e) |
| | 427 | | { |
| 0 | 428 | | scope.Failed(e); |
| 0 | 429 | | throw; |
| | 430 | | } |
| 6 | 431 | | } |
| | 432 | | Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 433 | | { |
| 0 | 434 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListBuiltIn"); |
| 0 | 435 | | scope.Start(); |
| | 436 | | try |
| | 437 | | { |
| 0 | 438 | | var response = RestClient.ListBuiltInNextPage(nextLink, cancellationToken); |
| 0 | 439 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 440 | | } |
| 0 | 441 | | catch (Exception e) |
| | 442 | | { |
| 0 | 443 | | scope.Failed(e); |
| 0 | 444 | | throw; |
| | 445 | | } |
| 0 | 446 | | } |
| 6 | 447 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 448 | | } |
| | 449 | |
|
| | 450 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 451 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 452 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 453 | | public virtual AsyncPageable<PolicyDefinition> ListByManagementGroupAsync(string managementGroupId, Cancellation |
| | 454 | | { |
| 0 | 455 | | if (managementGroupId == null) |
| | 456 | | { |
| 0 | 457 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 458 | | } |
| | 459 | |
|
| | 460 | | async Task<Page<PolicyDefinition>> FirstPageFunc(int? pageSizeHint) |
| | 461 | | { |
| 0 | 462 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup"); |
| 0 | 463 | | scope.Start(); |
| | 464 | | try |
| | 465 | | { |
| 0 | 466 | | var response = await RestClient.ListByManagementGroupAsync(managementGroupId, cancellationToken).Con |
| 0 | 467 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 468 | | } |
| 0 | 469 | | catch (Exception e) |
| | 470 | | { |
| 0 | 471 | | scope.Failed(e); |
| 0 | 472 | | throw; |
| | 473 | | } |
| 0 | 474 | | } |
| | 475 | | async Task<Page<PolicyDefinition>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 476 | | { |
| 0 | 477 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup"); |
| 0 | 478 | | scope.Start(); |
| | 479 | | try |
| | 480 | | { |
| 0 | 481 | | var response = await RestClient.ListByManagementGroupNextPageAsync(nextLink, managementGroupId, canc |
| 0 | 482 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 483 | | } |
| 0 | 484 | | catch (Exception e) |
| | 485 | | { |
| 0 | 486 | | scope.Failed(e); |
| 0 | 487 | | throw; |
| | 488 | | } |
| 0 | 489 | | } |
| 0 | 490 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 491 | | } |
| | 492 | |
|
| | 493 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 494 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 495 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 496 | | public virtual Pageable<PolicyDefinition> ListByManagementGroup(string managementGroupId, CancellationToken canc |
| | 497 | | { |
| 0 | 498 | | if (managementGroupId == null) |
| | 499 | | { |
| 0 | 500 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 501 | | } |
| | 502 | |
|
| | 503 | | Page<PolicyDefinition> FirstPageFunc(int? pageSizeHint) |
| | 504 | | { |
| 0 | 505 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup"); |
| 0 | 506 | | scope.Start(); |
| | 507 | | try |
| | 508 | | { |
| 0 | 509 | | var response = RestClient.ListByManagementGroup(managementGroupId, cancellationToken); |
| 0 | 510 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 511 | | } |
| 0 | 512 | | catch (Exception e) |
| | 513 | | { |
| 0 | 514 | | scope.Failed(e); |
| 0 | 515 | | throw; |
| | 516 | | } |
| 0 | 517 | | } |
| | 518 | | Page<PolicyDefinition> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 519 | | { |
| 0 | 520 | | using var scope = _clientDiagnostics.CreateScope("PolicyDefinitionsOperations.ListByManagementGroup"); |
| 0 | 521 | | scope.Start(); |
| | 522 | | try |
| | 523 | | { |
| 0 | 524 | | var response = RestClient.ListByManagementGroupNextPage(nextLink, managementGroupId, cancellationTok |
| 0 | 525 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 526 | | } |
| 0 | 527 | | catch (Exception e) |
| | 528 | | { |
| 0 | 529 | | scope.Failed(e); |
| 0 | 530 | | throw; |
| | 531 | | } |
| 0 | 532 | | } |
| 0 | 533 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 534 | | } |
| | 535 | | } |
| | 536 | | } |