Skip to content

Commit 1b9c737

Browse files
authored
Update Resources SDK 2024-11-01 (#27308)
1 parent 6fd908b commit 1b9c737

26 files changed

+356
-179
lines changed

src/Resources/ResourceManager/SdkClient/NewResourceManagerSdkClient.cs

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -489,36 +489,16 @@ private TemplateValidationInfo GetTemplateValidationResult(PSDeploymentCmdletPar
489489
try
490490
{
491491
var validationResult = this.ValidateDeployment(parameters, deployment);
492-
switch (validationResult)
493-
{
494-
case DeploymentExtended deploymentExtended:
495-
return new TemplateValidationInfo(deploymentExtended.Properties?.Providers?.ToList() ?? new List<Provider>(), new List<ErrorDetail>(), deploymentExtended.Properties?.Diagnostics?.ToList() ?? new List<DeploymentDiagnosticsDefinition>());
496-
case DeploymentValidationError deploymentValidationError:
497-
return new TemplateValidationInfo(new List<Provider>(), new List<ErrorDetail>(deploymentValidationError.Error.AsArray()), new List<DeploymentDiagnosticsDefinition>());
498-
case JObject obj:
499-
// 202 Response is not deserialized in DeploymentsOperations so we should attempt to deserialize the object here before failing
500-
// Should attempt to deserialize for success(DeploymentExtended)
501-
try
502-
{
503-
var deploymentDeserialized = SafeJsonConvert.DeserializeObject<DeploymentExtended>(validationResult.ToString(), ResourceManagementClient.DeserializationSettings);
504-
return new TemplateValidationInfo(deploymentDeserialized?.Properties?.Providers?.ToList() ?? new List<Provider>(), new List<ErrorDetail>(), deploymentDeserialized?.Properties?.Diagnostics?.ToList() ?? new List<DeploymentDiagnosticsDefinition>());
505-
}
506-
catch (Newtonsoft.Json.JsonException)
507-
{
508-
throw new InvalidOperationException($"Received unexpected type {validationResult.GetType()}");
509-
}
510-
default:
511-
throw new InvalidOperationException($"Received unexpected type {validationResult.GetType()}");
512-
}
492+
return new TemplateValidationInfo(validationResult);
513493
}
514494
catch (Exception ex)
515495
{
516496
var error = HandleError(ex).FirstOrDefault();
517-
return new TemplateValidationInfo(new List<Provider>(), error.AsArray().ToList(), new List<DeploymentDiagnosticsDefinition>());
497+
return new TemplateValidationInfo(new DeploymentValidateResult(error));
518498
}
519499
}
520500

521-
private object ValidateDeployment(PSDeploymentCmdletParameters parameters, Deployment deployment)
501+
private DeploymentValidateResult ValidateDeployment(PSDeploymentCmdletParameters parameters, Deployment deployment)
522502
{
523503
var scopedDeployment = new ScopedDeployment { Properties = deployment.Properties, Location = deployment.Location };
524504

@@ -547,26 +527,26 @@ private object ValidateDeployment(PSDeploymentCmdletParameters parameters, Deplo
547527
}
548528
}
549529

550-
private List<ErrorDetail> HandleError(Exception ex)
530+
private List<ErrorResponse> HandleError(Exception ex)
551531
{
552532
if (ex == null)
553533
{
554534
return null;
555535
}
556536

557-
ErrorDetail error = null;
537+
ErrorResponse error = null;
558538
var innerException = HandleError(ex.InnerException);
559539
if (ex is CloudException)
560540
{
561541
var cloudEx = ex as CloudException;
562-
error = new ErrorDetail(cloudEx.Body?.Code, cloudEx.Body?.Message, cloudEx.Body?.Target, innerException);
542+
error = new ErrorResponse(cloudEx.Body?.Code, cloudEx.Body?.Message, cloudEx.Body?.Target, innerException);
563543
}
564544
else
565545
{
566-
error = new ErrorDetail(null, ex.Message, null, innerException);
546+
error = new ErrorResponse(null, ex.Message, null, innerException);
567547
}
568548

569-
return new List<ErrorDetail> { error };
549+
return new List<ErrorResponse> { error };
570550

571551
}
572552

@@ -1529,7 +1509,7 @@ private DeploymentExtended ExecuteDeploymentInternal(PSDeploymentCmdletParameter
15291509
return ProvisionDeploymentStatus(parameters, deployment);
15301510
}
15311511

1532-
private void DisplayInnerDetailErrorMessage(ErrorDetail error)
1512+
private void DisplayInnerDetailErrorMessage(ErrorResponse error)
15331513
{
15341514
WriteError(string.Format(ErrorFormat, error.Code, error.Message));
15351515
if (error.Details != null)

src/Resources/ResourceManager/SdkModels/Deployments/TemplateValidationInfo.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,38 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System.Collections.Generic;
16+
using System.ComponentModel.DataAnnotations;
1617
using Microsoft.Azure.Management.Resources.Models;
1718

1819
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels
1920
{
2021
public class TemplateValidationInfo
2122
{
22-
public TemplateValidationInfo(List<Provider> requiredProviders, List<ErrorDetail> errors, List<DeploymentDiagnosticsDefinition> diagnostics)
23+
public TemplateValidationInfo(DeploymentValidateResult validationResult)
2324
{
24-
Errors = errors;
25-
RequiredProviders = requiredProviders;
26-
Diagnostics = diagnostics;
25+
Errors = new List<ErrorResponse>();
26+
RequiredProviders = new List<Provider>();
27+
Diagnostics = new List<DeploymentDiagnosticsDefinition>();
28+
29+
if (validationResult.Error != null)
30+
{
31+
Errors.Add(validationResult.Error);
32+
}
33+
34+
if (validationResult.Properties != null &&
35+
validationResult.Properties.Providers != null)
36+
{
37+
RequiredProviders.AddRange(validationResult.Properties.Providers);
38+
}
39+
40+
if (validationResult.Properties != null &&
41+
validationResult.Properties.Diagnostics != null)
42+
{
43+
Diagnostics.AddRange(validationResult.Properties.Diagnostics);
44+
}
2745
}
2846

29-
public List<ErrorDetail> Errors { get; set; }
47+
public List<ErrorResponse> Errors { get; set; }
3048

3149
public List<Provider> RequiredProviders { get; set; }
3250

src/Resources/Resources.Management.Sdk/Customizations/Models/WhatIfChange.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public partial class WhatIfChange
2424
/// <param name="delta">The predicted changes to resource
2525
/// properties.</param>
2626
public WhatIfChange(string resourceId, ChangeType changeType, object before = default(object), object after = default(object), IList<WhatIfPropertyChange> delta = default(IList<WhatIfPropertyChange>))
27-
: this(resourceId, changeType, default(string), before, after, delta)
27+
: this(resourceId: resourceId, changeType: changeType, deploymentId: default(string), symbolicName: default(string), identifiers: default(object), unsupportedReason: default(string), before: before, after: after, delta: delta)
2828
{
2929
}
3030
}

src/Resources/Resources.Management.Sdk/Generated/DeploymentScriptsClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ public DeploymentScriptsClient(System.Uri baseUri, Microsoft.Rest.ServiceClientC
269269
/// <param name='rootHandler'>
270270
/// Optional. The http client handler used to handle http transport.
271271
/// </param>
272+
/// <param name='handlers'>
273+
/// Optional. The delegating handlers to add to the http client pipeline.
274+
/// </param>
272275
/// <exception cref="System.ArgumentNullException">
273276
/// Thrown when a required parameter is null
274277
/// </exception>

src/Resources/Resources.Management.Sdk/Generated/DeploymentStacksClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ public DeploymentStacksClient(System.Uri baseUri, Microsoft.Rest.ServiceClientCr
269269
/// <param name='rootHandler'>
270270
/// Optional. The http client handler used to handle http transport.
271271
/// </param>
272+
/// <param name='handlers'>
273+
/// Optional. The delegating handlers to add to the http client pipeline.
274+
/// </param>
272275
/// <exception cref="System.ArgumentNullException">
273276
/// Thrown when a required parameter is null
274277
/// </exception>

0 commit comments

Comments
 (0)