diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md b/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md index 5c646f09c221..1d71153793ce 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md +++ b/sdk/core/Azure.Core.Expressions.DataFactory/CHANGELOG.md @@ -1,10 +1,11 @@ # Release History -## 1.0.0-beta.4 (2023-07-10) +## 1.0.0-beta.4 (2023-07-13) ### Other Changes -- Added `TypeReferenceTypeAttribute` to Data Factory types to support code generation. +- Added `PropertyReferenceTypeAttribute` to Data Factory types to support code generation. +- Added `DataFactoryModelFactory` to support mocking. ## 1.0.0-beta.3 (2023-06-27) diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs index 984d64614b28..457451c1fa96 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/api/Azure.Core.Expressions.DataFactory.netstandard2.0.cs @@ -64,6 +64,13 @@ public DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.Data public static bool operator !=(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType left, Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType right) { throw null; } public override string ToString() { throw null; } } + public static partial class DataFactoryModelFactory + { + public static Azure.Core.Expressions.DataFactory.DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReference store, Azure.Core.Expressions.DataFactory.DataFactoryElement secretName, Azure.Core.Expressions.DataFactory.DataFactoryElement secretVersion) { throw null; } + public static Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference(Azure.Core.Expressions.DataFactory.DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, System.Collections.Generic.IDictionary parameters) { throw null; } + public static Azure.Core.Expressions.DataFactory.DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) { throw null; } + public static Azure.Core.Expressions.DataFactory.DataFactorySecretString DataFactorySecretString(string value) { throw null; } + } public abstract partial class DataFactorySecretBaseDefinition { protected DataFactorySecretBaseDefinition() { } diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj index fdcaa96d7173..c42a834e3325 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/Azure.Core.Expressions.DataFactory.csproj @@ -29,7 +29,9 @@ - + + + diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs index 9d96351b84dc..147eb3c0c9de 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryKeyVaultSecretReference.cs @@ -10,13 +10,14 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Key Vault secret reference. - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactoryKeyVaultSecretReference : DataFactorySecretBaseDefinition { /// Initializes a new instance of AzureKeyVaultSecretReference. /// The Azure Key Vault linked service reference. /// The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). /// or is null. + [InitializationConstructor] public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference store, DataFactoryElement secretName) { Argument.AssertNotNull(store, nameof(store)); @@ -32,6 +33,7 @@ public DataFactoryKeyVaultSecretReference(DataFactoryLinkedServiceReference stor /// The Azure Key Vault linked service reference. /// The name of the secret in Azure Key Vault. Type: string (or Expression with resultType string). /// The version of the secret in Azure Key Vault. The default value is the latest version of the secret. Type: string (or Expression with resultType string). + [SerializationConstructor] internal DataFactoryKeyVaultSecretReference(string secretBaseType, DataFactoryLinkedServiceReference store, DataFactoryElement secretName, DataFactoryElement secretVersion) : base(secretBaseType) { Store = store; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs index 5d8502b688fe..953b5c08a0e6 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryLinkedServiceReference.cs @@ -8,13 +8,14 @@ namespace Azure.Core.Expressions.DataFactory { /// Linked service reference type. - [TypeReferenceType] + [PropertyReferenceType] public partial class DataFactoryLinkedServiceReference { /// Initializes a new instance of DataFactoryLinkedServiceReference. /// Linked service reference type. /// Reference LinkedService name. /// is null. + [InitializationConstructor] public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string referenceName) { Argument.AssertNotNull(referenceName, nameof(referenceName)); @@ -28,6 +29,7 @@ public DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType r /// Linked service reference type. /// Reference LinkedService name. /// Arguments for LinkedService. + [SerializationConstructor] internal DataFactoryLinkedServiceReference(DataFactoryLinkedServiceReferenceType referenceType, string? referenceName, IDictionary parameters) { ReferenceType = referenceType; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs new file mode 100644 index 000000000000..16fb8e8e6fe6 --- /dev/null +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactoryModelFactory.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.Core.Expressions.DataFactory +{ + /// + /// Model factory to construct types for mocking. + /// + public static class DataFactoryModelFactory + { + /// + /// Constructs a for mocking. + /// + /// The secret string value. + /// The constructed . + public static DataFactorySecretString DataFactorySecretString(string value) => + new DataFactorySecretString(value); + + /// + /// Constructs a for mocking. + /// + /// The linked store. + /// The secret name. + /// The secret version. + /// The constructed . + public static DataFactoryKeyVaultSecretReference DataFactoryKeyVaultSecretReference( + DataFactoryLinkedServiceReference store, + DataFactoryElement secretName, + DataFactoryElement secretVersion) => + new DataFactoryKeyVaultSecretReference(store, secretName) { SecretVersion = secretVersion }; + + /// + /// Constructs a for mocking. + /// + /// The secret base type. + /// The constructed . + public static DataFactorySecretBaseDefinition DataFactorySecretBaseDefinition(string secretBaseType) => + new UnknownSecretBase(secretBaseType); + + /// + /// Constructs a for mocking. + /// + /// The reference type. + /// The reference name. + /// The reference parameters. + /// The constructed . + public static DataFactoryLinkedServiceReference DataFactoryLinkedServiceReference( + DataFactoryLinkedServiceReferenceType referenceType, + string? referenceName, + IDictionary parameters) => + new DataFactoryLinkedServiceReference(referenceType, referenceName, parameters); + } +} \ No newline at end of file diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs index d1425f57caae..c5dbf3be458e 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretBaseDefinition.cs @@ -8,16 +8,18 @@ namespace Azure.Core.Expressions.DataFactory /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include and . /// - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public abstract partial class DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretBaseDefinition. + [InitializationConstructor] protected DataFactorySecretBaseDefinition() { } /// Initializes a new instance of DataFactorySecretBaseDefinition. /// Type of the secret. + [SerializationConstructor] internal DataFactorySecretBaseDefinition(string? secretBaseType) { SecretBaseType = secretBaseType; diff --git a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs index 9cc2dc1c0d6b..6b55f118c987 100644 --- a/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs +++ b/sdk/core/Azure.Core.Expressions.DataFactory/src/DataFactorySecretString.cs @@ -6,12 +6,13 @@ namespace Azure.Core.Expressions.DataFactory { /// Azure Data Factory secure string definition. The string value will be masked with asterisks '*' during Get or List API calls. - [TypeReferenceType(false, new[]{ nameof(SecretBaseType)})] + [PropertyReferenceType(new string[0], new[]{ nameof(SecretBaseType)})] public partial class DataFactorySecretString : DataFactorySecretBaseDefinition { /// Initializes a new instance of DataFactorySecretString. /// Value of secure string. /// is null. + [InitializationConstructor] public DataFactorySecretString(string value) { Argument.AssertNotNull(value, nameof(value)); @@ -23,6 +24,7 @@ public DataFactorySecretString(string value) /// Initializes a new instance of DataFactorySecretString. /// Type of the secret. /// Value of secure string. + [SerializationConstructor] internal DataFactorySecretString(string? secretBaseType, string? value) : base(secretBaseType) { Value = value; diff --git a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs index 3987820d7210..141b350a5eae 100644 --- a/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs +++ b/sdk/core/Azure.Core/src/Shared/PropertyReferenceTypeAttribute.cs @@ -12,19 +12,35 @@ namespace Azure.Core internal class PropertyReferenceTypeAttribute : Attribute { /// - /// Instatiate a new reference type attribute. + /// Instantiate a new reference type attribute. /// /// An array of property names that are optional when comparing the type. public PropertyReferenceTypeAttribute(string[] optionalProperties) + : this(optionalProperties, Array.Empty()) + { + } + + /// + /// Instantiate a new reference type attribute. + /// + /// An array of property names that are optional when comparing the type. + /// An array of internal properties to include for the reference type when evaluating whether type + /// replacement should occur. When evaluating a type for replacement with a reference type, all internal properties are considered on the + /// type to be replaced. Thus this parameter can be used to specify internal properties to allow replacement to occur on a type with internal + /// properties. + public PropertyReferenceTypeAttribute(string[] optionalProperties, string[] internalPropertiesToInclude) { OptionalProperties = optionalProperties; + InternalPropertiesToInclude = internalPropertiesToInclude; } + public string[] InternalPropertiesToInclude { get; } + /// /// Instantiate a new reference type attribute. /// public PropertyReferenceTypeAttribute() - : this(Array.Empty()) + : this(Array.Empty(), Array.Empty()) { }