Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/OpenAI.net8.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6933,7 +6933,7 @@ public class VideoClient {
public virtual Task<ClientResult> DownloadVideoAsync(string videoId, string variant = null, RequestOptions options = null);
public virtual ClientResult GetVideo(string videoId, RequestOptions options = null);
public virtual Task<ClientResult> GetVideoAsync(string videoId, RequestOptions options = null);
public virtual ClientResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual Task<ClientResult> GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual CollectionResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual AsyncCollectionResult GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
}
}
4 changes: 2 additions & 2 deletions api/OpenAI.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6116,7 +6116,7 @@ public class VideoClient {
public virtual Task<ClientResult> DownloadVideoAsync(string videoId, string variant = null, RequestOptions options = null);
public virtual ClientResult GetVideo(string videoId, RequestOptions options = null);
public virtual Task<ClientResult> GetVideoAsync(string videoId, RequestOptions options = null);
public virtual ClientResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual Task<ClientResult> GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual CollectionResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
public virtual AsyncCollectionResult GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
}
}
6 changes: 3 additions & 3 deletions specification/base/typespec/videos/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ model VideoListResource {
object: "list" = "list";

/** A list of items */
data: VideoResource[];
@pageItems data: VideoResource[];

#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import."
#suppress "@azure-tools/typespec-azure-core/casing-style" "Auto-suppressed warnings non-applicable rules during import."
#suppress "@azure-tools/typespec-azure-core/no-nullable" "Auto-suppressed warnings non-applicable rules during import."
first_id: string | null;
first_id: string;
#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import."
#suppress "@azure-tools/typespec-azure-core/casing-style" "Auto-suppressed warnings non-applicable rules during import."
#suppress "@azure-tools/typespec-azure-core/no-nullable" "Auto-suppressed warnings non-applicable rules during import."
last_id: string | null;
@continuationToken last_id: string;

/** Whether there are more items available. */
#suppress "@azure-tools/typespec-azure-core/casing-style" "Auto-suppressed warnings non-applicable rules during import."
Expand Down
1 change: 1 addition & 0 deletions specification/base/typespec/videos/operations.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace OpenAI;
}
)
@tag("Videos")
@list
op ListVideos(
/** Number of items to retrieve */
#suppress "@azure-tools/typespec-azure-core/no-query-explode" "Auto-suppressed warnings non-applicable rules during import."
Expand Down
30 changes: 30 additions & 0 deletions specification/client/models/videos.models.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import "../../base/typespec/videos/main.tsp";
import "./common.models.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using TypeSpec.Http;

namespace OpenAI;

alias VideoCollectionOrderQueryParameter = {
/**
* Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
* for descending order.
*/
@query order?: VideoCollectionOrder;
};

union VideoCollectionOrder {
string,
Ascending: "asc",
Descending: "desc",
}

@access(Access.public)
@usage(Usage.input)
model VideoCollectionOptions {
...DotNetCollectionAfterQueryParameter,
...DotNetCollectionLimitQueryParameter,
...VideoCollectionOrderQueryParameter,
}
1 change: 1 addition & 0 deletions specification/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ import "./client/models/containers.models.tsp";
import "./client/models/conversations.models.tsp";
import "./client/models/responses.models.tsp";
import "./client/models/vector-stores.models.tsp";
import "./client/models/videos.models.tsp";

import "./base/entrypoints/sdk.dotnet";
9 changes: 9 additions & 0 deletions src/Custom/Videos/Internal/InternaVideoCollectionOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace OpenAI.Videos;

// CUSTOM:
// - Renamed.
// - Made internal until we support the convenience methods.
[CodeGenType("VideoCollectionOptions")]
internal partial class InternaVideoCollectionOptions
{
}
9 changes: 9 additions & 0 deletions src/Custom/Videos/Internal/InternalVideoCollectionOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace OpenAI.Videos;

// CUSTOM:
// - Renamed.
// - Made internal until we support the convenience methods.
[CodeGenType("VideoCollectionOrder")]
internal readonly partial struct InternalVideoCollectionOrder
{
}
2 changes: 2 additions & 0 deletions src/Generated/Models/OpenAIContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using OpenAI.Realtime;
using OpenAI.Responses;
using OpenAI.VectorStores;
using OpenAI.Videos;

namespace OpenAI
{
Expand Down Expand Up @@ -621,6 +622,7 @@ namespace OpenAI
[ModelReaderWriterBuildable(typeof(InternalVectorStoreSearchResultsPage))]
[ModelReaderWriterBuildable(typeof(InternalWebSearchLocation))]
[ModelReaderWriterBuildable(typeof(InternalWebSearchToolCallItemParam))]
[ModelReaderWriterBuildable(typeof(InternaVideoCollectionOptions))]
[ModelReaderWriterBuildable(typeof(ItemCreatedUpdate))]
[ModelReaderWriterBuildable(typeof(ItemDeletedUpdate))]
[ModelReaderWriterBuildable(typeof(ItemRetrievedUpdate))]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// <auto-generated/>

#nullable disable

using System;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Text.Json;
using OpenAI;

namespace OpenAI.Videos
{
internal partial class InternaVideoCollectionOptions : IJsonModel<InternaVideoCollectionOptions>
{
void IJsonModel<InternaVideoCollectionOptions>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
writer.WriteStartObject();
JsonModelWriteCore(writer, options);
writer.WriteEndObject();
}

protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options)
{
string format = options.Format == "W" ? ((IPersistableModel<InternaVideoCollectionOptions>)this).GetFormatFromOptions(options) : options.Format;
if (format != "J")
{
throw new FormatException($"The model {nameof(InternaVideoCollectionOptions)} does not support writing '{format}' format.");
}
// Plugin customization: remove options.Format != "W" check
if (_additionalBinaryDataProperties != null)
{
foreach (var item in _additionalBinaryDataProperties)
{
if (ModelSerializationExtensions.IsSentinelValue(item.Value))
{
continue;
}
writer.WritePropertyName(item.Key);
#if NET6_0_OR_GREATER
writer.WriteRawValue(item.Value);
#else
using (JsonDocument document = JsonDocument.Parse(item.Value))
{
JsonSerializer.Serialize(writer, document.RootElement);
}
#endif
}
}
}

InternaVideoCollectionOptions IJsonModel<InternaVideoCollectionOptions>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options);

protected virtual InternaVideoCollectionOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options)
{
string format = options.Format == "W" ? ((IPersistableModel<InternaVideoCollectionOptions>)this).GetFormatFromOptions(options) : options.Format;
if (format != "J")
{
throw new FormatException($"The model {nameof(InternaVideoCollectionOptions)} does not support reading '{format}' format.");
}
using JsonDocument document = JsonDocument.ParseValue(ref reader);
return DeserializeInternaVideoCollectionOptions(document.RootElement, options);
}

