diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs index 801d22774bed..4455bacf83e8 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionProperties.Serialization.cs @@ -37,7 +37,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("authType"u8); writer.WriteStringValue(AuthType.ToSerialString()); writer.WritePropertyName("category"u8); - writer.WriteStringValue(Category.ToSerialString()); + writer.WriteStringValue(Category.ToString()); writer.WritePropertyName("target"u8); writer.WriteStringValue(Target); if (options.Format != "W" && _serializedAdditionalRawData != null) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs index 6a6495a009c4..3bb1ad1f6f7d 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionPropertiesApiKeyAuth.Serialization.cs @@ -79,7 +79,7 @@ internal static ConnectionPropertiesApiKeyAuth DeserializeConnectionPropertiesAp } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.Serialization.cs deleted file mode 100644 index f33d91b5170d..000000000000 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.Serialization.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.AI.Projects -{ - internal static partial class ConnectionTypeExtensions - { - public static string ToSerialString(this ConnectionType value) => value switch - { - ConnectionType.AzureOpenAI => "AzureOpenAI", - ConnectionType.Serverless => "Serverless", - ConnectionType.AzureBlobStorage => "AzureBlob", - ConnectionType.AzureAIServices => "AIServices", - ConnectionType.AzureAISearch => "CognitiveSearch", - ConnectionType.APIKey => "ApiKey", - ConnectionType.Custom => "CustomKeys", - ConnectionType.CognitiveService => "CognitiveService", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ConnectionType value.") - }; - - public static ConnectionType ToConnectionType(this string value) - { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureOpenAI")) return ConnectionType.AzureOpenAI; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "Serverless")) return ConnectionType.Serverless; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AzureBlob")) return ConnectionType.AzureBlobStorage; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "AIServices")) return ConnectionType.AzureAIServices; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CognitiveSearch")) return ConnectionType.AzureAISearch; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "ApiKey")) return ConnectionType.APIKey; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CustomKeys")) return ConnectionType.Custom; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "CognitiveService")) return ConnectionType.CognitiveService; - throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ConnectionType value."); - } - } -} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs index 9d7336835f44..8c7c10020180 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs @@ -5,26 +5,65 @@ #nullable disable +using System; +using System.ComponentModel; + namespace Azure.AI.Projects { /// The Type (or category) of the connection. - public enum ConnectionType + public readonly partial struct ConnectionType : IEquatable { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ConnectionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AzureOpenAIValue = "AzureOpenAI"; + private const string ServerlessValue = "Serverless"; + private const string AzureBlobStorageValue = "AzureBlob"; + private const string AzureAIServicesValue = "AIServices"; + private const string AzureAISearchValue = "CognitiveSearch"; + private const string APIKeyValue = "ApiKey"; + private const string CustomValue = "CustomKeys"; + private const string CognitiveServiceValue = "CognitiveService"; + /// Azure OpenAI Service. - AzureOpenAI, + public static ConnectionType AzureOpenAI { get; } = new ConnectionType(AzureOpenAIValue); /// Serverless API Service. - Serverless, + public static ConnectionType Serverless { get; } = new ConnectionType(ServerlessValue); /// Azure Blob Storage. - AzureBlobStorage, + public static ConnectionType AzureBlobStorage { get; } = new ConnectionType(AzureBlobStorageValue); /// Azure AI Services. - AzureAIServices, + public static ConnectionType AzureAIServices { get; } = new ConnectionType(AzureAIServicesValue); /// Azure AI Search. - AzureAISearch, + public static ConnectionType AzureAISearch { get; } = new ConnectionType(AzureAISearchValue); /// Generic connection that uses API Key authentication. - APIKey, + public static ConnectionType APIKey { get; } = new ConnectionType(APIKeyValue); /// Generic connection that uses Custom authentication. - Custom, + public static ConnectionType Custom { get; } = new ConnectionType(CustomValue); /// Cognitive Service. - CognitiveService + public static ConnectionType CognitiveService { get; } = new ConnectionType(CognitiveServiceValue); + /// Determines if two values are the same. + public static bool operator ==(ConnectionType left, ConnectionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ConnectionType left, ConnectionType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ConnectionType(string value) => new ConnectionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ConnectionType other && Equals(other); + /// + public bool Equals(ConnectionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs index 2cf2342cfcb9..64759c46845c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesAADAuth.Serialization.cs @@ -71,7 +71,7 @@ internal static InternalConnectionPropertiesAADAuth DeserializeInternalConnectio } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs index dc277ff52eba..9fdd49a39339 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesCustomAuth.Serialization.cs @@ -71,7 +71,7 @@ internal static InternalConnectionPropertiesCustomAuth DeserializeInternalConnec } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs index 55c35f980c91..5e4ed78b2f33 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesNoAuth.Serialization.cs @@ -71,7 +71,7 @@ internal static InternalConnectionPropertiesNoAuth DeserializeInternalConnection } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs index e68ec9e9cea7..af6d2a739145 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalConnectionPropertiesSASAuth.Serialization.cs @@ -79,7 +79,7 @@ internal static InternalConnectionPropertiesSASAuth DeserializeInternalConnectio } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs index 857d2305634f..fb180659e0dd 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInternalConnectionProperties.Serialization.cs @@ -71,7 +71,7 @@ internal static UnknownInternalConnectionProperties DeserializeUnknownInternalCo } if (property.NameEquals("category"u8)) { - category = property.Value.GetString().ToConnectionType(); + category = new ConnectionType(property.Value.GetString()); continue; } if (property.NameEquals("target"u8)) diff --git a/sdk/ai/Azure.AI.Projects/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml index ff0097afc661..0217de1cd0e4 100644 --- a/sdk/ai/Azure.AI.Projects/tsp-location.yaml +++ b/sdk/ai/Azure.AI.Projects/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Azure.AI.Projects -commit: f150e1bec3af8ff0fc242308c9a4e727bbdb3977 +commit: 3a5c5913bb9769cab9b3ad2c4dd7dbebd1492bee repo: Azure/azure-rest-api-specs additionalDirectories: