generated from tryAGI/SdkTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions[bot]
committed
Nov 25, 2024
1 parent
f27c875
commit 2d425d2
Showing
55 changed files
with
3,902 additions
and
843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
248 changes: 248 additions & 0 deletions
248
src/libs/Instill/Generated/Instill.AppClient.AppPublicServiceCreateChat.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
|
||
#nullable enable | ||
|
||
namespace Instill | ||
{ | ||
public partial class AppClient | ||
{ | ||
partial void PrepareAppPublicServiceCreateChatArguments( | ||
global::System.Net.Http.HttpClient httpClient, | ||
ref string namespaceId, | ||
global::Instill.CreateChatBody request); | ||
partial void PrepareAppPublicServiceCreateChatRequest( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpRequestMessage httpRequestMessage, | ||
string namespaceId, | ||
global::Instill.CreateChatBody request); | ||
partial void ProcessAppPublicServiceCreateChatResponse( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage); | ||
|
||
partial void ProcessAppPublicServiceCreateChatResponseContent( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage, | ||
ref string content); | ||
|
||
/// <summary> | ||
/// Create a chat<br/> | ||
/// Creates a chat. | ||
/// </summary> | ||
/// <param name="namespaceId"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::Instill.ApiException"></exception> | ||
[global::System.Diagnostics.CodeAnalysis.Experimental(diagnosticId: "INSTILL_ALPHA_001")] | ||
public async global::System.Threading.Tasks.Task<global::Instill.CreateChatResponse> AppPublicServiceCreateChatAsync( | ||
string namespaceId, | ||
global::Instill.CreateChatBody request, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
request = request ?? throw new global::System.ArgumentNullException(nameof(request)); | ||
|
||
PrepareArguments( | ||
client: HttpClient); | ||
PrepareAppPublicServiceCreateChatArguments( | ||
httpClient: HttpClient, | ||
namespaceId: ref namespaceId, | ||
request: request); | ||
|
||
var __pathBuilder = new PathBuilder( | ||
path: $"/v1alpha/namespaces/{namespaceId}/chats", | ||
baseUri: HttpClient.BaseAddress); | ||
var __path = __pathBuilder.ToString(); | ||
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( | ||
method: global::System.Net.Http.HttpMethod.Post, | ||
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); | ||
|
||
foreach (var __authorization in Authorizations) | ||
{ | ||
if (__authorization.Type == "Http" || | ||
__authorization.Type == "OAuth2") | ||
{ | ||
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( | ||
scheme: __authorization.Name, | ||
parameter: __authorization.Value); | ||
} | ||
else if (__authorization.Type == "ApiKey" && | ||
__authorization.Location == "Header") | ||
{ | ||
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value); | ||
} | ||
} | ||
var __httpRequestContentBody = request.ToJson(JsonSerializerContext); | ||
var __httpRequestContent = new global::System.Net.Http.StringContent( | ||
content: __httpRequestContentBody, | ||
encoding: global::System.Text.Encoding.UTF8, | ||
mediaType: "application/json"); | ||
__httpRequest.Content = __httpRequestContent; | ||
|
||
PrepareRequest( | ||
client: HttpClient, | ||
request: __httpRequest); | ||
PrepareAppPublicServiceCreateChatRequest( | ||
httpClient: HttpClient, | ||
httpRequestMessage: __httpRequest, | ||
namespaceId: namespaceId, | ||
request: request); | ||
|
||
using var __response = await HttpClient.SendAsync( | ||
request: __httpRequest, | ||
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponse( | ||
client: HttpClient, | ||
response: __response); | ||
ProcessAppPublicServiceCreateChatResponse( | ||
httpClient: HttpClient, | ||
httpResponseMessage: __response); | ||
// Returned when the client credentials are not valid. | ||
if ((int)__response.StatusCode == 401) | ||
{ | ||
string? __content_401 = null; | ||
string? __value_401 = null; | ||
if (ReadResponseAsString) | ||
{ | ||
__content_401 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
__value_401 = global::System.Text.Json.JsonSerializer.Deserialize(__content_401, typeof(string), JsonSerializerContext) as string; | ||
} | ||
else | ||
{ | ||
var __contentStream_401 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); | ||
__value_401 = await global::System.Text.Json.JsonSerializer.DeserializeAsync(__contentStream_401, typeof(string), JsonSerializerContext).ConfigureAwait(false) as string; | ||
} | ||
|
||
throw new global::Instill.ApiException<string>( | ||
message: __response.ReasonPhrase ?? string.Empty, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseBody = __content_401, | ||
ResponseObject = __value_401, | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
// An unexpected error response. | ||
if (!__response.IsSuccessStatusCode) | ||
{ | ||
string? __content_default = null; | ||
global::Instill.RpcStatus? __value_default = null; | ||
if (ReadResponseAsString) | ||
{ | ||
__content_default = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
__value_default = global::Instill.RpcStatus.FromJson(__content_default, JsonSerializerContext); | ||
} | ||
else | ||
{ | ||
var __contentStream_default = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); | ||
__value_default = await global::Instill.RpcStatus.FromJsonStreamAsync(__contentStream_default, JsonSerializerContext).ConfigureAwait(false); | ||
} | ||
|
||
throw new global::Instill.ApiException<global::Instill.RpcStatus>( | ||
message: __response.ReasonPhrase ?? string.Empty, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseBody = __content_default, | ||
ResponseObject = __value_default, | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
if (ReadResponseAsString) | ||
{ | ||
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponseContent( | ||
client: HttpClient, | ||
response: __response, | ||
content: ref __content); | ||
ProcessAppPublicServiceCreateChatResponseContent( | ||
httpClient: HttpClient, | ||
httpResponseMessage: __response, | ||
content: ref __content); | ||
|
||
try | ||
{ | ||
__response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException __ex) | ||
{ | ||
throw new global::Instill.ApiException( | ||
message: __content ?? __response.ReasonPhrase ?? string.Empty, | ||
innerException: __ex, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseBody = __content, | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
return | ||
global::Instill.CreateChatResponse.FromJson(__content, JsonSerializerContext) ?? | ||
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
__response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException __ex) | ||
{ | ||
throw new global::Instill.ApiException( | ||
message: __response.ReasonPhrase ?? string.Empty, | ||
innerException: __ex, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
using var __content = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
return | ||
await global::Instill.CreateChatResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? | ||
throw new global::System.InvalidOperationException("Response deserialization failed."); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Create a chat<br/> | ||
/// Creates a chat. | ||
/// </summary> | ||
/// <param name="namespaceId"></param> | ||
/// <param name="chatDisplayName"></param> | ||
/// <param name="aiAgentApp"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
[global::System.Diagnostics.CodeAnalysis.Experimental(diagnosticId: "INSTILL_ALPHA_001")] | ||
public async global::System.Threading.Tasks.Task<global::Instill.CreateChatResponse> AppPublicServiceCreateChatAsync( | ||
string namespaceId, | ||
string? chatDisplayName = default, | ||
global::Instill.AIAgentAppMetadata? aiAgentApp = default, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
var __request = new global::Instill.CreateChatBody | ||
{ | ||
ChatDisplayName = chatDisplayName, | ||
AiAgentApp = aiAgentApp, | ||
}; | ||
|
||
return await AppPublicServiceCreateChatAsync( | ||
namespaceId: namespaceId, | ||
request: __request, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.