internal static InternaVideoCollectionOptions DeserializeInternaVideoCollectionOptions(JsonElement element, ModelReaderWriterOptions options)
{
if (element.ValueKind == JsonValueKind.Null)
{
return null;
}
string afterId = default;
int? pageSizeLimit = default;
InternalVideoCollectionOrder? order = default;
IDictionary<string, BinaryData> additionalBinaryDataProperties = new ChangeTrackingDictionary<string, BinaryData>();
foreach (var prop in element.EnumerateObject())
{
// Plugin customization: remove options.Format != "W" check
additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText()));
}
return new InternaVideoCollectionOptions(afterId, pageSizeLimit, order, additionalBinaryDataProperties);
}

BinaryData IPersistableModel<InternaVideoCollectionOptions>.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options);

protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options)
{
string format = options.Format == "W" ? ((IPersistableModel<InternaVideoCollectionOptions>)this).GetFormatFromOptions(options) : options.Format;
switch (format)
{
case "J":
return ModelReaderWriter.Write(this, options, OpenAIContext.Default);
default:
throw new FormatException($"The model {nameof(InternaVideoCollectionOptions)} does not support writing '{options.Format}' format.");
}
}

InternaVideoCollectionOptions IPersistableModel<InternaVideoCollectionOptions>.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options);

protected virtual InternaVideoCollectionOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options)
{
string format = options.Format == "W" ? ((IPersistableModel<InternaVideoCollectionOptions>)this).GetFormatFromOptions(options) : options.Format;
switch (format)
{
case "J":
using (JsonDocument document = JsonDocument.Parse(data))
{
return DeserializeInternaVideoCollectionOptions(document.RootElement, options);
}
default:
throw new FormatException($"The model {nameof(InternaVideoCollectionOptions)} does not support reading '{options.Format}' format.");
}
}

string IPersistableModel<InternaVideoCollectionOptions>.GetFormatFromOptions(ModelReaderWriterOptions options) => "J";
}
}
38 changes: 38 additions & 0 deletions src/Generated/Models/Videos/InternaVideoCollectionOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// <auto-generated/>

#nullable disable

using System;
using System.Collections.Generic;

