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