| | 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.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.ResourceManager.Resources.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.ResourceManager.Resources |
| | 18 | | { |
| | 19 | | internal partial class PolicyDefinitionsRestOperations |
| | 20 | | { |
| | 21 | | private string subscriptionId; |
| | 22 | | private Uri endpoint; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of PolicyDefinitionsRestOperations. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="subscriptionId"> The ID of the target subscription. </param> |
| | 30 | | /// <param name="endpoint"> server parameter. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> This occurs when one of the required arguments is null. </exception |
| 256 | 32 | | public PolicyDefinitionsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscr |
| | 33 | | { |
| 256 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 256 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 256 | 40 | | this.subscriptionId = subscriptionId; |
| 256 | 41 | | this.endpoint = endpoint; |
| 256 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 256 | 43 | | _pipeline = pipeline; |
| 256 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string policyDefinitionName, PolicyDefinition parameters) |
| | 47 | | { |
| 68 | 48 | | var message = _pipeline.CreateMessage(); |
| 68 | 49 | | var request = message.Request; |
| 68 | 50 | | request.Method = RequestMethod.Put; |
| 68 | 51 | | var uri = new RawRequestUriBuilder(); |
| 68 | 52 | | uri.Reset(endpoint); |
| 68 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 68 | 54 | | uri.AppendPath(subscriptionId, true); |
| 68 | 55 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 68 | 56 | | uri.AppendPath(policyDefinitionName, true); |
| 68 | 57 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 68 | 58 | | request.Uri = uri; |
| 68 | 59 | | request.Headers.Add("Content-Type", "application/json"); |
| 68 | 60 | | var content = new Utf8JsonRequestContent(); |
| 68 | 61 | | content.JsonWriter.WriteObjectValue(parameters); |
| 68 | 62 | | request.Content = content; |
| 68 | 63 | | return message; |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam |
| | 67 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 68 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 69 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 70 | | public async Task<Response<PolicyDefinition>> CreateOrUpdateAsync(string policyDefinitionName, PolicyDefinition |
| | 71 | | { |
| 34 | 72 | | if (policyDefinitionName == null) |
| | 73 | | { |
| 0 | 74 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 75 | | } |
| 34 | 76 | | if (parameters == null) |
| | 77 | | { |
| 0 | 78 | | throw new ArgumentNullException(nameof(parameters)); |
| | 79 | | } |
| | 80 | |
|
| 34 | 81 | | using var message = CreateCreateOrUpdateRequest(policyDefinitionName, parameters); |
| 34 | 82 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 34 | 83 | | switch (message.Response.Status) |
| | 84 | | { |
| | 85 | | case 201: |
| | 86 | | { |
| 26 | 87 | | PolicyDefinition value = default; |
| 26 | 88 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 26 | 89 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 90 | | { |
| 0 | 91 | | value = null; |
| | 92 | | } |
| | 93 | | else |
| | 94 | | { |
| 26 | 95 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 96 | | } |
| 26 | 97 | | return Response.FromValue(value, message.Response); |
| | 98 | | } |
| | 99 | | default: |
| 8 | 100 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 101 | | } |
| 26 | 102 | | } |
| | 103 | |
|
| | 104 | | /// <summary> This operation creates or updates a policy definition in the given subscription with the given nam |
| | 105 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 106 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 107 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 108 | | public Response<PolicyDefinition> CreateOrUpdate(string policyDefinitionName, PolicyDefinition parameters, Cance |
| | 109 | | { |
| 34 | 110 | | if (policyDefinitionName == null) |
| | 111 | | { |
| 0 | 112 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 113 | | } |
| 34 | 114 | | if (parameters == null) |
| | 115 | | { |
| 0 | 116 | | throw new ArgumentNullException(nameof(parameters)); |
| | 117 | | } |
| | 118 | |
|
| 34 | 119 | | using var message = CreateCreateOrUpdateRequest(policyDefinitionName, parameters); |
| 34 | 120 | | _pipeline.Send(message, cancellationToken); |
| 34 | 121 | | switch (message.Response.Status) |
| | 122 | | { |
| | 123 | | case 201: |
| | 124 | | { |
| 26 | 125 | | PolicyDefinition value = default; |
| 26 | 126 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 26 | 127 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 128 | | { |
| 0 | 129 | | value = null; |
| | 130 | | } |
| | 131 | | else |
| | 132 | | { |
| 26 | 133 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 134 | | } |
| 26 | 135 | | return Response.FromValue(value, message.Response); |
| | 136 | | } |
| | 137 | | default: |
| 8 | 138 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 139 | | } |
| 26 | 140 | | } |
| | 141 | |
|
| | 142 | | internal Core.HttpMessage CreateDeleteRequest(string policyDefinitionName) |
| | 143 | | { |
| 244 | 144 | | var message = _pipeline.CreateMessage(); |
| 244 | 145 | | var request = message.Request; |
| 244 | 146 | | request.Method = RequestMethod.Delete; |
| 244 | 147 | | var uri = new RawRequestUriBuilder(); |
| 244 | 148 | | uri.Reset(endpoint); |
| 244 | 149 | | uri.AppendPath("/subscriptions/", false); |
| 244 | 150 | | uri.AppendPath(subscriptionId, true); |
| 244 | 151 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 244 | 152 | | uri.AppendPath(policyDefinitionName, true); |
| 244 | 153 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 244 | 154 | | request.Uri = uri; |
| 244 | 155 | | return message; |
| | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ |
| | 159 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 160 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 161 | | public async Task<Response> DeleteAsync(string policyDefinitionName, CancellationToken cancellationToken = defau |
| | 162 | | { |
| 122 | 163 | | if (policyDefinitionName == null) |
| | 164 | | { |
| 0 | 165 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 166 | | } |
| | 167 | |
|
| 122 | 168 | | using var message = CreateDeleteRequest(policyDefinitionName); |
| 122 | 169 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 122 | 170 | | switch (message.Response.Status) |
| | 171 | | { |
| | 172 | | case 200: |
| | 173 | | case 204: |
| 122 | 174 | | return message.Response; |
| | 175 | | default: |
| 0 | 176 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 177 | | } |
| 122 | 178 | | } |
| | 179 | |
|
| | 180 | | /// <summary> This operation deletes the policy definition in the given subscription with the given name. </summ |
| | 181 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 182 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 183 | | public Response Delete(string policyDefinitionName, CancellationToken cancellationToken = default) |
| | 184 | | { |
| 122 | 185 | | if (policyDefinitionName == null) |
| | 186 | | { |
| 0 | 187 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 188 | | } |
| | 189 | |
|
| 122 | 190 | | using var message = CreateDeleteRequest(policyDefinitionName); |
| 122 | 191 | | _pipeline.Send(message, cancellationToken); |
| 122 | 192 | | switch (message.Response.Status) |
| | 193 | | { |
| | 194 | | case 200: |
| | 195 | | case 204: |
| 122 | 196 | | return message.Response; |
| | 197 | | default: |
| 0 | 198 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 199 | | } |
| 122 | 200 | | } |
| | 201 | |
|
| | 202 | | internal Core.HttpMessage CreateGetRequest(string policyDefinitionName) |
| | 203 | | { |
| 56 | 204 | | var message = _pipeline.CreateMessage(); |
| 56 | 205 | | var request = message.Request; |
| 56 | 206 | | request.Method = RequestMethod.Get; |
| 56 | 207 | | var uri = new RawRequestUriBuilder(); |
| 56 | 208 | | uri.Reset(endpoint); |
| 56 | 209 | | uri.AppendPath("/subscriptions/", false); |
| 56 | 210 | | uri.AppendPath(subscriptionId, true); |
| 56 | 211 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 56 | 212 | | uri.AppendPath(policyDefinitionName, true); |
| 56 | 213 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 56 | 214 | | request.Uri = uri; |
| 56 | 215 | | return message; |
| | 216 | | } |
| | 217 | |
|
| | 218 | | /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su |
| | 219 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 220 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 221 | | public async Task<Response<PolicyDefinition>> GetAsync(string policyDefinitionName, CancellationToken cancellati |
| | 222 | | { |
| 28 | 223 | | if (policyDefinitionName == null) |
| | 224 | | { |
| 0 | 225 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 226 | | } |
| | 227 | |
|
| 28 | 228 | | using var message = CreateGetRequest(policyDefinitionName); |
| 28 | 229 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 28 | 230 | | switch (message.Response.Status) |
| | 231 | | { |
| | 232 | | case 200: |
| | 233 | | { |
| 10 | 234 | | PolicyDefinition value = default; |
| 10 | 235 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 10 | 236 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 237 | | { |
| 0 | 238 | | value = null; |
| | 239 | | } |
| | 240 | | else |
| | 241 | | { |
| 10 | 242 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 243 | | } |
| 10 | 244 | | return Response.FromValue(value, message.Response); |
| | 245 | | } |
| | 246 | | default: |
| 18 | 247 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 248 | | } |
| 10 | 249 | | } |
| | 250 | |
|
| | 251 | | /// <summary> This operation retrieves the policy definition in the given subscription with the given name. </su |
| | 252 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 253 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 254 | | public Response<PolicyDefinition> Get(string policyDefinitionName, CancellationToken cancellationToken = default |
| | 255 | | { |
| 28 | 256 | | if (policyDefinitionName == null) |
| | 257 | | { |
| 0 | 258 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 259 | | } |
| | 260 | |
|
| 28 | 261 | | using var message = CreateGetRequest(policyDefinitionName); |
| 28 | 262 | | _pipeline.Send(message, cancellationToken); |
| 28 | 263 | | switch (message.Response.Status) |
| | 264 | | { |
| | 265 | | case 200: |
| | 266 | | { |
| 10 | 267 | | PolicyDefinition value = default; |
| 10 | 268 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 10 | 269 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 270 | | { |
| 0 | 271 | | value = null; |
| | 272 | | } |
| | 273 | | else |
| | 274 | | { |
| 10 | 275 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 276 | | } |
| 10 | 277 | | return Response.FromValue(value, message.Response); |
| | 278 | | } |
| | 279 | | default: |
| 18 | 280 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 281 | | } |
| 10 | 282 | | } |
| | 283 | |
|
| | 284 | | internal Core.HttpMessage CreateGetBuiltInRequest(string policyDefinitionName) |
| | 285 | | { |
| 13208 | 286 | | var message = _pipeline.CreateMessage(); |
| 13208 | 287 | | var request = message.Request; |
| 13208 | 288 | | request.Method = RequestMethod.Get; |
| 13208 | 289 | | var uri = new RawRequestUriBuilder(); |
| 13208 | 290 | | uri.Reset(endpoint); |
| 13208 | 291 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 13208 | 292 | | uri.AppendPath(policyDefinitionName, true); |
| 13208 | 293 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 13208 | 294 | | request.Uri = uri; |
| 13208 | 295 | | return message; |
| | 296 | | } |
| | 297 | |
|
| | 298 | | /// <summary> This operation retrieves the built-in policy definition with the given name. </summary> |
| | 299 | | /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param> |
| | 300 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 301 | | public async Task<Response<PolicyDefinition>> GetBuiltInAsync(string policyDefinitionName, CancellationToken can |
| | 302 | | { |
| 6604 | 303 | | if (policyDefinitionName == null) |
| | 304 | | { |
| 0 | 305 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 306 | | } |
| | 307 | |
|
| 6604 | 308 | | using var message = CreateGetBuiltInRequest(policyDefinitionName); |
| 6604 | 309 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6604 | 310 | | switch (message.Response.Status) |
| | 311 | | { |
| | 312 | | case 200: |
| | 313 | | { |
| 6604 | 314 | | PolicyDefinition value = default; |
| 6604 | 315 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6604 | 316 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 317 | | { |
| 0 | 318 | | value = null; |
| | 319 | | } |
| | 320 | | else |
| | 321 | | { |
| 6604 | 322 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 323 | | } |
| 6604 | 324 | | return Response.FromValue(value, message.Response); |
| | 325 | | } |
| | 326 | | default: |
| 0 | 327 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 328 | | } |
| 6604 | 329 | | } |
| | 330 | |
|
| | 331 | | /// <summary> This operation retrieves the built-in policy definition with the given name. </summary> |
| | 332 | | /// <param name="policyDefinitionName"> The name of the built-in policy definition to get. </param> |
| | 333 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 334 | | public Response<PolicyDefinition> GetBuiltIn(string policyDefinitionName, CancellationToken cancellationToken = |
| | 335 | | { |
| 6604 | 336 | | if (policyDefinitionName == null) |
| | 337 | | { |
| 0 | 338 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 339 | | } |
| | 340 | |
|
| 6604 | 341 | | using var message = CreateGetBuiltInRequest(policyDefinitionName); |
| 6604 | 342 | | _pipeline.Send(message, cancellationToken); |
| 6604 | 343 | | switch (message.Response.Status) |
| | 344 | | { |
| | 345 | | case 200: |
| | 346 | | { |
| 6604 | 347 | | PolicyDefinition value = default; |
| 6604 | 348 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6604 | 349 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 350 | | { |
| 0 | 351 | | value = null; |
| | 352 | | } |
| | 353 | | else |
| | 354 | | { |
| 6604 | 355 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 356 | | } |
| 6604 | 357 | | return Response.FromValue(value, message.Response); |
| | 358 | | } |
| | 359 | | default: |
| 0 | 360 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 361 | | } |
| 6604 | 362 | | } |
| | 363 | |
|
| | 364 | | internal Core.HttpMessage CreateCreateOrUpdateAtManagementGroupRequest(string policyDefinitionName, string manag |
| | 365 | | { |
| 0 | 366 | | var message = _pipeline.CreateMessage(); |
| 0 | 367 | | var request = message.Request; |
| 0 | 368 | | request.Method = RequestMethod.Put; |
| 0 | 369 | | var uri = new RawRequestUriBuilder(); |
| 0 | 370 | | uri.Reset(endpoint); |
| 0 | 371 | | uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false); |
| 0 | 372 | | uri.AppendPath(managementGroupId, true); |
| 0 | 373 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 0 | 374 | | uri.AppendPath(policyDefinitionName, true); |
| 0 | 375 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 0 | 376 | | request.Uri = uri; |
| 0 | 377 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 378 | | var content = new Utf8JsonRequestContent(); |
| 0 | 379 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 380 | | request.Content = content; |
| 0 | 381 | | return message; |
| | 382 | | } |
| | 383 | |
|
| | 384 | | /// <summary> This operation creates or updates a policy definition in the given management group with the given |
| | 385 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 386 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 387 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 388 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 389 | | public async Task<Response<PolicyDefinition>> CreateOrUpdateAtManagementGroupAsync(string policyDefinitionName, |
| | 390 | | { |
| 0 | 391 | | if (policyDefinitionName == null) |
| | 392 | | { |
| 0 | 393 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 394 | | } |
| 0 | 395 | | if (managementGroupId == null) |
| | 396 | | { |
| 0 | 397 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 398 | | } |
| 0 | 399 | | if (parameters == null) |
| | 400 | | { |
| 0 | 401 | | throw new ArgumentNullException(nameof(parameters)); |
| | 402 | | } |
| | 403 | |
|
| 0 | 404 | | using var message = CreateCreateOrUpdateAtManagementGroupRequest(policyDefinitionName, managementGroupId, pa |
| 0 | 405 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 406 | | switch (message.Response.Status) |
| | 407 | | { |
| | 408 | | case 201: |
| | 409 | | { |
| 0 | 410 | | PolicyDefinition value = default; |
| 0 | 411 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 412 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 413 | | { |
| 0 | 414 | | value = null; |
| | 415 | | } |
| | 416 | | else |
| | 417 | | { |
| 0 | 418 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 419 | | } |
| 0 | 420 | | return Response.FromValue(value, message.Response); |
| | 421 | | } |
| | 422 | | default: |
| 0 | 423 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 424 | | } |
| 0 | 425 | | } |
| | 426 | |
|
| | 427 | | /// <summary> This operation creates or updates a policy definition in the given management group with the given |
| | 428 | | /// <param name="policyDefinitionName"> The name of the policy definition to create. </param> |
| | 429 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 430 | | /// <param name="parameters"> The policy definition properties. </param> |
| | 431 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 432 | | public Response<PolicyDefinition> CreateOrUpdateAtManagementGroup(string policyDefinitionName, string management |
| | 433 | | { |
| 0 | 434 | | if (policyDefinitionName == null) |
| | 435 | | { |
| 0 | 436 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 437 | | } |
| 0 | 438 | | if (managementGroupId == null) |
| | 439 | | { |
| 0 | 440 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 441 | | } |
| 0 | 442 | | if (parameters == null) |
| | 443 | | { |
| 0 | 444 | | throw new ArgumentNullException(nameof(parameters)); |
| | 445 | | } |
| | 446 | |
|
| 0 | 447 | | using var message = CreateCreateOrUpdateAtManagementGroupRequest(policyDefinitionName, managementGroupId, pa |
| 0 | 448 | | _pipeline.Send(message, cancellationToken); |
| 0 | 449 | | switch (message.Response.Status) |
| | 450 | | { |
| | 451 | | case 201: |
| | 452 | | { |
| 0 | 453 | | PolicyDefinition value = default; |
| 0 | 454 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 455 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 456 | | { |
| 0 | 457 | | value = null; |
| | 458 | | } |
| | 459 | | else |
| | 460 | | { |
| 0 | 461 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 462 | | } |
| 0 | 463 | | return Response.FromValue(value, message.Response); |
| | 464 | | } |
| | 465 | | default: |
| 0 | 466 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 467 | | } |
| 0 | 468 | | } |
| | 469 | |
|
| | 470 | | internal Core.HttpMessage CreateDeleteAtManagementGroupRequest(string policyDefinitionName, string managementGro |
| | 471 | | { |
| 0 | 472 | | var message = _pipeline.CreateMessage(); |
| 0 | 473 | | var request = message.Request; |
| 0 | 474 | | request.Method = RequestMethod.Delete; |
| 0 | 475 | | var uri = new RawRequestUriBuilder(); |
| 0 | 476 | | uri.Reset(endpoint); |
| 0 | 477 | | uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false); |
| 0 | 478 | | uri.AppendPath(managementGroupId, true); |
| 0 | 479 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 0 | 480 | | uri.AppendPath(policyDefinitionName, true); |
| 0 | 481 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 0 | 482 | | request.Uri = uri; |
| 0 | 483 | | return message; |
| | 484 | | } |
| | 485 | |
|
| | 486 | | /// <summary> This operation deletes the policy definition in the given management group with the given name. </ |
| | 487 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 488 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 489 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 490 | | public async Task<Response> DeleteAtManagementGroupAsync(string policyDefinitionName, string managementGroupId, |
| | 491 | | { |
| 0 | 492 | | if (policyDefinitionName == null) |
| | 493 | | { |
| 0 | 494 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 495 | | } |
| 0 | 496 | | if (managementGroupId == null) |
| | 497 | | { |
| 0 | 498 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 499 | | } |
| | 500 | |
|
| 0 | 501 | | using var message = CreateDeleteAtManagementGroupRequest(policyDefinitionName, managementGroupId); |
| 0 | 502 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 503 | | switch (message.Response.Status) |
| | 504 | | { |
| | 505 | | case 200: |
| | 506 | | case 204: |
| 0 | 507 | | return message.Response; |
| | 508 | | default: |
| 0 | 509 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 510 | | } |
| 0 | 511 | | } |
| | 512 | |
|
| | 513 | | /// <summary> This operation deletes the policy definition in the given management group with the given name. </ |
| | 514 | | /// <param name="policyDefinitionName"> The name of the policy definition to delete. </param> |
| | 515 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 516 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 517 | | public Response DeleteAtManagementGroup(string policyDefinitionName, string managementGroupId, CancellationToken |
| | 518 | | { |
| 0 | 519 | | if (policyDefinitionName == null) |
| | 520 | | { |
| 0 | 521 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 522 | | } |
| 0 | 523 | | if (managementGroupId == null) |
| | 524 | | { |
| 0 | 525 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 526 | | } |
| | 527 | |
|
| 0 | 528 | | using var message = CreateDeleteAtManagementGroupRequest(policyDefinitionName, managementGroupId); |
| 0 | 529 | | _pipeline.Send(message, cancellationToken); |
| 0 | 530 | | switch (message.Response.Status) |
| | 531 | | { |
| | 532 | | case 200: |
| | 533 | | case 204: |
| 0 | 534 | | return message.Response; |
| | 535 | | default: |
| 0 | 536 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 537 | | } |
| 0 | 538 | | } |
| | 539 | |
|
| | 540 | | internal Core.HttpMessage CreateGetAtManagementGroupRequest(string policyDefinitionName, string managementGroupI |
| | 541 | | { |
| 0 | 542 | | var message = _pipeline.CreateMessage(); |
| 0 | 543 | | var request = message.Request; |
| 0 | 544 | | request.Method = RequestMethod.Get; |
| 0 | 545 | | var uri = new RawRequestUriBuilder(); |
| 0 | 546 | | uri.Reset(endpoint); |
| 0 | 547 | | uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false); |
| 0 | 548 | | uri.AppendPath(managementGroupId, true); |
| 0 | 549 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions/", false); |
| 0 | 550 | | uri.AppendPath(policyDefinitionName, true); |
| 0 | 551 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 0 | 552 | | request.Uri = uri; |
| 0 | 553 | | return message; |
| | 554 | | } |
| | 555 | |
|
| | 556 | | /// <summary> This operation retrieves the policy definition in the given management group with the given name. |
| | 557 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 558 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 559 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 560 | | public async Task<Response<PolicyDefinition>> GetAtManagementGroupAsync(string policyDefinitionName, string mana |
| | 561 | | { |
| 0 | 562 | | if (policyDefinitionName == null) |
| | 563 | | { |
| 0 | 564 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 565 | | } |
| 0 | 566 | | if (managementGroupId == null) |
| | 567 | | { |
| 0 | 568 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 569 | | } |
| | 570 | |
|
| 0 | 571 | | using var message = CreateGetAtManagementGroupRequest(policyDefinitionName, managementGroupId); |
| 0 | 572 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 573 | | switch (message.Response.Status) |
| | 574 | | { |
| | 575 | | case 200: |
| | 576 | | { |
| 0 | 577 | | PolicyDefinition value = default; |
| 0 | 578 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 579 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 580 | | { |
| 0 | 581 | | value = null; |
| | 582 | | } |
| | 583 | | else |
| | 584 | | { |
| 0 | 585 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 586 | | } |
| 0 | 587 | | return Response.FromValue(value, message.Response); |
| | 588 | | } |
| | 589 | | default: |
| 0 | 590 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 591 | | } |
| 0 | 592 | | } |
| | 593 | |
|
| | 594 | | /// <summary> This operation retrieves the policy definition in the given management group with the given name. |
| | 595 | | /// <param name="policyDefinitionName"> The name of the policy definition to get. </param> |
| | 596 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 597 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 598 | | public Response<PolicyDefinition> GetAtManagementGroup(string policyDefinitionName, string managementGroupId, Ca |
| | 599 | | { |
| 0 | 600 | | if (policyDefinitionName == null) |
| | 601 | | { |
| 0 | 602 | | throw new ArgumentNullException(nameof(policyDefinitionName)); |
| | 603 | | } |
| 0 | 604 | | if (managementGroupId == null) |
| | 605 | | { |
| 0 | 606 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 607 | | } |
| | 608 | |
|
| 0 | 609 | | using var message = CreateGetAtManagementGroupRequest(policyDefinitionName, managementGroupId); |
| 0 | 610 | | _pipeline.Send(message, cancellationToken); |
| 0 | 611 | | switch (message.Response.Status) |
| | 612 | | { |
| | 613 | | case 200: |
| | 614 | | { |
| 0 | 615 | | PolicyDefinition value = default; |
| 0 | 616 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 617 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 618 | | { |
| 0 | 619 | | value = null; |
| | 620 | | } |
| | 621 | | else |
| | 622 | | { |
| 0 | 623 | | value = PolicyDefinition.DeserializePolicyDefinition(document.RootElement); |
| | 624 | | } |
| 0 | 625 | | return Response.FromValue(value, message.Response); |
| | 626 | | } |
| | 627 | | default: |
| 0 | 628 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 629 | | } |
| 0 | 630 | | } |
| | 631 | |
|
| | 632 | | internal Core.HttpMessage CreateListRequest() |
| | 633 | | { |
| 44 | 634 | | var message = _pipeline.CreateMessage(); |
| 44 | 635 | | var request = message.Request; |
| 44 | 636 | | request.Method = RequestMethod.Get; |
| 44 | 637 | | var uri = new RawRequestUriBuilder(); |
| 44 | 638 | | uri.Reset(endpoint); |
| 44 | 639 | | uri.AppendPath("/subscriptions/", false); |
| 44 | 640 | | uri.AppendPath(subscriptionId, true); |
| 44 | 641 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions", false); |
| 44 | 642 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 44 | 643 | | request.Uri = uri; |
| 44 | 644 | | return message; |
| | 645 | | } |
| | 646 | |
|
| | 647 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 648 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 649 | | public async Task<Response<PolicyDefinitionListResult>> ListAsync(CancellationToken cancellationToken = default) |
| | 650 | | { |
| 22 | 651 | | using var message = CreateListRequest(); |
| 22 | 652 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 22 | 653 | | switch (message.Response.Status) |
| | 654 | | { |
| | 655 | | case 200: |
| | 656 | | { |
| 22 | 657 | | PolicyDefinitionListResult value = default; |
| 22 | 658 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 22 | 659 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 660 | | { |
| 0 | 661 | | value = null; |
| | 662 | | } |
| | 663 | | else |
| | 664 | | { |
| 22 | 665 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 666 | | } |
| 22 | 667 | | return Response.FromValue(value, message.Response); |
| | 668 | | } |
| | 669 | | default: |
| 0 | 670 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 671 | | } |
| 22 | 672 | | } |
| | 673 | |
|
| | 674 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 675 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 676 | | public Response<PolicyDefinitionListResult> List(CancellationToken cancellationToken = default) |
| | 677 | | { |
| 22 | 678 | | using var message = CreateListRequest(); |
| 22 | 679 | | _pipeline.Send(message, cancellationToken); |
| 22 | 680 | | switch (message.Response.Status) |
| | 681 | | { |
| | 682 | | case 200: |
| | 683 | | { |
| 22 | 684 | | PolicyDefinitionListResult value = default; |
| 22 | 685 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 22 | 686 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 687 | | { |
| 0 | 688 | | value = null; |
| | 689 | | } |
| | 690 | | else |
| | 691 | | { |
| 22 | 692 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 693 | | } |
| 22 | 694 | | return Response.FromValue(value, message.Response); |
| | 695 | | } |
| | 696 | | default: |
| 0 | 697 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 698 | | } |
| 22 | 699 | | } |
| | 700 | |
|
| | 701 | | internal Core.HttpMessage CreateListBuiltInRequest() |
| | 702 | | { |
| 12 | 703 | | var message = _pipeline.CreateMessage(); |
| 12 | 704 | | var request = message.Request; |
| 12 | 705 | | request.Method = RequestMethod.Get; |
| 12 | 706 | | var uri = new RawRequestUriBuilder(); |
| 12 | 707 | | uri.Reset(endpoint); |
| 12 | 708 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions", false); |
| 12 | 709 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 12 | 710 | | request.Uri = uri; |
| 12 | 711 | | return message; |
| | 712 | | } |
| | 713 | |
|
| | 714 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 715 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 716 | | public async Task<Response<PolicyDefinitionListResult>> ListBuiltInAsync(CancellationToken cancellationToken = d |
| | 717 | | { |
| 6 | 718 | | using var message = CreateListBuiltInRequest(); |
| 6 | 719 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 720 | | switch (message.Response.Status) |
| | 721 | | { |
| | 722 | | case 200: |
| | 723 | | { |
| 6 | 724 | | PolicyDefinitionListResult value = default; |
| 6 | 725 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 726 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 727 | | { |
| 0 | 728 | | value = null; |
| | 729 | | } |
| | 730 | | else |
| | 731 | | { |
| 6 | 732 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 733 | | } |
| 6 | 734 | | return Response.FromValue(value, message.Response); |
| | 735 | | } |
| | 736 | | default: |
| 0 | 737 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 738 | | } |
| 6 | 739 | | } |
| | 740 | |
|
| | 741 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 742 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 743 | | public Response<PolicyDefinitionListResult> ListBuiltIn(CancellationToken cancellationToken = default) |
| | 744 | | { |
| 6 | 745 | | using var message = CreateListBuiltInRequest(); |
| 6 | 746 | | _pipeline.Send(message, cancellationToken); |
| 6 | 747 | | switch (message.Response.Status) |
| | 748 | | { |
| | 749 | | case 200: |
| | 750 | | { |
| 6 | 751 | | PolicyDefinitionListResult value = default; |
| 6 | 752 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 753 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 754 | | { |
| 0 | 755 | | value = null; |
| | 756 | | } |
| | 757 | | else |
| | 758 | | { |
| 6 | 759 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 760 | | } |
| 6 | 761 | | return Response.FromValue(value, message.Response); |
| | 762 | | } |
| | 763 | | default: |
| 0 | 764 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 765 | | } |
| 6 | 766 | | } |
| | 767 | |
|
| | 768 | | internal Core.HttpMessage CreateListByManagementGroupRequest(string managementGroupId) |
| | 769 | | { |
| 0 | 770 | | var message = _pipeline.CreateMessage(); |
| 0 | 771 | | var request = message.Request; |
| 0 | 772 | | request.Method = RequestMethod.Get; |
| 0 | 773 | | var uri = new RawRequestUriBuilder(); |
| 0 | 774 | | uri.Reset(endpoint); |
| 0 | 775 | | uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false); |
| 0 | 776 | | uri.AppendPath(managementGroupId, true); |
| 0 | 777 | | uri.AppendPath("/providers/Microsoft.Authorization/policyDefinitions", false); |
| 0 | 778 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| 0 | 779 | | request.Uri = uri; |
| 0 | 780 | | return message; |
| | 781 | | } |
| | 782 | |
|
| | 783 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 784 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 785 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 786 | | public async Task<Response<PolicyDefinitionListResult>> ListByManagementGroupAsync(string managementGroupId, Can |
| | 787 | | { |
| 0 | 788 | | if (managementGroupId == null) |
| | 789 | | { |
| 0 | 790 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 791 | | } |
| | 792 | |
|
| 0 | 793 | | using var message = CreateListByManagementGroupRequest(managementGroupId); |
| 0 | 794 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 795 | | switch (message.Response.Status) |
| | 796 | | { |
| | 797 | | case 200: |
| | 798 | | { |
| 0 | 799 | | PolicyDefinitionListResult value = default; |
| 0 | 800 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 801 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 802 | | { |
| 0 | 803 | | value = null; |
| | 804 | | } |
| | 805 | | else |
| | 806 | | { |
| 0 | 807 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 808 | | } |
| 0 | 809 | | return Response.FromValue(value, message.Response); |
| | 810 | | } |
| | 811 | | default: |
| 0 | 812 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 813 | | } |
| 0 | 814 | | } |
| | 815 | |
|
| | 816 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 817 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 818 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 819 | | public Response<PolicyDefinitionListResult> ListByManagementGroup(string managementGroupId, CancellationToken ca |
| | 820 | | { |
| 0 | 821 | | if (managementGroupId == null) |
| | 822 | | { |
| 0 | 823 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 824 | | } |
| | 825 | |
|
| 0 | 826 | | using var message = CreateListByManagementGroupRequest(managementGroupId); |
| 0 | 827 | | _pipeline.Send(message, cancellationToken); |
| 0 | 828 | | switch (message.Response.Status) |
| | 829 | | { |
| | 830 | | case 200: |
| | 831 | | { |
| 0 | 832 | | PolicyDefinitionListResult value = default; |
| 0 | 833 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 834 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 835 | | { |
| 0 | 836 | | value = null; |
| | 837 | | } |
| | 838 | | else |
| | 839 | | { |
| 0 | 840 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 841 | | } |
| 0 | 842 | | return Response.FromValue(value, message.Response); |
| | 843 | | } |
| | 844 | | default: |
| 0 | 845 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 846 | | } |
| 0 | 847 | | } |
| | 848 | |
|
| | 849 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink) |
| | 850 | | { |
| 0 | 851 | | var message = _pipeline.CreateMessage(); |
| 0 | 852 | | var request = message.Request; |
| 0 | 853 | | request.Method = RequestMethod.Get; |
| 0 | 854 | | var uri = new RawRequestUriBuilder(); |
| 0 | 855 | | uri.Reset(endpoint); |
| 0 | 856 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 857 | | request.Uri = uri; |
| 0 | 858 | | return message; |
| | 859 | | } |
| | 860 | |
|
| | 861 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 862 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 863 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 864 | | public async Task<Response<PolicyDefinitionListResult>> ListNextPageAsync(string nextLink, CancellationToken can |
| | 865 | | { |
| 0 | 866 | | if (nextLink == null) |
| | 867 | | { |
| 0 | 868 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 869 | | } |
| | 870 | |
|
| 0 | 871 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 872 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 873 | | switch (message.Response.Status) |
| | 874 | | { |
| | 875 | | case 200: |
| | 876 | | { |
| 0 | 877 | | PolicyDefinitionListResult value = default; |
| 0 | 878 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 879 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 880 | | { |
| 0 | 881 | | value = null; |
| | 882 | | } |
| | 883 | | else |
| | 884 | | { |
| 0 | 885 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 886 | | } |
| 0 | 887 | | return Response.FromValue(value, message.Response); |
| | 888 | | } |
| | 889 | | default: |
| 0 | 890 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 891 | | } |
| 0 | 892 | | } |
| | 893 | |
|
| | 894 | | /// <summary> This operation retrieves a list of all the policy definitions in a given subscription. </summary> |
| | 895 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 896 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 897 | | public Response<PolicyDefinitionListResult> ListNextPage(string nextLink, CancellationToken cancellationToken = |
| | 898 | | { |
| 0 | 899 | | if (nextLink == null) |
| | 900 | | { |
| 0 | 901 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 902 | | } |
| | 903 | |
|
| 0 | 904 | | using var message = CreateListNextPageRequest(nextLink); |
| 0 | 905 | | _pipeline.Send(message, cancellationToken); |
| 0 | 906 | | switch (message.Response.Status) |
| | 907 | | { |
| | 908 | | case 200: |
| | 909 | | { |
| 0 | 910 | | PolicyDefinitionListResult value = default; |
| 0 | 911 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 912 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 913 | | { |
| 0 | 914 | | value = null; |
| | 915 | | } |
| | 916 | | else |
| | 917 | | { |
| 0 | 918 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 919 | | } |
| 0 | 920 | | return Response.FromValue(value, message.Response); |
| | 921 | | } |
| | 922 | | default: |
| 0 | 923 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 924 | | } |
| 0 | 925 | | } |
| | 926 | |
|
| | 927 | | internal Core.HttpMessage CreateListBuiltInNextPageRequest(string nextLink) |
| | 928 | | { |
| 0 | 929 | | var message = _pipeline.CreateMessage(); |
| 0 | 930 | | var request = message.Request; |
| 0 | 931 | | request.Method = RequestMethod.Get; |
| 0 | 932 | | var uri = new RawRequestUriBuilder(); |
| 0 | 933 | | uri.Reset(endpoint); |
| 0 | 934 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 935 | | request.Uri = uri; |
| 0 | 936 | | return message; |
| | 937 | | } |
| | 938 | |
|
| | 939 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 940 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 941 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 942 | | public async Task<Response<PolicyDefinitionListResult>> ListBuiltInNextPageAsync(string nextLink, CancellationTo |
| | 943 | | { |
| 0 | 944 | | if (nextLink == null) |
| | 945 | | { |
| 0 | 946 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 947 | | } |
| | 948 | |
|
| 0 | 949 | | using var message = CreateListBuiltInNextPageRequest(nextLink); |
| 0 | 950 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 951 | | switch (message.Response.Status) |
| | 952 | | { |
| | 953 | | case 200: |
| | 954 | | { |
| 0 | 955 | | PolicyDefinitionListResult value = default; |
| 0 | 956 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 957 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 958 | | { |
| 0 | 959 | | value = null; |
| | 960 | | } |
| | 961 | | else |
| | 962 | | { |
| 0 | 963 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 964 | | } |
| 0 | 965 | | return Response.FromValue(value, message.Response); |
| | 966 | | } |
| | 967 | | default: |
| 0 | 968 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 969 | | } |
| 0 | 970 | | } |
| | 971 | |
|
| | 972 | | /// <summary> This operation retrieves a list of all the built-in policy definitions. </summary> |
| | 973 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 974 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 975 | | public Response<PolicyDefinitionListResult> ListBuiltInNextPage(string nextLink, CancellationToken cancellationT |
| | 976 | | { |
| 0 | 977 | | if (nextLink == null) |
| | 978 | | { |
| 0 | 979 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 980 | | } |
| | 981 | |
|
| 0 | 982 | | using var message = CreateListBuiltInNextPageRequest(nextLink); |
| 0 | 983 | | _pipeline.Send(message, cancellationToken); |
| 0 | 984 | | switch (message.Response.Status) |
| | 985 | | { |
| | 986 | | case 200: |
| | 987 | | { |
| 0 | 988 | | PolicyDefinitionListResult value = default; |
| 0 | 989 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 990 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 991 | | { |
| 0 | 992 | | value = null; |
| | 993 | | } |
| | 994 | | else |
| | 995 | | { |
| 0 | 996 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 997 | | } |
| 0 | 998 | | return Response.FromValue(value, message.Response); |
| | 999 | | } |
| | 1000 | | default: |
| 0 | 1001 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1002 | | } |
| 0 | 1003 | | } |
| | 1004 | |
|
| | 1005 | | internal Core.HttpMessage CreateListByManagementGroupNextPageRequest(string nextLink, string managementGroupId) |
| | 1006 | | { |
| 0 | 1007 | | var message = _pipeline.CreateMessage(); |
| 0 | 1008 | | var request = message.Request; |
| 0 | 1009 | | request.Method = RequestMethod.Get; |
| 0 | 1010 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1011 | | uri.Reset(endpoint); |
| 0 | 1012 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1013 | | request.Uri = uri; |
| 0 | 1014 | | return message; |
| | 1015 | | } |
| | 1016 | |
|
| | 1017 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 1018 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1019 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 1020 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1021 | | public async Task<Response<PolicyDefinitionListResult>> ListByManagementGroupNextPageAsync(string nextLink, stri |
| | 1022 | | { |
| 0 | 1023 | | if (nextLink == null) |
| | 1024 | | { |
| 0 | 1025 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1026 | | } |
| 0 | 1027 | | if (managementGroupId == null) |
| | 1028 | | { |
| 0 | 1029 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 1030 | | } |
| | 1031 | |
|
| 0 | 1032 | | using var message = CreateListByManagementGroupNextPageRequest(nextLink, managementGroupId); |
| 0 | 1033 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1034 | | switch (message.Response.Status) |
| | 1035 | | { |
| | 1036 | | case 200: |
| | 1037 | | { |
| 0 | 1038 | | PolicyDefinitionListResult value = default; |
| 0 | 1039 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1040 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1041 | | { |
| 0 | 1042 | | value = null; |
| | 1043 | | } |
| | 1044 | | else |
| | 1045 | | { |
| 0 | 1046 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 1047 | | } |
| 0 | 1048 | | return Response.FromValue(value, message.Response); |
| | 1049 | | } |
| | 1050 | | default: |
| 0 | 1051 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1052 | | } |
| 0 | 1053 | | } |
| | 1054 | |
|
| | 1055 | | /// <summary> This operation retrieves a list of all the policy definitions in a given management group. </summa |
| | 1056 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1057 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | 1058 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1059 | | public Response<PolicyDefinitionListResult> ListByManagementGroupNextPage(string nextLink, string managementGrou |
| | 1060 | | { |
| 0 | 1061 | | if (nextLink == null) |
| | 1062 | | { |
| 0 | 1063 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1064 | | } |
| 0 | 1065 | | if (managementGroupId == null) |
| | 1066 | | { |
| 0 | 1067 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | 1068 | | } |
| | 1069 | |
|
| 0 | 1070 | | using var message = CreateListByManagementGroupNextPageRequest(nextLink, managementGroupId); |
| 0 | 1071 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1072 | | switch (message.Response.Status) |
| | 1073 | | { |
| | 1074 | | case 200: |
| | 1075 | | { |
| 0 | 1076 | | PolicyDefinitionListResult value = default; |
| 0 | 1077 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1078 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1079 | | { |
| 0 | 1080 | | value = null; |
| | 1081 | | } |
| | 1082 | | else |
| | 1083 | | { |
| 0 | 1084 | | value = PolicyDefinitionListResult.DeserializePolicyDefinitionListResult(document.RootElemen |
| | 1085 | | } |
| 0 | 1086 | | return Response.FromValue(value, message.Response); |
| | 1087 | | } |
| | 1088 | | default: |
| 0 | 1089 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1090 | | } |
| 0 | 1091 | | } |
| | 1092 | | } |
| | 1093 | | } |