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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#nullable enable

namespace AssemblyAI
{
public sealed partial class AssemblyAIClient
{

/// <inheritdoc/>
public void AuthorizeUsingBearer(
string apiKey)
{
apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey));

for (var i = Authorizations.Count - 1; i >= 0; i--)
{
var __authorization = Authorizations[i];
if (__authorization.Type == "Http" &&
__authorization.Name == "Bearer")
{
Authorizations.RemoveAt(i);
}
}

Authorizations.Add(new global::AssemblyAI.EndPointAuthorization
{
Type = "Http",
SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
Value = apiKey,
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

#nullable enable

namespace AssemblyAI
{
public sealed partial class AssemblyAIClient
{
/// <inheritdoc cref="AssemblyAIClient(global::System.Net.Http.HttpClient?, global::System.Uri?, global::System.Collections.Generic.List{global::AssemblyAI.EndPointAuthorization}?, bool)"/>

public AssemblyAIClient(
string apiKey,
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::AssemblyAI.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true) : this(httpClient, baseUri, authorizations, disposeHttpClient)
{
Authorizing(HttpClient, ref apiKey);

AuthorizeUsingBearer(apiKey);

Authorized(HttpClient);
}

partial void Authorizing(
global::System.Net.Http.HttpClient client,
ref string apiKey);
partial void Authorized(
global::System.Net.Http.HttpClient client);

}
}

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

205 changes: 4 additions & 201 deletions src/libs/AssemblyAI/Generated/AssemblyAI.AssemblyAIClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace AssemblyAI
{
/// <summary>
/// A sample API that uses a plant store as an example to demonstrate features in the OpenAPI specification<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 @@ -12,15 +13,15 @@ public sealed partial class AssemblyAIClient : global::AssemblyAI.IAssemblyAICli
/// <summary>
///
/// </summary>
public const string DefaultBaseUrl = "https://api.assemblyai.com/";
public const string DefaultBaseUrl = "http://sandbox.mintlify.com/";

private bool _disposeHttpClient = true;

/// <inheritdoc/>
public global::System.Net.Http.HttpClient HttpClient { get; }

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

/// <inheritdoc/>
public global::System.Collections.Generic.List<global::AssemblyAI.EndPointAuthorization> Authorizations { get; }
Expand All @@ -33,93 +34,12 @@ public sealed partial class AssemblyAIClient : global::AssemblyAI.IAssemblyAICli

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


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


/// <summary>
///
/// </summary>
public SubpackageFilesClient SubpackageFiles => new SubpackageFilesClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};

/// <summary>
///
/// </summary>
public SubpackageStreamingApiClient SubpackageStreamingApi => new SubpackageStreamingApiClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};

/// <summary>
///
/// </summary>
public SubpackageTranscriptsClient SubpackageTranscripts => new SubpackageTranscriptsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};

/// <summary>
///
/// </summary>
public SubpackageVoiceAgentApiClient SubpackageVoiceAgentApi => new SubpackageVoiceAgentApiClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
{
ReadResponseAsString = ReadResponseAsString,
JsonSerializerContext = JsonSerializerContext,
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
};


private static readonly global::AssemblyAI.AutoSDKServer[] s_availableServers = new global::AssemblyAI.AutoSDKServer[]
{ new global::AssemblyAI.AutoSDKServer(
id: "https-api-assemblyai-com",
name: "api.assemblyai.com",
url: "https://api.assemblyai.com/",
description: ""),
new global::AssemblyAI.AutoSDKServer(
id: "https-llm-gateway-assemblyai-com-v1",
name: "llm-gateway.assemblyai.com v1",
url: "https://llm-gateway.assemblyai.com/v1",
description: ""),
new global::AssemblyAI.AutoSDKServer(
id: "https-streaming-assemblyai-com",
name: "streaming.assemblyai.com",
url: "https://streaming.assemblyai.com/",
description: ""),
new global::AssemblyAI.AutoSDKServer(
id: "https-agents-assemblyai-com",
name: "agents.assemblyai.com",
url: "https://agents.assemblyai.com/",
description: ""),
};

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

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

/// <summary>
/// Creates a new instance of the AssemblyAIClient.
/// If no httpClient is provided, a new one will be created.
Expand Down Expand Up @@ -182,16 +102,11 @@ public AssemblyAIClient(
{

HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
if (baseUri is not null)
{
HttpClient.BaseAddress ??= baseUri;
}
HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl);
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::AssemblyAI.EndPointAuthorization>();
Options = options ?? new global::AssemblyAI.AutoSDKClientOptions();
_disposeHttpClient = disposeHttpClient;

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

Initialized(HttpClient);
}

Expand All @@ -218,117 +133,5 @@ 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::AssemblyAI.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::AssemblyAI.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 ?? (s_availableServers.Length > 0 ? s_availableServers[0].Uri : HttpClient.BaseAddress);
}

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

if (AutoSDKServerConfiguration.SelectedServer is global::AssemblyAI.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
@@ -0,0 +1,16 @@

#nullable enable

namespace AssemblyAI
{
public partial interface IAssemblyAIClient
{
/// <summary>
/// Authorize using bearer authentication.
/// </summary>
/// <param name="apiKey"></param>

public void AuthorizeUsingBearer(
string apiKey);
}
}
Loading
Loading