diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 9b6b35f5afac..fb01d2819cdf 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -174,7 +174,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + diff --git a/eng/emitter-package.json b/eng/emitter-package.json index ab43d2d8f420..29a7cd892e83 100644 --- a/eng/emitter-package.json +++ b/eng/emitter-package.json @@ -1,6 +1,6 @@ { "main": "dist/src/index.js", "dependencies": { - "@azure-tools/typespec-csharp": "0.2.0-beta.20230824.1" + "@azure-tools/typespec-csharp": "0.2.0-alpha.20230824.5" } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs index f10cb319f22e..bcfd74d73699 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Azure; namespace Azure.AI.OpenAI { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.Serialization.cs new file mode 100644 index 000000000000..24fa8217d51e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.Serialization.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + internal partial class Error + { + internal static Error DeserializeError(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + Optional target = default; + Optional> details = default; + Optional innererror = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + details = array; + continue; + } + if (property.NameEquals("innererror"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = InnerError.DeserializeInnerError(property.Value); + continue; + } + } + return new Error(code, message, target.Value, Optional.ToList(details), innererror.Value); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Error FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeError(document.RootElement); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.cs new file mode 100644 index 000000000000..628deaa5620e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Error.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The error object. + internal partial class Error + { + /// Initializes a new instance of Error. + /// One of a server-defined set of error codes. + /// A human-readable representation of the error. + /// or is null. + internal Error(string code, string message) + { + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + Details = new ChangeTrackingList(); + } + + /// Initializes a new instance of Error. + /// One of a server-defined set of error codes. + /// A human-readable representation of the error. + /// The target of the error. + /// An array of details about specific errors that led to this reported error. + /// An object containing more specific information than the current object about the error. + internal Error(string code, string message, string target, IReadOnlyList details, InnerError innererror) + { + Code = code; + Message = message; + Target = target; + Details = details; + Innererror = innererror; + } + + /// One of a server-defined set of error codes. + public string Code { get; } + /// A human-readable representation of the error. + public string Message { get; } + /// The target of the error. + public string Target { get; } + /// An array of details about specific errors that led to this reported error. + public IReadOnlyList Details { get; } + /// An object containing more specific information than the current object about the error. + public InnerError Innererror { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.Serialization.cs new file mode 100644 index 000000000000..ae30ef9d4133 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.Serialization.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + internal partial class InnerError + { + internal static InnerError DeserializeInnerError(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional code = default; + Optional innererror = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("innererror"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = DeserializeInnerError(property.Value); + continue; + } + } + return new InnerError(code.Value, innererror.Value); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static InnerError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeInnerError(document.RootElement); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.cs new file mode 100644 index 000000000000..a31235eb6783 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/InnerError.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.AI.OpenAI +{ + /// An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. + internal partial class InnerError + { + /// Initializes a new instance of InnerError. + internal InnerError() + { + } + + /// Initializes a new instance of InnerError. + /// One of a server-defined set of error codes. + /// Inner error. + internal InnerError(string code, InnerError innerErrorObject) + { + Code = code; + InnerErrorObject = innerErrorObject; + } + + /// One of a server-defined set of error codes. + public string Code { get; } + /// Inner error. + public InnerError InnerErrorObject { get; } + } +}