namespace OpenAI.Videos
{
internal partial class InternaVideoCollectionOptions
{
private protected IDictionary<string, BinaryData> _additionalBinaryDataProperties;

public InternaVideoCollectionOptions()
{
}

internal InternaVideoCollectionOptions(string afterId, int? pageSizeLimit, InternalVideoCollectionOrder? order, IDictionary<string, BinaryData> additionalBinaryDataProperties)
{
AfterId = afterId;
PageSizeLimit = pageSizeLimit;
Order = order;
_additionalBinaryDataProperties = additionalBinaryDataProperties;
}

public string AfterId { get; set; }

public int? PageSizeLimit { get; set; }

internal InternalVideoCollectionOrder? Order { get; set; }

internal IDictionary<string, BinaryData> SerializedAdditionalRawData
{
get => _additionalBinaryDataProperties;
set => _additionalBinaryDataProperties = value;
}
}
}
46 changes: 46 additions & 0 deletions src/Generated/Models/Videos/InternalVideoCollectionOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// <auto-generated/>

#nullable disable

using System;
using System.ComponentModel;
using OpenAI;

namespace OpenAI.Videos
{
internal readonly partial struct InternalVideoCollectionOrder : IEquatable<InternalVideoCollectionOrder>
{
private readonly string _value;
private const string AscendingValue = "asc";
private const string DescendingValue = "desc";

public InternalVideoCollectionOrder(string value)
{
Argument.AssertNotNull(value, nameof(value));

_value = value;
}

internal static InternalVideoCollectionOrder Ascending { get; } = new InternalVideoCollectionOrder(AscendingValue);

internal static InternalVideoCollectionOrder Descending { get; } = new InternalVideoCollectionOrder(DescendingValue);

public static bool operator ==(InternalVideoCollectionOrder left, InternalVideoCollectionOrder right) => left.Equals(right);

public static bool operator !=(InternalVideoCollectionOrder left, InternalVideoCollectionOrder right) => !left.Equals(right);

public static implicit operator InternalVideoCollectionOrder(string value) => new InternalVideoCollectionOrder(value);

public static implicit operator InternalVideoCollectionOrder?(string value) => value == null ? null : new InternalVideoCollectionOrder(value);

[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => obj is InternalVideoCollectionOrder other && Equals(other);

public bool Equals(InternalVideoCollectionOrder 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;
}
}
10 changes: 4 additions & 6 deletions src/Generated/VideoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ protected VideoClient()

public ClientPipeline Pipeline { get; }

public virtual ClientResult GetVideos(long? limit = default, string order = default, string after = default, RequestOptions options = null)
public virtual CollectionResult GetVideos(long? limit = default, string order = default, string after = default, RequestOptions options = null)
{
using PipelineMessage message = CreateGetVideosRequest(limit, order, after, options);
return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
return new VideoClientGetVideosCollectionResult(this, limit, order, after, options);
}

public virtual async Task<ClientResult> GetVideosAsync(long? limit = default, string order = default, string after = default, RequestOptions options = null)
public virtual AsyncCollectionResult GetVideosAsync(long? limit = default, string order = default, string after = default, RequestOptions options = null)
{
using PipelineMessage message = CreateGetVideosRequest(limit, order, after, options);
return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
return new VideoClientGetVideosAsyncCollectionResult(this, limit, order, after, options);
}

public virtual ClientResult CreateVideo(BinaryContent content, string contentType, RequestOptions options = null)
Expand Down
39 changes: 39 additions & 0 deletions src/Generated/VideoClientGetVideosAsyncCollectionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// <auto-generated/>

#nullable disable

using System.ClientModel;
using System.ClientModel.Primitives;
using System.Collections.Generic;

namespace OpenAI.Videos
{
internal partial class VideoClientGetVideosAsyncCollectionResult : AsyncCollectionResult
{
private readonly VideoClient _client;
private readonly long? _limit;
private readonly string _order;
private readonly string _after;
private readonly RequestOptions _options;

public VideoClientGetVideosAsyncCollectionResult(VideoClient client, long? limit, string order, string after, RequestOptions options)
{
_client = client;
_limit = limit;
_order = order;
_after = after;
_options = options;
}

public override async IAsyncEnumerable<ClientResult> GetRawPagesAsync()
{
PipelineMessage message = _client.CreateGetVideosRequest(_limit, _order, _after, _options);
yield return ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false));
}

public override ContinuationToken GetContinuationToken(ClientResult page)
{
return null;
}
}
}
Loading
Loading