openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Images/GeneratedImageCollection.cs
88lines · modecode
| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Collections.ObjectModel; |
| 4 | |
| 5 | namespace OpenAI.Images; |
| 6 | |
| 7 | /// <summary> |
| 8 | /// Represents an image generation response payload that contains information for multiple generated images. |
| 9 | /// </summary> |
| 10 | [CodeGenModel("ImagesResponse")] |
| 11 | [CodeGenSuppress("Data")] |
| 12 | [CodeGenSuppress("Created")] |
| 13 | [CodeGenSuppress(nameof(GeneratedImageCollection))] |
| 14 | [CodeGenSuppress(nameof(GeneratedImageCollection), typeof(DateTimeOffset), typeof(IReadOnlyList<GeneratedImage>))] |
| 15 | public partial class GeneratedImageCollection : ReadOnlyCollection<GeneratedImage> |
| 16 | { |
| 17 | // CUSTOM: Recovered this field. See https://github.com/Azure/autorest.csharp/issues/4636. |
| 18 | /// <summary> |
| 19 | /// Keeps track of any properties unknown to the library. |
| 20 | /// <para> |
| 21 | /// To assign an object to the value of this property use <see cref="BinaryData.FromObjectAsJson{T}(T, System.Text.Json.JsonSerializerOptions?)"/>. |
| 22 | /// </para> |
| 23 | /// <para> |
| 24 | /// To assign an already formatted json string to this property use <see cref="BinaryData.FromString(string)"/>. |
| 25 | /// </para> |
| 26 | /// <para> |
| 27 | /// Examples: |
| 28 | /// <list type="bullet"> |
| 29 | /// <item> |
| 30 | /// <term>BinaryData.FromObjectAsJson("foo")</term> |
| 31 | /// <description>Creates a payload of "foo".</description> |
| 32 | /// </item> |
| 33 | /// <item> |
| 34 | /// <term>BinaryData.FromString("\"foo\"")</term> |
| 35 | /// <description>Creates a payload of "foo".</description> |
| 36 | /// </item> |
| 37 | /// <item> |
| 38 | /// <term>BinaryData.FromObjectAsJson(new { key = "value" })</term> |
| 39 | /// <description>Creates a payload of { "key": "value" }.</description> |
| 40 | /// </item> |
| 41 | /// <item> |
| 42 | /// <term>BinaryData.FromString("{\"key\": \"value\"}")</term> |
| 43 | /// <description>Creates a payload of { "key": "value" }.</description> |
| 44 | /// </item> |
| 45 | /// </list> |
| 46 | /// </para> |
| 47 | /// </summary> |
| 48 | private IDictionary<string, BinaryData> SerializedAdditionalRawData; |
| 49 | |
| 50 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 51 | /// <summary> Initializes a new instance of <see cref="GeneratedImageCollection"/>. </summary> |
| 52 | /// <param name="created"></param> |
| 53 | /// <param name="data"></param> |
| 54 | /// <exception cref="ArgumentNullException"> <paramref name="data"/> is null. </exception> |
| 55 | internal GeneratedImageCollection(DateTimeOffset created, IEnumerable<GeneratedImage> data) |
| 56 | : base([.. data]) |
| 57 | { |
| 58 | Argument.AssertNotNull(data, nameof(data)); |
| 59 | |
| 60 | CreatedAt = created; |
| 61 | } |
| 62 | |
| 63 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 64 | /// <summary> Initializes a new instance of <see cref="GeneratedImageCollection"/>. </summary> |
| 65 | /// <param name="created"></param> |
| 66 | /// <param name="data"></param> |
| 67 | /// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param> |
| 68 | internal GeneratedImageCollection(DateTimeOffset created, IReadOnlyList<GeneratedImage> data, IDictionary<string, BinaryData> serializedAdditionalRawData) |
| 69 | : base([.. data]) |
| 70 | { |
| 71 | CreatedAt = created; |
| 72 | SerializedAdditionalRawData = serializedAdditionalRawData; |
| 73 | } |
| 74 | |
| 75 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 76 | /// <summary> Initializes a new instance of <see cref="GeneratedImageCollection"/> for deserialization. </summary> |
| 77 | internal GeneratedImageCollection() |
| 78 | : base([]) |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | // CUSTOM: Renamed. |
| 83 | /// <summary> |
| 84 | /// The timestamp at which the result image was generated. |
| 85 | /// </summary> |
| 86 | [CodeGenMember("Created")] |
| 87 | public DateTimeOffset CreatedAt { get; } |
| 88 | } |