| | 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 DeploymentsRestOperations |
| | 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 DeploymentsRestOperations. </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 |
| 352 | 32 | | public DeploymentsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription |
| | 33 | | { |
| 352 | 34 | | if (subscriptionId == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(subscriptionId)); |
| | 37 | | } |
| 352 | 38 | | endpoint ??= new Uri("https://management.azure.com"); |
| | 39 | |
|
| 352 | 40 | | this.subscriptionId = subscriptionId; |
| 352 | 41 | | this.endpoint = endpoint; |
| 352 | 42 | | _clientDiagnostics = clientDiagnostics; |
| 352 | 43 | | _pipeline = pipeline; |
| 352 | 44 | | } |
| | 45 | |
|
| | 46 | | internal Core.HttpMessage CreateDeleteAtScopeRequest(string scope, string deploymentName) |
| | 47 | | { |
| 0 | 48 | | var message = _pipeline.CreateMessage(); |
| 0 | 49 | | var request = message.Request; |
| 0 | 50 | | request.Method = RequestMethod.Delete; |
| 0 | 51 | | var uri = new RawRequestUriBuilder(); |
| 0 | 52 | | uri.Reset(endpoint); |
| 0 | 53 | | uri.AppendPath("/", false); |
| 0 | 54 | | uri.AppendPath(scope, false); |
| 0 | 55 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 56 | | uri.AppendPath(deploymentName, true); |
| 0 | 57 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 58 | | request.Uri = uri; |
| 0 | 59 | | return message; |
| | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 63 | | /// <param name="scope"> The resource scope. </param> |
| | 64 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 65 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 66 | | public async Task<Response> DeleteAtScopeAsync(string scope, string deploymentName, CancellationToken cancellati |
| | 67 | | { |
| 0 | 68 | | if (scope == null) |
| | 69 | | { |
| 0 | 70 | | throw new ArgumentNullException(nameof(scope)); |
| | 71 | | } |
| 0 | 72 | | if (deploymentName == null) |
| | 73 | | { |
| 0 | 74 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 75 | | } |
| | 76 | |
|
| 0 | 77 | | using var message = CreateDeleteAtScopeRequest(scope, deploymentName); |
| 0 | 78 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 79 | | switch (message.Response.Status) |
| | 80 | | { |
| | 81 | | case 202: |
| | 82 | | case 204: |
| 0 | 83 | | return message.Response; |
| | 84 | | default: |
| 0 | 85 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 86 | | } |
| 0 | 87 | | } |
| | 88 | |
|
| | 89 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 90 | | /// <param name="scope"> The resource scope. </param> |
| | 91 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 92 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 93 | | public Response DeleteAtScope(string scope, string deploymentName, CancellationToken cancellationToken = default |
| | 94 | | { |
| 0 | 95 | | if (scope == null) |
| | 96 | | { |
| 0 | 97 | | throw new ArgumentNullException(nameof(scope)); |
| | 98 | | } |
| 0 | 99 | | if (deploymentName == null) |
| | 100 | | { |
| 0 | 101 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 102 | | } |
| | 103 | |
|
| 0 | 104 | | using var message = CreateDeleteAtScopeRequest(scope, deploymentName); |
| 0 | 105 | | _pipeline.Send(message, cancellationToken); |
| 0 | 106 | | switch (message.Response.Status) |
| | 107 | | { |
| | 108 | | case 202: |
| | 109 | | case 204: |
| 0 | 110 | | return message.Response; |
| | 111 | | default: |
| 0 | 112 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 113 | | } |
| 0 | 114 | | } |
| | 115 | |
|
| | 116 | | internal Core.HttpMessage CreateCheckExistenceAtScopeRequest(string scope, string deploymentName) |
| | 117 | | { |
| 0 | 118 | | var message = _pipeline.CreateMessage(); |
| 0 | 119 | | var request = message.Request; |
| 0 | 120 | | request.Method = RequestMethod.Head; |
| 0 | 121 | | var uri = new RawRequestUriBuilder(); |
| 0 | 122 | | uri.Reset(endpoint); |
| 0 | 123 | | uri.AppendPath("/", false); |
| 0 | 124 | | uri.AppendPath(scope, false); |
| 0 | 125 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 126 | | uri.AppendPath(deploymentName, true); |
| 0 | 127 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 128 | | request.Uri = uri; |
| 0 | 129 | | return message; |
| | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 133 | | /// <param name="scope"> The resource scope. </param> |
| | 134 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 135 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 136 | | public async Task<Response> CheckExistenceAtScopeAsync(string scope, string deploymentName, CancellationToken ca |
| | 137 | | { |
| 0 | 138 | | if (scope == null) |
| | 139 | | { |
| 0 | 140 | | throw new ArgumentNullException(nameof(scope)); |
| | 141 | | } |
| 0 | 142 | | if (deploymentName == null) |
| | 143 | | { |
| 0 | 144 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 145 | | } |
| | 146 | |
|
| 0 | 147 | | using var message = CreateCheckExistenceAtScopeRequest(scope, deploymentName); |
| 0 | 148 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 149 | | switch (message.Response.Status) |
| | 150 | | { |
| | 151 | | case 204: |
| | 152 | | case 404: |
| 0 | 153 | | return message.Response; |
| | 154 | | default: |
| 0 | 155 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 156 | | } |
| 0 | 157 | | } |
| | 158 | |
|
| | 159 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 160 | | /// <param name="scope"> The resource scope. </param> |
| | 161 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 162 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 163 | | public Response CheckExistenceAtScope(string scope, string deploymentName, CancellationToken cancellationToken = |
| | 164 | | { |
| 0 | 165 | | if (scope == null) |
| | 166 | | { |
| 0 | 167 | | throw new ArgumentNullException(nameof(scope)); |
| | 168 | | } |
| 0 | 169 | | if (deploymentName == null) |
| | 170 | | { |
| 0 | 171 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 172 | | } |
| | 173 | |
|
| 0 | 174 | | using var message = CreateCheckExistenceAtScopeRequest(scope, deploymentName); |
| 0 | 175 | | _pipeline.Send(message, cancellationToken); |
| 0 | 176 | | switch (message.Response.Status) |
| | 177 | | { |
| | 178 | | case 204: |
| | 179 | | case 404: |
| 0 | 180 | | return message.Response; |
| | 181 | | default: |
| 0 | 182 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 183 | | } |
| 0 | 184 | | } |
| | 185 | |
|
| | 186 | | internal Core.HttpMessage CreateCreateOrUpdateAtScopeRequest(string scope, string deploymentName, Deployment par |
| | 187 | | { |
| 24 | 188 | | var message = _pipeline.CreateMessage(); |
| 24 | 189 | | var request = message.Request; |
| 24 | 190 | | request.Method = RequestMethod.Put; |
| 24 | 191 | | var uri = new RawRequestUriBuilder(); |
| 24 | 192 | | uri.Reset(endpoint); |
| 24 | 193 | | uri.AppendPath("/", false); |
| 24 | 194 | | uri.AppendPath(scope, false); |
| 24 | 195 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 24 | 196 | | uri.AppendPath(deploymentName, true); |
| 24 | 197 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 24 | 198 | | request.Uri = uri; |
| 24 | 199 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 200 | | var content = new Utf8JsonRequestContent(); |
| 24 | 201 | | content.JsonWriter.WriteObjectValue(parameters); |
| 24 | 202 | | request.Content = content; |
| 24 | 203 | | return message; |
| | 204 | | } |
| | 205 | |
|
| | 206 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 207 | | /// <param name="scope"> The resource scope. </param> |
| | 208 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 209 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 210 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 211 | | public async Task<Response> CreateOrUpdateAtScopeAsync(string scope, string deploymentName, Deployment parameter |
| | 212 | | { |
| 6 | 213 | | if (scope == null) |
| | 214 | | { |
| 0 | 215 | | throw new ArgumentNullException(nameof(scope)); |
| | 216 | | } |
| 6 | 217 | | if (deploymentName == null) |
| | 218 | | { |
| 0 | 219 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 220 | | } |
| 6 | 221 | | if (parameters == null) |
| | 222 | | { |
| 0 | 223 | | throw new ArgumentNullException(nameof(parameters)); |
| | 224 | | } |
| | 225 | |
|
| 6 | 226 | | using var message = CreateCreateOrUpdateAtScopeRequest(scope, deploymentName, parameters); |
| 6 | 227 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 228 | | switch (message.Response.Status) |
| | 229 | | { |
| | 230 | | case 200: |
| | 231 | | case 201: |
| 6 | 232 | | return message.Response; |
| | 233 | | default: |
| 0 | 234 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 235 | | } |
| 6 | 236 | | } |
| | 237 | |
|
| | 238 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 239 | | /// <param name="scope"> The resource scope. </param> |
| | 240 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 241 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 242 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 243 | | public Response CreateOrUpdateAtScope(string scope, string deploymentName, Deployment parameters, CancellationTo |
| | 244 | | { |
| 6 | 245 | | if (scope == null) |
| | 246 | | { |
| 0 | 247 | | throw new ArgumentNullException(nameof(scope)); |
| | 248 | | } |
| 6 | 249 | | if (deploymentName == null) |
| | 250 | | { |
| 0 | 251 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 252 | | } |
| 6 | 253 | | if (parameters == null) |
| | 254 | | { |
| 0 | 255 | | throw new ArgumentNullException(nameof(parameters)); |
| | 256 | | } |
| | 257 | |
|
| 6 | 258 | | using var message = CreateCreateOrUpdateAtScopeRequest(scope, deploymentName, parameters); |
| 6 | 259 | | _pipeline.Send(message, cancellationToken); |
| 6 | 260 | | switch (message.Response.Status) |
| | 261 | | { |
| | 262 | | case 200: |
| | 263 | | case 201: |
| 6 | 264 | | return message.Response; |
| | 265 | | default: |
| 0 | 266 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 267 | | } |
| 6 | 268 | | } |
| | 269 | |
|
| | 270 | | internal Core.HttpMessage CreateGetAtScopeRequest(string scope, string deploymentName) |
| | 271 | | { |
| 12 | 272 | | var message = _pipeline.CreateMessage(); |
| 12 | 273 | | var request = message.Request; |
| 12 | 274 | | request.Method = RequestMethod.Get; |
| 12 | 275 | | var uri = new RawRequestUriBuilder(); |
| 12 | 276 | | uri.Reset(endpoint); |
| 12 | 277 | | uri.AppendPath("/", false); |
| 12 | 278 | | uri.AppendPath(scope, false); |
| 12 | 279 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 12 | 280 | | uri.AppendPath(deploymentName, true); |
| 12 | 281 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 12 | 282 | | request.Uri = uri; |
| 12 | 283 | | return message; |
| | 284 | | } |
| | 285 | |
|
| | 286 | | /// <summary> Gets a deployment. </summary> |
| | 287 | | /// <param name="scope"> The resource scope. </param> |
| | 288 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 289 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 290 | | public async Task<Response<DeploymentExtended>> GetAtScopeAsync(string scope, string deploymentName, Cancellatio |
| | 291 | | { |
| 6 | 292 | | if (scope == null) |
| | 293 | | { |
| 0 | 294 | | throw new ArgumentNullException(nameof(scope)); |
| | 295 | | } |
| 6 | 296 | | if (deploymentName == null) |
| | 297 | | { |
| 0 | 298 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 299 | | } |
| | 300 | |
|
| 6 | 301 | | using var message = CreateGetAtScopeRequest(scope, deploymentName); |
| 6 | 302 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 303 | | switch (message.Response.Status) |
| | 304 | | { |
| | 305 | | case 200: |
| | 306 | | { |
| 6 | 307 | | DeploymentExtended value = default; |
| 6 | 308 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 309 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 310 | | { |
| 0 | 311 | | value = null; |
| | 312 | | } |
| | 313 | | else |
| | 314 | | { |
| 6 | 315 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 316 | | } |
| 6 | 317 | | return Response.FromValue(value, message.Response); |
| | 318 | | } |
| | 319 | | default: |
| 0 | 320 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 321 | | } |
| 6 | 322 | | } |
| | 323 | |
|
| | 324 | | /// <summary> Gets a deployment. </summary> |
| | 325 | | /// <param name="scope"> The resource scope. </param> |
| | 326 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 327 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 328 | | public Response<DeploymentExtended> GetAtScope(string scope, string deploymentName, CancellationToken cancellati |
| | 329 | | { |
| 6 | 330 | | if (scope == null) |
| | 331 | | { |
| 0 | 332 | | throw new ArgumentNullException(nameof(scope)); |
| | 333 | | } |
| 6 | 334 | | if (deploymentName == null) |
| | 335 | | { |
| 0 | 336 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 337 | | } |
| | 338 | |
|
| 6 | 339 | | using var message = CreateGetAtScopeRequest(scope, deploymentName); |
| 6 | 340 | | _pipeline.Send(message, cancellationToken); |
| 6 | 341 | | switch (message.Response.Status) |
| | 342 | | { |
| | 343 | | case 200: |
| | 344 | | { |
| 6 | 345 | | DeploymentExtended value = default; |
| 6 | 346 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 347 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 348 | | { |
| 0 | 349 | | value = null; |
| | 350 | | } |
| | 351 | | else |
| | 352 | | { |
| 6 | 353 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 354 | | } |
| 6 | 355 | | return Response.FromValue(value, message.Response); |
| | 356 | | } |
| | 357 | | default: |
| 0 | 358 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 359 | | } |
| 6 | 360 | | } |
| | 361 | |
|
| | 362 | | internal Core.HttpMessage CreateCancelAtScopeRequest(string scope, string deploymentName) |
| | 363 | | { |
| 0 | 364 | | var message = _pipeline.CreateMessage(); |
| 0 | 365 | | var request = message.Request; |
| 0 | 366 | | request.Method = RequestMethod.Post; |
| 0 | 367 | | var uri = new RawRequestUriBuilder(); |
| 0 | 368 | | uri.Reset(endpoint); |
| 0 | 369 | | uri.AppendPath("/", false); |
| 0 | 370 | | uri.AppendPath(scope, false); |
| 0 | 371 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 372 | | uri.AppendPath(deploymentName, true); |
| 0 | 373 | | uri.AppendPath("/cancel", false); |
| 0 | 374 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 375 | | request.Uri = uri; |
| 0 | 376 | | return message; |
| | 377 | | } |
| | 378 | |
|
| | 379 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 380 | | /// <param name="scope"> The resource scope. </param> |
| | 381 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 382 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 383 | | public async Task<Response> CancelAtScopeAsync(string scope, string deploymentName, CancellationToken cancellati |
| | 384 | | { |
| 0 | 385 | | if (scope == null) |
| | 386 | | { |
| 0 | 387 | | throw new ArgumentNullException(nameof(scope)); |
| | 388 | | } |
| 0 | 389 | | if (deploymentName == null) |
| | 390 | | { |
| 0 | 391 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 392 | | } |
| | 393 | |
|
| 0 | 394 | | using var message = CreateCancelAtScopeRequest(scope, deploymentName); |
| 0 | 395 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 396 | | switch (message.Response.Status) |
| | 397 | | { |
| | 398 | | case 204: |
| 0 | 399 | | return message.Response; |
| | 400 | | default: |
| 0 | 401 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 402 | | } |
| 0 | 403 | | } |
| | 404 | |
|
| | 405 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 406 | | /// <param name="scope"> The resource scope. </param> |
| | 407 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 408 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 409 | | public Response CancelAtScope(string scope, string deploymentName, CancellationToken cancellationToken = default |
| | 410 | | { |
| 0 | 411 | | if (scope == null) |
| | 412 | | { |
| 0 | 413 | | throw new ArgumentNullException(nameof(scope)); |
| | 414 | | } |
| 0 | 415 | | if (deploymentName == null) |
| | 416 | | { |
| 0 | 417 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 418 | | } |
| | 419 | |
|
| 0 | 420 | | using var message = CreateCancelAtScopeRequest(scope, deploymentName); |
| 0 | 421 | | _pipeline.Send(message, cancellationToken); |
| 0 | 422 | | switch (message.Response.Status) |
| | 423 | | { |
| | 424 | | case 204: |
| 0 | 425 | | return message.Response; |
| | 426 | | default: |
| 0 | 427 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 428 | | } |
| 0 | 429 | | } |
| | 430 | |
|
| | 431 | | internal Core.HttpMessage CreateValidateAtScopeRequest(string scope, string deploymentName, Deployment parameter |
| | 432 | | { |
| 24 | 433 | | var message = _pipeline.CreateMessage(); |
| 24 | 434 | | var request = message.Request; |
| 24 | 435 | | request.Method = RequestMethod.Post; |
| 24 | 436 | | var uri = new RawRequestUriBuilder(); |
| 24 | 437 | | uri.Reset(endpoint); |
| 24 | 438 | | uri.AppendPath("/", false); |
| 24 | 439 | | uri.AppendPath(scope, false); |
| 24 | 440 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 24 | 441 | | uri.AppendPath(deploymentName, true); |
| 24 | 442 | | uri.AppendPath("/validate", false); |
| 24 | 443 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 24 | 444 | | request.Uri = uri; |
| 24 | 445 | | request.Headers.Add("Content-Type", "application/json"); |
| 24 | 446 | | var content = new Utf8JsonRequestContent(); |
| 24 | 447 | | content.JsonWriter.WriteObjectValue(parameters); |
| 24 | 448 | | request.Content = content; |
| 24 | 449 | | return message; |
| | 450 | | } |
| | 451 | |
|
| | 452 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 453 | | /// <param name="scope"> The resource scope. </param> |
| | 454 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 455 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 456 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 457 | | public async Task<Response> ValidateAtScopeAsync(string scope, string deploymentName, Deployment parameters, Can |
| | 458 | | { |
| 6 | 459 | | if (scope == null) |
| | 460 | | { |
| 0 | 461 | | throw new ArgumentNullException(nameof(scope)); |
| | 462 | | } |
| 6 | 463 | | if (deploymentName == null) |
| | 464 | | { |
| 0 | 465 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 466 | | } |
| 6 | 467 | | if (parameters == null) |
| | 468 | | { |
| 0 | 469 | | throw new ArgumentNullException(nameof(parameters)); |
| | 470 | | } |
| | 471 | |
|
| 6 | 472 | | using var message = CreateValidateAtScopeRequest(scope, deploymentName, parameters); |
| 6 | 473 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 474 | | switch (message.Response.Status) |
| | 475 | | { |
| | 476 | | case 200: |
| | 477 | | case 202: |
| | 478 | | case 400: |
| 6 | 479 | | return message.Response; |
| | 480 | | default: |
| 0 | 481 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 482 | | } |
| 6 | 483 | | } |
| | 484 | |
|
| | 485 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 486 | | /// <param name="scope"> The resource scope. </param> |
| | 487 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 488 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 489 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 490 | | public Response ValidateAtScope(string scope, string deploymentName, Deployment parameters, CancellationToken ca |
| | 491 | | { |
| 6 | 492 | | if (scope == null) |
| | 493 | | { |
| 0 | 494 | | throw new ArgumentNullException(nameof(scope)); |
| | 495 | | } |
| 6 | 496 | | if (deploymentName == null) |
| | 497 | | { |
| 0 | 498 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 499 | | } |
| 6 | 500 | | if (parameters == null) |
| | 501 | | { |
| 0 | 502 | | throw new ArgumentNullException(nameof(parameters)); |
| | 503 | | } |
| | 504 | |
|
| 6 | 505 | | using var message = CreateValidateAtScopeRequest(scope, deploymentName, parameters); |
| 6 | 506 | | _pipeline.Send(message, cancellationToken); |
| 6 | 507 | | switch (message.Response.Status) |
| | 508 | | { |
| | 509 | | case 200: |
| | 510 | | case 202: |
| | 511 | | case 400: |
| 6 | 512 | | return message.Response; |
| | 513 | | default: |
| 0 | 514 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 515 | | } |
| 6 | 516 | | } |
| | 517 | |
|
| | 518 | | internal Core.HttpMessage CreateExportTemplateAtScopeRequest(string scope, string deploymentName) |
| | 519 | | { |
| 0 | 520 | | var message = _pipeline.CreateMessage(); |
| 0 | 521 | | var request = message.Request; |
| 0 | 522 | | request.Method = RequestMethod.Post; |
| 0 | 523 | | var uri = new RawRequestUriBuilder(); |
| 0 | 524 | | uri.Reset(endpoint); |
| 0 | 525 | | uri.AppendPath("/", false); |
| 0 | 526 | | uri.AppendPath(scope, false); |
| 0 | 527 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 528 | | uri.AppendPath(deploymentName, true); |
| 0 | 529 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 530 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 531 | | request.Uri = uri; |
| 0 | 532 | | return message; |
| | 533 | | } |
| | 534 | |
|
| | 535 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 536 | | /// <param name="scope"> The resource scope. </param> |
| | 537 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 538 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 539 | | public async Task<Response<DeploymentExportResult>> ExportTemplateAtScopeAsync(string scope, string deploymentNa |
| | 540 | | { |
| 0 | 541 | | if (scope == null) |
| | 542 | | { |
| 0 | 543 | | throw new ArgumentNullException(nameof(scope)); |
| | 544 | | } |
| 0 | 545 | | if (deploymentName == null) |
| | 546 | | { |
| 0 | 547 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 548 | | } |
| | 549 | |
|
| 0 | 550 | | using var message = CreateExportTemplateAtScopeRequest(scope, deploymentName); |
| 0 | 551 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 552 | | switch (message.Response.Status) |
| | 553 | | { |
| | 554 | | case 200: |
| | 555 | | { |
| 0 | 556 | | DeploymentExportResult value = default; |
| 0 | 557 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 558 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 559 | | { |
| 0 | 560 | | value = null; |
| | 561 | | } |
| | 562 | | else |
| | 563 | | { |
| 0 | 564 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 565 | | } |
| 0 | 566 | | return Response.FromValue(value, message.Response); |
| | 567 | | } |
| | 568 | | default: |
| 0 | 569 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 570 | | } |
| 0 | 571 | | } |
| | 572 | |
|
| | 573 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 574 | | /// <param name="scope"> The resource scope. </param> |
| | 575 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 576 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 577 | | public Response<DeploymentExportResult> ExportTemplateAtScope(string scope, string deploymentName, CancellationT |
| | 578 | | { |
| 0 | 579 | | if (scope == null) |
| | 580 | | { |
| 0 | 581 | | throw new ArgumentNullException(nameof(scope)); |
| | 582 | | } |
| 0 | 583 | | if (deploymentName == null) |
| | 584 | | { |
| 0 | 585 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 586 | | } |
| | 587 | |
|
| 0 | 588 | | using var message = CreateExportTemplateAtScopeRequest(scope, deploymentName); |
| 0 | 589 | | _pipeline.Send(message, cancellationToken); |
| 0 | 590 | | switch (message.Response.Status) |
| | 591 | | { |
| | 592 | | case 200: |
| | 593 | | { |
| 0 | 594 | | DeploymentExportResult value = default; |
| 0 | 595 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 596 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 597 | | { |
| 0 | 598 | | value = null; |
| | 599 | | } |
| | 600 | | else |
| | 601 | | { |
| 0 | 602 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 603 | | } |
| 0 | 604 | | return Response.FromValue(value, message.Response); |
| | 605 | | } |
| | 606 | | default: |
| 0 | 607 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 608 | | } |
| 0 | 609 | | } |
| | 610 | |
|
| | 611 | | internal Core.HttpMessage CreateListAtScopeRequest(string scope, string filter, int? top) |
| | 612 | | { |
| 0 | 613 | | var message = _pipeline.CreateMessage(); |
| 0 | 614 | | var request = message.Request; |
| 0 | 615 | | request.Method = RequestMethod.Get; |
| 0 | 616 | | var uri = new RawRequestUriBuilder(); |
| 0 | 617 | | uri.Reset(endpoint); |
| 0 | 618 | | uri.AppendPath("/", false); |
| 0 | 619 | | uri.AppendPath(scope, false); |
| 0 | 620 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 621 | | if (filter != null) |
| | 622 | | { |
| 0 | 623 | | uri.AppendQuery("$filter", filter, true); |
| | 624 | | } |
| 0 | 625 | | if (top != null) |
| | 626 | | { |
| 0 | 627 | | uri.AppendQuery("$top", top.Value, true); |
| | 628 | | } |
| 0 | 629 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 630 | | request.Uri = uri; |
| 0 | 631 | | return message; |
| | 632 | | } |
| | 633 | |
|
| | 634 | | /// <summary> Get all the deployments at the given scope. </summary> |
| | 635 | | /// <param name="scope"> The resource scope. </param> |
| | 636 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 637 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 638 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 639 | | public async Task<Response<DeploymentListResult>> ListAtScopeAsync(string scope, string filter = null, int? top |
| | 640 | | { |
| 0 | 641 | | if (scope == null) |
| | 642 | | { |
| 0 | 643 | | throw new ArgumentNullException(nameof(scope)); |
| | 644 | | } |
| | 645 | |
|
| 0 | 646 | | using var message = CreateListAtScopeRequest(scope, filter, top); |
| 0 | 647 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 648 | | switch (message.Response.Status) |
| | 649 | | { |
| | 650 | | case 200: |
| | 651 | | { |
| 0 | 652 | | DeploymentListResult value = default; |
| 0 | 653 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 654 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 655 | | { |
| 0 | 656 | | value = null; |
| | 657 | | } |
| | 658 | | else |
| | 659 | | { |
| 0 | 660 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 661 | | } |
| 0 | 662 | | return Response.FromValue(value, message.Response); |
| | 663 | | } |
| | 664 | | default: |
| 0 | 665 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 666 | | } |
| 0 | 667 | | } |
| | 668 | |
|
| | 669 | | /// <summary> Get all the deployments at the given scope. </summary> |
| | 670 | | /// <param name="scope"> The resource scope. </param> |
| | 671 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 672 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 673 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 674 | | public Response<DeploymentListResult> ListAtScope(string scope, string filter = null, int? top = null, Cancellat |
| | 675 | | { |
| 0 | 676 | | if (scope == null) |
| | 677 | | { |
| 0 | 678 | | throw new ArgumentNullException(nameof(scope)); |
| | 679 | | } |
| | 680 | |
|
| 0 | 681 | | using var message = CreateListAtScopeRequest(scope, filter, top); |
| 0 | 682 | | _pipeline.Send(message, cancellationToken); |
| 0 | 683 | | switch (message.Response.Status) |
| | 684 | | { |
| | 685 | | case 200: |
| | 686 | | { |
| 0 | 687 | | DeploymentListResult value = default; |
| 0 | 688 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 689 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 690 | | { |
| 0 | 691 | | value = null; |
| | 692 | | } |
| | 693 | | else |
| | 694 | | { |
| 0 | 695 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 696 | | } |
| 0 | 697 | | return Response.FromValue(value, message.Response); |
| | 698 | | } |
| | 699 | | default: |
| 0 | 700 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 701 | | } |
| 0 | 702 | | } |
| | 703 | |
|
| | 704 | | internal Core.HttpMessage CreateDeleteAtTenantScopeRequest(string deploymentName) |
| | 705 | | { |
| 0 | 706 | | var message = _pipeline.CreateMessage(); |
| 0 | 707 | | var request = message.Request; |
| 0 | 708 | | request.Method = RequestMethod.Delete; |
| 0 | 709 | | var uri = new RawRequestUriBuilder(); |
| 0 | 710 | | uri.Reset(endpoint); |
| 0 | 711 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 712 | | uri.AppendPath(deploymentName, true); |
| 0 | 713 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 714 | | request.Uri = uri; |
| 0 | 715 | | return message; |
| | 716 | | } |
| | 717 | |
|
| | 718 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 719 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 720 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 721 | | public async Task<Response> DeleteAtTenantScopeAsync(string deploymentName, CancellationToken cancellationToken |
| | 722 | | { |
| 0 | 723 | | if (deploymentName == null) |
| | 724 | | { |
| 0 | 725 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 726 | | } |
| | 727 | |
|
| 0 | 728 | | using var message = CreateDeleteAtTenantScopeRequest(deploymentName); |
| 0 | 729 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 730 | | switch (message.Response.Status) |
| | 731 | | { |
| | 732 | | case 202: |
| | 733 | | case 204: |
| 0 | 734 | | return message.Response; |
| | 735 | | default: |
| 0 | 736 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 737 | | } |
| 0 | 738 | | } |
| | 739 | |
|
| | 740 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 741 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 742 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 743 | | public Response DeleteAtTenantScope(string deploymentName, CancellationToken cancellationToken = default) |
| | 744 | | { |
| 0 | 745 | | if (deploymentName == null) |
| | 746 | | { |
| 0 | 747 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 748 | | } |
| | 749 | |
|
| 0 | 750 | | using var message = CreateDeleteAtTenantScopeRequest(deploymentName); |
| 0 | 751 | | _pipeline.Send(message, cancellationToken); |
| 0 | 752 | | switch (message.Response.Status) |
| | 753 | | { |
| | 754 | | case 202: |
| | 755 | | case 204: |
| 0 | 756 | | return message.Response; |
| | 757 | | default: |
| 0 | 758 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 759 | | } |
| 0 | 760 | | } |
| | 761 | |
|
| | 762 | | internal Core.HttpMessage CreateCheckExistenceAtTenantScopeRequest(string deploymentName) |
| | 763 | | { |
| 0 | 764 | | var message = _pipeline.CreateMessage(); |
| 0 | 765 | | var request = message.Request; |
| 0 | 766 | | request.Method = RequestMethod.Head; |
| 0 | 767 | | var uri = new RawRequestUriBuilder(); |
| 0 | 768 | | uri.Reset(endpoint); |
| 0 | 769 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 770 | | uri.AppendPath(deploymentName, true); |
| 0 | 771 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 772 | | request.Uri = uri; |
| 0 | 773 | | return message; |
| | 774 | | } |
| | 775 | |
|
| | 776 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 777 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 778 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 779 | | public async Task<Response> CheckExistenceAtTenantScopeAsync(string deploymentName, CancellationToken cancellati |
| | 780 | | { |
| 0 | 781 | | if (deploymentName == null) |
| | 782 | | { |
| 0 | 783 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 784 | | } |
| | 785 | |
|
| 0 | 786 | | using var message = CreateCheckExistenceAtTenantScopeRequest(deploymentName); |
| 0 | 787 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 788 | | switch (message.Response.Status) |
| | 789 | | { |
| | 790 | | case 204: |
| | 791 | | case 404: |
| 0 | 792 | | return message.Response; |
| | 793 | | default: |
| 0 | 794 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 795 | | } |
| 0 | 796 | | } |
| | 797 | |
|
| | 798 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 799 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 800 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 801 | | public Response CheckExistenceAtTenantScope(string deploymentName, CancellationToken cancellationToken = default |
| | 802 | | { |
| 0 | 803 | | if (deploymentName == null) |
| | 804 | | { |
| 0 | 805 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 806 | | } |
| | 807 | |
|
| 0 | 808 | | using var message = CreateCheckExistenceAtTenantScopeRequest(deploymentName); |
| 0 | 809 | | _pipeline.Send(message, cancellationToken); |
| 0 | 810 | | switch (message.Response.Status) |
| | 811 | | { |
| | 812 | | case 204: |
| | 813 | | case 404: |
| 0 | 814 | | return message.Response; |
| | 815 | | default: |
| 0 | 816 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 817 | | } |
| 0 | 818 | | } |
| | 819 | |
|
| | 820 | | internal Core.HttpMessage CreateCreateOrUpdateAtTenantScopeRequest(string deploymentName, ScopedDeployment param |
| | 821 | | { |
| 0 | 822 | | var message = _pipeline.CreateMessage(); |
| 0 | 823 | | var request = message.Request; |
| 0 | 824 | | request.Method = RequestMethod.Put; |
| 0 | 825 | | var uri = new RawRequestUriBuilder(); |
| 0 | 826 | | uri.Reset(endpoint); |
| 0 | 827 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 828 | | uri.AppendPath(deploymentName, true); |
| 0 | 829 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 830 | | request.Uri = uri; |
| 0 | 831 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 832 | | var content = new Utf8JsonRequestContent(); |
| 0 | 833 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 834 | | request.Content = content; |
| 0 | 835 | | return message; |
| | 836 | | } |
| | 837 | |
|
| | 838 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 839 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 840 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 841 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 842 | | public async Task<Response> CreateOrUpdateAtTenantScopeAsync(string deploymentName, ScopedDeployment parameters, |
| | 843 | | { |
| 0 | 844 | | if (deploymentName == null) |
| | 845 | | { |
| 0 | 846 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 847 | | } |
| 0 | 848 | | if (parameters == null) |
| | 849 | | { |
| 0 | 850 | | throw new ArgumentNullException(nameof(parameters)); |
| | 851 | | } |
| | 852 | |
|
| 0 | 853 | | using var message = CreateCreateOrUpdateAtTenantScopeRequest(deploymentName, parameters); |
| 0 | 854 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 855 | | switch (message.Response.Status) |
| | 856 | | { |
| | 857 | | case 200: |
| | 858 | | case 201: |
| 0 | 859 | | return message.Response; |
| | 860 | | default: |
| 0 | 861 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 862 | | } |
| 0 | 863 | | } |
| | 864 | |
|
| | 865 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 866 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 867 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 868 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 869 | | public Response CreateOrUpdateAtTenantScope(string deploymentName, ScopedDeployment parameters, CancellationToke |
| | 870 | | { |
| 0 | 871 | | if (deploymentName == null) |
| | 872 | | { |
| 0 | 873 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 874 | | } |
| 0 | 875 | | if (parameters == null) |
| | 876 | | { |
| 0 | 877 | | throw new ArgumentNullException(nameof(parameters)); |
| | 878 | | } |
| | 879 | |
|
| 0 | 880 | | using var message = CreateCreateOrUpdateAtTenantScopeRequest(deploymentName, parameters); |
| 0 | 881 | | _pipeline.Send(message, cancellationToken); |
| 0 | 882 | | switch (message.Response.Status) |
| | 883 | | { |
| | 884 | | case 200: |
| | 885 | | case 201: |
| 0 | 886 | | return message.Response; |
| | 887 | | default: |
| 0 | 888 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 889 | | } |
| 0 | 890 | | } |
| | 891 | |
|
| | 892 | | internal Core.HttpMessage CreateGetAtTenantScopeRequest(string deploymentName) |
| | 893 | | { |
| 0 | 894 | | var message = _pipeline.CreateMessage(); |
| 0 | 895 | | var request = message.Request; |
| 0 | 896 | | request.Method = RequestMethod.Get; |
| 0 | 897 | | var uri = new RawRequestUriBuilder(); |
| 0 | 898 | | uri.Reset(endpoint); |
| 0 | 899 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 900 | | uri.AppendPath(deploymentName, true); |
| 0 | 901 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 902 | | request.Uri = uri; |
| 0 | 903 | | return message; |
| | 904 | | } |
| | 905 | |
|
| | 906 | | /// <summary> Gets a deployment. </summary> |
| | 907 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 908 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 909 | | public async Task<Response<DeploymentExtended>> GetAtTenantScopeAsync(string deploymentName, CancellationToken c |
| | 910 | | { |
| 0 | 911 | | if (deploymentName == null) |
| | 912 | | { |
| 0 | 913 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 914 | | } |
| | 915 | |
|
| 0 | 916 | | using var message = CreateGetAtTenantScopeRequest(deploymentName); |
| 0 | 917 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 918 | | switch (message.Response.Status) |
| | 919 | | { |
| | 920 | | case 200: |
| | 921 | | { |
| 0 | 922 | | DeploymentExtended value = default; |
| 0 | 923 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 924 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 925 | | { |
| 0 | 926 | | value = null; |
| | 927 | | } |
| | 928 | | else |
| | 929 | | { |
| 0 | 930 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 931 | | } |
| 0 | 932 | | return Response.FromValue(value, message.Response); |
| | 933 | | } |
| | 934 | | default: |
| 0 | 935 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 936 | | } |
| 0 | 937 | | } |
| | 938 | |
|
| | 939 | | /// <summary> Gets a deployment. </summary> |
| | 940 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 941 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 942 | | public Response<DeploymentExtended> GetAtTenantScope(string deploymentName, CancellationToken cancellationToken |
| | 943 | | { |
| 0 | 944 | | if (deploymentName == null) |
| | 945 | | { |
| 0 | 946 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 947 | | } |
| | 948 | |
|
| 0 | 949 | | using var message = CreateGetAtTenantScopeRequest(deploymentName); |
| 0 | 950 | | _pipeline.Send(message, cancellationToken); |
| 0 | 951 | | switch (message.Response.Status) |
| | 952 | | { |
| | 953 | | case 200: |
| | 954 | | { |
| 0 | 955 | | DeploymentExtended value = default; |
| 0 | 956 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 957 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 958 | | { |
| 0 | 959 | | value = null; |
| | 960 | | } |
| | 961 | | else |
| | 962 | | { |
| 0 | 963 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 964 | | } |
| 0 | 965 | | return Response.FromValue(value, message.Response); |
| | 966 | | } |
| | 967 | | default: |
| 0 | 968 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 969 | | } |
| 0 | 970 | | } |
| | 971 | |
|
| | 972 | | internal Core.HttpMessage CreateCancelAtTenantScopeRequest(string deploymentName) |
| | 973 | | { |
| 0 | 974 | | var message = _pipeline.CreateMessage(); |
| 0 | 975 | | var request = message.Request; |
| 0 | 976 | | request.Method = RequestMethod.Post; |
| 0 | 977 | | var uri = new RawRequestUriBuilder(); |
| 0 | 978 | | uri.Reset(endpoint); |
| 0 | 979 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 980 | | uri.AppendPath(deploymentName, true); |
| 0 | 981 | | uri.AppendPath("/cancel", false); |
| 0 | 982 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 983 | | request.Uri = uri; |
| 0 | 984 | | return message; |
| | 985 | | } |
| | 986 | |
|
| | 987 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 988 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 989 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 990 | | public async Task<Response> CancelAtTenantScopeAsync(string deploymentName, CancellationToken cancellationToken |
| | 991 | | { |
| 0 | 992 | | if (deploymentName == null) |
| | 993 | | { |
| 0 | 994 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 995 | | } |
| | 996 | |
|
| 0 | 997 | | using var message = CreateCancelAtTenantScopeRequest(deploymentName); |
| 0 | 998 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 999 | | switch (message.Response.Status) |
| | 1000 | | { |
| | 1001 | | case 204: |
| 0 | 1002 | | return message.Response; |
| | 1003 | | default: |
| 0 | 1004 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1005 | | } |
| 0 | 1006 | | } |
| | 1007 | |
|
| | 1008 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 1009 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1010 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1011 | | public Response CancelAtTenantScope(string deploymentName, CancellationToken cancellationToken = default) |
| | 1012 | | { |
| 0 | 1013 | | if (deploymentName == null) |
| | 1014 | | { |
| 0 | 1015 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1016 | | } |
| | 1017 | |
|
| 0 | 1018 | | using var message = CreateCancelAtTenantScopeRequest(deploymentName); |
| 0 | 1019 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1020 | | switch (message.Response.Status) |
| | 1021 | | { |
| | 1022 | | case 204: |
| 0 | 1023 | | return message.Response; |
| | 1024 | | default: |
| 0 | 1025 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1026 | | } |
| 0 | 1027 | | } |
| | 1028 | |
|
| | 1029 | | internal Core.HttpMessage CreateValidateAtTenantScopeRequest(string deploymentName, ScopedDeployment parameters) |
| | 1030 | | { |
| 0 | 1031 | | var message = _pipeline.CreateMessage(); |
| 0 | 1032 | | var request = message.Request; |
| 0 | 1033 | | request.Method = RequestMethod.Post; |
| 0 | 1034 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1035 | | uri.Reset(endpoint); |
| 0 | 1036 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1037 | | uri.AppendPath(deploymentName, true); |
| 0 | 1038 | | uri.AppendPath("/validate", false); |
| 0 | 1039 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1040 | | request.Uri = uri; |
| 0 | 1041 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 1042 | | var content = new Utf8JsonRequestContent(); |
| 0 | 1043 | | content.JsonWriter.WriteObjectValue(parameters); |
| 0 | 1044 | | request.Content = content; |
| 0 | 1045 | | return message; |
| | 1046 | | } |
| | 1047 | |
|
| | 1048 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 1049 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1050 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 1051 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1052 | | public async Task<Response> ValidateAtTenantScopeAsync(string deploymentName, ScopedDeployment parameters, Cance |
| | 1053 | | { |
| 0 | 1054 | | if (deploymentName == null) |
| | 1055 | | { |
| 0 | 1056 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1057 | | } |
| 0 | 1058 | | if (parameters == null) |
| | 1059 | | { |
| 0 | 1060 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1061 | | } |
| | 1062 | |
|
| 0 | 1063 | | using var message = CreateValidateAtTenantScopeRequest(deploymentName, parameters); |
| 0 | 1064 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1065 | | switch (message.Response.Status) |
| | 1066 | | { |
| | 1067 | | case 200: |
| | 1068 | | case 202: |
| | 1069 | | case 400: |
| 0 | 1070 | | return message.Response; |
| | 1071 | | default: |
| 0 | 1072 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1073 | | } |
| 0 | 1074 | | } |
| | 1075 | |
|
| | 1076 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 1077 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1078 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 1079 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1080 | | public Response ValidateAtTenantScope(string deploymentName, ScopedDeployment parameters, CancellationToken canc |
| | 1081 | | { |
| 0 | 1082 | | if (deploymentName == null) |
| | 1083 | | { |
| 0 | 1084 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1085 | | } |
| 0 | 1086 | | if (parameters == null) |
| | 1087 | | { |
| 0 | 1088 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1089 | | } |
| | 1090 | |
|
| 0 | 1091 | | using var message = CreateValidateAtTenantScopeRequest(deploymentName, parameters); |
| 0 | 1092 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1093 | | switch (message.Response.Status) |
| | 1094 | | { |
| | 1095 | | case 200: |
| | 1096 | | case 202: |
| | 1097 | | case 400: |
| 0 | 1098 | | return message.Response; |
| | 1099 | | default: |
| 0 | 1100 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1101 | | } |
| 0 | 1102 | | } |
| | 1103 | |
|
| | 1104 | | internal Core.HttpMessage CreateExportTemplateAtTenantScopeRequest(string deploymentName) |
| | 1105 | | { |
| 0 | 1106 | | var message = _pipeline.CreateMessage(); |
| 0 | 1107 | | var request = message.Request; |
| 0 | 1108 | | request.Method = RequestMethod.Post; |
| 0 | 1109 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1110 | | uri.Reset(endpoint); |
| 0 | 1111 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1112 | | uri.AppendPath(deploymentName, true); |
| 0 | 1113 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 1114 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1115 | | request.Uri = uri; |
| 0 | 1116 | | return message; |
| | 1117 | | } |
| | 1118 | |
|
| | 1119 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 1120 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1121 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1122 | | public async Task<Response<DeploymentExportResult>> ExportTemplateAtTenantScopeAsync(string deploymentName, Canc |
| | 1123 | | { |
| 0 | 1124 | | if (deploymentName == null) |
| | 1125 | | { |
| 0 | 1126 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1127 | | } |
| | 1128 | |
|
| 0 | 1129 | | using var message = CreateExportTemplateAtTenantScopeRequest(deploymentName); |
| 0 | 1130 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1131 | | switch (message.Response.Status) |
| | 1132 | | { |
| | 1133 | | case 200: |
| | 1134 | | { |
| 0 | 1135 | | DeploymentExportResult value = default; |
| 0 | 1136 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1137 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1138 | | { |
| 0 | 1139 | | value = null; |
| | 1140 | | } |
| | 1141 | | else |
| | 1142 | | { |
| 0 | 1143 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 1144 | | } |
| 0 | 1145 | | return Response.FromValue(value, message.Response); |
| | 1146 | | } |
| | 1147 | | default: |
| 0 | 1148 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1149 | | } |
| 0 | 1150 | | } |
| | 1151 | |
|
| | 1152 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 1153 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1154 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1155 | | public Response<DeploymentExportResult> ExportTemplateAtTenantScope(string deploymentName, CancellationToken can |
| | 1156 | | { |
| 0 | 1157 | | if (deploymentName == null) |
| | 1158 | | { |
| 0 | 1159 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1160 | | } |
| | 1161 | |
|
| 0 | 1162 | | using var message = CreateExportTemplateAtTenantScopeRequest(deploymentName); |
| 0 | 1163 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1164 | | switch (message.Response.Status) |
| | 1165 | | { |
| | 1166 | | case 200: |
| | 1167 | | { |
| 0 | 1168 | | DeploymentExportResult value = default; |
| 0 | 1169 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1170 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1171 | | { |
| 0 | 1172 | | value = null; |
| | 1173 | | } |
| | 1174 | | else |
| | 1175 | | { |
| 0 | 1176 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 1177 | | } |
| 0 | 1178 | | return Response.FromValue(value, message.Response); |
| | 1179 | | } |
| | 1180 | | default: |
| 0 | 1181 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1182 | | } |
| 0 | 1183 | | } |
| | 1184 | |
|
| | 1185 | | internal Core.HttpMessage CreateListAtTenantScopeRequest(string filter, int? top) |
| | 1186 | | { |
| 0 | 1187 | | var message = _pipeline.CreateMessage(); |
| 0 | 1188 | | var request = message.Request; |
| 0 | 1189 | | request.Method = RequestMethod.Get; |
| 0 | 1190 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1191 | | uri.Reset(endpoint); |
| 0 | 1192 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1193 | | if (filter != null) |
| | 1194 | | { |
| 0 | 1195 | | uri.AppendQuery("$filter", filter, true); |
| | 1196 | | } |
| 0 | 1197 | | if (top != null) |
| | 1198 | | { |
| 0 | 1199 | | uri.AppendQuery("$top", top.Value, true); |
| | 1200 | | } |
| 0 | 1201 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1202 | | request.Uri = uri; |
| 0 | 1203 | | return message; |
| | 1204 | | } |
| | 1205 | |
|
| | 1206 | | /// <summary> Get all the deployments at the tenant scope. </summary> |
| | 1207 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 1208 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 1209 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1210 | | public async Task<Response<DeploymentListResult>> ListAtTenantScopeAsync(string filter = null, int? top = null, |
| | 1211 | | { |
| 0 | 1212 | | using var message = CreateListAtTenantScopeRequest(filter, top); |
| 0 | 1213 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1214 | | switch (message.Response.Status) |
| | 1215 | | { |
| | 1216 | | case 200: |
| | 1217 | | { |
| 0 | 1218 | | DeploymentListResult value = default; |
| 0 | 1219 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1220 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1221 | | { |
| 0 | 1222 | | value = null; |
| | 1223 | | } |
| | 1224 | | else |
| | 1225 | | { |
| 0 | 1226 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 1227 | | } |
| 0 | 1228 | | return Response.FromValue(value, message.Response); |
| | 1229 | | } |
| | 1230 | | default: |
| 0 | 1231 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1232 | | } |
| 0 | 1233 | | } |
| | 1234 | |
|
| | 1235 | | /// <summary> Get all the deployments at the tenant scope. </summary> |
| | 1236 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 1237 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 1238 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1239 | | public Response<DeploymentListResult> ListAtTenantScope(string filter = null, int? top = null, CancellationToken |
| | 1240 | | { |
| 0 | 1241 | | using var message = CreateListAtTenantScopeRequest(filter, top); |
| 0 | 1242 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1243 | | switch (message.Response.Status) |
| | 1244 | | { |
| | 1245 | | case 200: |
| | 1246 | | { |
| 0 | 1247 | | DeploymentListResult value = default; |
| 0 | 1248 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1249 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1250 | | { |
| 0 | 1251 | | value = null; |
| | 1252 | | } |
| | 1253 | | else |
| | 1254 | | { |
| 0 | 1255 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 1256 | | } |
| 0 | 1257 | | return Response.FromValue(value, message.Response); |
| | 1258 | | } |
| | 1259 | | default: |
| 0 | 1260 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1261 | | } |
| 0 | 1262 | | } |
| | 1263 | |
|
| | 1264 | | internal Core.HttpMessage CreateDeleteAtManagementGroupScopeRequest(string groupId, string deploymentName) |
| | 1265 | | { |
| 0 | 1266 | | var message = _pipeline.CreateMessage(); |
| 0 | 1267 | | var request = message.Request; |
| 0 | 1268 | | request.Method = RequestMethod.Delete; |
| 0 | 1269 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1270 | | uri.Reset(endpoint); |
| 0 | 1271 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 0 | 1272 | | uri.AppendPath(groupId, true); |
| 0 | 1273 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1274 | | uri.AppendPath(deploymentName, true); |
| 0 | 1275 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1276 | | request.Uri = uri; |
| 0 | 1277 | | return message; |
| | 1278 | | } |
| | 1279 | |
|
| | 1280 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 1281 | | /// <param name="groupId"> The management group ID. </param> |
| | 1282 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1283 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1284 | | public async Task<Response> DeleteAtManagementGroupScopeAsync(string groupId, string deploymentName, Cancellatio |
| | 1285 | | { |
| 0 | 1286 | | if (groupId == null) |
| | 1287 | | { |
| 0 | 1288 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1289 | | } |
| 0 | 1290 | | if (deploymentName == null) |
| | 1291 | | { |
| 0 | 1292 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1293 | | } |
| | 1294 | |
|
| 0 | 1295 | | using var message = CreateDeleteAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1296 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1297 | | switch (message.Response.Status) |
| | 1298 | | { |
| | 1299 | | case 202: |
| | 1300 | | case 204: |
| 0 | 1301 | | return message.Response; |
| | 1302 | | default: |
| 0 | 1303 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1304 | | } |
| 0 | 1305 | | } |
| | 1306 | |
|
| | 1307 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 1308 | | /// <param name="groupId"> The management group ID. </param> |
| | 1309 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1310 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1311 | | public Response DeleteAtManagementGroupScope(string groupId, string deploymentName, CancellationToken cancellati |
| | 1312 | | { |
| 0 | 1313 | | if (groupId == null) |
| | 1314 | | { |
| 0 | 1315 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1316 | | } |
| 0 | 1317 | | if (deploymentName == null) |
| | 1318 | | { |
| 0 | 1319 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1320 | | } |
| | 1321 | |
|
| 0 | 1322 | | using var message = CreateDeleteAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1323 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1324 | | switch (message.Response.Status) |
| | 1325 | | { |
| | 1326 | | case 202: |
| | 1327 | | case 204: |
| 0 | 1328 | | return message.Response; |
| | 1329 | | default: |
| 0 | 1330 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1331 | | } |
| 0 | 1332 | | } |
| | 1333 | |
|
| | 1334 | | internal Core.HttpMessage CreateCheckExistenceAtManagementGroupScopeRequest(string groupId, string deploymentNam |
| | 1335 | | { |
| 0 | 1336 | | var message = _pipeline.CreateMessage(); |
| 0 | 1337 | | var request = message.Request; |
| 0 | 1338 | | request.Method = RequestMethod.Head; |
| 0 | 1339 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1340 | | uri.Reset(endpoint); |
| 0 | 1341 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 0 | 1342 | | uri.AppendPath(groupId, true); |
| 0 | 1343 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1344 | | uri.AppendPath(deploymentName, true); |
| 0 | 1345 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1346 | | request.Uri = uri; |
| 0 | 1347 | | return message; |
| | 1348 | | } |
| | 1349 | |
|
| | 1350 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 1351 | | /// <param name="groupId"> The management group ID. </param> |
| | 1352 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1353 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1354 | | public async Task<Response> CheckExistenceAtManagementGroupScopeAsync(string groupId, string deploymentName, Can |
| | 1355 | | { |
| 0 | 1356 | | if (groupId == null) |
| | 1357 | | { |
| 0 | 1358 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1359 | | } |
| 0 | 1360 | | if (deploymentName == null) |
| | 1361 | | { |
| 0 | 1362 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1363 | | } |
| | 1364 | |
|
| 0 | 1365 | | using var message = CreateCheckExistenceAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1366 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1367 | | switch (message.Response.Status) |
| | 1368 | | { |
| | 1369 | | case 204: |
| | 1370 | | case 404: |
| 0 | 1371 | | return message.Response; |
| | 1372 | | default: |
| 0 | 1373 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1374 | | } |
| 0 | 1375 | | } |
| | 1376 | |
|
| | 1377 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 1378 | | /// <param name="groupId"> The management group ID. </param> |
| | 1379 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1380 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1381 | | public Response CheckExistenceAtManagementGroupScope(string groupId, string deploymentName, CancellationToken ca |
| | 1382 | | { |
| 0 | 1383 | | if (groupId == null) |
| | 1384 | | { |
| 0 | 1385 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1386 | | } |
| 0 | 1387 | | if (deploymentName == null) |
| | 1388 | | { |
| 0 | 1389 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1390 | | } |
| | 1391 | |
|
| 0 | 1392 | | using var message = CreateCheckExistenceAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1393 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1394 | | switch (message.Response.Status) |
| | 1395 | | { |
| | 1396 | | case 204: |
| | 1397 | | case 404: |
| 0 | 1398 | | return message.Response; |
| | 1399 | | default: |
| 0 | 1400 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1401 | | } |
| 0 | 1402 | | } |
| | 1403 | |
|
| | 1404 | | internal Core.HttpMessage CreateCreateOrUpdateAtManagementGroupScopeRequest(string groupId, string deploymentNam |
| | 1405 | | { |
| 8 | 1406 | | var message = _pipeline.CreateMessage(); |
| 8 | 1407 | | var request = message.Request; |
| 8 | 1408 | | request.Method = RequestMethod.Put; |
| 8 | 1409 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1410 | | uri.Reset(endpoint); |
| 8 | 1411 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 8 | 1412 | | uri.AppendPath(groupId, true); |
| 8 | 1413 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 8 | 1414 | | uri.AppendPath(deploymentName, true); |
| 8 | 1415 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 1416 | | request.Uri = uri; |
| 8 | 1417 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1418 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1419 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 1420 | | request.Content = content; |
| 8 | 1421 | | return message; |
| | 1422 | | } |
| | 1423 | |
|
| | 1424 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 1425 | | /// <param name="groupId"> The management group ID. </param> |
| | 1426 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1427 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 1428 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1429 | | public async Task<Response> CreateOrUpdateAtManagementGroupScopeAsync(string groupId, string deploymentName, Sco |
| | 1430 | | { |
| 2 | 1431 | | if (groupId == null) |
| | 1432 | | { |
| 0 | 1433 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1434 | | } |
| 2 | 1435 | | if (deploymentName == null) |
| | 1436 | | { |
| 0 | 1437 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1438 | | } |
| 2 | 1439 | | if (parameters == null) |
| | 1440 | | { |
| 0 | 1441 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1442 | | } |
| | 1443 | |
|
| 2 | 1444 | | using var message = CreateCreateOrUpdateAtManagementGroupScopeRequest(groupId, deploymentName, parameters); |
| 2 | 1445 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1446 | | switch (message.Response.Status) |
| | 1447 | | { |
| | 1448 | | case 200: |
| | 1449 | | case 201: |
| 2 | 1450 | | return message.Response; |
| | 1451 | | default: |
| 0 | 1452 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1453 | | } |
| 2 | 1454 | | } |
| | 1455 | |
|
| | 1456 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 1457 | | /// <param name="groupId"> The management group ID. </param> |
| | 1458 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1459 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 1460 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1461 | | public Response CreateOrUpdateAtManagementGroupScope(string groupId, string deploymentName, ScopedDeployment par |
| | 1462 | | { |
| 2 | 1463 | | if (groupId == null) |
| | 1464 | | { |
| 0 | 1465 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1466 | | } |
| 2 | 1467 | | if (deploymentName == null) |
| | 1468 | | { |
| 0 | 1469 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1470 | | } |
| 2 | 1471 | | if (parameters == null) |
| | 1472 | | { |
| 0 | 1473 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1474 | | } |
| | 1475 | |
|
| 2 | 1476 | | using var message = CreateCreateOrUpdateAtManagementGroupScopeRequest(groupId, deploymentName, parameters); |
| 2 | 1477 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1478 | | switch (message.Response.Status) |
| | 1479 | | { |
| | 1480 | | case 200: |
| | 1481 | | case 201: |
| 2 | 1482 | | return message.Response; |
| | 1483 | | default: |
| 0 | 1484 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1485 | | } |
| 2 | 1486 | | } |
| | 1487 | |
|
| | 1488 | | internal Core.HttpMessage CreateGetAtManagementGroupScopeRequest(string groupId, string deploymentName) |
| | 1489 | | { |
| 4 | 1490 | | var message = _pipeline.CreateMessage(); |
| 4 | 1491 | | var request = message.Request; |
| 4 | 1492 | | request.Method = RequestMethod.Get; |
| 4 | 1493 | | var uri = new RawRequestUriBuilder(); |
| 4 | 1494 | | uri.Reset(endpoint); |
| 4 | 1495 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 4 | 1496 | | uri.AppendPath(groupId, true); |
| 4 | 1497 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 4 | 1498 | | uri.AppendPath(deploymentName, true); |
| 4 | 1499 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 1500 | | request.Uri = uri; |
| 4 | 1501 | | return message; |
| | 1502 | | } |
| | 1503 | |
|
| | 1504 | | /// <summary> Gets a deployment. </summary> |
| | 1505 | | /// <param name="groupId"> The management group ID. </param> |
| | 1506 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1507 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1508 | | public async Task<Response<DeploymentExtended>> GetAtManagementGroupScopeAsync(string groupId, string deployment |
| | 1509 | | { |
| 2 | 1510 | | if (groupId == null) |
| | 1511 | | { |
| 0 | 1512 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1513 | | } |
| 2 | 1514 | | if (deploymentName == null) |
| | 1515 | | { |
| 0 | 1516 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1517 | | } |
| | 1518 | |
|
| 2 | 1519 | | using var message = CreateGetAtManagementGroupScopeRequest(groupId, deploymentName); |
| 2 | 1520 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1521 | | switch (message.Response.Status) |
| | 1522 | | { |
| | 1523 | | case 200: |
| | 1524 | | { |
| 2 | 1525 | | DeploymentExtended value = default; |
| 2 | 1526 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 1527 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1528 | | { |
| 0 | 1529 | | value = null; |
| | 1530 | | } |
| | 1531 | | else |
| | 1532 | | { |
| 2 | 1533 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 1534 | | } |
| 2 | 1535 | | return Response.FromValue(value, message.Response); |
| | 1536 | | } |
| | 1537 | | default: |
| 0 | 1538 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1539 | | } |
| 2 | 1540 | | } |
| | 1541 | |
|
| | 1542 | | /// <summary> Gets a deployment. </summary> |
| | 1543 | | /// <param name="groupId"> The management group ID. </param> |
| | 1544 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1545 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1546 | | public Response<DeploymentExtended> GetAtManagementGroupScope(string groupId, string deploymentName, Cancellatio |
| | 1547 | | { |
| 2 | 1548 | | if (groupId == null) |
| | 1549 | | { |
| 0 | 1550 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1551 | | } |
| 2 | 1552 | | if (deploymentName == null) |
| | 1553 | | { |
| 0 | 1554 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1555 | | } |
| | 1556 | |
|
| 2 | 1557 | | using var message = CreateGetAtManagementGroupScopeRequest(groupId, deploymentName); |
| 2 | 1558 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1559 | | switch (message.Response.Status) |
| | 1560 | | { |
| | 1561 | | case 200: |
| | 1562 | | { |
| 2 | 1563 | | DeploymentExtended value = default; |
| 2 | 1564 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 1565 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1566 | | { |
| 0 | 1567 | | value = null; |
| | 1568 | | } |
| | 1569 | | else |
| | 1570 | | { |
| 2 | 1571 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 1572 | | } |
| 2 | 1573 | | return Response.FromValue(value, message.Response); |
| | 1574 | | } |
| | 1575 | | default: |
| 0 | 1576 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1577 | | } |
| 2 | 1578 | | } |
| | 1579 | |
|
| | 1580 | | internal Core.HttpMessage CreateCancelAtManagementGroupScopeRequest(string groupId, string deploymentName) |
| | 1581 | | { |
| 0 | 1582 | | var message = _pipeline.CreateMessage(); |
| 0 | 1583 | | var request = message.Request; |
| 0 | 1584 | | request.Method = RequestMethod.Post; |
| 0 | 1585 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1586 | | uri.Reset(endpoint); |
| 0 | 1587 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 0 | 1588 | | uri.AppendPath(groupId, true); |
| 0 | 1589 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1590 | | uri.AppendPath(deploymentName, true); |
| 0 | 1591 | | uri.AppendPath("/cancel", false); |
| 0 | 1592 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1593 | | request.Uri = uri; |
| 0 | 1594 | | return message; |
| | 1595 | | } |
| | 1596 | |
|
| | 1597 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 1598 | | /// <param name="groupId"> The management group ID. </param> |
| | 1599 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1600 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1601 | | public async Task<Response> CancelAtManagementGroupScopeAsync(string groupId, string deploymentName, Cancellatio |
| | 1602 | | { |
| 0 | 1603 | | if (groupId == null) |
| | 1604 | | { |
| 0 | 1605 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1606 | | } |
| 0 | 1607 | | if (deploymentName == null) |
| | 1608 | | { |
| 0 | 1609 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1610 | | } |
| | 1611 | |
|
| 0 | 1612 | | using var message = CreateCancelAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1613 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1614 | | switch (message.Response.Status) |
| | 1615 | | { |
| | 1616 | | case 204: |
| 0 | 1617 | | return message.Response; |
| | 1618 | | default: |
| 0 | 1619 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1620 | | } |
| 0 | 1621 | | } |
| | 1622 | |
|
| | 1623 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 1624 | | /// <param name="groupId"> The management group ID. </param> |
| | 1625 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1626 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1627 | | public Response CancelAtManagementGroupScope(string groupId, string deploymentName, CancellationToken cancellati |
| | 1628 | | { |
| 0 | 1629 | | if (groupId == null) |
| | 1630 | | { |
| 0 | 1631 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1632 | | } |
| 0 | 1633 | | if (deploymentName == null) |
| | 1634 | | { |
| 0 | 1635 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1636 | | } |
| | 1637 | |
|
| 0 | 1638 | | using var message = CreateCancelAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1639 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1640 | | switch (message.Response.Status) |
| | 1641 | | { |
| | 1642 | | case 204: |
| 0 | 1643 | | return message.Response; |
| | 1644 | | default: |
| 0 | 1645 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1646 | | } |
| 0 | 1647 | | } |
| | 1648 | |
|
| | 1649 | | internal Core.HttpMessage CreateValidateAtManagementGroupScopeRequest(string groupId, string deploymentName, Sco |
| | 1650 | | { |
| 8 | 1651 | | var message = _pipeline.CreateMessage(); |
| 8 | 1652 | | var request = message.Request; |
| 8 | 1653 | | request.Method = RequestMethod.Post; |
| 8 | 1654 | | var uri = new RawRequestUriBuilder(); |
| 8 | 1655 | | uri.Reset(endpoint); |
| 8 | 1656 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 8 | 1657 | | uri.AppendPath(groupId, true); |
| 8 | 1658 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 8 | 1659 | | uri.AppendPath(deploymentName, true); |
| 8 | 1660 | | uri.AppendPath("/validate", false); |
| 8 | 1661 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 1662 | | request.Uri = uri; |
| 8 | 1663 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 1664 | | var content = new Utf8JsonRequestContent(); |
| 8 | 1665 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 1666 | | request.Content = content; |
| 8 | 1667 | | return message; |
| | 1668 | | } |
| | 1669 | |
|
| | 1670 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 1671 | | /// <param name="groupId"> The management group ID. </param> |
| | 1672 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1673 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 1674 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1675 | | public async Task<Response> ValidateAtManagementGroupScopeAsync(string groupId, string deploymentName, ScopedDep |
| | 1676 | | { |
| 2 | 1677 | | if (groupId == null) |
| | 1678 | | { |
| 0 | 1679 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1680 | | } |
| 2 | 1681 | | if (deploymentName == null) |
| | 1682 | | { |
| 0 | 1683 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1684 | | } |
| 2 | 1685 | | if (parameters == null) |
| | 1686 | | { |
| 0 | 1687 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1688 | | } |
| | 1689 | |
|
| 2 | 1690 | | using var message = CreateValidateAtManagementGroupScopeRequest(groupId, deploymentName, parameters); |
| 2 | 1691 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 1692 | | switch (message.Response.Status) |
| | 1693 | | { |
| | 1694 | | case 200: |
| | 1695 | | case 202: |
| | 1696 | | case 400: |
| 2 | 1697 | | return message.Response; |
| | 1698 | | default: |
| 0 | 1699 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1700 | | } |
| 2 | 1701 | | } |
| | 1702 | |
|
| | 1703 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 1704 | | /// <param name="groupId"> The management group ID. </param> |
| | 1705 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1706 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 1707 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1708 | | public Response ValidateAtManagementGroupScope(string groupId, string deploymentName, ScopedDeployment parameter |
| | 1709 | | { |
| 2 | 1710 | | if (groupId == null) |
| | 1711 | | { |
| 0 | 1712 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1713 | | } |
| 2 | 1714 | | if (deploymentName == null) |
| | 1715 | | { |
| 0 | 1716 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1717 | | } |
| 2 | 1718 | | if (parameters == null) |
| | 1719 | | { |
| 0 | 1720 | | throw new ArgumentNullException(nameof(parameters)); |
| | 1721 | | } |
| | 1722 | |
|
| 2 | 1723 | | using var message = CreateValidateAtManagementGroupScopeRequest(groupId, deploymentName, parameters); |
| 2 | 1724 | | _pipeline.Send(message, cancellationToken); |
| 2 | 1725 | | switch (message.Response.Status) |
| | 1726 | | { |
| | 1727 | | case 200: |
| | 1728 | | case 202: |
| | 1729 | | case 400: |
| 2 | 1730 | | return message.Response; |
| | 1731 | | default: |
| 0 | 1732 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1733 | | } |
| 2 | 1734 | | } |
| | 1735 | |
|
| | 1736 | | internal Core.HttpMessage CreateExportTemplateAtManagementGroupScopeRequest(string groupId, string deploymentNam |
| | 1737 | | { |
| 0 | 1738 | | var message = _pipeline.CreateMessage(); |
| 0 | 1739 | | var request = message.Request; |
| 0 | 1740 | | request.Method = RequestMethod.Post; |
| 0 | 1741 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1742 | | uri.Reset(endpoint); |
| 0 | 1743 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 0 | 1744 | | uri.AppendPath(groupId, true); |
| 0 | 1745 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1746 | | uri.AppendPath(deploymentName, true); |
| 0 | 1747 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 1748 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1749 | | request.Uri = uri; |
| 0 | 1750 | | return message; |
| | 1751 | | } |
| | 1752 | |
|
| | 1753 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 1754 | | /// <param name="groupId"> The management group ID. </param> |
| | 1755 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1756 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1757 | | public async Task<Response<DeploymentExportResult>> ExportTemplateAtManagementGroupScopeAsync(string groupId, st |
| | 1758 | | { |
| 0 | 1759 | | if (groupId == null) |
| | 1760 | | { |
| 0 | 1761 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1762 | | } |
| 0 | 1763 | | if (deploymentName == null) |
| | 1764 | | { |
| 0 | 1765 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1766 | | } |
| | 1767 | |
|
| 0 | 1768 | | using var message = CreateExportTemplateAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1769 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1770 | | switch (message.Response.Status) |
| | 1771 | | { |
| | 1772 | | case 200: |
| | 1773 | | { |
| 0 | 1774 | | DeploymentExportResult value = default; |
| 0 | 1775 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1776 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1777 | | { |
| 0 | 1778 | | value = null; |
| | 1779 | | } |
| | 1780 | | else |
| | 1781 | | { |
| 0 | 1782 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 1783 | | } |
| 0 | 1784 | | return Response.FromValue(value, message.Response); |
| | 1785 | | } |
| | 1786 | | default: |
| 0 | 1787 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1788 | | } |
| 0 | 1789 | | } |
| | 1790 | |
|
| | 1791 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 1792 | | /// <param name="groupId"> The management group ID. </param> |
| | 1793 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1794 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1795 | | public Response<DeploymentExportResult> ExportTemplateAtManagementGroupScope(string groupId, string deploymentNa |
| | 1796 | | { |
| 0 | 1797 | | if (groupId == null) |
| | 1798 | | { |
| 0 | 1799 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1800 | | } |
| 0 | 1801 | | if (deploymentName == null) |
| | 1802 | | { |
| 0 | 1803 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1804 | | } |
| | 1805 | |
|
| 0 | 1806 | | using var message = CreateExportTemplateAtManagementGroupScopeRequest(groupId, deploymentName); |
| 0 | 1807 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1808 | | switch (message.Response.Status) |
| | 1809 | | { |
| | 1810 | | case 200: |
| | 1811 | | { |
| 0 | 1812 | | DeploymentExportResult value = default; |
| 0 | 1813 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1814 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1815 | | { |
| 0 | 1816 | | value = null; |
| | 1817 | | } |
| | 1818 | | else |
| | 1819 | | { |
| 0 | 1820 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 1821 | | } |
| 0 | 1822 | | return Response.FromValue(value, message.Response); |
| | 1823 | | } |
| | 1824 | | default: |
| 0 | 1825 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1826 | | } |
| 0 | 1827 | | } |
| | 1828 | |
|
| | 1829 | | internal Core.HttpMessage CreateListAtManagementGroupScopeRequest(string groupId, string filter, int? top) |
| | 1830 | | { |
| 0 | 1831 | | var message = _pipeline.CreateMessage(); |
| 0 | 1832 | | var request = message.Request; |
| 0 | 1833 | | request.Method = RequestMethod.Get; |
| 0 | 1834 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1835 | | uri.Reset(endpoint); |
| 0 | 1836 | | uri.AppendPath("/providers/Microsoft.Management/managementGroups/", false); |
| 0 | 1837 | | uri.AppendPath(groupId, true); |
| 0 | 1838 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1839 | | if (filter != null) |
| | 1840 | | { |
| 0 | 1841 | | uri.AppendQuery("$filter", filter, true); |
| | 1842 | | } |
| 0 | 1843 | | if (top != null) |
| | 1844 | | { |
| 0 | 1845 | | uri.AppendQuery("$top", top.Value, true); |
| | 1846 | | } |
| 0 | 1847 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1848 | | request.Uri = uri; |
| 0 | 1849 | | return message; |
| | 1850 | | } |
| | 1851 | |
|
| | 1852 | | /// <summary> Get all the deployments for a management group. </summary> |
| | 1853 | | /// <param name="groupId"> The management group ID. </param> |
| | 1854 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 1855 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 1856 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1857 | | public async Task<Response<DeploymentListResult>> ListAtManagementGroupScopeAsync(string groupId, string filter |
| | 1858 | | { |
| 0 | 1859 | | if (groupId == null) |
| | 1860 | | { |
| 0 | 1861 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1862 | | } |
| | 1863 | |
|
| 0 | 1864 | | using var message = CreateListAtManagementGroupScopeRequest(groupId, filter, top); |
| 0 | 1865 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1866 | | switch (message.Response.Status) |
| | 1867 | | { |
| | 1868 | | case 200: |
| | 1869 | | { |
| 0 | 1870 | | DeploymentListResult value = default; |
| 0 | 1871 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 1872 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1873 | | { |
| 0 | 1874 | | value = null; |
| | 1875 | | } |
| | 1876 | | else |
| | 1877 | | { |
| 0 | 1878 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 1879 | | } |
| 0 | 1880 | | return Response.FromValue(value, message.Response); |
| | 1881 | | } |
| | 1882 | | default: |
| 0 | 1883 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1884 | | } |
| 0 | 1885 | | } |
| | 1886 | |
|
| | 1887 | | /// <summary> Get all the deployments for a management group. </summary> |
| | 1888 | | /// <param name="groupId"> The management group ID. </param> |
| | 1889 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 1890 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 1891 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1892 | | public Response<DeploymentListResult> ListAtManagementGroupScope(string groupId, string filter = null, int? top |
| | 1893 | | { |
| 0 | 1894 | | if (groupId == null) |
| | 1895 | | { |
| 0 | 1896 | | throw new ArgumentNullException(nameof(groupId)); |
| | 1897 | | } |
| | 1898 | |
|
| 0 | 1899 | | using var message = CreateListAtManagementGroupScopeRequest(groupId, filter, top); |
| 0 | 1900 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1901 | | switch (message.Response.Status) |
| | 1902 | | { |
| | 1903 | | case 200: |
| | 1904 | | { |
| 0 | 1905 | | DeploymentListResult value = default; |
| 0 | 1906 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 1907 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 1908 | | { |
| 0 | 1909 | | value = null; |
| | 1910 | | } |
| | 1911 | | else |
| | 1912 | | { |
| 0 | 1913 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 1914 | | } |
| 0 | 1915 | | return Response.FromValue(value, message.Response); |
| | 1916 | | } |
| | 1917 | | default: |
| 0 | 1918 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1919 | | } |
| 0 | 1920 | | } |
| | 1921 | |
|
| | 1922 | | internal Core.HttpMessage CreateDeleteAtSubscriptionScopeRequest(string deploymentName) |
| | 1923 | | { |
| 0 | 1924 | | var message = _pipeline.CreateMessage(); |
| 0 | 1925 | | var request = message.Request; |
| 0 | 1926 | | request.Method = RequestMethod.Delete; |
| 0 | 1927 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1928 | | uri.Reset(endpoint); |
| 0 | 1929 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1930 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1931 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1932 | | uri.AppendPath(deploymentName, true); |
| 0 | 1933 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1934 | | request.Uri = uri; |
| 0 | 1935 | | return message; |
| | 1936 | | } |
| | 1937 | |
|
| | 1938 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 1939 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1940 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1941 | | public async Task<Response> DeleteAtSubscriptionScopeAsync(string deploymentName, CancellationToken cancellation |
| | 1942 | | { |
| 0 | 1943 | | if (deploymentName == null) |
| | 1944 | | { |
| 0 | 1945 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1946 | | } |
| | 1947 | |
|
| 0 | 1948 | | using var message = CreateDeleteAtSubscriptionScopeRequest(deploymentName); |
| 0 | 1949 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 1950 | | switch (message.Response.Status) |
| | 1951 | | { |
| | 1952 | | case 202: |
| | 1953 | | case 204: |
| 0 | 1954 | | return message.Response; |
| | 1955 | | default: |
| 0 | 1956 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 1957 | | } |
| 0 | 1958 | | } |
| | 1959 | |
|
| | 1960 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 1961 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 1962 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 1963 | | public Response DeleteAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = default) |
| | 1964 | | { |
| 0 | 1965 | | if (deploymentName == null) |
| | 1966 | | { |
| 0 | 1967 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 1968 | | } |
| | 1969 | |
|
| 0 | 1970 | | using var message = CreateDeleteAtSubscriptionScopeRequest(deploymentName); |
| 0 | 1971 | | _pipeline.Send(message, cancellationToken); |
| 0 | 1972 | | switch (message.Response.Status) |
| | 1973 | | { |
| | 1974 | | case 202: |
| | 1975 | | case 204: |
| 0 | 1976 | | return message.Response; |
| | 1977 | | default: |
| 0 | 1978 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 1979 | | } |
| 0 | 1980 | | } |
| | 1981 | |
|
| | 1982 | | internal Core.HttpMessage CreateCheckExistenceAtSubscriptionScopeRequest(string deploymentName) |
| | 1983 | | { |
| 0 | 1984 | | var message = _pipeline.CreateMessage(); |
| 0 | 1985 | | var request = message.Request; |
| 0 | 1986 | | request.Method = RequestMethod.Head; |
| 0 | 1987 | | var uri = new RawRequestUriBuilder(); |
| 0 | 1988 | | uri.Reset(endpoint); |
| 0 | 1989 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 1990 | | uri.AppendPath(subscriptionId, true); |
| 0 | 1991 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 1992 | | uri.AppendPath(deploymentName, true); |
| 0 | 1993 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 1994 | | request.Uri = uri; |
| 0 | 1995 | | return message; |
| | 1996 | | } |
| | 1997 | |
|
| | 1998 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 1999 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2000 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2001 | | public async Task<Response> CheckExistenceAtSubscriptionScopeAsync(string deploymentName, CancellationToken canc |
| | 2002 | | { |
| 0 | 2003 | | if (deploymentName == null) |
| | 2004 | | { |
| 0 | 2005 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2006 | | } |
| | 2007 | |
|
| 0 | 2008 | | using var message = CreateCheckExistenceAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2009 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2010 | | switch (message.Response.Status) |
| | 2011 | | { |
| | 2012 | | case 204: |
| | 2013 | | case 404: |
| 0 | 2014 | | return message.Response; |
| | 2015 | | default: |
| 0 | 2016 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2017 | | } |
| 0 | 2018 | | } |
| | 2019 | |
|
| | 2020 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 2021 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2022 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2023 | | public Response CheckExistenceAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = d |
| | 2024 | | { |
| 0 | 2025 | | if (deploymentName == null) |
| | 2026 | | { |
| 0 | 2027 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2028 | | } |
| | 2029 | |
|
| 0 | 2030 | | using var message = CreateCheckExistenceAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2031 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2032 | | switch (message.Response.Status) |
| | 2033 | | { |
| | 2034 | | case 204: |
| | 2035 | | case 404: |
| 0 | 2036 | | return message.Response; |
| | 2037 | | default: |
| 0 | 2038 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2039 | | } |
| 0 | 2040 | | } |
| | 2041 | |
|
| | 2042 | | internal Core.HttpMessage CreateCreateOrUpdateAtSubscriptionScopeRequest(string deploymentName, Deployment param |
| | 2043 | | { |
| 16 | 2044 | | var message = _pipeline.CreateMessage(); |
| 16 | 2045 | | var request = message.Request; |
| 16 | 2046 | | request.Method = RequestMethod.Put; |
| 16 | 2047 | | var uri = new RawRequestUriBuilder(); |
| 16 | 2048 | | uri.Reset(endpoint); |
| 16 | 2049 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 2050 | | uri.AppendPath(subscriptionId, true); |
| 16 | 2051 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 16 | 2052 | | uri.AppendPath(deploymentName, true); |
| 16 | 2053 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 16 | 2054 | | request.Uri = uri; |
| 16 | 2055 | | request.Headers.Add("Content-Type", "application/json"); |
| 16 | 2056 | | var content = new Utf8JsonRequestContent(); |
| 16 | 2057 | | content.JsonWriter.WriteObjectValue(parameters); |
| 16 | 2058 | | request.Content = content; |
| 16 | 2059 | | return message; |
| | 2060 | | } |
| | 2061 | |
|
| | 2062 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 2063 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2064 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 2065 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2066 | | public async Task<Response> CreateOrUpdateAtSubscriptionScopeAsync(string deploymentName, Deployment parameters, |
| | 2067 | | { |
| 4 | 2068 | | if (deploymentName == null) |
| | 2069 | | { |
| 0 | 2070 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2071 | | } |
| 4 | 2072 | | if (parameters == null) |
| | 2073 | | { |
| 0 | 2074 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2075 | | } |
| | 2076 | |
|
| 4 | 2077 | | using var message = CreateCreateOrUpdateAtSubscriptionScopeRequest(deploymentName, parameters); |
| 4 | 2078 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 4 | 2079 | | switch (message.Response.Status) |
| | 2080 | | { |
| | 2081 | | case 200: |
| | 2082 | | case 201: |
| 4 | 2083 | | return message.Response; |
| | 2084 | | default: |
| 0 | 2085 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2086 | | } |
| 4 | 2087 | | } |
| | 2088 | |
|
| | 2089 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 2090 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2091 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 2092 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2093 | | public Response CreateOrUpdateAtSubscriptionScope(string deploymentName, Deployment parameters, CancellationToke |
| | 2094 | | { |
| 4 | 2095 | | if (deploymentName == null) |
| | 2096 | | { |
| 0 | 2097 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2098 | | } |
| 4 | 2099 | | if (parameters == null) |
| | 2100 | | { |
| 0 | 2101 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2102 | | } |
| | 2103 | |
|
| 4 | 2104 | | using var message = CreateCreateOrUpdateAtSubscriptionScopeRequest(deploymentName, parameters); |
| 4 | 2105 | | _pipeline.Send(message, cancellationToken); |
| 4 | 2106 | | switch (message.Response.Status) |
| | 2107 | | { |
| | 2108 | | case 200: |
| | 2109 | | case 201: |
| 4 | 2110 | | return message.Response; |
| | 2111 | | default: |
| 0 | 2112 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2113 | | } |
| 4 | 2114 | | } |
| | 2115 | |
|
| | 2116 | | internal Core.HttpMessage CreateGetAtSubscriptionScopeRequest(string deploymentName) |
| | 2117 | | { |
| 4 | 2118 | | var message = _pipeline.CreateMessage(); |
| 4 | 2119 | | var request = message.Request; |
| 4 | 2120 | | request.Method = RequestMethod.Get; |
| 4 | 2121 | | var uri = new RawRequestUriBuilder(); |
| 4 | 2122 | | uri.Reset(endpoint); |
| 4 | 2123 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 2124 | | uri.AppendPath(subscriptionId, true); |
| 4 | 2125 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 4 | 2126 | | uri.AppendPath(deploymentName, true); |
| 4 | 2127 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 2128 | | request.Uri = uri; |
| 4 | 2129 | | return message; |
| | 2130 | | } |
| | 2131 | |
|
| | 2132 | | /// <summary> Gets a deployment. </summary> |
| | 2133 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2134 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2135 | | public async Task<Response<DeploymentExtended>> GetAtSubscriptionScopeAsync(string deploymentName, CancellationT |
| | 2136 | | { |
| 2 | 2137 | | if (deploymentName == null) |
| | 2138 | | { |
| 0 | 2139 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2140 | | } |
| | 2141 | |
|
| 2 | 2142 | | using var message = CreateGetAtSubscriptionScopeRequest(deploymentName); |
| 2 | 2143 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 2144 | | switch (message.Response.Status) |
| | 2145 | | { |
| | 2146 | | case 200: |
| | 2147 | | { |
| 2 | 2148 | | DeploymentExtended value = default; |
| 2 | 2149 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 2 | 2150 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2151 | | { |
| 0 | 2152 | | value = null; |
| | 2153 | | } |
| | 2154 | | else |
| | 2155 | | { |
| 2 | 2156 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 2157 | | } |
| 2 | 2158 | | return Response.FromValue(value, message.Response); |
| | 2159 | | } |
| | 2160 | | default: |
| 0 | 2161 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2162 | | } |
| 2 | 2163 | | } |
| | 2164 | |
|
| | 2165 | | /// <summary> Gets a deployment. </summary> |
| | 2166 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2167 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2168 | | public Response<DeploymentExtended> GetAtSubscriptionScope(string deploymentName, CancellationToken cancellation |
| | 2169 | | { |
| 2 | 2170 | | if (deploymentName == null) |
| | 2171 | | { |
| 0 | 2172 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2173 | | } |
| | 2174 | |
|
| 2 | 2175 | | using var message = CreateGetAtSubscriptionScopeRequest(deploymentName); |
| 2 | 2176 | | _pipeline.Send(message, cancellationToken); |
| 2 | 2177 | | switch (message.Response.Status) |
| | 2178 | | { |
| | 2179 | | case 200: |
| | 2180 | | { |
| 2 | 2181 | | DeploymentExtended value = default; |
| 2 | 2182 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 2183 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2184 | | { |
| 0 | 2185 | | value = null; |
| | 2186 | | } |
| | 2187 | | else |
| | 2188 | | { |
| 2 | 2189 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 2190 | | } |
| 2 | 2191 | | return Response.FromValue(value, message.Response); |
| | 2192 | | } |
| | 2193 | | default: |
| 0 | 2194 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2195 | | } |
| 2 | 2196 | | } |
| | 2197 | |
|
| | 2198 | | internal Core.HttpMessage CreateCancelAtSubscriptionScopeRequest(string deploymentName) |
| | 2199 | | { |
| 0 | 2200 | | var message = _pipeline.CreateMessage(); |
| 0 | 2201 | | var request = message.Request; |
| 0 | 2202 | | request.Method = RequestMethod.Post; |
| 0 | 2203 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2204 | | uri.Reset(endpoint); |
| 0 | 2205 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 2206 | | uri.AppendPath(subscriptionId, true); |
| 0 | 2207 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 2208 | | uri.AppendPath(deploymentName, true); |
| 0 | 2209 | | uri.AppendPath("/cancel", false); |
| 0 | 2210 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 2211 | | request.Uri = uri; |
| 0 | 2212 | | return message; |
| | 2213 | | } |
| | 2214 | |
|
| | 2215 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 2216 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2217 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2218 | | public async Task<Response> CancelAtSubscriptionScopeAsync(string deploymentName, CancellationToken cancellation |
| | 2219 | | { |
| 0 | 2220 | | if (deploymentName == null) |
| | 2221 | | { |
| 0 | 2222 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2223 | | } |
| | 2224 | |
|
| 0 | 2225 | | using var message = CreateCancelAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2226 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2227 | | switch (message.Response.Status) |
| | 2228 | | { |
| | 2229 | | case 204: |
| 0 | 2230 | | return message.Response; |
| | 2231 | | default: |
| 0 | 2232 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2233 | | } |
| 0 | 2234 | | } |
| | 2235 | |
|
| | 2236 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 2237 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2238 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2239 | | public Response CancelAtSubscriptionScope(string deploymentName, CancellationToken cancellationToken = default) |
| | 2240 | | { |
| 0 | 2241 | | if (deploymentName == null) |
| | 2242 | | { |
| 0 | 2243 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2244 | | } |
| | 2245 | |
|
| 0 | 2246 | | using var message = CreateCancelAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2247 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2248 | | switch (message.Response.Status) |
| | 2249 | | { |
| | 2250 | | case 204: |
| 0 | 2251 | | return message.Response; |
| | 2252 | | default: |
| 0 | 2253 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2254 | | } |
| 0 | 2255 | | } |
| | 2256 | |
|
| | 2257 | | internal Core.HttpMessage CreateValidateAtSubscriptionScopeRequest(string deploymentName, Deployment parameters) |
| | 2258 | | { |
| 8 | 2259 | | var message = _pipeline.CreateMessage(); |
| 8 | 2260 | | var request = message.Request; |
| 8 | 2261 | | request.Method = RequestMethod.Post; |
| 8 | 2262 | | var uri = new RawRequestUriBuilder(); |
| 8 | 2263 | | uri.Reset(endpoint); |
| 8 | 2264 | | uri.AppendPath("/subscriptions/", false); |
| 8 | 2265 | | uri.AppendPath(subscriptionId, true); |
| 8 | 2266 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 8 | 2267 | | uri.AppendPath(deploymentName, true); |
| 8 | 2268 | | uri.AppendPath("/validate", false); |
| 8 | 2269 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 8 | 2270 | | request.Uri = uri; |
| 8 | 2271 | | request.Headers.Add("Content-Type", "application/json"); |
| 8 | 2272 | | var content = new Utf8JsonRequestContent(); |
| 8 | 2273 | | content.JsonWriter.WriteObjectValue(parameters); |
| 8 | 2274 | | request.Content = content; |
| 8 | 2275 | | return message; |
| | 2276 | | } |
| | 2277 | |
|
| | 2278 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 2279 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2280 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 2281 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2282 | | public async Task<Response> ValidateAtSubscriptionScopeAsync(string deploymentName, Deployment parameters, Cance |
| | 2283 | | { |
| 2 | 2284 | | if (deploymentName == null) |
| | 2285 | | { |
| 0 | 2286 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2287 | | } |
| 2 | 2288 | | if (parameters == null) |
| | 2289 | | { |
| 0 | 2290 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2291 | | } |
| | 2292 | |
|
| 2 | 2293 | | using var message = CreateValidateAtSubscriptionScopeRequest(deploymentName, parameters); |
| 2 | 2294 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 2295 | | switch (message.Response.Status) |
| | 2296 | | { |
| | 2297 | | case 200: |
| | 2298 | | case 202: |
| | 2299 | | case 400: |
| 2 | 2300 | | return message.Response; |
| | 2301 | | default: |
| 0 | 2302 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2303 | | } |
| 2 | 2304 | | } |
| | 2305 | |
|
| | 2306 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 2307 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2308 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 2309 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2310 | | public Response ValidateAtSubscriptionScope(string deploymentName, Deployment parameters, CancellationToken canc |
| | 2311 | | { |
| 2 | 2312 | | if (deploymentName == null) |
| | 2313 | | { |
| 0 | 2314 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2315 | | } |
| 2 | 2316 | | if (parameters == null) |
| | 2317 | | { |
| 0 | 2318 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2319 | | } |
| | 2320 | |
|
| 2 | 2321 | | using var message = CreateValidateAtSubscriptionScopeRequest(deploymentName, parameters); |
| 2 | 2322 | | _pipeline.Send(message, cancellationToken); |
| 2 | 2323 | | switch (message.Response.Status) |
| | 2324 | | { |
| | 2325 | | case 200: |
| | 2326 | | case 202: |
| | 2327 | | case 400: |
| 2 | 2328 | | return message.Response; |
| | 2329 | | default: |
| 0 | 2330 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2331 | | } |
| 2 | 2332 | | } |
| | 2333 | |
|
| | 2334 | | internal Core.HttpMessage CreateWhatIfAtSubscriptionScopeRequest(string deploymentName, DeploymentWhatIf paramet |
| | 2335 | | { |
| 72 | 2336 | | var message = _pipeline.CreateMessage(); |
| 72 | 2337 | | var request = message.Request; |
| 72 | 2338 | | request.Method = RequestMethod.Post; |
| 72 | 2339 | | var uri = new RawRequestUriBuilder(); |
| 72 | 2340 | | uri.Reset(endpoint); |
| 72 | 2341 | | uri.AppendPath("/subscriptions/", false); |
| 72 | 2342 | | uri.AppendPath(subscriptionId, true); |
| 72 | 2343 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 72 | 2344 | | uri.AppendPath(deploymentName, true); |
| 72 | 2345 | | uri.AppendPath("/whatIf", false); |
| 72 | 2346 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 72 | 2347 | | request.Uri = uri; |
| 72 | 2348 | | request.Headers.Add("Content-Type", "application/json"); |
| 72 | 2349 | | var content = new Utf8JsonRequestContent(); |
| 72 | 2350 | | content.JsonWriter.WriteObjectValue(parameters); |
| 72 | 2351 | | request.Content = content; |
| 72 | 2352 | | return message; |
| | 2353 | | } |
| | 2354 | |
|
| | 2355 | | /// <summary> Returns changes that will be made by the deployment if executed at the scope of the subscription. |
| | 2356 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2357 | | /// <param name="parameters"> Parameters to What If. </param> |
| | 2358 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2359 | | public async Task<ResponseWithHeaders<DeploymentsWhatIfAtSubscriptionScopeHeaders>> WhatIfAtSubscriptionScopeAsy |
| | 2360 | | { |
| 18 | 2361 | | if (deploymentName == null) |
| | 2362 | | { |
| 0 | 2363 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2364 | | } |
| 18 | 2365 | | if (parameters == null) |
| | 2366 | | { |
| 0 | 2367 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2368 | | } |
| | 2369 | |
|
| 18 | 2370 | | using var message = CreateWhatIfAtSubscriptionScopeRequest(deploymentName, parameters); |
| 18 | 2371 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 18 | 2372 | | var headers = new DeploymentsWhatIfAtSubscriptionScopeHeaders(message.Response); |
| 18 | 2373 | | switch (message.Response.Status) |
| | 2374 | | { |
| | 2375 | | case 200: |
| | 2376 | | case 202: |
| 18 | 2377 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 2378 | | default: |
| 0 | 2379 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2380 | | } |
| 18 | 2381 | | } |
| | 2382 | |
|
| | 2383 | | /// <summary> Returns changes that will be made by the deployment if executed at the scope of the subscription. |
| | 2384 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2385 | | /// <param name="parameters"> Parameters to What If. </param> |
| | 2386 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2387 | | public ResponseWithHeaders<DeploymentsWhatIfAtSubscriptionScopeHeaders> WhatIfAtSubscriptionScope(string deploym |
| | 2388 | | { |
| 18 | 2389 | | if (deploymentName == null) |
| | 2390 | | { |
| 0 | 2391 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2392 | | } |
| 18 | 2393 | | if (parameters == null) |
| | 2394 | | { |
| 0 | 2395 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2396 | | } |
| | 2397 | |
|
| 18 | 2398 | | using var message = CreateWhatIfAtSubscriptionScopeRequest(deploymentName, parameters); |
| 18 | 2399 | | _pipeline.Send(message, cancellationToken); |
| 18 | 2400 | | var headers = new DeploymentsWhatIfAtSubscriptionScopeHeaders(message.Response); |
| 18 | 2401 | | switch (message.Response.Status) |
| | 2402 | | { |
| | 2403 | | case 200: |
| | 2404 | | case 202: |
| 18 | 2405 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 2406 | | default: |
| 0 | 2407 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2408 | | } |
| 18 | 2409 | | } |
| | 2410 | |
|
| | 2411 | | internal Core.HttpMessage CreateExportTemplateAtSubscriptionScopeRequest(string deploymentName) |
| | 2412 | | { |
| 0 | 2413 | | var message = _pipeline.CreateMessage(); |
| 0 | 2414 | | var request = message.Request; |
| 0 | 2415 | | request.Method = RequestMethod.Post; |
| 0 | 2416 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2417 | | uri.Reset(endpoint); |
| 0 | 2418 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 2419 | | uri.AppendPath(subscriptionId, true); |
| 0 | 2420 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 2421 | | uri.AppendPath(deploymentName, true); |
| 0 | 2422 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 2423 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 2424 | | request.Uri = uri; |
| 0 | 2425 | | return message; |
| | 2426 | | } |
| | 2427 | |
|
| | 2428 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 2429 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2430 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2431 | | public async Task<Response<DeploymentExportResult>> ExportTemplateAtSubscriptionScopeAsync(string deploymentName |
| | 2432 | | { |
| 0 | 2433 | | if (deploymentName == null) |
| | 2434 | | { |
| 0 | 2435 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2436 | | } |
| | 2437 | |
|
| 0 | 2438 | | using var message = CreateExportTemplateAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2439 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2440 | | switch (message.Response.Status) |
| | 2441 | | { |
| | 2442 | | case 200: |
| | 2443 | | { |
| 0 | 2444 | | DeploymentExportResult value = default; |
| 0 | 2445 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 2446 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2447 | | { |
| 0 | 2448 | | value = null; |
| | 2449 | | } |
| | 2450 | | else |
| | 2451 | | { |
| 0 | 2452 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 2453 | | } |
| 0 | 2454 | | return Response.FromValue(value, message.Response); |
| | 2455 | | } |
| | 2456 | | default: |
| 0 | 2457 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2458 | | } |
| 0 | 2459 | | } |
| | 2460 | |
|
| | 2461 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 2462 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2463 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2464 | | public Response<DeploymentExportResult> ExportTemplateAtSubscriptionScope(string deploymentName, CancellationTok |
| | 2465 | | { |
| 0 | 2466 | | if (deploymentName == null) |
| | 2467 | | { |
| 0 | 2468 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2469 | | } |
| | 2470 | |
|
| 0 | 2471 | | using var message = CreateExportTemplateAtSubscriptionScopeRequest(deploymentName); |
| 0 | 2472 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2473 | | switch (message.Response.Status) |
| | 2474 | | { |
| | 2475 | | case 200: |
| | 2476 | | { |
| 0 | 2477 | | DeploymentExportResult value = default; |
| 0 | 2478 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2479 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2480 | | { |
| 0 | 2481 | | value = null; |
| | 2482 | | } |
| | 2483 | | else |
| | 2484 | | { |
| 0 | 2485 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 2486 | | } |
| 0 | 2487 | | return Response.FromValue(value, message.Response); |
| | 2488 | | } |
| | 2489 | | default: |
| 0 | 2490 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2491 | | } |
| 0 | 2492 | | } |
| | 2493 | |
|
| | 2494 | | internal Core.HttpMessage CreateListAtSubscriptionScopeRequest(string filter, int? top) |
| | 2495 | | { |
| 0 | 2496 | | var message = _pipeline.CreateMessage(); |
| 0 | 2497 | | var request = message.Request; |
| 0 | 2498 | | request.Method = RequestMethod.Get; |
| 0 | 2499 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2500 | | uri.Reset(endpoint); |
| 0 | 2501 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 2502 | | uri.AppendPath(subscriptionId, true); |
| 0 | 2503 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 2504 | | if (filter != null) |
| | 2505 | | { |
| 0 | 2506 | | uri.AppendQuery("$filter", filter, true); |
| | 2507 | | } |
| 0 | 2508 | | if (top != null) |
| | 2509 | | { |
| 0 | 2510 | | uri.AppendQuery("$top", top.Value, true); |
| | 2511 | | } |
| 0 | 2512 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 2513 | | request.Uri = uri; |
| 0 | 2514 | | return message; |
| | 2515 | | } |
| | 2516 | |
|
| | 2517 | | /// <summary> Get all the deployments for a subscription. </summary> |
| | 2518 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 2519 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 2520 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2521 | | public async Task<Response<DeploymentListResult>> ListAtSubscriptionScopeAsync(string filter = null, int? top = |
| | 2522 | | { |
| 0 | 2523 | | using var message = CreateListAtSubscriptionScopeRequest(filter, top); |
| 0 | 2524 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2525 | | switch (message.Response.Status) |
| | 2526 | | { |
| | 2527 | | case 200: |
| | 2528 | | { |
| 0 | 2529 | | DeploymentListResult value = default; |
| 0 | 2530 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 2531 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2532 | | { |
| 0 | 2533 | | value = null; |
| | 2534 | | } |
| | 2535 | | else |
| | 2536 | | { |
| 0 | 2537 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 2538 | | } |
| 0 | 2539 | | return Response.FromValue(value, message.Response); |
| | 2540 | | } |
| | 2541 | | default: |
| 0 | 2542 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2543 | | } |
| 0 | 2544 | | } |
| | 2545 | |
|
| | 2546 | | /// <summary> Get all the deployments for a subscription. </summary> |
| | 2547 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 2548 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 2549 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2550 | | public Response<DeploymentListResult> ListAtSubscriptionScope(string filter = null, int? top = null, Cancellatio |
| | 2551 | | { |
| 0 | 2552 | | using var message = CreateListAtSubscriptionScopeRequest(filter, top); |
| 0 | 2553 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2554 | | switch (message.Response.Status) |
| | 2555 | | { |
| | 2556 | | case 200: |
| | 2557 | | { |
| 0 | 2558 | | DeploymentListResult value = default; |
| 0 | 2559 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 2560 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2561 | | { |
| 0 | 2562 | | value = null; |
| | 2563 | | } |
| | 2564 | | else |
| | 2565 | | { |
| 0 | 2566 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 2567 | | } |
| 0 | 2568 | | return Response.FromValue(value, message.Response); |
| | 2569 | | } |
| | 2570 | | default: |
| 0 | 2571 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2572 | | } |
| 0 | 2573 | | } |
| | 2574 | |
|
| | 2575 | | internal Core.HttpMessage CreateDeleteRequest(string resourceGroupName, string deploymentName) |
| | 2576 | | { |
| 0 | 2577 | | var message = _pipeline.CreateMessage(); |
| 0 | 2578 | | var request = message.Request; |
| 0 | 2579 | | request.Method = RequestMethod.Delete; |
| 0 | 2580 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2581 | | uri.Reset(endpoint); |
| 0 | 2582 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 2583 | | uri.AppendPath(subscriptionId, true); |
| 0 | 2584 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 2585 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 2586 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 2587 | | uri.AppendPath(deploymentName, true); |
| 0 | 2588 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 2589 | | request.Uri = uri; |
| 0 | 2590 | | return message; |
| | 2591 | | } |
| | 2592 | |
|
| | 2593 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 2594 | | /// <param name="resourceGroupName"> The name of the resource group with the deployment to delete. The name is c |
| | 2595 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2596 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2597 | | public async Task<Response> DeleteAsync(string resourceGroupName, string deploymentName, CancellationToken cance |
| | 2598 | | { |
| 0 | 2599 | | if (resourceGroupName == null) |
| | 2600 | | { |
| 0 | 2601 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2602 | | } |
| 0 | 2603 | | if (deploymentName == null) |
| | 2604 | | { |
| 0 | 2605 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2606 | | } |
| | 2607 | |
|
| 0 | 2608 | | using var message = CreateDeleteRequest(resourceGroupName, deploymentName); |
| 0 | 2609 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2610 | | switch (message.Response.Status) |
| | 2611 | | { |
| | 2612 | | case 202: |
| | 2613 | | case 204: |
| 0 | 2614 | | return message.Response; |
| | 2615 | | default: |
| 0 | 2616 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2617 | | } |
| 0 | 2618 | | } |
| | 2619 | |
|
| | 2620 | | /// <summary> A template deployment that is currently running cannot be deleted. Deleting a template deployment |
| | 2621 | | /// <param name="resourceGroupName"> The name of the resource group with the deployment to delete. The name is c |
| | 2622 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2623 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2624 | | public Response Delete(string resourceGroupName, string deploymentName, CancellationToken cancellationToken = de |
| | 2625 | | { |
| 0 | 2626 | | if (resourceGroupName == null) |
| | 2627 | | { |
| 0 | 2628 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2629 | | } |
| 0 | 2630 | | if (deploymentName == null) |
| | 2631 | | { |
| 0 | 2632 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2633 | | } |
| | 2634 | |
|
| 0 | 2635 | | using var message = CreateDeleteRequest(resourceGroupName, deploymentName); |
| 0 | 2636 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2637 | | switch (message.Response.Status) |
| | 2638 | | { |
| | 2639 | | case 202: |
| | 2640 | | case 204: |
| 0 | 2641 | | return message.Response; |
| | 2642 | | default: |
| 0 | 2643 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2644 | | } |
| 0 | 2645 | | } |
| | 2646 | |
|
| | 2647 | | internal Core.HttpMessage CreateCheckExistenceRequest(string resourceGroupName, string deploymentName) |
| | 2648 | | { |
| 0 | 2649 | | var message = _pipeline.CreateMessage(); |
| 0 | 2650 | | var request = message.Request; |
| 0 | 2651 | | request.Method = RequestMethod.Head; |
| 0 | 2652 | | var uri = new RawRequestUriBuilder(); |
| 0 | 2653 | | uri.Reset(endpoint); |
| 0 | 2654 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 2655 | | uri.AppendPath(subscriptionId, true); |
| 0 | 2656 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 2657 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 2658 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 2659 | | uri.AppendPath(deploymentName, true); |
| 0 | 2660 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 2661 | | request.Uri = uri; |
| 0 | 2662 | | return message; |
| | 2663 | | } |
| | 2664 | |
|
| | 2665 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 2666 | | /// <param name="resourceGroupName"> The name of the resource group with the deployment to check. The name is ca |
| | 2667 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2668 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2669 | | public async Task<Response> CheckExistenceAsync(string resourceGroupName, string deploymentName, CancellationTok |
| | 2670 | | { |
| 0 | 2671 | | if (resourceGroupName == null) |
| | 2672 | | { |
| 0 | 2673 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2674 | | } |
| 0 | 2675 | | if (deploymentName == null) |
| | 2676 | | { |
| 0 | 2677 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2678 | | } |
| | 2679 | |
|
| 0 | 2680 | | using var message = CreateCheckExistenceRequest(resourceGroupName, deploymentName); |
| 0 | 2681 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 2682 | | switch (message.Response.Status) |
| | 2683 | | { |
| | 2684 | | case 204: |
| | 2685 | | case 404: |
| 0 | 2686 | | return message.Response; |
| | 2687 | | default: |
| 0 | 2688 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2689 | | } |
| 0 | 2690 | | } |
| | 2691 | |
|
| | 2692 | | /// <summary> Checks whether the deployment exists. </summary> |
| | 2693 | | /// <param name="resourceGroupName"> The name of the resource group with the deployment to check. The name is ca |
| | 2694 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2695 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2696 | | public Response CheckExistence(string resourceGroupName, string deploymentName, CancellationToken cancellationTo |
| | 2697 | | { |
| 0 | 2698 | | if (resourceGroupName == null) |
| | 2699 | | { |
| 0 | 2700 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2701 | | } |
| 0 | 2702 | | if (deploymentName == null) |
| | 2703 | | { |
| 0 | 2704 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2705 | | } |
| | 2706 | |
|
| 0 | 2707 | | using var message = CreateCheckExistenceRequest(resourceGroupName, deploymentName); |
| 0 | 2708 | | _pipeline.Send(message, cancellationToken); |
| 0 | 2709 | | switch (message.Response.Status) |
| | 2710 | | { |
| | 2711 | | case 204: |
| | 2712 | | case 404: |
| 0 | 2713 | | return message.Response; |
| | 2714 | | default: |
| 0 | 2715 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2716 | | } |
| 0 | 2717 | | } |
| | 2718 | |
|
| | 2719 | | internal Core.HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string deploymentName, Deploymen |
| | 2720 | | { |
| 64 | 2721 | | var message = _pipeline.CreateMessage(); |
| 64 | 2722 | | var request = message.Request; |
| 64 | 2723 | | request.Method = RequestMethod.Put; |
| 64 | 2724 | | var uri = new RawRequestUriBuilder(); |
| 64 | 2725 | | uri.Reset(endpoint); |
| 64 | 2726 | | uri.AppendPath("/subscriptions/", false); |
| 64 | 2727 | | uri.AppendPath(subscriptionId, true); |
| 64 | 2728 | | uri.AppendPath("/resourcegroups/", false); |
| 64 | 2729 | | uri.AppendPath(resourceGroupName, true); |
| 64 | 2730 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 64 | 2731 | | uri.AppendPath(deploymentName, true); |
| 64 | 2732 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 64 | 2733 | | request.Uri = uri; |
| 64 | 2734 | | request.Headers.Add("Content-Type", "application/json"); |
| 64 | 2735 | | var content = new Utf8JsonRequestContent(); |
| 64 | 2736 | | content.JsonWriter.WriteObjectValue(parameters); |
| 64 | 2737 | | request.Content = content; |
| 64 | 2738 | | return message; |
| | 2739 | | } |
| | 2740 | |
|
| | 2741 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 2742 | | /// <param name="resourceGroupName"> The name of the resource group to deploy the resources to. The name is case |
| | 2743 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2744 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 2745 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2746 | | public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string deploymentName, Deployment para |
| | 2747 | | { |
| 16 | 2748 | | if (resourceGroupName == null) |
| | 2749 | | { |
| 0 | 2750 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2751 | | } |
| 16 | 2752 | | if (deploymentName == null) |
| | 2753 | | { |
| 0 | 2754 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2755 | | } |
| 16 | 2756 | | if (parameters == null) |
| | 2757 | | { |
| 0 | 2758 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2759 | | } |
| | 2760 | |
|
| 16 | 2761 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, deploymentName, parameters); |
| 16 | 2762 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 16 | 2763 | | switch (message.Response.Status) |
| | 2764 | | { |
| | 2765 | | case 200: |
| | 2766 | | case 201: |
| 16 | 2767 | | return message.Response; |
| | 2768 | | default: |
| 0 | 2769 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2770 | | } |
| 16 | 2771 | | } |
| | 2772 | |
|
| | 2773 | | /// <summary> You can provide the template and parameters directly in the request or link to JSON files. </summa |
| | 2774 | | /// <param name="resourceGroupName"> The name of the resource group to deploy the resources to. The name is case |
| | 2775 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2776 | | /// <param name="parameters"> Additional parameters supplied to the operation. </param> |
| | 2777 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2778 | | public Response CreateOrUpdate(string resourceGroupName, string deploymentName, Deployment parameters, Cancellat |
| | 2779 | | { |
| 16 | 2780 | | if (resourceGroupName == null) |
| | 2781 | | { |
| 0 | 2782 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2783 | | } |
| 16 | 2784 | | if (deploymentName == null) |
| | 2785 | | { |
| 0 | 2786 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2787 | | } |
| 16 | 2788 | | if (parameters == null) |
| | 2789 | | { |
| 0 | 2790 | | throw new ArgumentNullException(nameof(parameters)); |
| | 2791 | | } |
| | 2792 | |
|
| 16 | 2793 | | using var message = CreateCreateOrUpdateRequest(resourceGroupName, deploymentName, parameters); |
| 16 | 2794 | | _pipeline.Send(message, cancellationToken); |
| 16 | 2795 | | switch (message.Response.Status) |
| | 2796 | | { |
| | 2797 | | case 200: |
| | 2798 | | case 201: |
| 16 | 2799 | | return message.Response; |
| | 2800 | | default: |
| 0 | 2801 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2802 | | } |
| 16 | 2803 | | } |
| | 2804 | |
|
| | 2805 | | internal Core.HttpMessage CreateGetRequest(string resourceGroupName, string deploymentName) |
| | 2806 | | { |
| 12 | 2807 | | var message = _pipeline.CreateMessage(); |
| 12 | 2808 | | var request = message.Request; |
| 12 | 2809 | | request.Method = RequestMethod.Get; |
| 12 | 2810 | | var uri = new RawRequestUriBuilder(); |
| 12 | 2811 | | uri.Reset(endpoint); |
| 12 | 2812 | | uri.AppendPath("/subscriptions/", false); |
| 12 | 2813 | | uri.AppendPath(subscriptionId, true); |
| 12 | 2814 | | uri.AppendPath("/resourcegroups/", false); |
| 12 | 2815 | | uri.AppendPath(resourceGroupName, true); |
| 12 | 2816 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 12 | 2817 | | uri.AppendPath(deploymentName, true); |
| 12 | 2818 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 12 | 2819 | | request.Uri = uri; |
| 12 | 2820 | | return message; |
| | 2821 | | } |
| | 2822 | |
|
| | 2823 | | /// <summary> Gets a deployment. </summary> |
| | 2824 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 2825 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2826 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2827 | | public async Task<Response<DeploymentExtended>> GetAsync(string resourceGroupName, string deploymentName, Cancel |
| | 2828 | | { |
| 6 | 2829 | | if (resourceGroupName == null) |
| | 2830 | | { |
| 0 | 2831 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2832 | | } |
| 6 | 2833 | | if (deploymentName == null) |
| | 2834 | | { |
| 0 | 2835 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2836 | | } |
| | 2837 | |
|
| 6 | 2838 | | using var message = CreateGetRequest(resourceGroupName, deploymentName); |
| 6 | 2839 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 6 | 2840 | | switch (message.Response.Status) |
| | 2841 | | { |
| | 2842 | | case 200: |
| | 2843 | | { |
| 6 | 2844 | | DeploymentExtended value = default; |
| 6 | 2845 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 6 | 2846 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2847 | | { |
| 0 | 2848 | | value = null; |
| | 2849 | | } |
| | 2850 | | else |
| | 2851 | | { |
| 6 | 2852 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 2853 | | } |
| 6 | 2854 | | return Response.FromValue(value, message.Response); |
| | 2855 | | } |
| | 2856 | | default: |
| 0 | 2857 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2858 | | } |
| 6 | 2859 | | } |
| | 2860 | |
|
| | 2861 | | /// <summary> Gets a deployment. </summary> |
| | 2862 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 2863 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2864 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2865 | | public Response<DeploymentExtended> Get(string resourceGroupName, string deploymentName, CancellationToken cance |
| | 2866 | | { |
| 6 | 2867 | | if (resourceGroupName == null) |
| | 2868 | | { |
| 0 | 2869 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2870 | | } |
| 6 | 2871 | | if (deploymentName == null) |
| | 2872 | | { |
| 0 | 2873 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2874 | | } |
| | 2875 | |
|
| 6 | 2876 | | using var message = CreateGetRequest(resourceGroupName, deploymentName); |
| 6 | 2877 | | _pipeline.Send(message, cancellationToken); |
| 6 | 2878 | | switch (message.Response.Status) |
| | 2879 | | { |
| | 2880 | | case 200: |
| | 2881 | | { |
| 6 | 2882 | | DeploymentExtended value = default; |
| 6 | 2883 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 6 | 2884 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 2885 | | { |
| 0 | 2886 | | value = null; |
| | 2887 | | } |
| | 2888 | | else |
| | 2889 | | { |
| 6 | 2890 | | value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); |
| | 2891 | | } |
| 6 | 2892 | | return Response.FromValue(value, message.Response); |
| | 2893 | | } |
| | 2894 | | default: |
| 0 | 2895 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2896 | | } |
| 6 | 2897 | | } |
| | 2898 | |
|
| | 2899 | | internal Core.HttpMessage CreateCancelRequest(string resourceGroupName, string deploymentName) |
| | 2900 | | { |
| 4 | 2901 | | var message = _pipeline.CreateMessage(); |
| 4 | 2902 | | var request = message.Request; |
| 4 | 2903 | | request.Method = RequestMethod.Post; |
| 4 | 2904 | | var uri = new RawRequestUriBuilder(); |
| 4 | 2905 | | uri.Reset(endpoint); |
| 4 | 2906 | | uri.AppendPath("/subscriptions/", false); |
| 4 | 2907 | | uri.AppendPath(subscriptionId, true); |
| 4 | 2908 | | uri.AppendPath("/resourcegroups/", false); |
| 4 | 2909 | | uri.AppendPath(resourceGroupName, true); |
| 4 | 2910 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 4 | 2911 | | uri.AppendPath(deploymentName, true); |
| 4 | 2912 | | uri.AppendPath("/cancel", false); |
| 4 | 2913 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 4 | 2914 | | request.Uri = uri; |
| 4 | 2915 | | return message; |
| | 2916 | | } |
| | 2917 | |
|
| | 2918 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 2919 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 2920 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2921 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2922 | | public async Task<Response> CancelAsync(string resourceGroupName, string deploymentName, CancellationToken cance |
| | 2923 | | { |
| 6 | 2924 | | if (resourceGroupName == null) |
| | 2925 | | { |
| 2 | 2926 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2927 | | } |
| 4 | 2928 | | if (deploymentName == null) |
| | 2929 | | { |
| 2 | 2930 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2931 | | } |
| | 2932 | |
|
| 2 | 2933 | | using var message = CreateCancelRequest(resourceGroupName, deploymentName); |
| 2 | 2934 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 2935 | | switch (message.Response.Status) |
| | 2936 | | { |
| | 2937 | | case 204: |
| 2 | 2938 | | return message.Response; |
| | 2939 | | default: |
| 0 | 2940 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 2941 | | } |
| 2 | 2942 | | } |
| | 2943 | |
|
| | 2944 | | /// <summary> You can cancel a deployment only if the provisioningState is Accepted or Running. After the deploy |
| | 2945 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 2946 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2947 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2948 | | public Response Cancel(string resourceGroupName, string deploymentName, CancellationToken cancellationToken = de |
| | 2949 | | { |
| 6 | 2950 | | if (resourceGroupName == null) |
| | 2951 | | { |
| 2 | 2952 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 2953 | | } |
| 4 | 2954 | | if (deploymentName == null) |
| | 2955 | | { |
| 2 | 2956 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 2957 | | } |
| | 2958 | |
|
| 2 | 2959 | | using var message = CreateCancelRequest(resourceGroupName, deploymentName); |
| 2 | 2960 | | _pipeline.Send(message, cancellationToken); |
| 2 | 2961 | | switch (message.Response.Status) |
| | 2962 | | { |
| | 2963 | | case 204: |
| 2 | 2964 | | return message.Response; |
| | 2965 | | default: |
| 0 | 2966 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 2967 | | } |
| 2 | 2968 | | } |
| | 2969 | |
|
| | 2970 | | internal Core.HttpMessage CreateValidateRequest(string resourceGroupName, string deploymentName, Deployment para |
| | 2971 | | { |
| 48 | 2972 | | var message = _pipeline.CreateMessage(); |
| 48 | 2973 | | var request = message.Request; |
| 48 | 2974 | | request.Method = RequestMethod.Post; |
| 48 | 2975 | | var uri = new RawRequestUriBuilder(); |
| 48 | 2976 | | uri.Reset(endpoint); |
| 48 | 2977 | | uri.AppendPath("/subscriptions/", false); |
| 48 | 2978 | | uri.AppendPath(subscriptionId, true); |
| 48 | 2979 | | uri.AppendPath("/resourcegroups/", false); |
| 48 | 2980 | | uri.AppendPath(resourceGroupName, true); |
| 48 | 2981 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 48 | 2982 | | uri.AppendPath(deploymentName, true); |
| 48 | 2983 | | uri.AppendPath("/validate", false); |
| 48 | 2984 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 48 | 2985 | | request.Uri = uri; |
| 48 | 2986 | | request.Headers.Add("Content-Type", "application/json"); |
| 48 | 2987 | | var content = new Utf8JsonRequestContent(); |
| 48 | 2988 | | content.JsonWriter.WriteObjectValue(parameters); |
| 48 | 2989 | | request.Content = content; |
| 48 | 2990 | | return message; |
| | 2991 | | } |
| | 2992 | |
|
| | 2993 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 2994 | | /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i |
| | 2995 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 2996 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 2997 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 2998 | | public async Task<Response> ValidateAsync(string resourceGroupName, string deploymentName, Deployment parameters |
| | 2999 | | { |
| 12 | 3000 | | if (resourceGroupName == null) |
| | 3001 | | { |
| 0 | 3002 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3003 | | } |
| 12 | 3004 | | if (deploymentName == null) |
| | 3005 | | { |
| 0 | 3006 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3007 | | } |
| 12 | 3008 | | if (parameters == null) |
| | 3009 | | { |
| 0 | 3010 | | throw new ArgumentNullException(nameof(parameters)); |
| | 3011 | | } |
| | 3012 | |
|
| 12 | 3013 | | using var message = CreateValidateRequest(resourceGroupName, deploymentName, parameters); |
| 12 | 3014 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 12 | 3015 | | switch (message.Response.Status) |
| | 3016 | | { |
| | 3017 | | case 200: |
| | 3018 | | case 202: |
| | 3019 | | case 400: |
| 12 | 3020 | | return message.Response; |
| | 3021 | | default: |
| 0 | 3022 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3023 | | } |
| 12 | 3024 | | } |
| | 3025 | |
|
| | 3026 | | /// <summary> Validates whether the specified template is syntactically correct and will be accepted by Azure Re |
| | 3027 | | /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i |
| | 3028 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 3029 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 3030 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3031 | | public Response Validate(string resourceGroupName, string deploymentName, Deployment parameters, CancellationTok |
| | 3032 | | { |
| 12 | 3033 | | if (resourceGroupName == null) |
| | 3034 | | { |
| 0 | 3035 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3036 | | } |
| 12 | 3037 | | if (deploymentName == null) |
| | 3038 | | { |
| 0 | 3039 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3040 | | } |
| 12 | 3041 | | if (parameters == null) |
| | 3042 | | { |
| 0 | 3043 | | throw new ArgumentNullException(nameof(parameters)); |
| | 3044 | | } |
| | 3045 | |
|
| 12 | 3046 | | using var message = CreateValidateRequest(resourceGroupName, deploymentName, parameters); |
| 12 | 3047 | | _pipeline.Send(message, cancellationToken); |
| 12 | 3048 | | switch (message.Response.Status) |
| | 3049 | | { |
| | 3050 | | case 200: |
| | 3051 | | case 202: |
| | 3052 | | case 400: |
| 12 | 3053 | | return message.Response; |
| | 3054 | | default: |
| 0 | 3055 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3056 | | } |
| 12 | 3057 | | } |
| | 3058 | |
|
| | 3059 | | internal Core.HttpMessage CreateWhatIfRequest(string resourceGroupName, string deploymentName, DeploymentWhatIf |
| | 3060 | | { |
| 80 | 3061 | | var message = _pipeline.CreateMessage(); |
| 80 | 3062 | | var request = message.Request; |
| 80 | 3063 | | request.Method = RequestMethod.Post; |
| 80 | 3064 | | var uri = new RawRequestUriBuilder(); |
| 80 | 3065 | | uri.Reset(endpoint); |
| 80 | 3066 | | uri.AppendPath("/subscriptions/", false); |
| 80 | 3067 | | uri.AppendPath(subscriptionId, true); |
| 80 | 3068 | | uri.AppendPath("/resourcegroups/", false); |
| 80 | 3069 | | uri.AppendPath(resourceGroupName, true); |
| 80 | 3070 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 80 | 3071 | | uri.AppendPath(deploymentName, true); |
| 80 | 3072 | | uri.AppendPath("/whatIf", false); |
| 80 | 3073 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 80 | 3074 | | request.Uri = uri; |
| 80 | 3075 | | request.Headers.Add("Content-Type", "application/json"); |
| 80 | 3076 | | var content = new Utf8JsonRequestContent(); |
| 80 | 3077 | | content.JsonWriter.WriteObjectValue(parameters); |
| 80 | 3078 | | request.Content = content; |
| 80 | 3079 | | return message; |
| | 3080 | | } |
| | 3081 | |
|
| | 3082 | | /// <summary> Returns changes that will be made by the deployment if executed at the scope of the resource group |
| | 3083 | | /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i |
| | 3084 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 3085 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 3086 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3087 | | public async Task<ResponseWithHeaders<DeploymentsWhatIfHeaders>> WhatIfAsync(string resourceGroupName, string de |
| | 3088 | | { |
| 20 | 3089 | | if (resourceGroupName == null) |
| | 3090 | | { |
| 0 | 3091 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3092 | | } |
| 20 | 3093 | | if (deploymentName == null) |
| | 3094 | | { |
| 0 | 3095 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3096 | | } |
| 20 | 3097 | | if (parameters == null) |
| | 3098 | | { |
| 0 | 3099 | | throw new ArgumentNullException(nameof(parameters)); |
| | 3100 | | } |
| | 3101 | |
|
| 20 | 3102 | | using var message = CreateWhatIfRequest(resourceGroupName, deploymentName, parameters); |
| 20 | 3103 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 20 | 3104 | | var headers = new DeploymentsWhatIfHeaders(message.Response); |
| 20 | 3105 | | switch (message.Response.Status) |
| | 3106 | | { |
| | 3107 | | case 200: |
| | 3108 | | case 202: |
| 20 | 3109 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 3110 | | default: |
| 0 | 3111 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3112 | | } |
| 20 | 3113 | | } |
| | 3114 | |
|
| | 3115 | | /// <summary> Returns changes that will be made by the deployment if executed at the scope of the resource group |
| | 3116 | | /// <param name="resourceGroupName"> The name of the resource group the template will be deployed to. The name i |
| | 3117 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 3118 | | /// <param name="parameters"> Parameters to validate. </param> |
| | 3119 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3120 | | public ResponseWithHeaders<DeploymentsWhatIfHeaders> WhatIf(string resourceGroupName, string deploymentName, Dep |
| | 3121 | | { |
| 20 | 3122 | | if (resourceGroupName == null) |
| | 3123 | | { |
| 0 | 3124 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3125 | | } |
| 20 | 3126 | | if (deploymentName == null) |
| | 3127 | | { |
| 0 | 3128 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3129 | | } |
| 20 | 3130 | | if (parameters == null) |
| | 3131 | | { |
| 0 | 3132 | | throw new ArgumentNullException(nameof(parameters)); |
| | 3133 | | } |
| | 3134 | |
|
| 20 | 3135 | | using var message = CreateWhatIfRequest(resourceGroupName, deploymentName, parameters); |
| 20 | 3136 | | _pipeline.Send(message, cancellationToken); |
| 20 | 3137 | | var headers = new DeploymentsWhatIfHeaders(message.Response); |
| 20 | 3138 | | switch (message.Response.Status) |
| | 3139 | | { |
| | 3140 | | case 200: |
| | 3141 | | case 202: |
| 20 | 3142 | | return ResponseWithHeaders.FromValue(headers, message.Response); |
| | 3143 | | default: |
| 0 | 3144 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3145 | | } |
| 20 | 3146 | | } |
| | 3147 | |
|
| | 3148 | | internal Core.HttpMessage CreateExportTemplateRequest(string resourceGroupName, string deploymentName) |
| | 3149 | | { |
| 0 | 3150 | | var message = _pipeline.CreateMessage(); |
| 0 | 3151 | | var request = message.Request; |
| 0 | 3152 | | request.Method = RequestMethod.Post; |
| 0 | 3153 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3154 | | uri.Reset(endpoint); |
| 0 | 3155 | | uri.AppendPath("/subscriptions/", false); |
| 0 | 3156 | | uri.AppendPath(subscriptionId, true); |
| 0 | 3157 | | uri.AppendPath("/resourcegroups/", false); |
| 0 | 3158 | | uri.AppendPath(resourceGroupName, true); |
| 0 | 3159 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 0 | 3160 | | uri.AppendPath(deploymentName, true); |
| 0 | 3161 | | uri.AppendPath("/exportTemplate", false); |
| 0 | 3162 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 3163 | | request.Uri = uri; |
| 0 | 3164 | | return message; |
| | 3165 | | } |
| | 3166 | |
|
| | 3167 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 3168 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 3169 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 3170 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3171 | | public async Task<Response<DeploymentExportResult>> ExportTemplateAsync(string resourceGroupName, string deploym |
| | 3172 | | { |
| 0 | 3173 | | if (resourceGroupName == null) |
| | 3174 | | { |
| 0 | 3175 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3176 | | } |
| 0 | 3177 | | if (deploymentName == null) |
| | 3178 | | { |
| 0 | 3179 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3180 | | } |
| | 3181 | |
|
| 0 | 3182 | | using var message = CreateExportTemplateRequest(resourceGroupName, deploymentName); |
| 0 | 3183 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3184 | | switch (message.Response.Status) |
| | 3185 | | { |
| | 3186 | | case 200: |
| | 3187 | | { |
| 0 | 3188 | | DeploymentExportResult value = default; |
| 0 | 3189 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3190 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3191 | | { |
| 0 | 3192 | | value = null; |
| | 3193 | | } |
| | 3194 | | else |
| | 3195 | | { |
| 0 | 3196 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 3197 | | } |
| 0 | 3198 | | return Response.FromValue(value, message.Response); |
| | 3199 | | } |
| | 3200 | | default: |
| 0 | 3201 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3202 | | } |
| 0 | 3203 | | } |
| | 3204 | |
|
| | 3205 | | /// <summary> Exports the template used for specified deployment. </summary> |
| | 3206 | | /// <param name="resourceGroupName"> The name of the resource group. The name is case insensitive. </param> |
| | 3207 | | /// <param name="deploymentName"> The name of the deployment. </param> |
| | 3208 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3209 | | public Response<DeploymentExportResult> ExportTemplate(string resourceGroupName, string deploymentName, Cancella |
| | 3210 | | { |
| 0 | 3211 | | if (resourceGroupName == null) |
| | 3212 | | { |
| 0 | 3213 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3214 | | } |
| 0 | 3215 | | if (deploymentName == null) |
| | 3216 | | { |
| 0 | 3217 | | throw new ArgumentNullException(nameof(deploymentName)); |
| | 3218 | | } |
| | 3219 | |
|
| 0 | 3220 | | using var message = CreateExportTemplateRequest(resourceGroupName, deploymentName); |
| 0 | 3221 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3222 | | switch (message.Response.Status) |
| | 3223 | | { |
| | 3224 | | case 200: |
| | 3225 | | { |
| 0 | 3226 | | DeploymentExportResult value = default; |
| 0 | 3227 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3228 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3229 | | { |
| 0 | 3230 | | value = null; |
| | 3231 | | } |
| | 3232 | | else |
| | 3233 | | { |
| 0 | 3234 | | value = DeploymentExportResult.DeserializeDeploymentExportResult(document.RootElement); |
| | 3235 | | } |
| 0 | 3236 | | return Response.FromValue(value, message.Response); |
| | 3237 | | } |
| | 3238 | | default: |
| 0 | 3239 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3240 | | } |
| 0 | 3241 | | } |
| | 3242 | |
|
| | 3243 | | internal Core.HttpMessage CreateListByResourceGroupRequest(string resourceGroupName, string filter, int? top) |
| | 3244 | | { |
| 16 | 3245 | | var message = _pipeline.CreateMessage(); |
| 16 | 3246 | | var request = message.Request; |
| 16 | 3247 | | request.Method = RequestMethod.Get; |
| 16 | 3248 | | var uri = new RawRequestUriBuilder(); |
| 16 | 3249 | | uri.Reset(endpoint); |
| 16 | 3250 | | uri.AppendPath("/subscriptions/", false); |
| 16 | 3251 | | uri.AppendPath(subscriptionId, true); |
| 16 | 3252 | | uri.AppendPath("/resourcegroups/", false); |
| 16 | 3253 | | uri.AppendPath(resourceGroupName, true); |
| 16 | 3254 | | uri.AppendPath("/providers/Microsoft.Resources/deployments/", false); |
| 16 | 3255 | | if (filter != null) |
| | 3256 | | { |
| 4 | 3257 | | uri.AppendQuery("$filter", filter, true); |
| | 3258 | | } |
| 16 | 3259 | | if (top != null) |
| | 3260 | | { |
| 4 | 3261 | | uri.AppendQuery("$top", top.Value, true); |
| | 3262 | | } |
| 16 | 3263 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 16 | 3264 | | request.Uri = uri; |
| 16 | 3265 | | return message; |
| | 3266 | | } |
| | 3267 | |
|
| | 3268 | | /// <summary> Get all the deployments for a resource group. </summary> |
| | 3269 | | /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas |
| | 3270 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3271 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3272 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3273 | | public async Task<Response<DeploymentListResult>> ListByResourceGroupAsync(string resourceGroupName, string filt |
| | 3274 | | { |
| 8 | 3275 | | if (resourceGroupName == null) |
| | 3276 | | { |
| 0 | 3277 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3278 | | } |
| | 3279 | |
|
| 8 | 3280 | | using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, top); |
| 8 | 3281 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 8 | 3282 | | switch (message.Response.Status) |
| | 3283 | | { |
| | 3284 | | case 200: |
| | 3285 | | { |
| 8 | 3286 | | DeploymentListResult value = default; |
| 8 | 3287 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 8 | 3288 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3289 | | { |
| 0 | 3290 | | value = null; |
| | 3291 | | } |
| | 3292 | | else |
| | 3293 | | { |
| 8 | 3294 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3295 | | } |
| 8 | 3296 | | return Response.FromValue(value, message.Response); |
| | 3297 | | } |
| | 3298 | | default: |
| 0 | 3299 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3300 | | } |
| 8 | 3301 | | } |
| | 3302 | |
|
| | 3303 | | /// <summary> Get all the deployments for a resource group. </summary> |
| | 3304 | | /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas |
| | 3305 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3306 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3307 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3308 | | public Response<DeploymentListResult> ListByResourceGroup(string resourceGroupName, string filter = null, int? t |
| | 3309 | | { |
| 8 | 3310 | | if (resourceGroupName == null) |
| | 3311 | | { |
| 0 | 3312 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3313 | | } |
| | 3314 | |
|
| 8 | 3315 | | using var message = CreateListByResourceGroupRequest(resourceGroupName, filter, top); |
| 8 | 3316 | | _pipeline.Send(message, cancellationToken); |
| 8 | 3317 | | switch (message.Response.Status) |
| | 3318 | | { |
| | 3319 | | case 200: |
| | 3320 | | { |
| 8 | 3321 | | DeploymentListResult value = default; |
| 8 | 3322 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 8 | 3323 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3324 | | { |
| 0 | 3325 | | value = null; |
| | 3326 | | } |
| | 3327 | | else |
| | 3328 | | { |
| 8 | 3329 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3330 | | } |
| 8 | 3331 | | return Response.FromValue(value, message.Response); |
| | 3332 | | } |
| | 3333 | | default: |
| 0 | 3334 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3335 | | } |
| 8 | 3336 | | } |
| | 3337 | |
|
| | 3338 | | internal Core.HttpMessage CreateCalculateTemplateHashRequest(object template) |
| | 3339 | | { |
| 0 | 3340 | | var message = _pipeline.CreateMessage(); |
| 0 | 3341 | | var request = message.Request; |
| 0 | 3342 | | request.Method = RequestMethod.Post; |
| 0 | 3343 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3344 | | uri.Reset(endpoint); |
| 0 | 3345 | | uri.AppendPath("/providers/Microsoft.Resources/calculateTemplateHash", false); |
| 0 | 3346 | | uri.AppendQuery("api-version", "2019-10-01", true); |
| 0 | 3347 | | request.Uri = uri; |
| 0 | 3348 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 3349 | | var content = new Utf8JsonRequestContent(); |
| 0 | 3350 | | content.JsonWriter.WriteObjectValue(template); |
| 0 | 3351 | | request.Content = content; |
| 0 | 3352 | | return message; |
| | 3353 | | } |
| | 3354 | |
|
| | 3355 | | /// <summary> Calculate the hash of the given template. </summary> |
| | 3356 | | /// <param name="template"> The template provided to calculate hash. </param> |
| | 3357 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3358 | | public async Task<Response<TemplateHashResult>> CalculateTemplateHashAsync(object template, CancellationToken ca |
| | 3359 | | { |
| 0 | 3360 | | if (template == null) |
| | 3361 | | { |
| 0 | 3362 | | throw new ArgumentNullException(nameof(template)); |
| | 3363 | | } |
| | 3364 | |
|
| 0 | 3365 | | using var message = CreateCalculateTemplateHashRequest(template); |
| 0 | 3366 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3367 | | switch (message.Response.Status) |
| | 3368 | | { |
| | 3369 | | case 200: |
| | 3370 | | { |
| 0 | 3371 | | TemplateHashResult value = default; |
| 0 | 3372 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3373 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3374 | | { |
| 0 | 3375 | | value = null; |
| | 3376 | | } |
| | 3377 | | else |
| | 3378 | | { |
| 0 | 3379 | | value = TemplateHashResult.DeserializeTemplateHashResult(document.RootElement); |
| | 3380 | | } |
| 0 | 3381 | | return Response.FromValue(value, message.Response); |
| | 3382 | | } |
| | 3383 | | default: |
| 0 | 3384 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3385 | | } |
| 0 | 3386 | | } |
| | 3387 | |
|
| | 3388 | | /// <summary> Calculate the hash of the given template. </summary> |
| | 3389 | | /// <param name="template"> The template provided to calculate hash. </param> |
| | 3390 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3391 | | public Response<TemplateHashResult> CalculateTemplateHash(object template, CancellationToken cancellationToken = |
| | 3392 | | { |
| 0 | 3393 | | if (template == null) |
| | 3394 | | { |
| 0 | 3395 | | throw new ArgumentNullException(nameof(template)); |
| | 3396 | | } |
| | 3397 | |
|
| 0 | 3398 | | using var message = CreateCalculateTemplateHashRequest(template); |
| 0 | 3399 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3400 | | switch (message.Response.Status) |
| | 3401 | | { |
| | 3402 | | case 200: |
| | 3403 | | { |
| 0 | 3404 | | TemplateHashResult value = default; |
| 0 | 3405 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3406 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3407 | | { |
| 0 | 3408 | | value = null; |
| | 3409 | | } |
| | 3410 | | else |
| | 3411 | | { |
| 0 | 3412 | | value = TemplateHashResult.DeserializeTemplateHashResult(document.RootElement); |
| | 3413 | | } |
| 0 | 3414 | | return Response.FromValue(value, message.Response); |
| | 3415 | | } |
| | 3416 | | default: |
| 0 | 3417 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3418 | | } |
| 0 | 3419 | | } |
| | 3420 | |
|
| | 3421 | | internal Core.HttpMessage CreateListAtScopeNextPageRequest(string nextLink, string scope, string filter, int? to |
| | 3422 | | { |
| 0 | 3423 | | var message = _pipeline.CreateMessage(); |
| 0 | 3424 | | var request = message.Request; |
| 0 | 3425 | | request.Method = RequestMethod.Get; |
| 0 | 3426 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3427 | | uri.Reset(endpoint); |
| 0 | 3428 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 3429 | | request.Uri = uri; |
| 0 | 3430 | | return message; |
| | 3431 | | } |
| | 3432 | |
|
| | 3433 | | /// <summary> Get all the deployments at the given scope. </summary> |
| | 3434 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3435 | | /// <param name="scope"> The resource scope. </param> |
| | 3436 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3437 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3438 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3439 | | public async Task<Response<DeploymentListResult>> ListAtScopeNextPageAsync(string nextLink, string scope, string |
| | 3440 | | { |
| 0 | 3441 | | if (nextLink == null) |
| | 3442 | | { |
| 0 | 3443 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3444 | | } |
| 0 | 3445 | | if (scope == null) |
| | 3446 | | { |
| 0 | 3447 | | throw new ArgumentNullException(nameof(scope)); |
| | 3448 | | } |
| | 3449 | |
|
| 0 | 3450 | | using var message = CreateListAtScopeNextPageRequest(nextLink, scope, filter, top); |
| 0 | 3451 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3452 | | switch (message.Response.Status) |
| | 3453 | | { |
| | 3454 | | case 200: |
| | 3455 | | { |
| 0 | 3456 | | DeploymentListResult value = default; |
| 0 | 3457 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3458 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3459 | | { |
| 0 | 3460 | | value = null; |
| | 3461 | | } |
| | 3462 | | else |
| | 3463 | | { |
| 0 | 3464 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3465 | | } |
| 0 | 3466 | | return Response.FromValue(value, message.Response); |
| | 3467 | | } |
| | 3468 | | default: |
| 0 | 3469 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3470 | | } |
| 0 | 3471 | | } |
| | 3472 | |
|
| | 3473 | | /// <summary> Get all the deployments at the given scope. </summary> |
| | 3474 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3475 | | /// <param name="scope"> The resource scope. </param> |
| | 3476 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3477 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3478 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3479 | | public Response<DeploymentListResult> ListAtScopeNextPage(string nextLink, string scope, string filter = null, i |
| | 3480 | | { |
| 0 | 3481 | | if (nextLink == null) |
| | 3482 | | { |
| 0 | 3483 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3484 | | } |
| 0 | 3485 | | if (scope == null) |
| | 3486 | | { |
| 0 | 3487 | | throw new ArgumentNullException(nameof(scope)); |
| | 3488 | | } |
| | 3489 | |
|
| 0 | 3490 | | using var message = CreateListAtScopeNextPageRequest(nextLink, scope, filter, top); |
| 0 | 3491 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3492 | | switch (message.Response.Status) |
| | 3493 | | { |
| | 3494 | | case 200: |
| | 3495 | | { |
| 0 | 3496 | | DeploymentListResult value = default; |
| 0 | 3497 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3498 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3499 | | { |
| 0 | 3500 | | value = null; |
| | 3501 | | } |
| | 3502 | | else |
| | 3503 | | { |
| 0 | 3504 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3505 | | } |
| 0 | 3506 | | return Response.FromValue(value, message.Response); |
| | 3507 | | } |
| | 3508 | | default: |
| 0 | 3509 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3510 | | } |
| 0 | 3511 | | } |
| | 3512 | |
|
| | 3513 | | internal Core.HttpMessage CreateListAtTenantScopeNextPageRequest(string nextLink, string filter, int? top) |
| | 3514 | | { |
| 0 | 3515 | | var message = _pipeline.CreateMessage(); |
| 0 | 3516 | | var request = message.Request; |
| 0 | 3517 | | request.Method = RequestMethod.Get; |
| 0 | 3518 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3519 | | uri.Reset(endpoint); |
| 0 | 3520 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 3521 | | request.Uri = uri; |
| 0 | 3522 | | return message; |
| | 3523 | | } |
| | 3524 | |
|
| | 3525 | | /// <summary> Get all the deployments at the tenant scope. </summary> |
| | 3526 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3527 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3528 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3529 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3530 | | public async Task<Response<DeploymentListResult>> ListAtTenantScopeNextPageAsync(string nextLink, string filter |
| | 3531 | | { |
| 0 | 3532 | | if (nextLink == null) |
| | 3533 | | { |
| 0 | 3534 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3535 | | } |
| | 3536 | |
|
| 0 | 3537 | | using var message = CreateListAtTenantScopeNextPageRequest(nextLink, filter, top); |
| 0 | 3538 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3539 | | switch (message.Response.Status) |
| | 3540 | | { |
| | 3541 | | case 200: |
| | 3542 | | { |
| 0 | 3543 | | DeploymentListResult value = default; |
| 0 | 3544 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3545 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3546 | | { |
| 0 | 3547 | | value = null; |
| | 3548 | | } |
| | 3549 | | else |
| | 3550 | | { |
| 0 | 3551 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3552 | | } |
| 0 | 3553 | | return Response.FromValue(value, message.Response); |
| | 3554 | | } |
| | 3555 | | default: |
| 0 | 3556 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3557 | | } |
| 0 | 3558 | | } |
| | 3559 | |
|
| | 3560 | | /// <summary> Get all the deployments at the tenant scope. </summary> |
| | 3561 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3562 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3563 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3564 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3565 | | public Response<DeploymentListResult> ListAtTenantScopeNextPage(string nextLink, string filter = null, int? top |
| | 3566 | | { |
| 0 | 3567 | | if (nextLink == null) |
| | 3568 | | { |
| 0 | 3569 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3570 | | } |
| | 3571 | |
|
| 0 | 3572 | | using var message = CreateListAtTenantScopeNextPageRequest(nextLink, filter, top); |
| 0 | 3573 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3574 | | switch (message.Response.Status) |
| | 3575 | | { |
| | 3576 | | case 200: |
| | 3577 | | { |
| 0 | 3578 | | DeploymentListResult value = default; |
| 0 | 3579 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3580 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3581 | | { |
| 0 | 3582 | | value = null; |
| | 3583 | | } |
| | 3584 | | else |
| | 3585 | | { |
| 0 | 3586 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3587 | | } |
| 0 | 3588 | | return Response.FromValue(value, message.Response); |
| | 3589 | | } |
| | 3590 | | default: |
| 0 | 3591 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3592 | | } |
| 0 | 3593 | | } |
| | 3594 | |
|
| | 3595 | | internal Core.HttpMessage CreateListAtManagementGroupScopeNextPageRequest(string nextLink, string groupId, strin |
| | 3596 | | { |
| 0 | 3597 | | var message = _pipeline.CreateMessage(); |
| 0 | 3598 | | var request = message.Request; |
| 0 | 3599 | | request.Method = RequestMethod.Get; |
| 0 | 3600 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3601 | | uri.Reset(endpoint); |
| 0 | 3602 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 3603 | | request.Uri = uri; |
| 0 | 3604 | | return message; |
| | 3605 | | } |
| | 3606 | |
|
| | 3607 | | /// <summary> Get all the deployments for a management group. </summary> |
| | 3608 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3609 | | /// <param name="groupId"> The management group ID. </param> |
| | 3610 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3611 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3612 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3613 | | public async Task<Response<DeploymentListResult>> ListAtManagementGroupScopeNextPageAsync(string nextLink, strin |
| | 3614 | | { |
| 0 | 3615 | | if (nextLink == null) |
| | 3616 | | { |
| 0 | 3617 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3618 | | } |
| 0 | 3619 | | if (groupId == null) |
| | 3620 | | { |
| 0 | 3621 | | throw new ArgumentNullException(nameof(groupId)); |
| | 3622 | | } |
| | 3623 | |
|
| 0 | 3624 | | using var message = CreateListAtManagementGroupScopeNextPageRequest(nextLink, groupId, filter, top); |
| 0 | 3625 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3626 | | switch (message.Response.Status) |
| | 3627 | | { |
| | 3628 | | case 200: |
| | 3629 | | { |
| 0 | 3630 | | DeploymentListResult value = default; |
| 0 | 3631 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3632 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3633 | | { |
| 0 | 3634 | | value = null; |
| | 3635 | | } |
| | 3636 | | else |
| | 3637 | | { |
| 0 | 3638 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3639 | | } |
| 0 | 3640 | | return Response.FromValue(value, message.Response); |
| | 3641 | | } |
| | 3642 | | default: |
| 0 | 3643 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3644 | | } |
| 0 | 3645 | | } |
| | 3646 | |
|
| | 3647 | | /// <summary> Get all the deployments for a management group. </summary> |
| | 3648 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3649 | | /// <param name="groupId"> The management group ID. </param> |
| | 3650 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3651 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3652 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3653 | | public Response<DeploymentListResult> ListAtManagementGroupScopeNextPage(string nextLink, string groupId, string |
| | 3654 | | { |
| 0 | 3655 | | if (nextLink == null) |
| | 3656 | | { |
| 0 | 3657 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3658 | | } |
| 0 | 3659 | | if (groupId == null) |
| | 3660 | | { |
| 0 | 3661 | | throw new ArgumentNullException(nameof(groupId)); |
| | 3662 | | } |
| | 3663 | |
|
| 0 | 3664 | | using var message = CreateListAtManagementGroupScopeNextPageRequest(nextLink, groupId, filter, top); |
| 0 | 3665 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3666 | | switch (message.Response.Status) |
| | 3667 | | { |
| | 3668 | | case 200: |
| | 3669 | | { |
| 0 | 3670 | | DeploymentListResult value = default; |
| 0 | 3671 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3672 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3673 | | { |
| 0 | 3674 | | value = null; |
| | 3675 | | } |
| | 3676 | | else |
| | 3677 | | { |
| 0 | 3678 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3679 | | } |
| 0 | 3680 | | return Response.FromValue(value, message.Response); |
| | 3681 | | } |
| | 3682 | | default: |
| 0 | 3683 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3684 | | } |
| 0 | 3685 | | } |
| | 3686 | |
|
| | 3687 | | internal Core.HttpMessage CreateListAtSubscriptionScopeNextPageRequest(string nextLink, string filter, int? top) |
| | 3688 | | { |
| 0 | 3689 | | var message = _pipeline.CreateMessage(); |
| 0 | 3690 | | var request = message.Request; |
| 0 | 3691 | | request.Method = RequestMethod.Get; |
| 0 | 3692 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3693 | | uri.Reset(endpoint); |
| 0 | 3694 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 3695 | | request.Uri = uri; |
| 0 | 3696 | | return message; |
| | 3697 | | } |
| | 3698 | |
|
| | 3699 | | /// <summary> Get all the deployments for a subscription. </summary> |
| | 3700 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3701 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3702 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3703 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3704 | | public async Task<Response<DeploymentListResult>> ListAtSubscriptionScopeNextPageAsync(string nextLink, string f |
| | 3705 | | { |
| 0 | 3706 | | if (nextLink == null) |
| | 3707 | | { |
| 0 | 3708 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3709 | | } |
| | 3710 | |
|
| 0 | 3711 | | using var message = CreateListAtSubscriptionScopeNextPageRequest(nextLink, filter, top); |
| 0 | 3712 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3713 | | switch (message.Response.Status) |
| | 3714 | | { |
| | 3715 | | case 200: |
| | 3716 | | { |
| 0 | 3717 | | DeploymentListResult value = default; |
| 0 | 3718 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3719 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3720 | | { |
| 0 | 3721 | | value = null; |
| | 3722 | | } |
| | 3723 | | else |
| | 3724 | | { |
| 0 | 3725 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3726 | | } |
| 0 | 3727 | | return Response.FromValue(value, message.Response); |
| | 3728 | | } |
| | 3729 | | default: |
| 0 | 3730 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3731 | | } |
| 0 | 3732 | | } |
| | 3733 | |
|
| | 3734 | | /// <summary> Get all the deployments for a subscription. </summary> |
| | 3735 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3736 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3737 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3738 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3739 | | public Response<DeploymentListResult> ListAtSubscriptionScopeNextPage(string nextLink, string filter = null, int |
| | 3740 | | { |
| 0 | 3741 | | if (nextLink == null) |
| | 3742 | | { |
| 0 | 3743 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3744 | | } |
| | 3745 | |
|
| 0 | 3746 | | using var message = CreateListAtSubscriptionScopeNextPageRequest(nextLink, filter, top); |
| 0 | 3747 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3748 | | switch (message.Response.Status) |
| | 3749 | | { |
| | 3750 | | case 200: |
| | 3751 | | { |
| 0 | 3752 | | DeploymentListResult value = default; |
| 0 | 3753 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3754 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3755 | | { |
| 0 | 3756 | | value = null; |
| | 3757 | | } |
| | 3758 | | else |
| | 3759 | | { |
| 0 | 3760 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3761 | | } |
| 0 | 3762 | | return Response.FromValue(value, message.Response); |
| | 3763 | | } |
| | 3764 | | default: |
| 0 | 3765 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3766 | | } |
| 0 | 3767 | | } |
| | 3768 | |
|
| | 3769 | | internal Core.HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName, st |
| | 3770 | | { |
| 0 | 3771 | | var message = _pipeline.CreateMessage(); |
| 0 | 3772 | | var request = message.Request; |
| 0 | 3773 | | request.Method = RequestMethod.Get; |
| 0 | 3774 | | var uri = new RawRequestUriBuilder(); |
| 0 | 3775 | | uri.Reset(endpoint); |
| 0 | 3776 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 3777 | | request.Uri = uri; |
| 0 | 3778 | | return message; |
| | 3779 | | } |
| | 3780 | |
|
| | 3781 | | /// <summary> Get all the deployments for a resource group. </summary> |
| | 3782 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3783 | | /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas |
| | 3784 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3785 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3786 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3787 | | public async Task<Response<DeploymentListResult>> ListByResourceGroupNextPageAsync(string nextLink, string resou |
| | 3788 | | { |
| 0 | 3789 | | if (nextLink == null) |
| | 3790 | | { |
| 0 | 3791 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3792 | | } |
| 0 | 3793 | | if (resourceGroupName == null) |
| | 3794 | | { |
| 0 | 3795 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3796 | | } |
| | 3797 | |
|
| 0 | 3798 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, top); |
| 0 | 3799 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 3800 | | switch (message.Response.Status) |
| | 3801 | | { |
| | 3802 | | case 200: |
| | 3803 | | { |
| 0 | 3804 | | DeploymentListResult value = default; |
| 0 | 3805 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 3806 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3807 | | { |
| 0 | 3808 | | value = null; |
| | 3809 | | } |
| | 3810 | | else |
| | 3811 | | { |
| 0 | 3812 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3813 | | } |
| 0 | 3814 | | return Response.FromValue(value, message.Response); |
| | 3815 | | } |
| | 3816 | | default: |
| 0 | 3817 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 3818 | | } |
| 0 | 3819 | | } |
| | 3820 | |
|
| | 3821 | | /// <summary> Get all the deployments for a resource group. </summary> |
| | 3822 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 3823 | | /// <param name="resourceGroupName"> The name of the resource group with the deployments to get. The name is cas |
| | 3824 | | /// <param name="filter"> The filter to apply on the operation. For example, you can use $filter=provisioningSta |
| | 3825 | | /// <param name="top"> The number of results to get. If null is passed, returns all deployments. </param> |
| | 3826 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 3827 | | public Response<DeploymentListResult> ListByResourceGroupNextPage(string nextLink, string resourceGroupName, str |
| | 3828 | | { |
| 0 | 3829 | | if (nextLink == null) |
| | 3830 | | { |
| 0 | 3831 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 3832 | | } |
| 0 | 3833 | | if (resourceGroupName == null) |
| | 3834 | | { |
| 0 | 3835 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 3836 | | } |
| | 3837 | |
|
| 0 | 3838 | | using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName, filter, top); |
| 0 | 3839 | | _pipeline.Send(message, cancellationToken); |
| 0 | 3840 | | switch (message.Response.Status) |
| | 3841 | | { |
| | 3842 | | case 200: |
| | 3843 | | { |
| 0 | 3844 | | DeploymentListResult value = default; |
| 0 | 3845 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 3846 | | if (document.RootElement.ValueKind == JsonValueKind.Null) |
| | 3847 | | { |
| 0 | 3848 | | value = null; |
| | 3849 | | } |
| | 3850 | | else |
| | 3851 | | { |
| 0 | 3852 | | value = DeploymentListResult.DeserializeDeploymentListResult(document.RootElement); |
| | 3853 | | } |
| 0 | 3854 | | return Response.FromValue(value, message.Response); |
| | 3855 | | } |
| | 3856 | | default: |
| 0 | 3857 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 3858 | | } |
| 0 | 3859 | | } |
| | 3860 | | } |
| | 3861 | | } |