Skip to content

Commit

Permalink
[Blueprint] SDK update due to API schema change (Azure#9135)
Browse files Browse the repository at this point in the history
* Update parameter value model and add managedResource property. Update tests and add new recorded tests

* Add txt file produced after generate.ps1 ran

* Update docs for SDK new version
  • Loading branch information
filizt authored and isra-fel committed Dec 19, 2019
1 parent bf87856 commit fd9ed34
Show file tree
Hide file tree
Showing 20 changed files with 897 additions and 904 deletions.
14 changes: 14 additions & 0 deletions eng/mgmt/mgmtmetadata/blueprint_resource-manager.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installing AutoRest version: latest
AutoRest installed successfully.
Commencing code generation
Generating CSharp code
Executing AutoRest command
cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/blueprint/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\Workspace\Git\azure-sdk-for-net\sdk
2019-12-16 18:11:57 UTC
Azure-rest-api-specs repository information
GitHub fork: Azure
Branch: master
Commit: 17cd6b2edff44b87012e888876ce58de10129850
AutoRest information
Requested version: latest
Bootstrapper version: autorest@2.0.4407

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Assignment()
/// Possible values include: 'creating', 'validating', 'waiting',
/// 'deploying', 'cancelling', 'locking', 'succeeded', 'failed',
/// 'canceled', 'deleting'</param>
public Assignment(string location, ManagedServiceIdentity identity, IDictionary<string, ParameterValueBase> parameters, IDictionary<string, ResourceGroupValue> resourceGroups, string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), string description = default(string), string blueprintId = default(string), AssignmentStatus status = default(AssignmentStatus), AssignmentLockSettings locks = default(AssignmentLockSettings), string provisioningState = default(string))
public Assignment(string location, ManagedServiceIdentity identity, IDictionary<string, ParameterValue> parameters, IDictionary<string, ResourceGroupValue> resourceGroups, string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), string description = default(string), string blueprintId = default(string), AssignmentStatus status = default(AssignmentStatus), AssignmentLockSettings locks = default(AssignmentLockSettings), string provisioningState = default(string))
: base(location, id, type, name)
{
Identity = identity;
Expand Down Expand Up @@ -107,7 +107,7 @@ public Assignment()
/// Gets or sets blueprint assignment parameter values.
/// </summary>
[JsonProperty(PropertyName = "properties.parameters")]
public IDictionary<string, ParameterValueBase> Parameters { get; set; }
public IDictionary<string, ParameterValue> Parameters { get; set; }

/// <summary>
/// Gets or sets names and locations of resource group placeholders.
Expand Down Expand Up @@ -175,16 +175,26 @@ public override void Validate()
throw new ValidationException(ValidationRules.MaxLength, "Description", 500);
}
}
if (ResourceGroups != null)
if (Parameters != null)
{
foreach (var valueElement in ResourceGroups.Values)
foreach (var valueElement in Parameters.Values)
{
if (valueElement != null)
{
valueElement.Validate();
}
}
}
if (ResourceGroups != null)
{
foreach (var valueElement1 in ResourceGroups.Values)
{
if (valueElement1 != null)
{
valueElement1.Validate();
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace Microsoft.Azure.Management.Blueprint.Models
{
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

/// <summary>
Expand All @@ -32,9 +35,12 @@ public AssignmentStatus()
/// definition.</param>
/// <param name="lastModified">Last modified time of this blueprint
/// definition.</param>
public AssignmentStatus(System.DateTime? timeCreated = default(System.DateTime?), System.DateTime? lastModified = default(System.DateTime?))
/// <param name="managedResources">List of resources that were created
/// by the blueprint assignment.</param>
public AssignmentStatus(System.DateTime? timeCreated = default(System.DateTime?), System.DateTime? lastModified = default(System.DateTime?), IList<string> managedResources = default(IList<string>))
: base(timeCreated, lastModified)
{
ManagedResources = managedResources;
CustomInit();
}

Expand All @@ -43,5 +49,12 @@ public AssignmentStatus()
/// </summary>
partial void CustomInit();

/// <summary>
/// Gets list of resources that were created by the blueprint
/// assignment.
/// </summary>
[JsonProperty(PropertyName = "managedResources")]
public IList<string> ManagedResources { get; private set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

namespace Microsoft.Azure.Management.Blueprint.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;

/// <summary>
/// Value for the specified parameter.
/// Value for the specified parameter. Can be either 'value' or 'reference'
/// but not both.
/// </summary>
public partial class ParameterValue : ParameterValueBase
public partial class ParameterValue
{
/// <summary>
/// Initializes a new instance of the ParameterValue class.
Expand All @@ -30,13 +30,12 @@ public ParameterValue()
/// <summary>
/// Initializes a new instance of the ParameterValue class.
/// </summary>
/// <param name="value">Actual value.</param>
/// <param name="description">Optional property. Establishes
/// ParameterValueBase as a BaseClass.</param>
public ParameterValue(object value, string description = default(string))
: base(description)
/// <param name="value">Parameter value as value type.</param>
/// <param name="reference">Parameter value as reference type.</param>
public ParameterValue(object value = default(object), SecretValueReference reference = default(SecretValueReference))
{
Value = value;
Reference = reference;
CustomInit();
}

Expand All @@ -46,22 +45,28 @@ public ParameterValue()
partial void CustomInit();

/// <summary>
/// Gets or sets actual value.
/// Gets or sets parameter value as value type.
/// </summary>
[JsonProperty(PropertyName = "value")]
public object Value { get; set; }

/// <summary>
/// Gets or sets parameter value as reference type.
/// </summary>
[JsonProperty(PropertyName = "reference")]
public SecretValueReference Reference { get; set; }

/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// <exception cref="Rest.ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (Value == null)
if (Reference != null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "Value");
Reference.Validate();
}
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public PolicyAssignmentArtifact()
/// the specified artifact.</param>
/// <param name="resourceGroup">Name of the resource group placeholder
/// to which the policy will be assigned.</param>
public PolicyAssignmentArtifact(string policyDefinitionId, IDictionary<string, ParameterValueBase> parameters, string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), string description = default(string), IList<string> dependsOn = default(IList<string>), string resourceGroup = default(string))
public PolicyAssignmentArtifact(string policyDefinitionId, IDictionary<string, ParameterValue> parameters, string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), string description = default(string), IList<string> dependsOn = default(IList<string>), string resourceGroup = default(string))
: base(id, type, name)
{
DisplayName = displayName;
Expand Down Expand Up @@ -96,7 +96,7 @@ public PolicyAssignmentArtifact()
/// Gets or sets parameter values for the policy definition.
/// </summary>
[JsonProperty(PropertyName = "properties.parameters")]
public IDictionary<string, ParameterValueBase> Parameters { get; set; }
public IDictionary<string, ParameterValue> Parameters { get; set; }

/// <summary>
/// Gets or sets name of the resource group placeholder to which the
Expand Down Expand Up @@ -135,6 +135,16 @@ public virtual void Validate()
throw new ValidationException(ValidationRules.MaxLength, "Description", 500);
}
}
if (Parameters != null)
{
foreach (var valueElement in Parameters.Values)
{
if (valueElement != null)
{
valueElement.Validate();
}
}
}
}
}
}
Loading

0 comments on commit fd9ed34

Please sign in to comment.