| | 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 ManagementLocksRestOperations |
| | 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 ManagementLocksRestOperations. </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 |
| 0 | 32 | | public ManagementLocksRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscrip |
| | 33 | | { |
| 0 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 0 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 0 | 40 | | this.subscriptionId = subscriptionId; |
| 0 | 41 | | this.endpoint = endpoint; |
| 0 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 43 | | _pipeline = pipeline; |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateCreateOrUpdateAtResourceGroupLevelRequest(string resourceGroupName, string lockN |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Put; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 54 | | uri.AppendPath(subscriptionId, true); |
| 0 | 55 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 56 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 57 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 58 | | uri.AppendPath(lockName, true); |
| 0 | 59 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 60 | | request.Uri = uri; |
| 0 | 61 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 62 | | var content = new Utf8JsonRequestContent(); |
| 0 | 63 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 64 | | request.Content = content; |
| 0 | 65 | | return message; |
| | 66 | | } |
| | 67 | |
|
| | 68 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 69 | | /// <param name="resourceGroupName"> The name of the resource group to lock. </param> |
| | 70 | | /// <param name="lockName"> The lock name. The lock name can be a maximum of 260 characters. It cannot contain & |
| | 71 | | /// <param name="parameters"> The management lock parameters. </param> |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public async Task<Response<ManagementLockObject>> CreateOrUpdateAtResourceGroupLevelAsync(string resourceGroupNa |
| | 74 | | { |
| 0 | 75 | | if (resourceGroupName == null) |
| | 76 | | { |
| 0 | 77 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 78 | | } |
| 0 | 79 | | if (lockName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(lockName)); |
| | 82 | | } |
| 0 | 83 | | if (parameters == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(parameters)); |
| | 86 | | } |
| | 87 | |
|
| 0 | 88 | | using var message = CreateCreateOrUpdateAtResourceGroupLevelRequest(resourceGroupName, lockName, parameters) |
| 0 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | case 201: |
| | 94 | | { |
| 0 | 95 | | ManagementLockObject value = default; |
| 0 | 96 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 97 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 98 | | { |
| 0 | 99 | | value = null; |
| | 100 | | } |
| | 101 | | else |
| | 102 | | { |
| 0 | 103 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 104 | | } |
| 0 | 105 | | return Response.FromValue(value, message.Response); |
| | 106 | | } |
| | 107 | | default: |
| 0 | 108 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 109 | | } |
| 0 | 110 | | } |
| | 111 | |
|
| | 112 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 113 | | /// <param name="resourceGroupName"> The name of the resource group to lock. </param> |
| | 114 | | /// <param name="lockName"> The lock name. The lock name can be a maximum of 260 characters. It cannot contain & |
| | 115 | | /// <param name="parameters"> The management lock parameters. </param> |
| | 116 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 117 | | public Response<ManagementLockObject> CreateOrUpdateAtResourceGroupLevel(string resourceGroupName, string lockNa |
| | 118 | | { |
| 0 | 119 | | if (resourceGroupName == null) |
| | 120 | | { |
| 0 | 121 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 122 | | } |
| 0 | 123 | | if (lockName == null) |
| | 124 | | { |
| 0 | 125 | | throw new ArgumentNullException(nameof(lockName)); |
| | 126 | | } |
| 0 | 127 | | if (parameters == null) |
| | 128 | | { |
| 0 | 129 | | throw new ArgumentNullException(nameof(parameters)); |
| | 130 | | } |
| | 131 | |
|
| 0 | 132 | | using var message = CreateCreateOrUpdateAtResourceGroupLevelRequest(resourceGroupName, lockName, parameters) |
| 0 | 133 | | _pipeline.Send(message, cancellationToken); |
| 0 | 134 | | switch (message.Response.Status) |
| | 135 | | { |
| | 136 | | case 200: |
| | 137 | | case 201: |
| | 138 | | { |
| 0 | 139 | | ManagementLockObject value = default; |
| 0 | 140 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 141 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 142 | | { |
| 0 | 143 | | value = null; |
| | 144 | | } |
| | 145 | | else |
| | 146 | | { |
| 0 | 147 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 148 | | } |
| 0 | 149 | | return Response.FromValue(value, message.Response); |
| | 150 | | } |
| | 151 | | default: |
| 0 | 152 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 153 | | } |
| 0 | 154 | | } |
| | 155 | |
|
| | 156 | | internal Core.HttpMessage CreateDeleteAtResourceGroupLevelRequest(string resourceGroupName, string lockName) |
| | 157 | | { |
| 0 | 158 | | var message = _pipeline.CreateMessage(); |
| 0 | 159 | | var request = message.Request; |
| 0 | 160 | | request.Method = RequestMethod.Delete; |
| 0 | 161 | | var uri = new RawRequestUriBuilder(); |
| 0 | 162 | | uri.Reset(endpoint); |
| 0 | 163 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 164 | | uri.AppendPath(subscriptionId, true); |
| 0 | 165 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 166 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 167 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 168 | | uri.AppendPath(lockName, true); |
| 0 | 169 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 170 | | request.Uri = uri; |
| 0 | 171 | | return message; |
| | 172 | | } |
| | 173 | |
|
| | 174 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 175 | | /// <param name="resourceGroupName"> The name of the resource group containing the lock. </param> |
| | 176 | | /// <param name="lockName"> The name of lock to delete. </param> |
| | 177 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 178 | | public async Task<Response> DeleteAtResourceGroupLevelAsync(string resourceGroupName, string lockName, Cancellat |
| | 179 | | { |
| 0 | 180 | | if (resourceGroupName == null) |
| | 181 | | { |
| 0 | 182 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 183 | | } |
| 0 | 184 | | if (lockName == null) |
| | 185 | | { |
| 0 | 186 | | throw new ArgumentNullException(nameof(lockName)); |
| | 187 | | } |
| | 188 | |
|
| 0 | 189 | | using var message = CreateDeleteAtResourceGroupLevelRequest(resourceGroupName, lockName); |
| 0 | 190 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 191 | | switch (message.Response.Status) |
| | 192 | | { |
| | 193 | | case 200: |
| | 194 | | case 204: |
| 0 | 195 | | return message.Response; |
| | 196 | | default: |
| 0 | 197 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 198 | | } |
| 0 | 199 | | } |
| | 200 | |
|
| | 201 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 202 | | /// <param name="resourceGroupName"> The name of the resource group containing the lock. </param> |
| | 203 | | /// <param name="lockName"> The name of lock to delete. </param> |
| | 204 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 205 | | public Response DeleteAtResourceGroupLevel(string resourceGroupName, string lockName, CancellationToken cancella |
| | 206 | | { |
| 0 | 207 | | if (resourceGroupName == null) |
| | 208 | | { |
| 0 | 209 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 210 | | } |
| 0 | 211 | | if (lockName == null) |
| | 212 | | { |
| 0 | 213 | | throw new ArgumentNullException(nameof(lockName)); |
| | 214 | | } |
| | 215 | |
|
| 0 | 216 | | using var message = CreateDeleteAtResourceGroupLevelRequest(resourceGroupName, lockName); |
| 0 | 217 | | _pipeline.Send(message, cancellationToken); |
| 0 | 218 | | switch (message.Response.Status) |
| | 219 | | { |
| | 220 | | case 200: |
| | 221 | | case 204: |
| 0 | 222 | | return message.Response; |
| | 223 | | default: |
| 0 | 224 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 225 | | } |
| 0 | 226 | | } |
| | 227 | |
|
| | 228 | | internal Core.HttpMessage CreateGetAtResourceGroupLevelRequest(string resourceGroupName, string lockName) |
| | 229 | | { |
| 0 | 230 | | var message = _pipeline.CreateMessage(); |
| 0 | 231 | | var request = message.Request; |
| 0 | 232 | | request.Method = RequestMethod.Get; |
| 0 | 233 | | var uri = new RawRequestUriBuilder(); |
| 0 | 234 | | uri.Reset(endpoint); |
| 0 | 235 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 236 | | uri.AppendPath(subscriptionId, true); |
| 0 | 237 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 238 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 239 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 240 | | uri.AppendPath(lockName, true); |
| 0 | 241 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 242 | | request.Uri = uri; |
| 0 | 243 | | return message; |
| | 244 | | } |
| | 245 | |
|
| | 246 | | /// <summary> Gets a management lock at the resource group level. </summary> |
| | 247 | | /// <param name="resourceGroupName"> The name of the locked resource group. </param> |
| | 248 | | /// <param name="lockName"> The name of the lock to get. </param> |
| | 249 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 250 | | public async Task<Response<ManagementLockObject>> GetAtResourceGroupLevelAsync(string resourceGroupName, string |
| | 251 | | { |
| 0 | 252 | | if (resourceGroupName == null) |
| | 253 | | { |
| 0 | 254 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 255 | | } |
| 0 | 256 | | if (lockName == null) |
| | 257 | | { |
| 0 | 258 | | throw new ArgumentNullException(nameof(lockName)); |
| | 259 | | } |
| | 260 | |
|
| 0 | 261 | | using var message = CreateGetAtResourceGroupLevelRequest(resourceGroupName, lockName); |
| 0 | 262 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 263 | | switch (message.Response.Status) |
| | 264 | | { |
| | 265 | | case 200: |
| | 266 | | { |
| 0 | 267 | | ManagementLockObject value = default; |
| 0 | 268 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 269 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 270 | | { |
| 0 | 271 | | value = null; |
| | 272 | | } |
| | 273 | | else |
| | 274 | | { |
| 0 | 275 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 276 | | } |
| 0 | 277 | | return Response.FromValue(value, message.Response); |
| | 278 | | } |
| | 279 | | default: |
| 0 | 280 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 281 | | } |
| 0 | 282 | | } |
| | 283 | |
|
| | 284 | | /// <summary> Gets a management lock at the resource group level. </summary> |
| | 285 | | /// <param name="resourceGroupName"> The name of the locked resource group. </param> |
| | 286 | | /// <param name="lockName"> The name of the lock to get. </param> |
| | 287 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 288 | | public Response<ManagementLockObject> GetAtResourceGroupLevel(string resourceGroupName, string lockName, Cancell |
| | 289 | | { |
| 0 | 290 | | if (resourceGroupName == null) |
| | 291 | | { |
| 0 | 292 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 293 | | } |
| 0 | 294 | | if (lockName == null) |
| | 295 | | { |
| 0 | 296 | | throw new ArgumentNullException(nameof(lockName)); |
| | 297 | | } |
| | 298 | |
|
| 0 | 299 | | using var message = CreateGetAtResourceGroupLevelRequest(resourceGroupName, lockName); |
| 0 | 300 | | _pipeline.Send(message, cancellationToken); |
| 0 | 301 | | switch (message.Response.Status) |
| | 302 | | { |
| | 303 | | case 200: |
| | 304 | | { |
| 0 | 305 | | ManagementLockObject value = default; |
| 0 | 306 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 307 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 308 | | { |
| 0 | 309 | | value = null; |
| | 310 | | } |
| | 311 | | else |
| | 312 | | { |
| 0 | 313 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 314 | | } |
| 0 | 315 | | return Response.FromValue(value, message.Response); |
| | 316 | | } |
| | 317 | | default: |
| 0 | 318 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 319 | | } |
| 0 | 320 | | } |
| | 321 | |
|
| | 322 | | internal Core.HttpMessage CreateCreateOrUpdateByScopeRequest(string scope, string lockName, ManagementLockObject |
| | 323 | | { |
| 0 | 324 | | var message = _pipeline.CreateMessage(); |
| 0 | 325 | | var request = message.Request; |
| 0 | 326 | | request.Method = RequestMethod.Put; |
| 0 | 327 | | var uri = new RawRequestUriBuilder(); |
| 0 | 328 | | uri.Reset(endpoint); |
| 0 | 329 | | uri.AppendPath("/", false); |
| 0 | 330 | | uri.AppendPath(scope, true); |
| 0 | 331 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 332 | | uri.AppendPath(lockName, true); |
| 0 | 333 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 334 | | request.Uri = uri; |
| 0 | 335 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 336 | | var content = new Utf8JsonRequestContent(); |
| 0 | 337 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 338 | | request.Content = content; |
| 0 | 339 | | return message; |
| | 340 | | } |
| | 341 | |
|
| | 342 | | /// <summary> Create or update a management lock by scope. </summary> |
| | 343 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 344 | | /// <param name="lockName"> The name of lock. </param> |
| | 345 | | /// <param name="parameters"> Create or update management lock parameters. </param> |
| | 346 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 347 | | public async Task<Response<ManagementLockObject>> CreateOrUpdateByScopeAsync(string scope, string lockName, Mana |
| | 348 | | { |
| 0 | 349 | | if (scope == null) |
| | 350 | | { |
| 0 | 351 | | throw new ArgumentNullException(nameof(scope)); |
| | 352 | | } |
| 0 | 353 | | if (lockName == null) |
| | 354 | | { |
| 0 | 355 | | throw new ArgumentNullException(nameof(lockName)); |
| | 356 | | } |
| 0 | 357 | | if (parameters == null) |
| | 358 | | { |
| 0 | 359 | | throw new ArgumentNullException(nameof(parameters)); |
| | 360 | | } |
| | 361 | |
|
| 0 | 362 | | using var message = CreateCreateOrUpdateByScopeRequest(scope, lockName, parameters); |
| 0 | 363 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 364 | | switch (message.Response.Status) |
| | 365 | | { |
| | 366 | | case 200: |
| | 367 | | case 201: |
| | 368 | | { |
| 0 | 369 | | ManagementLockObject value = default; |
| 0 | 370 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 371 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 372 | | { |
| 0 | 373 | | value = null; |
| | 374 | | } |
| | 375 | | else |
| | 376 | | { |
| 0 | 377 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 378 | | } |
| 0 | 379 | | return Response.FromValue(value, message.Response); |
| | 380 | | } |
| | 381 | | default: |
| 0 | 382 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 383 | | } |
| 0 | 384 | | } |
| | 385 | |
|
| | 386 | | /// <summary> Create or update a management lock by scope. </summary> |
| | 387 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 388 | | /// <param name="lockName"> The name of lock. </param> |
| | 389 | | /// <param name="parameters"> Create or update management lock parameters. </param> |
| | 390 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 391 | | public Response<ManagementLockObject> CreateOrUpdateByScope(string scope, string lockName, ManagementLockObject |
| | 392 | | { |
| 0 | 393 | | if (scope == null) |
| | 394 | | { |
| 0 | 395 | | throw new ArgumentNullException(nameof(scope)); |
| | 396 | | } |
| 0 | 397 | | if (lockName == null) |
| | 398 | | { |
| 0 | 399 | | throw new ArgumentNullException(nameof(lockName)); |
| | 400 | | } |
| 0 | 401 | | if (parameters == null) |
| | 402 | | { |
| 0 | 403 | | throw new ArgumentNullException(nameof(parameters)); |
| | 404 | | } |
| | 405 | |
|
| 0 | 406 | | using var message = CreateCreateOrUpdateByScopeRequest(scope, lockName, parameters); |
| 0 | 407 | | _pipeline.Send(message, cancellationToken); |
| 0 | 408 | | switch (message.Response.Status) |
| | 409 | | { |
| | 410 | | case 200: |
| | 411 | | case 201: |
| | 412 | | { |
| 0 | 413 | | ManagementLockObject value = default; |
| 0 | 414 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 415 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 416 | | { |
| 0 | 417 | | value = null; |
| | 418 | | } |
| | 419 | | else |
| | 420 | | { |
| 0 | 421 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 422 | | } |
| 0 | 423 | | return Response.FromValue(value, message.Response); |
| | 424 | | } |
| | 425 | | default: |
| 0 | 426 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 427 | | } |
| 0 | 428 | | } |
| | 429 | |
|
| | 430 | | internal Core.HttpMessage CreateDeleteByScopeRequest(string scope, string lockName) |
| | 431 | | { |
| 0 | 432 | | var message = _pipeline.CreateMessage(); |
| 0 | 433 | | var request = message.Request; |
| 0 | 434 | | request.Method = RequestMethod.Delete; |
| 0 | 435 | | var uri = new RawRequestUriBuilder(); |
| 0 | 436 | | uri.Reset(endpoint); |
| 0 | 437 | | uri.AppendPath("/", false); |
| 0 | 438 | | uri.AppendPath(scope, true); |
| 0 | 439 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 440 | | uri.AppendPath(lockName, true); |
| 0 | 441 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 442 | | request.Uri = uri; |
| 0 | 443 | | return message; |
| | 444 | | } |
| | 445 | |
|
| | 446 | | /// <summary> Delete a management lock by scope. </summary> |
| | 447 | | /// <param name="scope"> The scope for the lock. </param> |
| | 448 | | /// <param name="lockName"> The name of lock. </param> |
| | 449 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 450 | | public async Task<Response> DeleteByScopeAsync(string scope, string lockName, CancellationToken cancellationToke |
| | 451 | | { |
| 0 | 452 | | if (scope == null) |
| | 453 | | { |
| 0 | 454 | | throw new ArgumentNullException(nameof(scope)); |
| | 455 | | } |
| 0 | 456 | | if (lockName == null) |
| | 457 | | { |
| 0 | 458 | | throw new ArgumentNullException(nameof(lockName)); |
| | 459 | | } |
| | 460 | |
|
| 0 | 461 | | using var message = CreateDeleteByScopeRequest(scope, lockName); |
| 0 | 462 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 463 | | switch (message.Response.Status) |
| | 464 | | { |
| | 465 | | case 200: |
| | 466 | | case 204: |
| 0 | 467 | | return message.Response; |
| | 468 | | default: |
| 0 | 469 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 470 | | } |
| 0 | 471 | | } |
| | 472 | |
|
| | 473 | | /// <summary> Delete a management lock by scope. </summary> |
| | 474 | | /// <param name="scope"> The scope for the lock. </param> |
| | 475 | | /// <param name="lockName"> The name of lock. </param> |
| | 476 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 477 | | public Response DeleteByScope(string scope, string lockName, CancellationToken cancellationToken = default) |
| | 478 | | { |
| 0 | 479 | | if (scope == null) |
| | 480 | | { |
| 0 | 481 | | throw new ArgumentNullException(nameof(scope)); |
| | 482 | | } |
| 0 | 483 | | if (lockName == null) |
| | 484 | | { |
| 0 | 485 | | throw new ArgumentNullException(nameof(lockName)); |
| | 486 | | } |
| | 487 | |
|
| 0 | 488 | | using var message = CreateDeleteByScopeRequest(scope, lockName); |
| 0 | 489 | | _pipeline.Send(message, cancellationToken); |
| 0 | 490 | | switch (message.Response.Status) |
| | 491 | | { |
| | 492 | | case 200: |
| | 493 | | case 204: |
| 0 | 494 | | return message.Response; |
| | 495 | | default: |
| 0 | 496 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 497 | | } |
| 0 | 498 | | } |
| | 499 | |
|
| | 500 | | internal Core.HttpMessage CreateGetByScopeRequest(string scope, string lockName) |
| | 501 | | { |
| 0 | 502 | | var message = _pipeline.CreateMessage(); |
| 0 | 503 | | var request = message.Request; |
| 0 | 504 | | request.Method = RequestMethod.Get; |
| 0 | 505 | | var uri = new RawRequestUriBuilder(); |
| 0 | 506 | | uri.Reset(endpoint); |
| 0 | 507 | | uri.AppendPath("/", false); |
| 0 | 508 | | uri.AppendPath(scope, true); |
| 0 | 509 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 510 | | uri.AppendPath(lockName, true); |
| 0 | 511 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 512 | | request.Uri = uri; |
| 0 | 513 | | return message; |
| | 514 | | } |
| | 515 | |
|
| | 516 | | /// <summary> Get a management lock by scope. </summary> |
| | 517 | | /// <param name="scope"> The scope for the lock. </param> |
| | 518 | | /// <param name="lockName"> The name of lock. </param> |
| | 519 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 520 | | public async Task<Response<ManagementLockObject>> GetByScopeAsync(string scope, string lockName, CancellationTok |
| | 521 | | { |
| 0 | 522 | | if (scope == null) |
| | 523 | | { |
| 0 | 524 | | throw new ArgumentNullException(nameof(scope)); |
| | 525 | | } |
| 0 | 526 | | if (lockName == null) |
| | 527 | | { |
| 0 | 528 | | throw new ArgumentNullException(nameof(lockName)); |
| | 529 | | } |
| | 530 | |
|
| 0 | 531 | | using var message = CreateGetByScopeRequest(scope, lockName); |
| 0 | 532 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 533 | | switch (message.Response.Status) |
| | 534 | | { |
| | 535 | | case 200: |
| | 536 | | { |
| 0 | 537 | | ManagementLockObject value = default; |
| 0 | 538 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 539 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 540 | | { |
| 0 | 541 | | value = null; |
| | 542 | | } |
| | 543 | | else |
| | 544 | | { |
| 0 | 545 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 546 | | } |
| 0 | 547 | | return Response.FromValue(value, message.Response); |
| | 548 | | } |
| | 549 | | default: |
| 0 | 550 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 551 | | } |
| 0 | 552 | | } |
| | 553 | |
|
| | 554 | | /// <summary> Get a management lock by scope. </summary> |
| | 555 | | /// <param name="scope"> The scope for the lock. </param> |
| | 556 | | /// <param name="lockName"> The name of lock. </param> |
| | 557 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 558 | | public Response<ManagementLockObject> GetByScope(string scope, string lockName, CancellationToken cancellationTo |
| | 559 | | { |
| 0 | 560 | | if (scope == null) |
| | 561 | | { |
| 0 | 562 | | throw new ArgumentNullException(nameof(scope)); |
| | 563 | | } |
| 0 | 564 | | if (lockName == null) |
| | 565 | | { |
| 0 | 566 | | throw new ArgumentNullException(nameof(lockName)); |
| | 567 | | } |
| | 568 | |
|
| 0 | 569 | | using var message = CreateGetByScopeRequest(scope, lockName); |
| 0 | 570 | | _pipeline.Send(message, cancellationToken); |
| 0 | 571 | | switch (message.Response.Status) |
| | 572 | | { |
| | 573 | | case 200: |
| | 574 | | { |
| 0 | 575 | | ManagementLockObject value = default; |
| 0 | 576 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 577 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 578 | | { |
| 0 | 579 | | value = null; |
| | 580 | | } |
| | 581 | | else |
| | 582 | | { |
| 0 | 583 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 584 | | } |
| 0 | 585 | | return Response.FromValue(value, message.Response); |
| | 586 | | } |
| | 587 | | default: |
| 0 | 588 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 589 | | } |
| 0 | 590 | | } |
| | 591 | |
|
| | 592 | | internal Core.HttpMessage CreateCreateOrUpdateAtResourceLevelRequest(string resourceGroupName, string resourcePr |
| | 593 | | { |
| 0 | 594 | | var message = _pipeline.CreateMessage(); |
| 0 | 595 | | var request = message.Request; |
| 0 | 596 | | request.Method = RequestMethod.Put; |
| 0 | 597 | | var uri = new RawRequestUriBuilder(); |
| 0 | 598 | | uri.Reset(endpoint); |
| 0 | 599 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 600 | | uri.AppendPath(subscriptionId, true); |
| 0 | 601 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 602 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 603 | | uri.AppendPath("/providers/", false); |
| 0 | 604 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 605 | | uri.AppendPath("/", false); |
| 0 | 606 | | uri.AppendPath(parentResourcePath, false); |
| 0 | 607 | | uri.AppendPath("/", false); |
| 0 | 608 | | uri.AppendPath(resourceType, false); |
| 0 | 609 | | uri.AppendPath("/", false); |
| 0 | 610 | | uri.AppendPath(resourceName, true); |
| 0 | 611 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 612 | | uri.AppendPath(lockName, true); |
| 0 | 613 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 614 | | request.Uri = uri; |
| 0 | 615 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 616 | | var content = new Utf8JsonRequestContent(); |
| 0 | 617 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 618 | | request.Content = content; |
| 0 | 619 | | return message; |
| | 620 | | } |
| | 621 | |
|
| | 622 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 623 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to lock. </param> |
| | 624 | | /// <param name="resourceProviderNamespace"> The resource provider namespace of the resource to lock. </param> |
| | 625 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 626 | | /// <param name="resourceType"> The resource type of the resource to lock. </param> |
| | 627 | | /// <param name="resourceName"> The name of the resource to lock. </param> |
| | 628 | | /// <param name="lockName"> The name of lock. The lock name can be a maximum of 260 characters. It cannot contai |
| | 629 | | /// <param name="parameters"> Parameters for creating or updating a management lock. </param> |
| | 630 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 631 | | public async Task<Response<ManagementLockObject>> CreateOrUpdateAtResourceLevelAsync(string resourceGroupName, s |
| | 632 | | { |
| 0 | 633 | | if (resourceGroupName == null) |
| | 634 | | { |
| 0 | 635 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 636 | | } |
| 0 | 637 | | if (resourceProviderNamespace == null) |
| | 638 | | { |
| 0 | 639 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 640 | | } |
| 0 | 641 | | if (parentResourcePath == null) |
| | 642 | | { |
| 0 | 643 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 644 | | } |
| 0 | 645 | | if (resourceType == null) |
| | 646 | | { |
| 0 | 647 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 648 | | } |
| 0 | 649 | | if (resourceName == null) |
| | 650 | | { |
| 0 | 651 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 652 | | } |
| 0 | 653 | | if (lockName == null) |
| | 654 | | { |
| 0 | 655 | | throw new ArgumentNullException(nameof(lockName)); |
| | 656 | | } |
| 0 | 657 | | if (parameters == null) |
| | 658 | | { |
| 0 | 659 | | throw new ArgumentNullException(nameof(parameters)); |
| | 660 | | } |
| | 661 | |
|
| 0 | 662 | | using var message = CreateCreateOrUpdateAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, |
| 0 | 663 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 664 | | switch (message.Response.Status) |
| | 665 | | { |
| | 666 | | case 200: |
| | 667 | | case 201: |
| | 668 | | { |
| 0 | 669 | | ManagementLockObject value = default; |
| 0 | 670 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 671 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 672 | | { |
| 0 | 673 | | value = null; |
| | 674 | | } |
| | 675 | | else |
| | 676 | | { |
| 0 | 677 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 678 | | } |
| 0 | 679 | | return Response.FromValue(value, message.Response); |
| | 680 | | } |
| | 681 | | default: |
| 0 | 682 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 683 | | } |
| 0 | 684 | | } |
| | 685 | |
|
| | 686 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 687 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource to lock. </param> |
| | 688 | | /// <param name="resourceProviderNamespace"> The resource provider namespace of the resource to lock. </param> |
| | 689 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 690 | | /// <param name="resourceType"> The resource type of the resource to lock. </param> |
| | 691 | | /// <param name="resourceName"> The name of the resource to lock. </param> |
| | 692 | | /// <param name="lockName"> The name of lock. The lock name can be a maximum of 260 characters. It cannot contai |
| | 693 | | /// <param name="parameters"> Parameters for creating or updating a management lock. </param> |
| | 694 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 695 | | public Response<ManagementLockObject> CreateOrUpdateAtResourceLevel(string resourceGroupName, string resourcePro |
| | 696 | | { |
| 0 | 697 | | if (resourceGroupName == null) |
| | 698 | | { |
| 0 | 699 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 700 | | } |
| 0 | 701 | | if (resourceProviderNamespace == null) |
| | 702 | | { |
| 0 | 703 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 704 | | } |
| 0 | 705 | | if (parentResourcePath == null) |
| | 706 | | { |
| 0 | 707 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 708 | | } |
| 0 | 709 | | if (resourceType == null) |
| | 710 | | { |
| 0 | 711 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 712 | | } |
| 0 | 713 | | if (resourceName == null) |
| | 714 | | { |
| 0 | 715 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 716 | | } |
| 0 | 717 | | if (lockName == null) |
| | 718 | | { |
| 0 | 719 | | throw new ArgumentNullException(nameof(lockName)); |
| | 720 | | } |
| 0 | 721 | | if (parameters == null) |
| | 722 | | { |
| 0 | 723 | | throw new ArgumentNullException(nameof(parameters)); |
| | 724 | | } |
| | 725 | |
|
| 0 | 726 | | using var message = CreateCreateOrUpdateAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, |
| 0 | 727 | | _pipeline.Send(message, cancellationToken); |
| 0 | 728 | | switch (message.Response.Status) |
| | 729 | | { |
| | 730 | | case 200: |
| | 731 | | case 201: |
| | 732 | | { |
| 0 | 733 | | ManagementLockObject value = default; |
| 0 | 734 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 735 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 736 | | { |
| 0 | 737 | | value = null; |
| | 738 | | } |
| | 739 | | else |
| | 740 | | { |
| 0 | 741 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 742 | | } |
| 0 | 743 | | return Response.FromValue(value, message.Response); |
| | 744 | | } |
| | 745 | | default: |
| 0 | 746 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 747 | | } |
| 0 | 748 | | } |
| | 749 | |
|
| | 750 | | internal Core.HttpMessage CreateDeleteAtResourceLevelRequest(string resourceGroupName, string resourceProviderNa |
| | 751 | | { |
| 0 | 752 | | var message = _pipeline.CreateMessage(); |
| 0 | 753 | | var request = message.Request; |
| 0 | 754 | | request.Method = RequestMethod.Delete; |
| 0 | 755 | | var uri = new RawRequestUriBuilder(); |
| 0 | 756 | | uri.Reset(endpoint); |
| 0 | 757 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 758 | | uri.AppendPath(subscriptionId, true); |
| 0 | 759 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 760 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 761 | | uri.AppendPath("/providers/", false); |
| 0 | 762 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 763 | | uri.AppendPath("/", false); |
| 0 | 764 | | uri.AppendPath(parentResourcePath, false); |
| 0 | 765 | | uri.AppendPath("/", false); |
| 0 | 766 | | uri.AppendPath(resourceType, false); |
| 0 | 767 | | uri.AppendPath("/", false); |
| 0 | 768 | | uri.AppendPath(resourceName, true); |
| 0 | 769 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 770 | | uri.AppendPath(lockName, true); |
| 0 | 771 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 772 | | request.Uri = uri; |
| 0 | 773 | | return message; |
| | 774 | | } |
| | 775 | |
|
| | 776 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 777 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource with the lock to del |
| | 778 | | /// <param name="resourceProviderNamespace"> The resource provider namespace of the resource with the lock to de |
| | 779 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 780 | | /// <param name="resourceType"> The resource type of the resource with the lock to delete. </param> |
| | 781 | | /// <param name="resourceName"> The name of the resource with the lock to delete. </param> |
| | 782 | | /// <param name="lockName"> The name of the lock to delete. </param> |
| | 783 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 784 | | public async Task<Response> DeleteAtResourceLevelAsync(string resourceGroupName, string resourceProviderNamespac |
| | 785 | | { |
| 0 | 786 | | if (resourceGroupName == null) |
| | 787 | | { |
| 0 | 788 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 789 | | } |
| 0 | 790 | | if (resourceProviderNamespace == null) |
| | 791 | | { |
| 0 | 792 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 793 | | } |
| 0 | 794 | | if (parentResourcePath == null) |
| | 795 | | { |
| 0 | 796 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 797 | | } |
| 0 | 798 | | if (resourceType == null) |
| | 799 | | { |
| 0 | 800 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 801 | | } |
| 0 | 802 | | if (resourceName == null) |
| | 803 | | { |
| 0 | 804 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 805 | | } |
| 0 | 806 | | if (lockName == null) |
| | 807 | | { |
| 0 | 808 | | throw new ArgumentNullException(nameof(lockName)); |
| | 809 | | } |
| | 810 | |
|
| 0 | 811 | | using var message = CreateDeleteAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentR |
| 0 | 812 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 813 | | switch (message.Response.Status) |
| | 814 | | { |
| | 815 | | case 200: |
| | 816 | | case 204: |
| 0 | 817 | | return message.Response; |
| | 818 | | default: |
| 0 | 819 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 820 | | } |
| 0 | 821 | | } |
| | 822 | |
|
| | 823 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 824 | | /// <param name="resourceGroupName"> The name of the resource group containing the resource with the lock to del |
| | 825 | | /// <param name="resourceProviderNamespace"> The resource provider namespace of the resource with the lock to de |
| | 826 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 827 | | /// <param name="resourceType"> The resource type of the resource with the lock to delete. </param> |
| | 828 | | /// <param name="resourceName"> The name of the resource with the lock to delete. </param> |
| | 829 | | /// <param name="lockName"> The name of the lock to delete. </param> |
| | 830 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 831 | | public Response DeleteAtResourceLevel(string resourceGroupName, string resourceProviderNamespace, string parentR |
| | 832 | | { |
| 0 | 833 | | if (resourceGroupName == null) |
| | 834 | | { |
| 0 | 835 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 836 | | } |
| 0 | 837 | | if (resourceProviderNamespace == null) |
| | 838 | | { |
| 0 | 839 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 840 | | } |
| 0 | 841 | | if (parentResourcePath == null) |
| | 842 | | { |
| 0 | 843 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 844 | | } |
| 0 | 845 | | if (resourceType == null) |
| | 846 | | { |
| 0 | 847 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 848 | | } |
| 0 | 849 | | if (resourceName == null) |
| | 850 | | { |
| 0 | 851 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 852 | | } |
| 0 | 853 | | if (lockName == null) |
| | 854 | | { |
| 0 | 855 | | throw new ArgumentNullException(nameof(lockName)); |
| | 856 | | } |
| | 857 | |
|
| 0 | 858 | | using var message = CreateDeleteAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentR |
| 0 | 859 | | _pipeline.Send(message, cancellationToken); |
| 0 | 860 | | switch (message.Response.Status) |
| | 861 | | { |
| | 862 | | case 200: |
| | 863 | | case 204: |
| 0 | 864 | | return message.Response; |
| | 865 | | default: |
| 0 | 866 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 867 | | } |
| 0 | 868 | | } |
| | 869 | |
|
| | 870 | | internal Core.HttpMessage CreateGetAtResourceLevelRequest(string resourceGroupName, string resourceProviderNames |
| | 871 | | { |
| 0 | 872 | | var message = _pipeline.CreateMessage(); |
| 0 | 873 | | var request = message.Request; |
| 0 | 874 | | request.Method = RequestMethod.Get; |
| 0 | 875 | | var uri = new RawRequestUriBuilder(); |
| 0 | 876 | | uri.Reset(endpoint); |
| 0 | 877 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 878 | | uri.AppendPath(subscriptionId, true); |
| 0 | 879 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 880 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 881 | | uri.AppendPath("/providers/", false); |
| 0 | 882 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 883 | | uri.AppendPath("/", false); |
| 0 | 884 | | uri.AppendPath(parentResourcePath, false); |
| 0 | 885 | | uri.AppendPath("/", false); |
| 0 | 886 | | uri.AppendPath(resourceType, false); |
| 0 | 887 | | uri.AppendPath("/", false); |
| 0 | 888 | | uri.AppendPath(resourceName, true); |
| 0 | 889 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 890 | | uri.AppendPath(lockName, true); |
| 0 | 891 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 892 | | request.Uri = uri; |
| 0 | 893 | | return message; |
| | 894 | | } |
| | 895 | |
|
| | 896 | | /// <summary> Get the management lock of a resource or any level below resource. </summary> |
| | 897 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 898 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 899 | | /// <param name="parentResourcePath"> An extra path parameter needed in some services, like SQL Databases. </par |
| | 900 | | /// <param name="resourceType"> The type of the resource. </param> |
| | 901 | | /// <param name="resourceName"> The name of the resource. </param> |
| | 902 | | /// <param name="lockName"> The name of lock. </param> |
| | 903 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 904 | | public async Task<Response<ManagementLockObject>> GetAtResourceLevelAsync(string resourceGroupName, string resou |
| | 905 | | { |
| 0 | 906 | | if (resourceGroupName == null) |
| | 907 | | { |
| 0 | 908 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 909 | | } |
| 0 | 910 | | if (resourceProviderNamespace == null) |
| | 911 | | { |
| 0 | 912 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 913 | | } |
| 0 | 914 | | if (parentResourcePath == null) |
| | 915 | | { |
| 0 | 916 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 917 | | } |
| 0 | 918 | | if (resourceType == null) |
| | 919 | | { |
| 0 | 920 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 921 | | } |
| 0 | 922 | | if (resourceName == null) |
| | 923 | | { |
| 0 | 924 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 925 | | } |
| 0 | 926 | | if (lockName == null) |
| | 927 | | { |
| 0 | 928 | | throw new ArgumentNullException(nameof(lockName)); |
| | 929 | | } |
| | 930 | |
|
| 0 | 931 | | using var message = CreateGetAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentReso |
| 0 | 932 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 933 | | switch (message.Response.Status) |
| | 934 | | { |
| | 935 | | case 200: |
| | 936 | | { |
| 0 | 937 | | ManagementLockObject value = default; |
| 0 | 938 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 939 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 940 | | { |
| 0 | 941 | | value = null; |
| | 942 | | } |
| | 943 | | else |
| | 944 | | { |
| 0 | 945 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 946 | | } |
| 0 | 947 | | return Response.FromValue(value, message.Response); |
| | 948 | | } |
| | 949 | | default: |
| 0 | 950 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 951 | | } |
| 0 | 952 | | } |
| | 953 | |
|
| | 954 | | /// <summary> Get the management lock of a resource or any level below resource. </summary> |
| | 955 | | /// <param name="resourceGroupName"> The name of the resource group. </param> |
| | 956 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 957 | | /// <param name="parentResourcePath"> An extra path parameter needed in some services, like SQL Databases. </par |
| | 958 | | /// <param name="resourceType"> The type of the resource. </param> |
| | 959 | | /// <param name="resourceName"> The name of the resource. </param> |
| | 960 | | /// <param name="lockName"> The name of lock. </param> |
| | 961 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 962 | | public Response<ManagementLockObject> GetAtResourceLevel(string resourceGroupName, string resourceProviderNamesp |
| | 963 | | { |
| 0 | 964 | | if (resourceGroupName == null) |
| | 965 | | { |
| 0 | 966 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 967 | | } |
| 0 | 968 | | if (resourceProviderNamespace == null) |
| | 969 | | { |
| 0 | 970 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 971 | | } |
| 0 | 972 | | if (parentResourcePath == null) |
| | 973 | | { |
| 0 | 974 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 975 | | } |
| 0 | 976 | | if (resourceType == null) |
| | 977 | | { |
| 0 | 978 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 979 | | } |
| 0 | 980 | | if (resourceName == null) |
| | 981 | | { |
| 0 | 982 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 983 | | } |
| 0 | 984 | | if (lockName == null) |
| | 985 | | { |
| 0 | 986 | | throw new ArgumentNullException(nameof(lockName)); |
| | 987 | | } |
| | 988 | |
|
| 0 | 989 | | using var message = CreateGetAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentReso |
| 0 | 990 | | _pipeline.Send(message, cancellationToken); |
| 0 | 991 | | switch (message.Response.Status) |
| | 992 | | { |
| | 993 | | case 200: |
| | 994 | | { |
| 0 | 995 | | ManagementLockObject value = default; |
| 0 | 996 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 997 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 998 | | { |
| 0 | 999 | | value = null; |
| | 1000 | | } |
| | 1001 | | else |
| | 1002 | | { |
| 0 | 1003 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 1004 | | } |
| 0 | 1005 | | return Response.FromValue(value, message.Response); |
| | 1006 | | } |
| | 1007 | | default: |
| 0 | 1008 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1009 | | } |
| 0 | 1010 | | } |
| | 1011 | |
|
| | 1012 | | internal Core.HttpMessage CreateCreateOrUpdateAtSubscriptionLevelRequest(string lockName, ManagementLockObject p |
| | 1013 | | { |
| 0 | 1014 | | var message = _pipeline.CreateMessage(); |
| 0 | 1015 | | var request = message.Request; |
| 0 | 1016 | | request.Method = RequestMethod.Put; |
| 0 | 1017 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1018 | | uri.Reset(endpoint); |
| 0 | 1019 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1020 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1021 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 1022 | | uri.AppendPath(lockName, true); |
| 0 | 1023 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1024 | | request.Uri = uri; |
| 0 | 1025 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1026 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1027 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1028 | | request.Content = content; |
| 0 | 1029 | | return message; |
| | 1030 | | } |
| | 1031 | |
|
| | 1032 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 1033 | | /// <param name="lockName"> The name of lock. The lock name can be a maximum of 260 characters. It cannot contai |
| | 1034 | | /// <param name="parameters"> The management lock parameters. </param> |
| | 1035 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1036 | | public async Task<Response<ManagementLockObject>> CreateOrUpdateAtSubscriptionLevelAsync(string lockName, Manage |
| | 1037 | | { |
| 0 | 1038 | | if (lockName == null) |
| | 1039 | | { |
| 0 | 1040 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1041 | | } |
| 0 | 1042 | | if (parameters == null) |
| | 1043 | | { |
| 0 | 1044 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1045 | | } |
| | 1046 | |
|
| 0 | 1047 | | using var message = CreateCreateOrUpdateAtSubscriptionLevelRequest(lockName, parameters); |
| 0 | 1048 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1049 | | switch (message.Response.Status) |
| | 1050 | | { |
| | 1051 | | case 200: |
| | 1052 | | case 201: |
| | 1053 | | { |
| 0 | 1054 | | ManagementLockObject value = default; |
| 0 | 1055 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1056 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1057 | | { |
| 0 | 1058 | | value = null; |
| | 1059 | | } |
| | 1060 | | else |
| | 1061 | | { |
| 0 | 1062 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 1063 | | } |
| 0 | 1064 | | return Response.FromValue(value, message.Response); |
| | 1065 | | } |
| | 1066 | | default: |
| 0 | 1067 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1068 | | } |
| 0 | 1069 | | } |
| | 1070 | |
|
| | 1071 | | /// <summary> When you apply a lock at a parent scope, all child resources inherit the same lock. To create mana |
| | 1072 | | /// <param name="lockName"> The name of lock. The lock name can be a maximum of 260 characters. It cannot contai |
| | 1073 | | /// <param name="parameters"> The management lock parameters. </param> |
| | 1074 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1075 | | public Response<ManagementLockObject> CreateOrUpdateAtSubscriptionLevel(string lockName, ManagementLockObject pa |
| | 1076 | | { |
| 0 | 1077 | | if (lockName == null) |
| | 1078 | | { |
| 0 | 1079 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1080 | | } |
| 0 | 1081 | | if (parameters == null) |
| | 1082 | | { |
| 0 | 1083 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1084 | | } |
| | 1085 | |
|
| 0 | 1086 | | using var message = CreateCreateOrUpdateAtSubscriptionLevelRequest(lockName, parameters); |
| 0 | 1087 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1088 | | switch (message.Response.Status) |
| | 1089 | | { |
| | 1090 | | case 200: |
| | 1091 | | case 201: |
| | 1092 | | { |
| 0 | 1093 | | ManagementLockObject value = default; |
| 0 | 1094 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1095 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1096 | | { |
| 0 | 1097 | | value = null; |
| | 1098 | | } |
| | 1099 | | else |
| | 1100 | | { |
| 0 | 1101 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 1102 | | } |
| 0 | 1103 | | return Response.FromValue(value, message.Response); |
| | 1104 | | } |
| | 1105 | | default: |
| 0 | 1106 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1107 | | } |
| 0 | 1108 | | } |
| | 1109 | |
|
| | 1110 | | internal Core.HttpMessage CreateDeleteAtSubscriptionLevelRequest(string lockName) |
| | 1111 | | { |
| 0 | 1112 | | var message = _pipeline.CreateMessage(); |
| 0 | 1113 | | var request = message.Request; |
| 0 | 1114 | | request.Method = RequestMethod.Delete; |
| 0 | 1115 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1116 | | uri.Reset(endpoint); |
| 0 | 1117 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1118 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1119 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 1120 | | uri.AppendPath(lockName, true); |
| 0 | 1121 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1122 | | request.Uri = uri; |
| 0 | 1123 | | return message; |
| | 1124 | | } |
| | 1125 | |
|
| | 1126 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 1127 | | /// <param name="lockName"> The name of lock to delete. </param> |
| | 1128 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1129 | | public async Task<Response> DeleteAtSubscriptionLevelAsync(string lockName, CancellationToken cancellationToken |
| | 1130 | | { |
| 0 | 1131 | | if (lockName == null) |
| | 1132 | | { |
| 0 | 1133 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1134 | | } |
| | 1135 | |
|
| 0 | 1136 | | using var message = CreateDeleteAtSubscriptionLevelRequest(lockName); |
| 0 | 1137 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1138 | | switch (message.Response.Status) |
| | 1139 | | { |
| | 1140 | | case 200: |
| | 1141 | | case 204: |
| 0 | 1142 | | return message.Response; |
| | 1143 | | default: |
| 0 | 1144 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1145 | | } |
| 0 | 1146 | | } |
| | 1147 | |
|
| | 1148 | | /// <summary> To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authori |
| | 1149 | | /// <param name="lockName"> The name of lock to delete. </param> |
| | 1150 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1151 | | public Response DeleteAtSubscriptionLevel(string lockName, CancellationToken cancellationToken = default) |
| | 1152 | | { |
| 0 | 1153 | | if (lockName == null) |
| | 1154 | | { |
| 0 | 1155 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1156 | | } |
| | 1157 | |
|
| 0 | 1158 | | using var message = CreateDeleteAtSubscriptionLevelRequest(lockName); |
| 0 | 1159 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1160 | | switch (message.Response.Status) |
| | 1161 | | { |
| | 1162 | | case 200: |
| | 1163 | | case 204: |
| 0 | 1164 | | return message.Response; |
| | 1165 | | default: |
| 0 | 1166 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1167 | | } |
| 0 | 1168 | | } |
| | 1169 | |
|
| | 1170 | | internal Core.HttpMessage CreateGetAtSubscriptionLevelRequest(string lockName) |
| | 1171 | | { |
| 0 | 1172 | | var message = _pipeline.CreateMessage(); |
| 0 | 1173 | | var request = message.Request; |
| 0 | 1174 | | request.Method = RequestMethod.Get; |
| 0 | 1175 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1176 | | uri.Reset(endpoint); |
| 0 | 1177 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1178 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1179 | | uri.AppendPath("/providers/Microsoft.Authorization/locks/", false); |
| 0 | 1180 | | uri.AppendPath(lockName, true); |
| 0 | 1181 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1182 | | request.Uri = uri; |
| 0 | 1183 | | return message; |
| | 1184 | | } |
| | 1185 | |
|
| | 1186 | | /// <summary> Gets a management lock at the subscription level. </summary> |
| | 1187 | | /// <param name="lockName"> The name of the lock to get. </param> |
| | 1188 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1189 | | public async Task<Response<ManagementLockObject>> GetAtSubscriptionLevelAsync(string lockName, CancellationToken |
| | 1190 | | { |
| 0 | 1191 | | if (lockName == null) |
| | 1192 | | { |
| 0 | 1193 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1194 | | } |
| | 1195 | |
|
| 0 | 1196 | | using var message = CreateGetAtSubscriptionLevelRequest(lockName); |
| 0 | 1197 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1198 | | switch (message.Response.Status) |
| | 1199 | | { |
| | 1200 | | case 200: |
| | 1201 | | { |
| 0 | 1202 | | ManagementLockObject value = default; |
| 0 | 1203 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1204 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1205 | | { |
| 0 | 1206 | | value = null; |
| | 1207 | | } |
| | 1208 | | else |
| | 1209 | | { |
| 0 | 1210 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 1211 | | } |
| 0 | 1212 | | return Response.FromValue(value, message.Response); |
| | 1213 | | } |
| | 1214 | | default: |
| 0 | 1215 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1216 | | } |
| 0 | 1217 | | } |
| | 1218 | |
|
| | 1219 | | /// <summary> Gets a management lock at the subscription level. </summary> |
| | 1220 | | /// <param name="lockName"> The name of the lock to get. </param> |
| | 1221 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1222 | | public Response<ManagementLockObject> GetAtSubscriptionLevel(string lockName, CancellationToken cancellationToke |
| | 1223 | | { |
| 0 | 1224 | | if (lockName == null) |
| | 1225 | | { |
| 0 | 1226 | | throw new ArgumentNullException(nameof(lockName)); |
| | 1227 | | } |
| | 1228 | |
|
| 0 | 1229 | | using var message = CreateGetAtSubscriptionLevelRequest(lockName); |
| 0 | 1230 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1231 | | switch (message.Response.Status) |
| | 1232 | | { |
| | 1233 | | case 200: |
| | 1234 | | { |
| 0 | 1235 | | ManagementLockObject value = default; |
| 0 | 1236 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1237 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1238 | | { |
| 0 | 1239 | | value = null; |
| | 1240 | | } |
| | 1241 | | else |
| | 1242 | | { |
| 0 | 1243 | | value = ManagementLockObject.DeserializeManagementLockObject(document.RootElement); |
| | 1244 | | } |
| 0 | 1245 | | return Response.FromValue(value, message.Response); |
| | 1246 | | } |
| | 1247 | | default: |
| 0 | 1248 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1249 | | } |
| 0 | 1250 | | } |
| | 1251 | |
|
| | 1252 | | internal Core.HttpMessage CreateListAtResourceGroupLevelRequest(string resourceGroupName, string filter) |
| | 1253 | | { |
| 0 | 1254 | | var message = _pipeline.CreateMessage(); |
| 0 | 1255 | | var request = message.Request; |
| 0 | 1256 | | request.Method = RequestMethod.Get; |
| 0 | 1257 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1258 | | uri.Reset(endpoint); |
| 0 | 1259 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1260 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1261 | | uri.AppendPath("/resourceGroups/", false); |
| 0 | 1262 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1263 | | uri.AppendPath("/providers/Microsoft.Authorization/locks", false); |
| 0 | 1264 | | if (filter != null) |
| | 1265 | | { |
| 0 | 1266 | | uri.AppendQuery("$filter", filter, true); |
| | 1267 | | } |
| 0 | 1268 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1269 | | request.Uri = uri; |
| 0 | 1270 | | return message; |
| | 1271 | | } |
| | 1272 | |
|
| | 1273 | | /// <summary> Gets all the management locks for a resource group. </summary> |
| | 1274 | | /// <param name="resourceGroupName"> The name of the resource group containing the locks to get. </param> |
| | 1275 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1276 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1277 | | public async Task<Response<ManagementLockListResult>> ListAtResourceGroupLevelAsync(string resourceGroupName, st |
| | 1278 | | { |
| 0 | 1279 | | if (resourceGroupName == null) |
| | 1280 | | { |
| 0 | 1281 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1282 | | } |
| | 1283 | |
|
| 0 | 1284 | | using var message = CreateListAtResourceGroupLevelRequest(resourceGroupName, filter); |
| 0 | 1285 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1286 | | switch (message.Response.Status) |
| | 1287 | | { |
| | 1288 | | case 200: |
| | 1289 | | { |
| 0 | 1290 | | ManagementLockListResult value = default; |
| 0 | 1291 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1292 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1293 | | { |
| 0 | 1294 | | value = null; |
| | 1295 | | } |
| | 1296 | | else |
| | 1297 | | { |
| 0 | 1298 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1299 | | } |
| 0 | 1300 | | return Response.FromValue(value, message.Response); |
| | 1301 | | } |
| | 1302 | | default: |
| 0 | 1303 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1304 | | } |
| 0 | 1305 | | } |
| | 1306 | |
|
| | 1307 | | /// <summary> Gets all the management locks for a resource group. </summary> |
| | 1308 | | /// <param name="resourceGroupName"> The name of the resource group containing the locks to get. </param> |
| | 1309 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1310 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1311 | | public Response<ManagementLockListResult> ListAtResourceGroupLevel(string resourceGroupName, string filter = nul |
| | 1312 | | { |
| 0 | 1313 | | if (resourceGroupName == null) |
| | 1314 | | { |
| 0 | 1315 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1316 | | } |
| | 1317 | |
|
| 0 | 1318 | | using var message = CreateListAtResourceGroupLevelRequest(resourceGroupName, filter); |
| 0 | 1319 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1320 | | switch (message.Response.Status) |
| | 1321 | | { |
| | 1322 | | case 200: |
| | 1323 | | { |
| 0 | 1324 | | ManagementLockListResult value = default; |
| 0 | 1325 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1326 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1327 | | { |
| 0 | 1328 | | value = null; |
| | 1329 | | } |
| | 1330 | | else |
| | 1331 | | { |
| 0 | 1332 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1333 | | } |
| 0 | 1334 | | return Response.FromValue(value, message.Response); |
| | 1335 | | } |
| | 1336 | | default: |
| 0 | 1337 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1338 | | } |
| 0 | 1339 | | } |
| | 1340 | |
|
| | 1341 | | internal Core.HttpMessage CreateListAtResourceLevelRequest(string resourceGroupName, string resourceProviderName |
| | 1342 | | { |
| 0 | 1343 | | var message = _pipeline.CreateMessage(); |
| 0 | 1344 | | var request = message.Request; |
| 0 | 1345 | | request.Method = RequestMethod.Get; |
| 0 | 1346 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1347 | | uri.Reset(endpoint); |
| 0 | 1348 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1349 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1350 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 1351 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 1352 | | uri.AppendPath("/providers/", false); |
| 0 | 1353 | | uri.AppendPath(resourceProviderNamespace, true); |
| 0 | 1354 | | uri.AppendPath("/", false); |
| 0 | 1355 | | uri.AppendPath(parentResourcePath, false); |
| 0 | 1356 | | uri.AppendPath("/", false); |
| 0 | 1357 | | uri.AppendPath(resourceType, false); |
| 0 | 1358 | | uri.AppendPath("/", false); |
| 0 | 1359 | | uri.AppendPath(resourceName, true); |
| 0 | 1360 | | uri.AppendPath("/providers/Microsoft.Authorization/locks", false); |
| 0 | 1361 | | if (filter != null) |
| | 1362 | | { |
| 0 | 1363 | | uri.AppendQuery("$filter", filter, true); |
| | 1364 | | } |
| 0 | 1365 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1366 | | request.Uri = uri; |
| 0 | 1367 | | return message; |
| | 1368 | | } |
| | 1369 | |
|
| | 1370 | | /// <summary> Gets all the management locks for a resource or any level below resource. </summary> |
| | 1371 | | /// <param name="resourceGroupName"> The name of the resource group containing the locked resource. The name is |
| | 1372 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 1373 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 1374 | | /// <param name="resourceType"> The resource type of the locked resource. </param> |
| | 1375 | | /// <param name="resourceName"> The name of the locked resource. </param> |
| | 1376 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1377 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1378 | | public async Task<Response<ManagementLockListResult>> ListAtResourceLevelAsync(string resourceGroupName, string |
| | 1379 | | { |
| 0 | 1380 | | if (resourceGroupName == null) |
| | 1381 | | { |
| 0 | 1382 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1383 | | } |
| 0 | 1384 | | if (resourceProviderNamespace == null) |
| | 1385 | | { |
| 0 | 1386 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 1387 | | } |
| 0 | 1388 | | if (parentResourcePath == null) |
| | 1389 | | { |
| 0 | 1390 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 1391 | | } |
| 0 | 1392 | | if (resourceType == null) |
| | 1393 | | { |
| 0 | 1394 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 1395 | | } |
| 0 | 1396 | | if (resourceName == null) |
| | 1397 | | { |
| 0 | 1398 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 1399 | | } |
| | 1400 | |
|
| 0 | 1401 | | using var message = CreateListAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentRes |
| 0 | 1402 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1403 | | switch (message.Response.Status) |
| | 1404 | | { |
| | 1405 | | case 200: |
| | 1406 | | { |
| 0 | 1407 | | ManagementLockListResult value = default; |
| 0 | 1408 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1409 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1410 | | { |
| 0 | 1411 | | value = null; |
| | 1412 | | } |
| | 1413 | | else |
| | 1414 | | { |
| 0 | 1415 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1416 | | } |
| 0 | 1417 | | return Response.FromValue(value, message.Response); |
| | 1418 | | } |
| | 1419 | | default: |
| 0 | 1420 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1421 | | } |
| 0 | 1422 | | } |
| | 1423 | |
|
| | 1424 | | /// <summary> Gets all the management locks for a resource or any level below resource. </summary> |
| | 1425 | | /// <param name="resourceGroupName"> The name of the resource group containing the locked resource. The name is |
| | 1426 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 1427 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 1428 | | /// <param name="resourceType"> The resource type of the locked resource. </param> |
| | 1429 | | /// <param name="resourceName"> The name of the locked resource. </param> |
| | 1430 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1431 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1432 | | public Response<ManagementLockListResult> ListAtResourceLevel(string resourceGroupName, string resourceProviderN |
| | 1433 | | { |
| 0 | 1434 | | if (resourceGroupName == null) |
| | 1435 | | { |
| 0 | 1436 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1437 | | } |
| 0 | 1438 | | if (resourceProviderNamespace == null) |
| | 1439 | | { |
| 0 | 1440 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 1441 | | } |
| 0 | 1442 | | if (parentResourcePath == null) |
| | 1443 | | { |
| 0 | 1444 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 1445 | | } |
| 0 | 1446 | | if (resourceType == null) |
| | 1447 | | { |
| 0 | 1448 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 1449 | | } |
| 0 | 1450 | | if (resourceName == null) |
| | 1451 | | { |
| 0 | 1452 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 1453 | | } |
| | 1454 | |
|
| 0 | 1455 | | using var message = CreateListAtResourceLevelRequest(resourceGroupName, resourceProviderNamespace, parentRes |
| 0 | 1456 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1457 | | switch (message.Response.Status) |
| | 1458 | | { |
| | 1459 | | case 200: |
| | 1460 | | { |
| 0 | 1461 | | ManagementLockListResult value = default; |
| 0 | 1462 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1463 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1464 | | { |
| 0 | 1465 | | value = null; |
| | 1466 | | } |
| | 1467 | | else |
| | 1468 | | { |
| 0 | 1469 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1470 | | } |
| 0 | 1471 | | return Response.FromValue(value, message.Response); |
| | 1472 | | } |
| | 1473 | | default: |
| 0 | 1474 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1475 | | } |
| 0 | 1476 | | } |
| | 1477 | |
|
| | 1478 | | internal Core.HttpMessage CreateListAtSubscriptionLevelRequest(string filter) |
| | 1479 | | { |
| 0 | 1480 | | var message = _pipeline.CreateMessage(); |
| 0 | 1481 | | var request = message.Request; |
| 0 | 1482 | | request.Method = RequestMethod.Get; |
| 0 | 1483 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1484 | | uri.Reset(endpoint); |
| 0 | 1485 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1486 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1487 | | uri.AppendPath("/providers/Microsoft.Authorization/locks", false); |
| 0 | 1488 | | if (filter != null) |
| | 1489 | | { |
| 0 | 1490 | | uri.AppendQuery("$filter", filter, true); |
| | 1491 | | } |
| 0 | 1492 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1493 | | request.Uri = uri; |
| 0 | 1494 | | return message; |
| | 1495 | | } |
| | 1496 | |
|
| | 1497 | | /// <summary> Gets all the management locks for a subscription. </summary> |
| | 1498 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1499 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1500 | | public async Task<Response<ManagementLockListResult>> ListAtSubscriptionLevelAsync(string filter = null, Cancell |
| | 1501 | | { |
| 0 | 1502 | | using var message = CreateListAtSubscriptionLevelRequest(filter); |
| 0 | 1503 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1504 | | switch (message.Response.Status) |
| | 1505 | | { |
| | 1506 | | case 200: |
| | 1507 | | { |
| 0 | 1508 | | ManagementLockListResult value = default; |
| 0 | 1509 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1510 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1511 | | { |
| 0 | 1512 | | value = null; |
| | 1513 | | } |
| | 1514 | | else |
| | 1515 | | { |
| 0 | 1516 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1517 | | } |
| 0 | 1518 | | return Response.FromValue(value, message.Response); |
| | 1519 | | } |
| | 1520 | | default: |
| 0 | 1521 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1522 | | } |
| 0 | 1523 | | } |
| | 1524 | |
|
| | 1525 | | /// <summary> Gets all the management locks for a subscription. </summary> |
| | 1526 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1527 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1528 | | public Response<ManagementLockListResult> ListAtSubscriptionLevel(string filter = null, CancellationToken cancel |
| | 1529 | | { |
| 0 | 1530 | | using var message = CreateListAtSubscriptionLevelRequest(filter); |
| 0 | 1531 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1532 | | switch (message.Response.Status) |
| | 1533 | | { |
| | 1534 | | case 200: |
| | 1535 | | { |
| 0 | 1536 | | ManagementLockListResult value = default; |
| 0 | 1537 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1538 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1539 | | { |
| 0 | 1540 | | value = null; |
| | 1541 | | } |
| | 1542 | | else |
| | 1543 | | { |
| 0 | 1544 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1545 | | } |
| 0 | 1546 | | return Response.FromValue(value, message.Response); |
| | 1547 | | } |
| | 1548 | | default: |
| 0 | 1549 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1550 | | } |
| 0 | 1551 | | } |
| | 1552 | |
|
| | 1553 | | internal Core.HttpMessage CreateListByScopeRequest(string scope, string filter) |
| | 1554 | | { |
| 0 | 1555 | | var message = _pipeline.CreateMessage(); |
| 0 | 1556 | | var request = message.Request; |
| 0 | 1557 | | request.Method = RequestMethod.Get; |
| 0 | 1558 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1559 | | uri.Reset(endpoint); |
| 0 | 1560 | | uri.AppendPath("/", false); |
| 0 | 1561 | | uri.AppendPath(scope, true); |
| 0 | 1562 | | uri.AppendPath("/providers/Microsoft.Authorization/locks", false); |
| 0 | 1563 | | if (filter != null) |
| | 1564 | | { |
| 0 | 1565 | | uri.AppendQuery("$filter", filter, true); |
| | 1566 | | } |
| 0 | 1567 | | uri.AppendQuery("api-version", "2016-09-01", true); |
| 0 | 1568 | | request.Uri = uri; |
| 0 | 1569 | | return message; |
| | 1570 | | } |
| | 1571 | |
|
| | 1572 | | /// <summary> Gets all the management locks for a scope. </summary> |
| | 1573 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 1574 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1575 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1576 | | public async Task<Response<ManagementLockListResult>> ListByScopeAsync(string scope, string filter = null, Cance |
| | 1577 | | { |
| 0 | 1578 | | if (scope == null) |
| | 1579 | | { |
| 0 | 1580 | | throw new ArgumentNullException(nameof(scope)); |
| | 1581 | | } |
| | 1582 | |
|
| 0 | 1583 | | using var message = CreateListByScopeRequest(scope, filter); |
| 0 | 1584 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1585 | | switch (message.Response.Status) |
| | 1586 | | { |
| | 1587 | | case 200: |
| | 1588 | | { |
| 0 | 1589 | | ManagementLockListResult value = default; |
| 0 | 1590 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1591 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1592 | | { |
| 0 | 1593 | | value = null; |
| | 1594 | | } |
| | 1595 | | else |
| | 1596 | | { |
| 0 | 1597 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1598 | | } |
| 0 | 1599 | | return Response.FromValue(value, message.Response); |
| | 1600 | | } |
| | 1601 | | default: |
| 0 | 1602 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1603 | | } |
| 0 | 1604 | | } |
| | 1605 | |
|
| | 1606 | | /// <summary> Gets all the management locks for a scope. </summary> |
| | 1607 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 1608 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1609 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1610 | | public Response<ManagementLockListResult> ListByScope(string scope, string filter = null, CancellationToken canc |
| | 1611 | | { |
| 0 | 1612 | | if (scope == null) |
| | 1613 | | { |
| 0 | 1614 | | throw new ArgumentNullException(nameof(scope)); |
| | 1615 | | } |
| | 1616 | |
|
| 0 | 1617 | | using var message = CreateListByScopeRequest(scope, filter); |
| 0 | 1618 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1619 | | switch (message.Response.Status) |
| | 1620 | | { |
| | 1621 | | case 200: |
| | 1622 | | { |
| 0 | 1623 | | ManagementLockListResult value = default; |
| 0 | 1624 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1625 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1626 | | { |
| 0 | 1627 | | value = null; |
| | 1628 | | } |
| | 1629 | | else |
| | 1630 | | { |
| 0 | 1631 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1632 | | } |
| 0 | 1633 | | return Response.FromValue(value, message.Response); |
| | 1634 | | } |
| | 1635 | | default: |
| 0 | 1636 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1637 | | } |
| 0 | 1638 | | } |
| | 1639 | |
|
| | 1640 | | internal Core.HttpMessage CreateListAtResourceGroupLevelNextPageRequest(string nextLink, string resourceGroupNam |
| | 1641 | | { |
| 0 | 1642 | | var message = _pipeline.CreateMessage(); |
| 0 | 1643 | | var request = message.Request; |
| 0 | 1644 | | request.Method = RequestMethod.Get; |
| 0 | 1645 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1646 | | uri.Reset(endpoint); |
| 0 | 1647 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1648 | | request.Uri = uri; |
| 0 | 1649 | | return message; |
| | 1650 | | } |
| | 1651 | |
|
| | 1652 | | /// <summary> Gets all the management locks for a resource group. </summary> |
| | 1653 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1654 | | /// <param name="resourceGroupName"> The name of the resource group containing the locks to get. </param> |
| | 1655 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1656 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1657 | | public async Task<Response<ManagementLockListResult>> ListAtResourceGroupLevelNextPageAsync(string nextLink, str |
| | 1658 | | { |
| 0 | 1659 | | if (nextLink == null) |
| | 1660 | | { |
| 0 | 1661 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1662 | | } |
| 0 | 1663 | | if (resourceGroupName == null) |
| | 1664 | | { |
| 0 | 1665 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1666 | | } |
| | 1667 | |
|
| 0 | 1668 | | using var message = CreateListAtResourceGroupLevelNextPageRequest(nextLink, resourceGroupName, filter); |
| 0 | 1669 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1670 | | switch (message.Response.Status) |
| | 1671 | | { |
| | 1672 | | case 200: |
| | 1673 | | { |
| 0 | 1674 | | ManagementLockListResult value = default; |
| 0 | 1675 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1676 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1677 | | { |
| 0 | 1678 | | value = null; |
| | 1679 | | } |
| | 1680 | | else |
| | 1681 | | { |
| 0 | 1682 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1683 | | } |
| 0 | 1684 | | return Response.FromValue(value, message.Response); |
| | 1685 | | } |
| | 1686 | | default: |
| 0 | 1687 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1688 | | } |
| 0 | 1689 | | } |
| | 1690 | |
|
| | 1691 | | /// <summary> Gets all the management locks for a resource group. </summary> |
| | 1692 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1693 | | /// <param name="resourceGroupName"> The name of the resource group containing the locks to get. </param> |
| | 1694 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1695 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1696 | | public Response<ManagementLockListResult> ListAtResourceGroupLevelNextPage(string nextLink, string resourceGroup |
| | 1697 | | { |
| 0 | 1698 | | if (nextLink == null) |
| | 1699 | | { |
| 0 | 1700 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1701 | | } |
| 0 | 1702 | | if (resourceGroupName == null) |
| | 1703 | | { |
| 0 | 1704 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1705 | | } |
| | 1706 | |
|
| 0 | 1707 | | using var message = CreateListAtResourceGroupLevelNextPageRequest(nextLink, resourceGroupName, filter); |
| 0 | 1708 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1709 | | switch (message.Response.Status) |
| | 1710 | | { |
| | 1711 | | case 200: |
| | 1712 | | { |
| 0 | 1713 | | ManagementLockListResult value = default; |
| 0 | 1714 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1715 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1716 | | { |
| 0 | 1717 | | value = null; |
| | 1718 | | } |
| | 1719 | | else |
| | 1720 | | { |
| 0 | 1721 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1722 | | } |
| 0 | 1723 | | return Response.FromValue(value, message.Response); |
| | 1724 | | } |
| | 1725 | | default: |
| 0 | 1726 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1727 | | } |
| 0 | 1728 | | } |
| | 1729 | |
|
| | 1730 | | internal Core.HttpMessage CreateListAtResourceLevelNextPageRequest(string nextLink, string resourceGroupName, st |
| | 1731 | | { |
| 0 | 1732 | | var message = _pipeline.CreateMessage(); |
| 0 | 1733 | | var request = message.Request; |
| 0 | 1734 | | request.Method = RequestMethod.Get; |
| 0 | 1735 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1736 | | uri.Reset(endpoint); |
| 0 | 1737 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1738 | | request.Uri = uri; |
| 0 | 1739 | | return message; |
| | 1740 | | } |
| | 1741 | |
|
| | 1742 | | /// <summary> Gets all the management locks for a resource or any level below resource. </summary> |
| | 1743 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1744 | | /// <param name="resourceGroupName"> The name of the resource group containing the locked resource. The name is |
| | 1745 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 1746 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 1747 | | /// <param name="resourceType"> The resource type of the locked resource. </param> |
| | 1748 | | /// <param name="resourceName"> The name of the locked resource. </param> |
| | 1749 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1750 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1751 | | public async Task<Response<ManagementLockListResult>> ListAtResourceLevelNextPageAsync(string nextLink, string r |
| | 1752 | | { |
| 0 | 1753 | | if (nextLink == null) |
| | 1754 | | { |
| 0 | 1755 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1756 | | } |
| 0 | 1757 | | if (resourceGroupName == null) |
| | 1758 | | { |
| 0 | 1759 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1760 | | } |
| 0 | 1761 | | if (resourceProviderNamespace == null) |
| | 1762 | | { |
| 0 | 1763 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 1764 | | } |
| 0 | 1765 | | if (parentResourcePath == null) |
| | 1766 | | { |
| 0 | 1767 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 1768 | | } |
| 0 | 1769 | | if (resourceType == null) |
| | 1770 | | { |
| 0 | 1771 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 1772 | | } |
| 0 | 1773 | | if (resourceName == null) |
| | 1774 | | { |
| 0 | 1775 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 1776 | | } |
| | 1777 | |
|
| 0 | 1778 | | using var message = CreateListAtResourceLevelNextPageRequest(nextLink, resourceGroupName, resourceProviderNa |
| 0 | 1779 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1780 | | switch (message.Response.Status) |
| | 1781 | | { |
| | 1782 | | case 200: |
| | 1783 | | { |
| 0 | 1784 | | ManagementLockListResult value = default; |
| 0 | 1785 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1786 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1787 | | { |
| 0 | 1788 | | value = null; |
| | 1789 | | } |
| | 1790 | | else |
| | 1791 | | { |
| 0 | 1792 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1793 | | } |
| 0 | 1794 | | return Response.FromValue(value, message.Response); |
| | 1795 | | } |
| | 1796 | | default: |
| 0 | 1797 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1798 | | } |
| 0 | 1799 | | } |
| | 1800 | |
|
| | 1801 | | /// <summary> Gets all the management locks for a resource or any level below resource. </summary> |
| | 1802 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1803 | | /// <param name="resourceGroupName"> The name of the resource group containing the locked resource. The name is |
| | 1804 | | /// <param name="resourceProviderNamespace"> The namespace of the resource provider. </param> |
| | 1805 | | /// <param name="parentResourcePath"> The parent resource identity. </param> |
| | 1806 | | /// <param name="resourceType"> The resource type of the locked resource. </param> |
| | 1807 | | /// <param name="resourceName"> The name of the locked resource. </param> |
| | 1808 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1809 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1810 | | public Response<ManagementLockListResult> ListAtResourceLevelNextPage(string nextLink, string resourceGroupName, |
| | 1811 | | { |
| 0 | 1812 | | if (nextLink == null) |
| | 1813 | | { |
| 0 | 1814 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1815 | | } |
| 0 | 1816 | | if (resourceGroupName == null) |
| | 1817 | | { |
| 0 | 1818 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 1819 | | } |
| 0 | 1820 | | if (resourceProviderNamespace == null) |
| | 1821 | | { |
| 0 | 1822 | | throw new ArgumentNullException(nameof(resourceProviderNamespace)); |
| | 1823 | | } |
| 0 | 1824 | | if (parentResourcePath == null) |
| | 1825 | | { |
| 0 | 1826 | | throw new ArgumentNullException(nameof(parentResourcePath)); |
| | 1827 | | } |
| 0 | 1828 | | if (resourceType == null) |
| | 1829 | | { |
| 0 | 1830 | | throw new ArgumentNullException(nameof(resourceType)); |
| | 1831 | | } |
| 0 | 1832 | | if (resourceName == null) |
| | 1833 | | { |
| 0 | 1834 | | throw new ArgumentNullException(nameof(resourceName)); |
| | 1835 | | } |
| | 1836 | |
|
| 0 | 1837 | | using var message = CreateListAtResourceLevelNextPageRequest(nextLink, resourceGroupName, resourceProviderNa |
| 0 | 1838 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1839 | | switch (message.Response.Status) |
| | 1840 | | { |
| | 1841 | | case 200: |
| | 1842 | | { |
| 0 | 1843 | | ManagementLockListResult value = default; |
| 0 | 1844 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1845 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1846 | | { |
| 0 | 1847 | | value = null; |
| | 1848 | | } |
| | 1849 | | else |
| | 1850 | | { |
| 0 | 1851 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1852 | | } |
| 0 | 1853 | | return Response.FromValue(value, message.Response); |
| | 1854 | | } |
| | 1855 | | default: |
| 0 | 1856 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1857 | | } |
| 0 | 1858 | | } |
| | 1859 | |
|
| | 1860 | | internal Core.HttpMessage CreateListAtSubscriptionLevelNextPageRequest(string nextLink, string filter) |
| | 1861 | | { |
| 0 | 1862 | | var message = _pipeline.CreateMessage(); |
| 0 | 1863 | | var request = message.Request; |
| 0 | 1864 | | request.Method = RequestMethod.Get; |
| 0 | 1865 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1866 | | uri.Reset(endpoint); |
| 0 | 1867 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1868 | | request.Uri = uri; |
| 0 | 1869 | | return message; |
| | 1870 | | } |
| | 1871 | |
|
| | 1872 | | /// <summary> Gets all the management locks for a subscription. </summary> |
| | 1873 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1874 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1875 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1876 | | public async Task<Response<ManagementLockListResult>> ListAtSubscriptionLevelNextPageAsync(string nextLink, stri |
| | 1877 | | { |
| 0 | 1878 | | if (nextLink == null) |
| | 1879 | | { |
| 0 | 1880 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1881 | | } |
| | 1882 | |
|
| 0 | 1883 | | using var message = CreateListAtSubscriptionLevelNextPageRequest(nextLink, filter); |
| 0 | 1884 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1885 | | switch (message.Response.Status) |
| | 1886 | | { |
| | 1887 | | case 200: |
| | 1888 | | { |
| 0 | 1889 | | ManagementLockListResult value = default; |
| 0 | 1890 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1891 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1892 | | { |
| 0 | 1893 | | value = null; |
| | 1894 | | } |
| | 1895 | | else |
| | 1896 | | { |
| 0 | 1897 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1898 | | } |
| 0 | 1899 | | return Response.FromValue(value, message.Response); |
| | 1900 | | } |
| | 1901 | | default: |
| 0 | 1902 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1903 | | } |
| 0 | 1904 | | } |
| | 1905 | |
|
| | 1906 | | /// <summary> Gets all the management locks for a subscription. </summary> |
| | 1907 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1908 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1909 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1910 | | public Response<ManagementLockListResult> ListAtSubscriptionLevelNextPage(string nextLink, string filter = null, |
| | 1911 | | { |
| 0 | 1912 | | if (nextLink == null) |
| | 1913 | | { |
| 0 | 1914 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1915 | | } |
| | 1916 | |
|
| 0 | 1917 | | using var message = CreateListAtSubscriptionLevelNextPageRequest(nextLink, filter); |
| 0 | 1918 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1919 | | switch (message.Response.Status) |
| | 1920 | | { |
| | 1921 | | case 200: |
| | 1922 | | { |
| 0 | 1923 | | ManagementLockListResult value = default; |
| 0 | 1924 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1925 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1926 | | { |
| 0 | 1927 | | value = null; |
| | 1928 | | } |
| | 1929 | | else |
| | 1930 | | { |
| 0 | 1931 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1932 | | } |
| 0 | 1933 | | return Response.FromValue(value, message.Response); |
| | 1934 | | } |
| | 1935 | | default: |
| 0 | 1936 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1937 | | } |
| 0 | 1938 | | } |
| | 1939 | |
|
| | 1940 | | internal Core.HttpMessage CreateListByScopeNextPageRequest(string nextLink, string scope, string filter) |
| | 1941 | | { |
| 0 | 1942 | | var message = _pipeline.CreateMessage(); |
| 0 | 1943 | | var request = message.Request; |
| 0 | 1944 | | request.Method = RequestMethod.Get; |
| 0 | 1945 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1946 | | uri.Reset(endpoint); |
| 0 | 1947 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 1948 | | request.Uri = uri; |
| 0 | 1949 | | return message; |
| | 1950 | | } |
| | 1951 | |
|
| | 1952 | | /// <summary> Gets all the management locks for a scope. </summary> |
| | 1953 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1954 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 1955 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1956 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1957 | | public async Task<Response<ManagementLockListResult>> ListByScopeNextPageAsync(string nextLink, string scope, st |
| | 1958 | | { |
| 0 | 1959 | | if (nextLink == null) |
| | 1960 | | { |
| 0 | 1961 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 1962 | | } |
| 0 | 1963 | | if (scope == null) |
| | 1964 | | { |
| 0 | 1965 | | throw new ArgumentNullException(nameof(scope)); |
| | 1966 | | } |
| | 1967 | |
|
| 0 | 1968 | | using var message = CreateListByScopeNextPageRequest(nextLink, scope, filter); |
| 0 | 1969 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1970 | | switch (message.Response.Status) |
| | 1971 | | { |
| | 1972 | | case 200: |
| | 1973 | | { |
| 0 | 1974 | | ManagementLockListResult value = default; |
| 0 | 1975 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1976 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1977 | | { |
| 0 | 1978 | | value = null; |
| | 1979 | | } |
| | 1980 | | else |
| | 1981 | | { |
| 0 | 1982 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 1983 | | } |
| 0 | 1984 | | return Response.FromValue(value, message.Response); |
| | 1985 | | } |
| | 1986 | | default: |
| 0 | 1987 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1988 | | } |
| 0 | 1989 | | } |
| | 1990 | |
|
| | 1991 | | /// <summary> Gets all the management locks for a scope. </summary> |
| | 1992 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 1993 | | /// <param name="scope"> The scope for the lock. When providing a scope for the assignment, use '/subscript |
| | 1994 | | /// <param name="filter"> The filter to apply on the operation. </param> |
| | 1995 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1996 | | public Response<ManagementLockListResult> ListByScopeNextPage(string nextLink, string scope, string filter = nul |
| | 1997 | | { |
| 0 | 1998 | | if (nextLink == null) |
| | 1999 | | { |
| 0 | 2000 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 2001 | | } |
| 0 | 2002 | | if (scope == null) |
| | 2003 | | { |
| 0 | 2004 | | throw new ArgumentNullException(nameof(scope)); |
| | 2005 | | } |
| | 2006 | |
|
| 0 | 2007 | | using var message = CreateListByScopeNextPageRequest(nextLink, scope, filter); |
| 0 | 2008 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2009 | | switch (message.Response.Status) |
| | 2010 | | { |
| | 2011 | | case 200: |
| | 2012 | | { |
| 0 | 2013 | | ManagementLockListResult value = default; |
| 0 | 2014 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2015 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2016 | | { |
| 0 | 2017 | | value = null; |
| | 2018 | | } |
| | 2019 | | else |
| | 2020 | | { |
| 0 | 2021 | | value = ManagementLockListResult.DeserializeManagementLockListResult(document.RootElement); |
| | 2022 | | } |
| 0 | 2023 | | return Response.FromValue(value, message.Response); |
| | 2024 | | } |
| | 2025 | | default: |
| 0 | 2026 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2027 | | } |
| 0 | 2028 | | } |
| | 2029 | | } |
| | 2030 | | } |