AI-Studio/app/ERIClientV1/Client.Generated.cs

1277 lines
57 KiB
C#
Raw Permalink Normal View History

2025-01-13 18:51:26 +00:00
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?'
#pragma warning disable 612 // Disable "CS0612 '...' is obsolete"
#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'"
#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant"
#pragma warning disable 8603 // Disable "CS8603 Possible null reference return"
#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter"
#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type"
namespace ERI_Client.V1
{
using System = global::System;
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class Client
{
private System.Net.Http.HttpClient _httpClient;
private static System.Lazy<System.Text.Json.JsonSerializerOptions> _settings = new System.Lazy<System.Text.Json.JsonSerializerOptions>(CreateSerializerSettings, true);
public Client(System.Net.Http.HttpClient httpClient)
{
_httpClient = httpClient;
}
private static System.Text.Json.JsonSerializerOptions CreateSerializerSettings()
{
var settings = new System.Text.Json.JsonSerializerOptions();
UpdateJsonSerializerSettings(settings);
return settings;
}
protected System.Text.Json.JsonSerializerOptions JsonSerializerSettings { get { return _settings.Value; } }
static partial void UpdateJsonSerializerSettings(System.Text.Json.JsonSerializerOptions settings);
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
/// <remarks>
/// Get the available authentication methods.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<AuthScheme>> GetAuthMethodsAsync()
{
return GetAuthMethodsAsync(System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Get the available authentication methods.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<AuthScheme>> GetAuthMethodsAsync(System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "auth/methods"
urlBuilder_.Append("auth/methods");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<AuthScheme>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Authenticate with the data source to get a token for further requests.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<AuthResponse> AuthenticateAsync(AuthMethod authMethod)
{
return AuthenticateAsync(authMethod, System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Authenticate with the data source to get a token for further requests.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<AuthResponse> AuthenticateAsync(AuthMethod authMethod, System.Threading.CancellationToken cancellationToken)
{
if (authMethod == null)
throw new System.ArgumentNullException("authMethod");
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "auth"
urlBuilder_.Append("auth");
urlBuilder_.Append('?');
urlBuilder_.Append(System.Uri.EscapeDataString("authMethod")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(authMethod, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
urlBuilder_.Length--;
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<AuthResponse>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Get information about the data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<DataSourceInfo> GetDataSourceInfoAsync()
{
return GetDataSourceInfoAsync(System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Get information about the data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<DataSourceInfo> GetDataSourceInfoAsync(System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "dataSource"
urlBuilder_.Append("dataSource");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<DataSourceInfo>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Get information about the used embedding(s).
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<EmbeddingInfo>> GetEmbeddingInfoAsync()
{
return GetEmbeddingInfoAsync(System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Get information about the used embedding(s).
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<EmbeddingInfo>> GetEmbeddingInfoAsync(System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "embedding/info"
urlBuilder_.Append("embedding/info");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<EmbeddingInfo>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Get information about the retrieval processes implemented by this data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<RetrievalInfo>> GetRetrievalInfoAsync()
{
return GetRetrievalInfoAsync(System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Get information about the retrieval processes implemented by this data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<RetrievalInfo>> GetRetrievalInfoAsync(System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "retrieval/info"
urlBuilder_.Append("retrieval/info");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<RetrievalInfo>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Retrieve information from the data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<System.Collections.Generic.ICollection<Context>> RetrieveAsync(RetrievalRequest body)
{
return RetrieveAsync(body, System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Retrieve information from the data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<System.Collections.Generic.ICollection<Context>> RetrieveAsync(RetrievalRequest body, System.Threading.CancellationToken cancellationToken)
{
if (body == null)
throw new System.ArgumentNullException("body");
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
var json_ = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(body, _settings.Value);
var content_ = new System.Net.Http.ByteArrayContent(json_);
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "retrieval"
urlBuilder_.Append("retrieval");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.ICollection<Context>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
/// <remarks>
/// Get the security requirements for this data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<SecurityRequirements> GetSecurityRequirementsAsync()
{
return GetSecurityRequirementsAsync(System.Threading.CancellationToken.None);
}
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <remarks>
/// Get the security requirements for this data source.
/// </remarks>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<SecurityRequirements> GetSecurityRequirementsAsync(System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("GET");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
var urlBuilder_ = new System.Text.StringBuilder();
// Operation Path: "security/requirements"
urlBuilder_.Append("security/requirements");
PrepareRequest(client_, request_, urlBuilder_);
var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
PrepareRequest(client_, request_, url_);
var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}
ProcessResponse(client_, response_);
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<SecurityRequirements>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}
protected struct ObjectResponseResult<T>
{
public ObjectResponseResult(T responseObject, string responseText)
{
this.Object = responseObject;
this.Text = responseText;
}
public T Object { get; }
public string Text { get; }
}
public bool ReadResponseAsString { get; set; }
protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Threading.CancellationToken cancellationToken)
{
if (response == null || response.Content == null)
{
return new ObjectResponseResult<T>(default(T), string.Empty);
}
if (ReadResponseAsString)
{
var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
var typedBody = System.Text.Json.JsonSerializer.Deserialize<T>(responseText, JsonSerializerSettings);
return new ObjectResponseResult<T>(typedBody, responseText);
}
catch (System.Text.Json.JsonException exception)
{
var message = "Could not deserialize the response body string as " + typeof(T).FullName + ".";
throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception);
}
}
else
{
try
{
using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
{
var typedBody = await System.Text.Json.JsonSerializer.DeserializeAsync<T>(responseStream, JsonSerializerSettings, cancellationToken).ConfigureAwait(false);
return new ObjectResponseResult<T>(typedBody, string.Empty);
}
}
catch (System.Text.Json.JsonException exception)
{
var message = "Could not deserialize the response body stream as " + typeof(T).FullName + ".";
throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception);
}
}
}
private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo)
{
if (value == null)
{
return "";
}
if (value is System.Enum)
{
var name = System.Enum.GetName(value.GetType(), value);
if (name != null)
{
var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name);
if (field != null)
{
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
as System.Runtime.Serialization.EnumMemberAttribute;
if (attribute != null)
{
return attribute.Value != null ? attribute.Value : name;
}
}
var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo));
return converted == null ? string.Empty : converted;
}
}
else if (value is bool)
{
return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant();
}
else if (value is byte[])
{
return System.Convert.ToBase64String((byte[]) value);
}
else if (value is string[])
{
return string.Join(",", (string[])value);
}
else if (value.GetType().IsArray)
{
var valueArray = (System.Array)value;
var valueTextArray = new string[valueArray.Length];
for (var i = 0; i < valueArray.Length; i++)
{
valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo);
}
return string.Join(",", valueTextArray);
}
var result = System.Convert.ToString(value, cultureInfo);
return result == null ? "" : result;
}
}
/// <summary>
/// An authentication field.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum AuthField
{
[System.Runtime.Serialization.EnumMember(Value = @"NONE")]
NONE = 0,
[System.Runtime.Serialization.EnumMember(Value = @"USERNAME")]
USERNAME = 1,
[System.Runtime.Serialization.EnumMember(Value = @"PASSWORD")]
PASSWORD = 2,
[System.Runtime.Serialization.EnumMember(Value = @"TOKEN")]
TOKEN = 3,
[System.Runtime.Serialization.EnumMember(Value = @"KERBEROS_TICKET")]
KERBEROS_TICKET = 4,
}
/// <summary>
/// The mapping between an AuthField and the field name in the authentication request.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class AuthFieldMapping
{
[System.Text.Json.Serialization.JsonPropertyName("authField")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public AuthField AuthField { get; set; }
/// <summary>
/// The field name in the authentication request.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("fieldName")]
public string FieldName { get; set; }
}
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum AuthMethod
{
[System.Runtime.Serialization.EnumMember(Value = @"NONE")]
NONE = 0,
[System.Runtime.Serialization.EnumMember(Value = @"KERBEROS")]
KERBEROS = 1,
[System.Runtime.Serialization.EnumMember(Value = @"USERNAME_PASSWORD")]
USERNAME_PASSWORD = 2,
[System.Runtime.Serialization.EnumMember(Value = @"TOKEN")]
TOKEN = 3,
}
/// <summary>
/// The response to an authentication request.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class AuthResponse
{
/// <summary>
/// True, when the authentication was successful.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("success")]
public bool Success { get; set; }
/// <summary>
/// The token to use for further requests.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("token")]
public string Token { get; set; }
/// <summary>
/// When the authentication was not successful, this contains the reason.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("message")]
public string Message { get; set; }
}
/// <summary>
/// Describes one authentication scheme for this data source.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class AuthScheme
{
[System.Text.Json.Serialization.JsonPropertyName("authMethod")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public AuthMethod AuthMethod { get; set; }
/// <summary>
/// A list of field mappings for the authentication method. The client must know,
/// <br/> e.g., how the password field is named in the request.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("authFieldMappings")]
public System.Collections.Generic.ICollection<AuthFieldMapping> AuthFieldMappings { get; set; }
}
/// <summary>
/// A chat thread, which is a list of content blocks.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ChatThread
{
/// <summary>
/// The content blocks in this chat thread.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("contentBlocks")]
public System.Collections.Generic.ICollection<ContentBlock> ContentBlocks { get; set; }
}
/// <summary>
/// A block of content of a chat thread.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ContentBlock
{
/// <summary>
/// The content of the block. Remember that images and other media are base64 encoded.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("content")]
public string Content { get; set; }
[System.Text.Json.Serialization.JsonPropertyName("role")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public Role Role { get; set; }
[System.Text.Json.Serialization.JsonPropertyName("type")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public ContentType Type { get; set; }
}
/// <summary>
/// The type of content.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum ContentType
{
[System.Runtime.Serialization.EnumMember(Value = @"NONE")]
NONE = 0,
[System.Runtime.Serialization.EnumMember(Value = @"UNKNOWN")]
UNKNOWN = 1,
[System.Runtime.Serialization.EnumMember(Value = @"TEXT")]
TEXT = 2,
[System.Runtime.Serialization.EnumMember(Value = @"IMAGE")]
IMAGE = 3,
[System.Runtime.Serialization.EnumMember(Value = @"VIDEO")]
VIDEO = 4,
[System.Runtime.Serialization.EnumMember(Value = @"AUDIO")]
AUDIO = 5,
[System.Runtime.Serialization.EnumMember(Value = @"SPEECH")]
SPEECH = 6,
}
/// <summary>
/// Matching context returned by the data source as a result of a retrieval request.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class Context
{
/// <summary>
/// The name of the source, e.g., a document name, database name,
/// <br/> collection name, etc.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// What are the contents of the source? For example, is it a
/// <br/> dictionary, a book chapter, business concept, a paper, etc.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("category")]
public string Category { get; set; }
/// <summary>
/// The path to the content, e.g., a URL, a file path, a path in a
/// <br/> graph database, etc.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("path")]
public string Path { get; set; }
[System.Text.Json.Serialization.JsonPropertyName("type")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public ContentType Type { get; set; }
/// <summary>
/// The content that matched the user prompt. For text, you
/// <br/> return the matched text and, e.g., three words before and after it.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("matchedContent")]
public string MatchedContent { get; set; }
/// <summary>
/// The surrounding content of the matched content.
/// <br/> For text, you may return, e.g., one sentence or paragraph before and after
/// <br/> the matched content.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("surroundingContent")]
public System.Collections.Generic.ICollection<string> SurroundingContent { get; set; }
/// <summary>
/// Links to related content, e.g., links to Wikipedia articles,
/// <br/> links to sources, etc.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("links")]
public System.Collections.Generic.ICollection<string> Links { get; set; }
}
/// <summary>
/// Information about the data source.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class DataSourceInfo
{
/// <summary>
/// The name of the data source, e.g., "Internal Organization Documents."
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// A short description of the data source. What kind of data does it contain?
/// <br/> What is the data source used for?
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("description")]
public string Description { get; set; }
}
/// <summary>
/// Represents information about the used embedding for this data source. The purpose of this information is to give the
/// <br/>interested user an idea of what kind of embedding is used and what it does.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class EmbeddingInfo
{
/// <summary>
/// What kind of embedding is used. For example, "Transformer Embedding," "Contextual Word
/// <br/> Embedding," "Graph Embedding," etc.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("embeddingType")]
public string EmbeddingType { get; set; }
/// <summary>
/// Name the embedding used. This can be a library, a framework, or the name of the used
/// <br/> algorithm.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("embeddingName")]
public string EmbeddingName { get; set; }
/// <summary>
/// A short description of the embedding. Describe what the embedding is doing.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("description")]
public string Description { get; set; }
/// <summary>
/// Describe when the embedding is used. For example, when the user prompt contains certain
/// <br/> keywords, or anytime?
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("usedWhen")]
public string UsedWhen { get; set; }
/// <summary>
/// A link to the embedding's documentation or the source code. Might be null.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("link")]
public string Link { get; set; }
}
/// <summary>
/// Known types of providers that can process data.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum ProviderType
{
[System.Runtime.Serialization.EnumMember(Value = @"NONE")]
NONE = 0,
[System.Runtime.Serialization.EnumMember(Value = @"ANY")]
ANY = 1,
[System.Runtime.Serialization.EnumMember(Value = @"SELF_HOSTED")]
SELF_HOSTED = 2,
}
/// <summary>
/// Information about a retrieval process, which this data source implements.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class RetrievalInfo
{
/// <summary>
/// A unique identifier for the retrieval process. This can be a GUID, a unique name, or an increasing integer.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("id")]
public string Id { get; set; }
/// <summary>
/// The name of the retrieval process, e.g., "Keyword-Based Wikipedia Article Retrieval".
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>
/// A short description of the retrieval process. What kind of retrieval process is it?
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("description")]
public string Description { get; set; }
/// <summary>
/// A link to the retrieval process's documentation, paper, Wikipedia article, or the source code. Might be null.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("link")]
public string Link { get; set; }
/// <summary>
/// A dictionary that describes the parameters of the retrieval process. The key is the parameter name,
/// <br/> and the value is a description of the parameter. Although each parameter will be sent as a string, the description should indicate the
/// <br/> expected type and range, e.g., 0.0 to 1.0 for a float parameter.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("parametersDescription")]
public System.Collections.Generic.IDictionary<string, string> ParametersDescription { get; set; }
/// <summary>
/// A list of embeddings used in this retrieval process. It might be empty in case no embedding is used.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("embeddings")]
public System.Collections.Generic.ICollection<EmbeddingInfo> Embeddings { get; set; }
}
/// <summary>
/// The retrieval request sent by AI Studio.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class RetrievalRequest
{
/// <summary>
/// The latest user prompt that AI Studio received.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("latestUserPrompt")]
public string LatestUserPrompt { get; set; }
[System.Text.Json.Serialization.JsonPropertyName("latestUserPromptType")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public ContentType LatestUserPromptType { get; set; }
[System.Text.Json.Serialization.JsonPropertyName("thread")]
public ChatThread Thread { get; set; }
/// <summary>
/// Optional. The ID of the retrieval process that the data source should use.
/// <br/> When null, the data source chooses an appropriate retrieval process. Selecting a retrieval process is optional
/// <br/> for AI Studio users. Most users do not specify a retrieval process.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("retrievalProcessId")]
public string RetrievalProcessId { get; set; }
/// <summary>
/// A dictionary of parameters that the data source should use for the retrieval process.
/// <br/> Although each parameter will be sent as a string, the retrieval process specifies the expected type and range.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("parameters")]
public System.Collections.Generic.IDictionary<string, string> Parameters { get; set; }
/// <summary>
/// The maximum number of matches that the data source should return. AI Studio uses
/// <br/> any value below 1 to indicate that the data source should return as many matches as appropriate.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("maxMatches")]
public int MaxMatches { get; set; }
}
/// <summary>
/// Possible roles of any chat thread.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public enum Role
{
[System.Runtime.Serialization.EnumMember(Value = @"NONE")]
NONE = 0,
[System.Runtime.Serialization.EnumMember(Value = @"UNKNOW")]
UNKNOW = 1,
[System.Runtime.Serialization.EnumMember(Value = @"SYSTEM")]
SYSTEM = 2,
[System.Runtime.Serialization.EnumMember(Value = @"USER")]
USER = 3,
[System.Runtime.Serialization.EnumMember(Value = @"AI")]
AI = 4,
[System.Runtime.Serialization.EnumMember(Value = @"AGENT")]
AGENT = 5,
}
/// <summary>
/// Represents the security requirements for this data source.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class SecurityRequirements
{
[System.Text.Json.Serialization.JsonPropertyName("allowedProviderType")]
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
public ProviderType AllowedProviderType { get; set; }
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ApiException : System.Exception
{
public int StatusCode { get; private set; }
public string Response { get; private set; }
public System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> Headers { get; private set; }
public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Exception innerException)
: base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException)
{
StatusCode = statusCode;
Response = response;
Headers = headers;
}
public override string ToString()
{
return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString());
}
}
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
public partial class ApiException<TResult> : ApiException
{
public TResult Result { get; private set; }
public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, TResult result, System.Exception innerException)
: base(message, statusCode, response, headers, innerException)
{
Result = result;
}
}
}
#pragma warning restore 108
#pragma warning restore 114
#pragma warning restore 472
#pragma warning restore 612
#pragma warning restore 1573
#pragma warning restore 1591
#pragma warning restore 8073
#pragma warning restore 3016
#pragma warning restore 8603
#pragma warning restore 8604
#pragma warning restore 8625