| | | 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 PolicyAssignmentsRestOperations |
| | | 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 PolicyAssignmentsRestOperations. </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 PolicyAssignmentsRestOperations(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 CreateDeleteRequest(string scope, string policyAssignmentName) |
| | | 47 | | { |
| | 16 | 48 | | var message = _pipeline.CreateMessage(); |
| | 16 | 49 | | var request = message.Request; |
| | 16 | 50 | | request.Method = RequestMethod.Delete; |
| | 16 | 51 | | var uri = new RawRequestUriBuilder(); |
| | 16 | 52 | | uri.Reset(endpoint); |
| | 16 | 53 | | uri.AppendPath("/", false); |
| | 16 | 54 | | uri.AppendPath(scope, false); |
| | 16 | 55 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments/", false); |
| | 16 | 56 | | uri.AppendPath(policyAssignmentName, true); |
| | 16 | 57 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 16 | 58 | | request.Uri = uri; |
| | 16 | 59 | | return message; |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | /// <summary> This operation deletes a policy assignment, given its name and the scope it was created in. The sc |
| | | 63 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 64 | | /// <param name="policyAssignmentName"> The name of the policy assignment to delete. </param> |
| | | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 66 | | public async Task<Response<PolicyAssignment>> DeleteAsync(string scope, string policyAssignmentName, Cancellatio |
| | | 67 | | { |
| | 8 | 68 | | if (scope == null) |
| | | 69 | | { |
| | 0 | 70 | | throw new ArgumentNullException(nameof(scope)); |
| | | 71 | | } |
| | 8 | 72 | | if (policyAssignmentName == null) |
| | | 73 | | { |
| | 0 | 74 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 75 | | } |
| | | 76 | | |
| | 8 | 77 | | using var message = CreateDeleteRequest(scope, policyAssignmentName); |
| | 8 | 78 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 8 | 79 | | switch (message.Response.Status) |
| | | 80 | | { |
| | | 81 | | case 200: |
| | | 82 | | { |
| | 8 | 83 | | PolicyAssignment value = default; |
| | 8 | 84 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 8 | 85 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 86 | | { |
| | 0 | 87 | | value = null; |
| | | 88 | | } |
| | | 89 | | else |
| | | 90 | | { |
| | 8 | 91 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 92 | | } |
| | 8 | 93 | | return Response.FromValue(value, message.Response); |
| | | 94 | | } |
| | | 95 | | case 204: |
| | 0 | 96 | | return Response.FromValue<PolicyAssignment>(null, message.Response); |
| | | 97 | | default: |
| | 0 | 98 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 99 | | } |
| | 8 | 100 | | } |
| | | 101 | | |
| | | 102 | | /// <summary> This operation deletes a policy assignment, given its name and the scope it was created in. The sc |
| | | 103 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 104 | | /// <param name="policyAssignmentName"> The name of the policy assignment to delete. </param> |
| | | 105 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 106 | | public Response<PolicyAssignment> Delete(string scope, string policyAssignmentName, CancellationToken cancellati |
| | | 107 | | { |
| | 8 | 108 | | if (scope == null) |
| | | 109 | | { |
| | 0 | 110 | | throw new ArgumentNullException(nameof(scope)); |
| | | 111 | | } |
| | 8 | 112 | | if (policyAssignmentName == null) |
| | | 113 | | { |
| | 0 | 114 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 115 | | } |
| | | 116 | | |
| | 8 | 117 | | using var message = CreateDeleteRequest(scope, policyAssignmentName); |
| | 8 | 118 | | _pipeline.Send(message, cancellationToken); |
| | 8 | 119 | | switch (message.Response.Status) |
| | | 120 | | { |
| | | 121 | | case 200: |
| | | 122 | | { |
| | 8 | 123 | | PolicyAssignment value = default; |
| | 8 | 124 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 8 | 125 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 126 | | { |
| | 0 | 127 | | value = null; |
| | | 128 | | } |
| | | 129 | | else |
| | | 130 | | { |
| | 8 | 131 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 132 | | } |
| | 8 | 133 | | return Response.FromValue(value, message.Response); |
| | | 134 | | } |
| | | 135 | | case 204: |
| | 0 | 136 | | return Response.FromValue<PolicyAssignment>(null, message.Response); |
| | | 137 | | default: |
| | 0 | 138 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 139 | | } |
| | 8 | 140 | | } |
| | | 141 | | |
| | | 142 | | internal Core.HttpMessage CreateCreateRequest(string scope, string policyAssignmentName, PolicyAssignment parame |
| | | 143 | | { |
| | 32 | 144 | | var message = _pipeline.CreateMessage(); |
| | 32 | 145 | | var request = message.Request; |
| | 32 | 146 | | request.Method = RequestMethod.Put; |
| | 32 | 147 | | var uri = new RawRequestUriBuilder(); |
| | 32 | 148 | | uri.Reset(endpoint); |
| | 32 | 149 | | uri.AppendPath("/", false); |
| | 32 | 150 | | uri.AppendPath(scope, false); |
| | 32 | 151 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments/", false); |
| | 32 | 152 | | uri.AppendPath(policyAssignmentName, true); |
| | 32 | 153 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 32 | 154 | | request.Uri = uri; |
| | 32 | 155 | | request.Headers.Add("Content-Type", "application/json"); |
| | 32 | 156 | | var content = new Utf8JsonRequestContent(); |
| | 32 | 157 | | content.JsonWriter.WriteObjectValue(parameters); |
| | 32 | 158 | | request.Content = content; |
| | 32 | 159 | | return message; |
| | | 160 | | } |
| | | 161 | | |
| | | 162 | | /// <summary> This operation creates or updates a policy assignment with the given scope and name. Policy assig |
| | | 163 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 164 | | /// <param name="policyAssignmentName"> The name of the policy assignment. </param> |
| | | 165 | | /// <param name="parameters"> Parameters for the policy assignment. </param> |
| | | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 167 | | public async Task<Response<PolicyAssignment>> CreateAsync(string scope, string policyAssignmentName, PolicyAssig |
| | | 168 | | { |
| | 16 | 169 | | if (scope == null) |
| | | 170 | | { |
| | 0 | 171 | | throw new ArgumentNullException(nameof(scope)); |
| | | 172 | | } |
| | 16 | 173 | | if (policyAssignmentName == null) |
| | | 174 | | { |
| | 0 | 175 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 176 | | } |
| | 16 | 177 | | if (parameters == null) |
| | | 178 | | { |
| | 0 | 179 | | throw new ArgumentNullException(nameof(parameters)); |
| | | 180 | | } |
| | | 181 | | |
| | 16 | 182 | | using var message = CreateCreateRequest(scope, policyAssignmentName, parameters); |
| | 16 | 183 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 16 | 184 | | switch (message.Response.Status) |
| | | 185 | | { |
| | | 186 | | case 201: |
| | | 187 | | { |
| | 10 | 188 | | PolicyAssignment value = default; |
| | 10 | 189 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 10 | 190 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 191 | | { |
| | 0 | 192 | | value = null; |
| | | 193 | | } |
| | | 194 | | else |
| | | 195 | | { |
| | 10 | 196 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 197 | | } |
| | 10 | 198 | | return Response.FromValue(value, message.Response); |
| | | 199 | | } |
| | | 200 | | default: |
| | 6 | 201 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 202 | | } |
| | 10 | 203 | | } |
| | | 204 | | |
| | | 205 | | /// <summary> This operation creates or updates a policy assignment with the given scope and name. Policy assig |
| | | 206 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 207 | | /// <param name="policyAssignmentName"> The name of the policy assignment. </param> |
| | | 208 | | /// <param name="parameters"> Parameters for the policy assignment. </param> |
| | | 209 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 210 | | public Response<PolicyAssignment> Create(string scope, string policyAssignmentName, PolicyAssignment parameters, |
| | | 211 | | { |
| | 16 | 212 | | if (scope == null) |
| | | 213 | | { |
| | 0 | 214 | | throw new ArgumentNullException(nameof(scope)); |
| | | 215 | | } |
| | 16 | 216 | | if (policyAssignmentName == null) |
| | | 217 | | { |
| | 0 | 218 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 219 | | } |
| | 16 | 220 | | if (parameters == null) |
| | | 221 | | { |
| | 0 | 222 | | throw new ArgumentNullException(nameof(parameters)); |
| | | 223 | | } |
| | | 224 | | |
| | 16 | 225 | | using var message = CreateCreateRequest(scope, policyAssignmentName, parameters); |
| | 16 | 226 | | _pipeline.Send(message, cancellationToken); |
| | 16 | 227 | | switch (message.Response.Status) |
| | | 228 | | { |
| | | 229 | | case 201: |
| | | 230 | | { |
| | 10 | 231 | | PolicyAssignment value = default; |
| | 10 | 232 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 10 | 233 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 234 | | { |
| | 0 | 235 | | value = null; |
| | | 236 | | } |
| | | 237 | | else |
| | | 238 | | { |
| | 10 | 239 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 240 | | } |
| | 10 | 241 | | return Response.FromValue(value, message.Response); |
| | | 242 | | } |
| | | 243 | | default: |
| | 6 | 244 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 245 | | } |
| | 10 | 246 | | } |
| | | 247 | | |
| | | 248 | | internal Core.HttpMessage CreateGetRequest(string scope, string policyAssignmentName) |
| | | 249 | | { |
| | 20 | 250 | | var message = _pipeline.CreateMessage(); |
| | 20 | 251 | | var request = message.Request; |
| | 20 | 252 | | request.Method = RequestMethod.Get; |
| | 20 | 253 | | var uri = new RawRequestUriBuilder(); |
| | 20 | 254 | | uri.Reset(endpoint); |
| | 20 | 255 | | uri.AppendPath("/", false); |
| | 20 | 256 | | uri.AppendPath(scope, false); |
| | 20 | 257 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments/", false); |
| | 20 | 258 | | uri.AppendPath(policyAssignmentName, true); |
| | 20 | 259 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 20 | 260 | | request.Uri = uri; |
| | 20 | 261 | | return message; |
| | | 262 | | } |
| | | 263 | | |
| | | 264 | | /// <summary> This operation retrieves a single policy assignment, given its name and the scope it was created a |
| | | 265 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 266 | | /// <param name="policyAssignmentName"> The name of the policy assignment to get. </param> |
| | | 267 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 268 | | public async Task<Response<PolicyAssignment>> GetAsync(string scope, string policyAssignmentName, CancellationTo |
| | | 269 | | { |
| | 10 | 270 | | if (scope == null) |
| | | 271 | | { |
| | 0 | 272 | | throw new ArgumentNullException(nameof(scope)); |
| | | 273 | | } |
| | 10 | 274 | | if (policyAssignmentName == null) |
| | | 275 | | { |
| | 0 | 276 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 277 | | } |
| | | 278 | | |
| | 10 | 279 | | using var message = CreateGetRequest(scope, policyAssignmentName); |
| | 10 | 280 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 10 | 281 | | switch (message.Response.Status) |
| | | 282 | | { |
| | | 283 | | case 200: |
| | | 284 | | { |
| | 6 | 285 | | PolicyAssignment value = default; |
| | 6 | 286 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 6 | 287 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 288 | | { |
| | 0 | 289 | | value = null; |
| | | 290 | | } |
| | | 291 | | else |
| | | 292 | | { |
| | 6 | 293 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 294 | | } |
| | 6 | 295 | | return Response.FromValue(value, message.Response); |
| | | 296 | | } |
| | | 297 | | default: |
| | 4 | 298 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 299 | | } |
| | 6 | 300 | | } |
| | | 301 | | |
| | | 302 | | /// <summary> This operation retrieves a single policy assignment, given its name and the scope it was created a |
| | | 303 | | /// <param name="scope"> The scope of the policy assignment. Valid scopes are: management group (format: '/ |
| | | 304 | | /// <param name="policyAssignmentName"> The name of the policy assignment to get. </param> |
| | | 305 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 306 | | public Response<PolicyAssignment> Get(string scope, string policyAssignmentName, CancellationToken cancellationT |
| | | 307 | | { |
| | 10 | 308 | | if (scope == null) |
| | | 309 | | { |
| | 0 | 310 | | throw new ArgumentNullException(nameof(scope)); |
| | | 311 | | } |
| | 10 | 312 | | if (policyAssignmentName == null) |
| | | 313 | | { |
| | 0 | 314 | | throw new ArgumentNullException(nameof(policyAssignmentName)); |
| | | 315 | | } |
| | | 316 | | |
| | 10 | 317 | | using var message = CreateGetRequest(scope, policyAssignmentName); |
| | 10 | 318 | | _pipeline.Send(message, cancellationToken); |
| | 10 | 319 | | switch (message.Response.Status) |
| | | 320 | | { |
| | | 321 | | case 200: |
| | | 322 | | { |
| | 6 | 323 | | PolicyAssignment value = default; |
| | 6 | 324 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 6 | 325 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 326 | | { |
| | 0 | 327 | | value = null; |
| | | 328 | | } |
| | | 329 | | else |
| | | 330 | | { |
| | 6 | 331 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 332 | | } |
| | 6 | 333 | | return Response.FromValue(value, message.Response); |
| | | 334 | | } |
| | | 335 | | default: |
| | 4 | 336 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 337 | | } |
| | 6 | 338 | | } |
| | | 339 | | |
| | | 340 | | internal Core.HttpMessage CreateListForResourceGroupRequest(string resourceGroupName, string filter) |
| | | 341 | | { |
| | 4 | 342 | | var message = _pipeline.CreateMessage(); |
| | 4 | 343 | | var request = message.Request; |
| | 4 | 344 | | request.Method = RequestMethod.Get; |
| | 4 | 345 | | var uri = new RawRequestUriBuilder(); |
| | 4 | 346 | | uri.Reset(endpoint); |
| | 4 | 347 | | uri.AppendPath("/subscriptions/", false); |
| | 4 | 348 | | uri.AppendPath(subscriptionId, true); |
| | 4 | 349 | | uri.AppendPath("/resourceGroups/", false); |
| | 4 | 350 | | uri.AppendPath(resourceGroupName, true); |
| | 4 | 351 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments", false); |
| | 4 | 352 | | if (filter != null) |
| | | 353 | | { |
| | 0 | 354 | | uri.AppendQuery("$filter", filter, false); |
| | | 355 | | } |
| | 4 | 356 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 4 | 357 | | request.Uri = uri; |
| | 4 | 358 | | return message; |
| | | 359 | | } |
| | | 360 | | |
| | | 361 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro |
| | | 362 | | /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param> |
| | | 363 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 364 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 365 | | public async Task<Response<PolicyAssignmentListResult>> ListForResourceGroupAsync(string resourceGroupName, stri |
| | | 366 | | { |
| | 2 | 367 | | if (resourceGroupName == null) |
| | | 368 | | { |
| | 0 | 369 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 370 | | } |
| | | 371 | | |
| | 2 | 372 | | using var message = CreateListForResourceGroupRequest(resourceGroupName, filter); |
| | 2 | 373 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 2 | 374 | | switch (message.Response.Status) |
| | | 375 | | { |
| | | 376 | | case 200: |
| | | 377 | | { |
| | 2 | 378 | | PolicyAssignmentListResult value = default; |
| | 2 | 379 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 2 | 380 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 381 | | { |
| | 0 | 382 | | value = null; |
| | | 383 | | } |
| | | 384 | | else |
| | | 385 | | { |
| | 2 | 386 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 387 | | } |
| | 2 | 388 | | return Response.FromValue(value, message.Response); |
| | | 389 | | } |
| | | 390 | | default: |
| | 0 | 391 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 392 | | } |
| | 2 | 393 | | } |
| | | 394 | | |
| | | 395 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro |
| | | 396 | | /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param> |
| | | 397 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 398 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 399 | | public Response<PolicyAssignmentListResult> ListForResourceGroup(string resourceGroupName, string filter = null, |
| | | 400 | | { |
| | 2 | 401 | | if (resourceGroupName == null) |
| | | 402 | | { |
| | 0 | 403 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 404 | | } |
| | | 405 | | |
| | 2 | 406 | | using var message = CreateListForResourceGroupRequest(resourceGroupName, filter); |
| | 2 | 407 | | _pipeline.Send(message, cancellationToken); |
| | 2 | 408 | | switch (message.Response.Status) |
| | | 409 | | { |
| | | 410 | | case 200: |
| | | 411 | | { |
| | 2 | 412 | | PolicyAssignmentListResult value = default; |
| | 2 | 413 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 2 | 414 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 415 | | { |
| | 0 | 416 | | value = null; |
| | | 417 | | } |
| | | 418 | | else |
| | | 419 | | { |
| | 2 | 420 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 421 | | } |
| | 2 | 422 | | return Response.FromValue(value, message.Response); |
| | | 423 | | } |
| | | 424 | | default: |
| | 0 | 425 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 426 | | } |
| | 2 | 427 | | } |
| | | 428 | | |
| | | 429 | | internal Core.HttpMessage CreateListForResourceRequest(string resourceGroupName, string resourceProviderNamespac |
| | | 430 | | { |
| | 4 | 431 | | var message = _pipeline.CreateMessage(); |
| | 4 | 432 | | var request = message.Request; |
| | 4 | 433 | | request.Method = RequestMethod.Get; |
| | 4 | 434 | | var uri = new RawRequestUriBuilder(); |
| | 4 | 435 | | uri.Reset(endpoint); |
| | 4 | 436 | | uri.AppendPath("/subscriptions/", false); |
| | 4 | 437 | | uri.AppendPath(subscriptionId, true); |
| | 4 | 438 | | uri.AppendPath("/resourcegroups/", false); |
| | 4 | 439 | | uri.AppendPath(resourceGroupName, true); |
| | 4 | 440 | | uri.AppendPath("/providers/", false); |
| | 4 | 441 | | uri.AppendPath(resourceProviderNamespace, true); |
| | 4 | 442 | | uri.AppendPath("/", false); |
| | 4 | 443 | | uri.AppendPath(parentResourcePath, false); |
| | 4 | 444 | | uri.AppendPath("/", false); |
| | 4 | 445 | | uri.AppendPath(resourceType, false); |
| | 4 | 446 | | uri.AppendPath("/", false); |
| | 4 | 447 | | uri.AppendPath(resourceName, true); |
| | 4 | 448 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments", false); |
| | 4 | 449 | | if (filter != null) |
| | | 450 | | { |
| | 0 | 451 | | uri.AppendQuery("$filter", filter, true); |
| | | 452 | | } |
| | 4 | 453 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 4 | 454 | | request.Uri = uri; |
| | 4 | 455 | | return message; |
| | | 456 | | } |
| | | 457 | | |
| | | 458 | | /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource |
| | | 459 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param> |
| | | 460 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace |
| | | 461 | | /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param> |
| | | 462 | | /// <param name="resourceType"> The resource type name. For example the type name of a web app is 'sites&ap |
| | | 463 | | /// <param name="resourceName"> The name of the resource. </param> |
| | | 464 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 465 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 466 | | public async Task<Response<PolicyAssignmentListResult>> ListForResourceAsync(string resourceGroupName, string re |
| | | 467 | | { |
| | 2 | 468 | | if (resourceGroupName == null) |
| | | 469 | | { |
| | 0 | 470 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 471 | | } |
| | 2 | 472 | | if (resourceProviderNamespace == null) |
| | | 473 | | { |
| | 0 | 474 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | | 475 | | } |
| | 2 | 476 | | if (parentResourcePath == null) |
| | | 477 | | { |
| | 0 | 478 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | | 479 | | } |
| | 2 | 480 | | if (resourceType == null) |
| | | 481 | | { |
| | 0 | 482 | | throw new ArgumentNullException(nameof(resourceType)); |
| | | 483 | | } |
| | 2 | 484 | | if (resourceName == null) |
| | | 485 | | { |
| | 0 | 486 | | throw new ArgumentNullException(nameof(resourceName)); |
| | | 487 | | } |
| | | 488 | | |
| | 2 | 489 | | using var message = CreateListForResourceRequest(resourceGroupName, resourceProviderNamespace, parentResourc |
| | 2 | 490 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 2 | 491 | | switch (message.Response.Status) |
| | | 492 | | { |
| | | 493 | | case 200: |
| | | 494 | | { |
| | 2 | 495 | | PolicyAssignmentListResult value = default; |
| | 2 | 496 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 2 | 497 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 498 | | { |
| | 0 | 499 | | value = null; |
| | | 500 | | } |
| | | 501 | | else |
| | | 502 | | { |
| | 2 | 503 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 504 | | } |
| | 2 | 505 | | return Response.FromValue(value, message.Response); |
| | | 506 | | } |
| | | 507 | | default: |
| | 0 | 508 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 509 | | } |
| | 2 | 510 | | } |
| | | 511 | | |
| | | 512 | | /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource |
| | | 513 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param> |
| | | 514 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace |
| | | 515 | | /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param> |
| | | 516 | | /// <param name="resourceType"> The resource type name. For example the type name of a web app is 'sites&ap |
| | | 517 | | /// <param name="resourceName"> The name of the resource. </param> |
| | | 518 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 519 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 520 | | public Response<PolicyAssignmentListResult> ListForResource(string resourceGroupName, string resourceProviderNam |
| | | 521 | | { |
| | 2 | 522 | | if (resourceGroupName == null) |
| | | 523 | | { |
| | 0 | 524 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 525 | | } |
| | 2 | 526 | | if (resourceProviderNamespace == null) |
| | | 527 | | { |
| | 0 | 528 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | | 529 | | } |
| | 2 | 530 | | if (parentResourcePath == null) |
| | | 531 | | { |
| | 0 | 532 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | | 533 | | } |
| | 2 | 534 | | if (resourceType == null) |
| | | 535 | | { |
| | 0 | 536 | | throw new ArgumentNullException(nameof(resourceType)); |
| | | 537 | | } |
| | 2 | 538 | | if (resourceName == null) |
| | | 539 | | { |
| | 0 | 540 | | throw new ArgumentNullException(nameof(resourceName)); |
| | | 541 | | } |
| | | 542 | | |
| | 2 | 543 | | using var message = CreateListForResourceRequest(resourceGroupName, resourceProviderNamespace, parentResourc |
| | 2 | 544 | | _pipeline.Send(message, cancellationToken); |
| | 2 | 545 | | switch (message.Response.Status) |
| | | 546 | | { |
| | | 547 | | case 200: |
| | | 548 | | { |
| | 2 | 549 | | PolicyAssignmentListResult value = default; |
| | 2 | 550 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 2 | 551 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 552 | | { |
| | 0 | 553 | | value = null; |
| | | 554 | | } |
| | | 555 | | else |
| | | 556 | | { |
| | 2 | 557 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 558 | | } |
| | 2 | 559 | | return Response.FromValue(value, message.Response); |
| | | 560 | | } |
| | | 561 | | default: |
| | 0 | 562 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 563 | | } |
| | 2 | 564 | | } |
| | | 565 | | |
| | | 566 | | internal Core.HttpMessage CreateListForManagementGroupRequest(string managementGroupId, string filter) |
| | | 567 | | { |
| | 0 | 568 | | var message = _pipeline.CreateMessage(); |
| | 0 | 569 | | var request = message.Request; |
| | 0 | 570 | | request.Method = RequestMethod.Get; |
| | 0 | 571 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 572 | | uri.Reset(endpoint); |
| | 0 | 573 | | uri.AppendPath("/providers/Microsoft.Management/managementgroups/", false); |
| | 0 | 574 | | uri.AppendPath(managementGroupId, true); |
| | 0 | 575 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments", false); |
| | 0 | 576 | | uri.AppendQuery("$filter", filter, false); |
| | 0 | 577 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 0 | 578 | | request.Uri = uri; |
| | 0 | 579 | | return message; |
| | | 580 | | } |
| | | 581 | | |
| | | 582 | | /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha |
| | | 583 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | | 584 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 585 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 586 | | public async Task<Response<PolicyAssignmentListResult>> ListForManagementGroupAsync(string managementGroupId, st |
| | | 587 | | { |
| | 0 | 588 | | if (managementGroupId == null) |
| | | 589 | | { |
| | 0 | 590 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | | 591 | | } |
| | 0 | 592 | | if (filter == null) |
| | | 593 | | { |
| | 0 | 594 | | throw new ArgumentNullException(nameof(filter)); |
| | | 595 | | } |
| | | 596 | | |
| | 0 | 597 | | using var message = CreateListForManagementGroupRequest(managementGroupId, filter); |
| | 0 | 598 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 599 | | switch (message.Response.Status) |
| | | 600 | | { |
| | | 601 | | case 200: |
| | | 602 | | { |
| | 0 | 603 | | PolicyAssignmentListResult value = default; |
| | 0 | 604 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 605 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 606 | | { |
| | 0 | 607 | | value = null; |
| | | 608 | | } |
| | | 609 | | else |
| | | 610 | | { |
| | 0 | 611 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 612 | | } |
| | 0 | 613 | | return Response.FromValue(value, message.Response); |
| | | 614 | | } |
| | | 615 | | default: |
| | 0 | 616 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 617 | | } |
| | 0 | 618 | | } |
| | | 619 | | |
| | | 620 | | /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha |
| | | 621 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | | 622 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 623 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 624 | | public Response<PolicyAssignmentListResult> ListForManagementGroup(string managementGroupId, string filter, Canc |
| | | 625 | | { |
| | 0 | 626 | | if (managementGroupId == null) |
| | | 627 | | { |
| | 0 | 628 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | | 629 | | } |
| | 0 | 630 | | if (filter == null) |
| | | 631 | | { |
| | 0 | 632 | | throw new ArgumentNullException(nameof(filter)); |
| | | 633 | | } |
| | | 634 | | |
| | 0 | 635 | | using var message = CreateListForManagementGroupRequest(managementGroupId, filter); |
| | 0 | 636 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 637 | | switch (message.Response.Status) |
| | | 638 | | { |
| | | 639 | | case 200: |
| | | 640 | | { |
| | 0 | 641 | | PolicyAssignmentListResult value = default; |
| | 0 | 642 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 643 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 644 | | { |
| | 0 | 645 | | value = null; |
| | | 646 | | } |
| | | 647 | | else |
| | | 648 | | { |
| | 0 | 649 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 650 | | } |
| | 0 | 651 | | return Response.FromValue(value, message.Response); |
| | | 652 | | } |
| | | 653 | | default: |
| | 0 | 654 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 655 | | } |
| | 0 | 656 | | } |
| | | 657 | | |
| | | 658 | | internal Core.HttpMessage CreateListRequest(string filter) |
| | | 659 | | { |
| | 12 | 660 | | var message = _pipeline.CreateMessage(); |
| | 12 | 661 | | var request = message.Request; |
| | 12 | 662 | | request.Method = RequestMethod.Get; |
| | 12 | 663 | | var uri = new RawRequestUriBuilder(); |
| | 12 | 664 | | uri.Reset(endpoint); |
| | 12 | 665 | | uri.AppendPath("/subscriptions/", false); |
| | 12 | 666 | | uri.AppendPath(subscriptionId, true); |
| | 12 | 667 | | uri.AppendPath("/providers/Microsoft.Authorization/policyAssignments", false); |
| | 12 | 668 | | if (filter != null) |
| | | 669 | | { |
| | 0 | 670 | | uri.AppendQuery("$filter", filter, true); |
| | | 671 | | } |
| | 12 | 672 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 12 | 673 | | request.Uri = uri; |
| | 12 | 674 | | return message; |
| | | 675 | | } |
| | | 676 | | |
| | | 677 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription |
| | | 678 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 679 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 680 | | public async Task<Response<PolicyAssignmentListResult>> ListAsync(string filter = null, CancellationToken cancel |
| | | 681 | | { |
| | 6 | 682 | | using var message = CreateListRequest(filter); |
| | 6 | 683 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 6 | 684 | | switch (message.Response.Status) |
| | | 685 | | { |
| | | 686 | | case 200: |
| | | 687 | | { |
| | 6 | 688 | | PolicyAssignmentListResult value = default; |
| | 6 | 689 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 6 | 690 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 691 | | { |
| | 0 | 692 | | value = null; |
| | | 693 | | } |
| | | 694 | | else |
| | | 695 | | { |
| | 6 | 696 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 697 | | } |
| | 6 | 698 | | return Response.FromValue(value, message.Response); |
| | | 699 | | } |
| | | 700 | | default: |
| | 0 | 701 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 702 | | } |
| | 6 | 703 | | } |
| | | 704 | | |
| | | 705 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription |
| | | 706 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 707 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 708 | | public Response<PolicyAssignmentListResult> List(string filter = null, CancellationToken cancellationToken = def |
| | | 709 | | { |
| | 6 | 710 | | using var message = CreateListRequest(filter); |
| | 6 | 711 | | _pipeline.Send(message, cancellationToken); |
| | 6 | 712 | | switch (message.Response.Status) |
| | | 713 | | { |
| | | 714 | | case 200: |
| | | 715 | | { |
| | 6 | 716 | | PolicyAssignmentListResult value = default; |
| | 6 | 717 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 6 | 718 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 719 | | { |
| | 0 | 720 | | value = null; |
| | | 721 | | } |
| | | 722 | | else |
| | | 723 | | { |
| | 6 | 724 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 725 | | } |
| | 6 | 726 | | return Response.FromValue(value, message.Response); |
| | | 727 | | } |
| | | 728 | | default: |
| | 0 | 729 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 730 | | } |
| | 6 | 731 | | } |
| | | 732 | | |
| | | 733 | | internal Core.HttpMessage CreateDeleteByIdRequest(string policyAssignmentId) |
| | | 734 | | { |
| | 0 | 735 | | var message = _pipeline.CreateMessage(); |
| | 0 | 736 | | var request = message.Request; |
| | 0 | 737 | | request.Method = RequestMethod.Delete; |
| | 0 | 738 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 739 | | uri.Reset(endpoint); |
| | 0 | 740 | | uri.AppendPath("/", false); |
| | 0 | 741 | | uri.AppendPath(policyAssignmentId, false); |
| | 0 | 742 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 0 | 743 | | request.Uri = uri; |
| | 0 | 744 | | return message; |
| | | 745 | | } |
| | | 746 | | |
| | | 747 | | /// <summary> This operation deletes the policy with the given ID. Policy assignment IDs have this format: &apos |
| | | 748 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to delete. Use the format '{scope}/pr |
| | | 749 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 750 | | public async Task<Response<PolicyAssignment>> DeleteByIdAsync(string policyAssignmentId, CancellationToken cance |
| | | 751 | | { |
| | 0 | 752 | | if (policyAssignmentId == null) |
| | | 753 | | { |
| | 0 | 754 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 755 | | } |
| | | 756 | | |
| | 0 | 757 | | using var message = CreateDeleteByIdRequest(policyAssignmentId); |
| | 0 | 758 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 759 | | switch (message.Response.Status) |
| | | 760 | | { |
| | | 761 | | case 200: |
| | | 762 | | { |
| | 0 | 763 | | PolicyAssignment value = default; |
| | 0 | 764 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 765 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 766 | | { |
| | 0 | 767 | | value = null; |
| | | 768 | | } |
| | | 769 | | else |
| | | 770 | | { |
| | 0 | 771 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 772 | | } |
| | 0 | 773 | | return Response.FromValue(value, message.Response); |
| | | 774 | | } |
| | | 775 | | case 204: |
| | 0 | 776 | | return Response.FromValue<PolicyAssignment>(null, message.Response); |
| | | 777 | | default: |
| | 0 | 778 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 779 | | } |
| | 0 | 780 | | } |
| | | 781 | | |
| | | 782 | | /// <summary> This operation deletes the policy with the given ID. Policy assignment IDs have this format: &apos |
| | | 783 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to delete. Use the format '{scope}/pr |
| | | 784 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 785 | | public Response<PolicyAssignment> DeleteById(string policyAssignmentId, CancellationToken cancellationToken = de |
| | | 786 | | { |
| | 0 | 787 | | if (policyAssignmentId == null) |
| | | 788 | | { |
| | 0 | 789 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 790 | | } |
| | | 791 | | |
| | 0 | 792 | | using var message = CreateDeleteByIdRequest(policyAssignmentId); |
| | 0 | 793 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 794 | | switch (message.Response.Status) |
| | | 795 | | { |
| | | 796 | | case 200: |
| | | 797 | | { |
| | 0 | 798 | | PolicyAssignment value = default; |
| | 0 | 799 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 800 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 801 | | { |
| | 0 | 802 | | value = null; |
| | | 803 | | } |
| | | 804 | | else |
| | | 805 | | { |
| | 0 | 806 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 807 | | } |
| | 0 | 808 | | return Response.FromValue(value, message.Response); |
| | | 809 | | } |
| | | 810 | | case 204: |
| | 0 | 811 | | return Response.FromValue<PolicyAssignment>(null, message.Response); |
| | | 812 | | default: |
| | 0 | 813 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 814 | | } |
| | 0 | 815 | | } |
| | | 816 | | |
| | | 817 | | internal Core.HttpMessage CreateCreateByIdRequest(string policyAssignmentId, PolicyAssignment parameters) |
| | | 818 | | { |
| | 0 | 819 | | var message = _pipeline.CreateMessage(); |
| | 0 | 820 | | var request = message.Request; |
| | 0 | 821 | | request.Method = RequestMethod.Put; |
| | 0 | 822 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 823 | | uri.Reset(endpoint); |
| | 0 | 824 | | uri.AppendPath("/", false); |
| | 0 | 825 | | uri.AppendPath(policyAssignmentId, false); |
| | 0 | 826 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 0 | 827 | | request.Uri = uri; |
| | 0 | 828 | | request.Headers.Add("Content-Type", "application/json"); |
| | 0 | 829 | | var content = new Utf8JsonRequestContent(); |
| | 0 | 830 | | content.JsonWriter.WriteObjectValue(parameters); |
| | 0 | 831 | | request.Content = content; |
| | 0 | 832 | | return message; |
| | | 833 | | } |
| | | 834 | | |
| | | 835 | | /// <summary> This operation creates or updates the policy assignment with the given ID. Policy assignments made |
| | | 836 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to create. Use the format '{scope}/pr |
| | | 837 | | /// <param name="parameters"> Parameters for policy assignment. </param> |
| | | 838 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 839 | | public async Task<Response<PolicyAssignment>> CreateByIdAsync(string policyAssignmentId, PolicyAssignment parame |
| | | 840 | | { |
| | 0 | 841 | | if (policyAssignmentId == null) |
| | | 842 | | { |
| | 0 | 843 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 844 | | } |
| | 0 | 845 | | if (parameters == null) |
| | | 846 | | { |
| | 0 | 847 | | throw new ArgumentNullException(nameof(parameters)); |
| | | 848 | | } |
| | | 849 | | |
| | 0 | 850 | | using var message = CreateCreateByIdRequest(policyAssignmentId, parameters); |
| | 0 | 851 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 852 | | switch (message.Response.Status) |
| | | 853 | | { |
| | | 854 | | case 201: |
| | | 855 | | { |
| | 0 | 856 | | PolicyAssignment value = default; |
| | 0 | 857 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 858 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 859 | | { |
| | 0 | 860 | | value = null; |
| | | 861 | | } |
| | | 862 | | else |
| | | 863 | | { |
| | 0 | 864 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 865 | | } |
| | 0 | 866 | | return Response.FromValue(value, message.Response); |
| | | 867 | | } |
| | | 868 | | default: |
| | 0 | 869 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 870 | | } |
| | 0 | 871 | | } |
| | | 872 | | |
| | | 873 | | /// <summary> This operation creates or updates the policy assignment with the given ID. Policy assignments made |
| | | 874 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to create. Use the format '{scope}/pr |
| | | 875 | | /// <param name="parameters"> Parameters for policy assignment. </param> |
| | | 876 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 877 | | public Response<PolicyAssignment> CreateById(string policyAssignmentId, PolicyAssignment parameters, Cancellatio |
| | | 878 | | { |
| | 0 | 879 | | if (policyAssignmentId == null) |
| | | 880 | | { |
| | 0 | 881 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 882 | | } |
| | 0 | 883 | | if (parameters == null) |
| | | 884 | | { |
| | 0 | 885 | | throw new ArgumentNullException(nameof(parameters)); |
| | | 886 | | } |
| | | 887 | | |
| | 0 | 888 | | using var message = CreateCreateByIdRequest(policyAssignmentId, parameters); |
| | 0 | 889 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 890 | | switch (message.Response.Status) |
| | | 891 | | { |
| | | 892 | | case 201: |
| | | 893 | | { |
| | 0 | 894 | | PolicyAssignment value = default; |
| | 0 | 895 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 896 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 897 | | { |
| | 0 | 898 | | value = null; |
| | | 899 | | } |
| | | 900 | | else |
| | | 901 | | { |
| | 0 | 902 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 903 | | } |
| | 0 | 904 | | return Response.FromValue(value, message.Response); |
| | | 905 | | } |
| | | 906 | | default: |
| | 0 | 907 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 908 | | } |
| | 0 | 909 | | } |
| | | 910 | | |
| | | 911 | | internal Core.HttpMessage CreateGetByIdRequest(string policyAssignmentId) |
| | | 912 | | { |
| | 8 | 913 | | var message = _pipeline.CreateMessage(); |
| | 8 | 914 | | var request = message.Request; |
| | 8 | 915 | | request.Method = RequestMethod.Get; |
| | 8 | 916 | | var uri = new RawRequestUriBuilder(); |
| | 8 | 917 | | uri.Reset(endpoint); |
| | 8 | 918 | | uri.AppendPath("/", false); |
| | 8 | 919 | | uri.AppendPath(policyAssignmentId, false); |
| | 8 | 920 | | uri.AppendQuery("api-version", "2019-09-01", true); |
| | 8 | 921 | | request.Uri = uri; |
| | 8 | 922 | | return message; |
| | | 923 | | } |
| | | 924 | | |
| | | 925 | | /// <summary> The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this f |
| | | 926 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to get. Use the format '{scope}/provi |
| | | 927 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 928 | | public async Task<Response<PolicyAssignment>> GetByIdAsync(string policyAssignmentId, CancellationToken cancella |
| | | 929 | | { |
| | 4 | 930 | | if (policyAssignmentId == null) |
| | | 931 | | { |
| | 0 | 932 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 933 | | } |
| | | 934 | | |
| | 4 | 935 | | using var message = CreateGetByIdRequest(policyAssignmentId); |
| | 4 | 936 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 4 | 937 | | switch (message.Response.Status) |
| | | 938 | | { |
| | | 939 | | case 200: |
| | | 940 | | { |
| | 4 | 941 | | PolicyAssignment value = default; |
| | 4 | 942 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 4 | 943 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 944 | | { |
| | 0 | 945 | | value = null; |
| | | 946 | | } |
| | | 947 | | else |
| | | 948 | | { |
| | 4 | 949 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 950 | | } |
| | 4 | 951 | | return Response.FromValue(value, message.Response); |
| | | 952 | | } |
| | | 953 | | default: |
| | 0 | 954 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 955 | | } |
| | 4 | 956 | | } |
| | | 957 | | |
| | | 958 | | /// <summary> The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this f |
| | | 959 | | /// <param name="policyAssignmentId"> The ID of the policy assignment to get. Use the format '{scope}/provi |
| | | 960 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 961 | | public Response<PolicyAssignment> GetById(string policyAssignmentId, CancellationToken cancellationToken = defau |
| | | 962 | | { |
| | 4 | 963 | | if (policyAssignmentId == null) |
| | | 964 | | { |
| | 0 | 965 | | throw new ArgumentNullException(nameof(policyAssignmentId)); |
| | | 966 | | } |
| | | 967 | | |
| | 4 | 968 | | using var message = CreateGetByIdRequest(policyAssignmentId); |
| | 4 | 969 | | _pipeline.Send(message, cancellationToken); |
| | 4 | 970 | | switch (message.Response.Status) |
| | | 971 | | { |
| | | 972 | | case 200: |
| | | 973 | | { |
| | 4 | 974 | | PolicyAssignment value = default; |
| | 4 | 975 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 4 | 976 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 977 | | { |
| | 0 | 978 | | value = null; |
| | | 979 | | } |
| | | 980 | | else |
| | | 981 | | { |
| | 4 | 982 | | value = PolicyAssignment.DeserializePolicyAssignment(document.RootElement); |
| | | 983 | | } |
| | 4 | 984 | | return Response.FromValue(value, message.Response); |
| | | 985 | | } |
| | | 986 | | default: |
| | 0 | 987 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 988 | | } |
| | 4 | 989 | | } |
| | | 990 | | |
| | | 991 | | internal Core.HttpMessage CreateListForResourceGroupNextPageRequest(string nextLink, string resourceGroupName, s |
| | | 992 | | { |
| | 0 | 993 | | var message = _pipeline.CreateMessage(); |
| | 0 | 994 | | var request = message.Request; |
| | 0 | 995 | | request.Method = RequestMethod.Get; |
| | 0 | 996 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 997 | | uri.Reset(endpoint); |
| | 0 | 998 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 999 | | request.Uri = uri; |
| | 0 | 1000 | | return message; |
| | | 1001 | | } |
| | | 1002 | | |
| | | 1003 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro |
| | | 1004 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1005 | | /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param> |
| | | 1006 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1007 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1008 | | public async Task<Response<PolicyAssignmentListResult>> ListForResourceGroupNextPageAsync(string nextLink, strin |
| | | 1009 | | { |
| | 0 | 1010 | | if (nextLink == null) |
| | | 1011 | | { |
| | 0 | 1012 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1013 | | } |
| | 0 | 1014 | | if (resourceGroupName == null) |
| | | 1015 | | { |
| | 0 | 1016 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 1017 | | } |
| | | 1018 | | |
| | 0 | 1019 | | using var message = CreateListForResourceGroupNextPageRequest(nextLink, resourceGroupName, filter); |
| | 0 | 1020 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 1021 | | switch (message.Response.Status) |
| | | 1022 | | { |
| | | 1023 | | case 200: |
| | | 1024 | | { |
| | 0 | 1025 | | PolicyAssignmentListResult value = default; |
| | 0 | 1026 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 1027 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1028 | | { |
| | 0 | 1029 | | value = null; |
| | | 1030 | | } |
| | | 1031 | | else |
| | | 1032 | | { |
| | 0 | 1033 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1034 | | } |
| | 0 | 1035 | | return Response.FromValue(value, message.Response); |
| | | 1036 | | } |
| | | 1037 | | default: |
| | 0 | 1038 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 1039 | | } |
| | 0 | 1040 | | } |
| | | 1041 | | |
| | | 1042 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given resource gro |
| | | 1043 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1044 | | /// <param name="resourceGroupName"> The name of the resource group that contains policy assignments. </param> |
| | | 1045 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1046 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1047 | | public Response<PolicyAssignmentListResult> ListForResourceGroupNextPage(string nextLink, string resourceGroupNa |
| | | 1048 | | { |
| | 0 | 1049 | | if (nextLink == null) |
| | | 1050 | | { |
| | 0 | 1051 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1052 | | } |
| | 0 | 1053 | | if (resourceGroupName == null) |
| | | 1054 | | { |
| | 0 | 1055 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 1056 | | } |
| | | 1057 | | |
| | 0 | 1058 | | using var message = CreateListForResourceGroupNextPageRequest(nextLink, resourceGroupName, filter); |
| | 0 | 1059 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 1060 | | switch (message.Response.Status) |
| | | 1061 | | { |
| | | 1062 | | case 200: |
| | | 1063 | | { |
| | 0 | 1064 | | PolicyAssignmentListResult value = default; |
| | 0 | 1065 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 1066 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1067 | | { |
| | 0 | 1068 | | value = null; |
| | | 1069 | | } |
| | | 1070 | | else |
| | | 1071 | | { |
| | 0 | 1072 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1073 | | } |
| | 0 | 1074 | | return Response.FromValue(value, message.Response); |
| | | 1075 | | } |
| | | 1076 | | default: |
| | 0 | 1077 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 1078 | | } |
| | 0 | 1079 | | } |
| | | 1080 | | |
| | | 1081 | | internal Core.HttpMessage CreateListForResourceNextPageRequest(string nextLink, string resourceGroupName, string |
| | | 1082 | | { |
| | 0 | 1083 | | var message = _pipeline.CreateMessage(); |
| | 0 | 1084 | | var request = message.Request; |
| | 0 | 1085 | | request.Method = RequestMethod.Get; |
| | 0 | 1086 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 1087 | | uri.Reset(endpoint); |
| | 0 | 1088 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 1089 | | request.Uri = uri; |
| | 0 | 1090 | | return message; |
| | | 1091 | | } |
| | | 1092 | | |
| | | 1093 | | /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource |
| | | 1094 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1095 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param> |
| | | 1096 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace |
| | | 1097 | | /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param> |
| | | 1098 | | /// <param name="resourceType"> The resource type name. For example the type name of a web app is 'sites&ap |
| | | 1099 | | /// <param name="resourceName"> The name of the resource. </param> |
| | | 1100 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1101 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1102 | | public async Task<Response<PolicyAssignmentListResult>> ListForResourceNextPageAsync(string nextLink, string res |
| | | 1103 | | { |
| | 0 | 1104 | | if (nextLink == null) |
| | | 1105 | | { |
| | 0 | 1106 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1107 | | } |
| | 0 | 1108 | | if (resourceGroupName == null) |
| | | 1109 | | { |
| | 0 | 1110 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 1111 | | } |
| | 0 | 1112 | | if (resourceProviderNamespace == null) |
| | | 1113 | | { |
| | 0 | 1114 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | | 1115 | | } |
| | 0 | 1116 | | if (parentResourcePath == null) |
| | | 1117 | | { |
| | 0 | 1118 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | | 1119 | | } |
| | 0 | 1120 | | if (resourceType == null) |
| | | 1121 | | { |
| | 0 | 1122 | | throw new ArgumentNullException(nameof(resourceType)); |
| | | 1123 | | } |
| | 0 | 1124 | | if (resourceName == null) |
| | | 1125 | | { |
| | 0 | 1126 | | throw new ArgumentNullException(nameof(resourceName)); |
| | | 1127 | | } |
| | | 1128 | | |
| | 0 | 1129 | | using var message = CreateListForResourceNextPageRequest(nextLink, resourceGroupName, resourceProviderNamesp |
| | 0 | 1130 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 1131 | | switch (message.Response.Status) |
| | | 1132 | | { |
| | | 1133 | | case 200: |
| | | 1134 | | { |
| | 0 | 1135 | | PolicyAssignmentListResult value = default; |
| | 0 | 1136 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 1137 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1138 | | { |
| | 0 | 1139 | | value = null; |
| | | 1140 | | } |
| | | 1141 | | else |
| | | 1142 | | { |
| | 0 | 1143 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1144 | | } |
| | 0 | 1145 | | return Response.FromValue(value, message.Response); |
| | | 1146 | | } |
| | | 1147 | | default: |
| | 0 | 1148 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 1149 | | } |
| | 0 | 1150 | | } |
| | | 1151 | | |
| | | 1152 | | /// <summary> This operation retrieves the list of all policy assignments associated with the specified resource |
| | | 1153 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1154 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource. </param> |
| | | 1155 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. For example, the namespace |
| | | 1156 | | /// <param name="parentResourcePath"> The parent resource path. Use empty string if there is none. </param> |
| | | 1157 | | /// <param name="resourceType"> The resource type name. For example the type name of a web app is 'sites&ap |
| | | 1158 | | /// <param name="resourceName"> The name of the resource. </param> |
| | | 1159 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1160 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1161 | | public Response<PolicyAssignmentListResult> ListForResourceNextPage(string nextLink, string resourceGroupName, s |
| | | 1162 | | { |
| | 0 | 1163 | | if (nextLink == null) |
| | | 1164 | | { |
| | 0 | 1165 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1166 | | } |
| | 0 | 1167 | | if (resourceGroupName == null) |
| | | 1168 | | { |
| | 0 | 1169 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | | 1170 | | } |
| | 0 | 1171 | | if (resourceProviderNamespace == null) |
| | | 1172 | | { |
| | 0 | 1173 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | | 1174 | | } |
| | 0 | 1175 | | if (parentResourcePath == null) |
| | | 1176 | | { |
| | 0 | 1177 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | | 1178 | | } |
| | 0 | 1179 | | if (resourceType == null) |
| | | 1180 | | { |
| | 0 | 1181 | | throw new ArgumentNullException(nameof(resourceType)); |
| | | 1182 | | } |
| | 0 | 1183 | | if (resourceName == null) |
| | | 1184 | | { |
| | 0 | 1185 | | throw new ArgumentNullException(nameof(resourceName)); |
| | | 1186 | | } |
| | | 1187 | | |
| | 0 | 1188 | | using var message = CreateListForResourceNextPageRequest(nextLink, resourceGroupName, resourceProviderNamesp |
| | 0 | 1189 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 1190 | | switch (message.Response.Status) |
| | | 1191 | | { |
| | | 1192 | | case 200: |
| | | 1193 | | { |
| | 0 | 1194 | | PolicyAssignmentListResult value = default; |
| | 0 | 1195 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 1196 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1197 | | { |
| | 0 | 1198 | | value = null; |
| | | 1199 | | } |
| | | 1200 | | else |
| | | 1201 | | { |
| | 0 | 1202 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1203 | | } |
| | 0 | 1204 | | return Response.FromValue(value, message.Response); |
| | | 1205 | | } |
| | | 1206 | | default: |
| | 0 | 1207 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 1208 | | } |
| | 0 | 1209 | | } |
| | | 1210 | | |
| | | 1211 | | internal Core.HttpMessage CreateListForManagementGroupNextPageRequest(string nextLink, string managementGroupId, |
| | | 1212 | | { |
| | 0 | 1213 | | var message = _pipeline.CreateMessage(); |
| | 0 | 1214 | | var request = message.Request; |
| | 0 | 1215 | | request.Method = RequestMethod.Get; |
| | 0 | 1216 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 1217 | | uri.Reset(endpoint); |
| | 0 | 1218 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 1219 | | request.Uri = uri; |
| | 0 | 1220 | | return message; |
| | | 1221 | | } |
| | | 1222 | | |
| | | 1223 | | /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha |
| | | 1224 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1225 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | | 1226 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1227 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1228 | | public async Task<Response<PolicyAssignmentListResult>> ListForManagementGroupNextPageAsync(string nextLink, str |
| | | 1229 | | { |
| | 0 | 1230 | | if (nextLink == null) |
| | | 1231 | | { |
| | 0 | 1232 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1233 | | } |
| | 0 | 1234 | | if (managementGroupId == null) |
| | | 1235 | | { |
| | 0 | 1236 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | | 1237 | | } |
| | 0 | 1238 | | if (filter == null) |
| | | 1239 | | { |
| | 0 | 1240 | | throw new ArgumentNullException(nameof(filter)); |
| | | 1241 | | } |
| | | 1242 | | |
| | 0 | 1243 | | using var message = CreateListForManagementGroupNextPageRequest(nextLink, managementGroupId, filter); |
| | 0 | 1244 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 1245 | | switch (message.Response.Status) |
| | | 1246 | | { |
| | | 1247 | | case 200: |
| | | 1248 | | { |
| | 0 | 1249 | | PolicyAssignmentListResult value = default; |
| | 0 | 1250 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 1251 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1252 | | { |
| | 0 | 1253 | | value = null; |
| | | 1254 | | } |
| | | 1255 | | else |
| | | 1256 | | { |
| | 0 | 1257 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1258 | | } |
| | 0 | 1259 | | return Response.FromValue(value, message.Response); |
| | | 1260 | | } |
| | | 1261 | | default: |
| | 0 | 1262 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 1263 | | } |
| | 0 | 1264 | | } |
| | | 1265 | | |
| | | 1266 | | /// <summary> This operation retrieves the list of all policy assignments applicable to the management group tha |
| | | 1267 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1268 | | /// <param name="managementGroupId"> The ID of the management group. </param> |
| | | 1269 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1270 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1271 | | public Response<PolicyAssignmentListResult> ListForManagementGroupNextPage(string nextLink, string managementGro |
| | | 1272 | | { |
| | 0 | 1273 | | if (nextLink == null) |
| | | 1274 | | { |
| | 0 | 1275 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1276 | | } |
| | 0 | 1277 | | if (managementGroupId == null) |
| | | 1278 | | { |
| | 0 | 1279 | | throw new ArgumentNullException(nameof(managementGroupId)); |
| | | 1280 | | } |
| | 0 | 1281 | | if (filter == null) |
| | | 1282 | | { |
| | 0 | 1283 | | throw new ArgumentNullException(nameof(filter)); |
| | | 1284 | | } |
| | | 1285 | | |
| | 0 | 1286 | | using var message = CreateListForManagementGroupNextPageRequest(nextLink, managementGroupId, filter); |
| | 0 | 1287 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 1288 | | switch (message.Response.Status) |
| | | 1289 | | { |
| | | 1290 | | case 200: |
| | | 1291 | | { |
| | 0 | 1292 | | PolicyAssignmentListResult value = default; |
| | 0 | 1293 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 1294 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1295 | | { |
| | 0 | 1296 | | value = null; |
| | | 1297 | | } |
| | | 1298 | | else |
| | | 1299 | | { |
| | 0 | 1300 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1301 | | } |
| | 0 | 1302 | | return Response.FromValue(value, message.Response); |
| | | 1303 | | } |
| | | 1304 | | default: |
| | 0 | 1305 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 1306 | | } |
| | 0 | 1307 | | } |
| | | 1308 | | |
| | | 1309 | | internal Core.HttpMessage CreateListNextPageRequest(string nextLink, string filter) |
| | | 1310 | | { |
| | 0 | 1311 | | var message = _pipeline.CreateMessage(); |
| | 0 | 1312 | | var request = message.Request; |
| | 0 | 1313 | | request.Method = RequestMethod.Get; |
| | 0 | 1314 | | var uri = new RawRequestUriBuilder(); |
| | 0 | 1315 | | uri.Reset(endpoint); |
| | 0 | 1316 | | uri.AppendRawNextLink(nextLink, false); |
| | 0 | 1317 | | request.Uri = uri; |
| | 0 | 1318 | | return message; |
| | | 1319 | | } |
| | | 1320 | | |
| | | 1321 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription |
| | | 1322 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1323 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1324 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1325 | | public async Task<Response<PolicyAssignmentListResult>> ListNextPageAsync(string nextLink, string filter = null, |
| | | 1326 | | { |
| | 0 | 1327 | | if (nextLink == null) |
| | | 1328 | | { |
| | 0 | 1329 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1330 | | } |
| | | 1331 | | |
| | 0 | 1332 | | using var message = CreateListNextPageRequest(nextLink, filter); |
| | 0 | 1333 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| | 0 | 1334 | | switch (message.Response.Status) |
| | | 1335 | | { |
| | | 1336 | | case 200: |
| | | 1337 | | { |
| | 0 | 1338 | | PolicyAssignmentListResult value = default; |
| | 0 | 1339 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| | 0 | 1340 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1341 | | { |
| | 0 | 1342 | | value = null; |
| | | 1343 | | } |
| | | 1344 | | else |
| | | 1345 | | { |
| | 0 | 1346 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1347 | | } |
| | 0 | 1348 | | return Response.FromValue(value, message.Response); |
| | | 1349 | | } |
| | | 1350 | | default: |
| | 0 | 1351 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | | 1352 | | } |
| | 0 | 1353 | | } |
| | | 1354 | | |
| | | 1355 | | /// <summary> This operation retrieves the list of all policy assignments associated with the given subscription |
| | | 1356 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | | 1357 | | /// <param name="filter"> The filter to apply on the operation. Valid values for $filter are: 'atScope()&ap |
| | | 1358 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | | 1359 | | public Response<PolicyAssignmentListResult> ListNextPage(string nextLink, string filter = null, CancellationToke |
| | | 1360 | | { |
| | 0 | 1361 | | if (nextLink == null) |
| | | 1362 | | { |
| | 0 | 1363 | | throw new ArgumentNullException(nameof(nextLink)); |
| | | 1364 | | } |
| | | 1365 | | |
| | 0 | 1366 | | using var message = CreateListNextPageRequest(nextLink, filter); |
| | 0 | 1367 | | _pipeline.Send(message, cancellationToken); |
| | 0 | 1368 | | switch (message.Response.Status) |
| | | 1369 | | { |
| | | 1370 | | case 200: |
| | | 1371 | | { |
| | 0 | 1372 | | PolicyAssignmentListResult value = default; |
| | 0 | 1373 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| | 0 | 1374 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | | 1375 | | { |
| | 0 | 1376 | | value = null; |
| | | 1377 | | } |
| | | 1378 | | else |
| | | 1379 | | { |
| | 0 | 1380 | | value = PolicyAssignmentListResult.DeserializePolicyAssignmentListResult(document.RootElemen |
| | | 1381 | | } |
| | 0 | 1382 | | return Response.FromValue(value, message.Response); |
| | | 1383 | | } |
| | | 1384 | | default: |
| | 0 | 1385 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | | 1386 | | } |
| | 0 | 1387 | | } |
| | | 1388 | | } |
| | | 1389 | | } |