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
17 changes: 16 additions & 1 deletion src/libs/HeyGen/Generated/HeyGen.AssetsClient.V1AssetUpload.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ namespace HeyGen
public partial class AssetsClient
{

private static readonly global::HeyGen.AutoSDKServer[] s_V1AssetUploadServers = new global::HeyGen.AutoSDKServer[]
{ new global::HeyGen.AutoSDKServer(
id: "https-api-heygen-com",
name: "api.heygen.com",
url: "https://api.heygen.com/",
description: ""),
new global::HeyGen.AutoSDKServer(
id: "https-upload-heygen-com",
name: "upload.heygen.com",
url: "https://upload.heygen.com/",
description: ""),
};


private static readonly global::HeyGen.EndPointSecurityRequirement s_V1AssetUploadSecurityRequirement0 =
new global::HeyGen.EndPointSecurityRequirement
Expand Down Expand Up @@ -74,7 +87,9 @@ partial void ProcessV1AssetUploadResponse(
{
var __pathBuilder = new global::HeyGen.PathBuilder(
path: "/v1/asset",
baseUri: HttpClient.BaseAddress);
baseUri: ResolveBaseUri(
servers: s_V1AssetUploadServers,
defaultBaseUrl: "https://api.heygen.com/"));
var __path = __pathBuilder.ToString();
__path = global::HeyGen.AutoSDKRequestOptionsSupport.AppendQueryParameters(
path: __path,
Expand Down
149 changes: 147 additions & 2 deletions src/libs/HeyGen/Generated/HeyGen.AssetsClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace HeyGen
{
/// <summary>
/// Upload an image or video asset to your account.<br/>
/// **Reference**: [https://docs.heygen.com/reference/upload-asset-1](https://docs.heygen.com/reference/upload-asset-1).<br/>
/// **Reference**: [https://docs.heygen.com/reference/upload-asset-1](https://docs.heygen.com/reference/upload-asset-1)<br/>
/// If no httpClient is provided, a new one will be created.<br/>
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
/// </summary>
Expand All @@ -22,7 +22,7 @@ public sealed partial class AssetsClient : global::HeyGen.IAssetsClient, global:
public global::System.Net.Http.HttpClient HttpClient { get; }

/// <inheritdoc/>
public System.Uri? BaseUri => HttpClient.BaseAddress;
public System.Uri? BaseUri => ResolveDisplayedBaseUri();

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::HeyGen.EndPointAuthorization> Authorizations { get; }
Expand All @@ -35,12 +35,43 @@ public sealed partial class AssetsClient : global::HeyGen.IAssetsClient, global:

/// <inheritdoc/>
public global::HeyGen.AutoSDKClientOptions Options { get; }


internal global::HeyGen.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::HeyGen.AutoSDKServerConfiguration();
/// <summary>
///
/// </summary>
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::HeyGen.SourceGenerationContext.Default;



private static readonly global::HeyGen.AutoSDKServer[] s_availableServers = new global::HeyGen.AutoSDKServer[]
{ new global::HeyGen.AutoSDKServer(
id: "https-api-heygen-com",
name: "api.heygen.com",
url: "https://api.heygen.com/",
description: ""),
new global::HeyGen.AutoSDKServer(
id: "https-upload-heygen-com",
name: "upload.heygen.com",
url: "https://upload.heygen.com/",
description: ""),
};

/// <summary>
/// The server options available for this client.
/// </summary>
public global::System.Collections.Generic.IReadOnlyList<global::HeyGen.AutoSDKServer> AvailableServers => s_availableServers;

/// <summary>
/// The currently selected server for this client, if any.
/// </summary>
public global::HeyGen.AutoSDKServer? SelectedServer
{
get => ResolveSelectedServer();
set => SelectServer(value);
}

/// <summary>
/// Creates a new instance of the AssetsClient.
/// If no httpClient is provided, a new one will be created.
Expand Down Expand Up @@ -87,6 +118,8 @@ public AssetsClient(
Options = options ?? new global::HeyGen.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;

AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress;

Initialized(HttpClient);
}

Expand All @@ -113,5 +146,117 @@ partial void ProcessResponseContent(
global::System.Net.Http.HttpClient client,
global::System.Net.Http.HttpResponseMessage response,
ref string content);


/// <summary>
/// Selects one of the generated server options by id.
/// </summary>
public bool TrySelectServer(string serverId)
{
if (string.IsNullOrWhiteSpace(serverId))
{
return false;
}

foreach (var server in s_availableServers)
{
if (string.Equals(server.Id, serverId, global::System.StringComparison.OrdinalIgnoreCase))
{
AutoSDKServerConfiguration.SelectedServer = server;
AutoSDKServerConfiguration.ExplicitBaseUri = null;
return true;
}
}

return false;
}

/// <summary>
/// Clears the currently selected server.
/// </summary>
public void ClearSelectedServer()
{
AutoSDKServerConfiguration.SelectedServer = null;
}

private global::HeyGen.AutoSDKServer? ResolveSelectedServer()
{
var selectedServer = AutoSDKServerConfiguration.SelectedServer;
if (selectedServer is null)
{
return null;
}

foreach (var server in s_availableServers)
{
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
{
return server;
}
}

return null;
}

private void SelectServer(global::HeyGen.AutoSDKServer? server)
{
if (server is null)
{
AutoSDKServerConfiguration.SelectedServer = null;
return;
}

foreach (var candidate in s_availableServers)
{
if (string.Equals(candidate.Id, server.Id, global::System.StringComparison.Ordinal))
{
AutoSDKServerConfiguration.SelectedServer = candidate;
AutoSDKServerConfiguration.ExplicitBaseUri = null;
return;
}
}

throw new global::System.ArgumentException("The provided server is not available for this client.", nameof(server));
}

private global::System.Uri? ResolveDisplayedBaseUri()
{
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
{
return explicitBaseUri;
}

return ResolveSelectedServer()?.Uri ?? HttpClient.BaseAddress;
}

private global::System.Uri? ResolveBaseUri(
global::HeyGen.AutoSDKServer[] servers,
string defaultBaseUrl)
{
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
{
return explicitBaseUri;
}

if (AutoSDKServerConfiguration.SelectedServer is global::HeyGen.AutoSDKServer selectedServer)
{
foreach (var server in servers)
{
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
{
return server.Uri;
}
}
}

if (servers.Length > 0)
{
return servers[0].Uri;
}

return string.IsNullOrWhiteSpace(defaultBaseUrl)
? HttpClient.BaseAddress
: new global::System.Uri(defaultBaseUrl, global::System.UriKind.RelativeOrAbsolute);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ namespace HeyGen
public partial class CreateVideoApiClient
{

private static readonly global::HeyGen.AutoSDKServer[] s_V1VideoDeleteServers = new global::HeyGen.AutoSDKServer[]
{ new global::HeyGen.AutoSDKServer(
id: "https-api-heygen-com",
name: "api.heygen.com",
url: "https://api.heygen.com/",
description: ""),
new global::HeyGen.AutoSDKServer(
id: "https-upload-heygen-com",
name: "upload.heygen.com",
url: "https://upload.heygen.com/",
description: ""),
};


private static readonly global::HeyGen.EndPointSecurityRequirement s_V1VideoDeleteSecurityRequirement0 =
new global::HeyGen.EndPointSecurityRequirement
Expand Down Expand Up @@ -81,7 +94,9 @@ partial void ProcessV1VideoDeleteResponse(
{
var __pathBuilder = new global::HeyGen.PathBuilder(
path: "/v1/video.delete",
baseUri: HttpClient.BaseAddress);
baseUri: ResolveBaseUri(
servers: s_V1VideoDeleteServers,
defaultBaseUrl: "https://api.heygen.com/"));
__pathBuilder
.AddOptionalParameter("video_id", videoId)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ namespace HeyGen
public partial class CreateVideoApiClient
{

private static readonly global::HeyGen.AutoSDKServer[] s_V2VideoGenerateServers = new global::HeyGen.AutoSDKServer[]
{ new global::HeyGen.AutoSDKServer(
id: "https-api-heygen-com",
name: "api.heygen.com",
url: "https://api.heygen.com/",
description: ""),
new global::HeyGen.AutoSDKServer(
id: "https-upload-heygen-com",
name: "upload.heygen.com",
url: "https://upload.heygen.com/",
description: ""),
};


private static readonly global::HeyGen.EndPointSecurityRequirement s_V2VideoGenerateSecurityRequirement0 =
new global::HeyGen.EndPointSecurityRequirement
Expand Down Expand Up @@ -83,7 +96,9 @@ partial void ProcessV2VideoGenerateResponse(
{
var __pathBuilder = new global::HeyGen.PathBuilder(
path: "/v2/video/generate",
baseUri: HttpClient.BaseAddress);
baseUri: ResolveBaseUri(
servers: s_V2VideoGenerateServers,
defaultBaseUrl: "https://api.heygen.com/"));
var __path = __pathBuilder.ToString();
__path = global::HeyGen.AutoSDKRequestOptionsSupport.AppendQueryParameters(
path: __path,
Expand Down
Loading