35#pragma warning disable CA1506
54 authenticationContext,
78 if (api.ChannelData !=
null)
131 ConnectionString =
model.ConnectionString,
134 Provider =
model.Provider,
135 ReconnectionInterval =
model.ReconnectionInterval,
136 ChannelLimit =
model.ChannelLimit,
150 if (
dbModel.Channels.Count > 0)
160 await instance.Chat.DeleteConnection(
dbModel.Id!.Value,
default);
189 .Where(
x =>
x.Id ==
id)
217 .Include(
x =>
x.Channels)
218 .OrderBy(
x =>
x.Id))),
221 if (!connectionStrings)
222 chatBot.ConnectionString = null;
224 return ValueTask.CompletedTask;
248 .Include(
x =>
x.Channels);
276#pragma warning disable CA1502, CA1506
278#pragma warning restore CA1502, CA1506
290 .Include(
x =>
x.Channels);
301 if (
model.Channels !=
null &&
model.ChannelLimit.HasValue)
302 return BadRequest(errorMessage);
303 return Conflict(errorMessage);
356 var chat = instance.Chat;
371 current.ConnectionString =
null;
386 if (
model.ReconnectionInterval == 0)
395 if (
model.ConnectionString !=
null &&
String.IsNullOrWhiteSpace(
model.ConnectionString))
398 if (!
model.ValidateProviderChannelTypes())
411#pragma warning restore CA1506
virtual ? long Id
The ID of the entity.
Metadata about a server instance.
ushort? ChatBotLimit
The maximum number of chat bots the Instance may contain.
string? Tag
A custom tag users can define to group channels together.
virtual ? string Name
The name of the entity represented by the NamedEntity.
Represents a request to update a chat bot.
Represents a request to update a chat bot.
Represents a chat bot response.
Represents an error message returned by the server.
Represents a paginated set of models.
Routes to a server actions.
const string List
The postfix for list operations.
const string Chat
The chat bot controller.
StatusCodeResult StatusCode(HttpStatusCode statusCode)
Strongly type calls to ControllerBase.StatusCode(int).
ApiController for managing ChatBots.
static Models.ChatChannel ConvertApiChatChannel(Api.Models.ChatChannel api, ChatProvider chatProvider)
Converts api to a ChatChannel.
async ValueTask< IActionResult > Delete(long id, CancellationToken cancellationToken)
Delete a ChatBot.
async ValueTask< IActionResult > GetId(long id, CancellationToken cancellationToken)
Get a specific ChatBot.
BadRequestObjectResult? StandardModelChecks(ChatBotApiBase model, bool forCreation)
Perform some basic validation of a given model .
async ValueTask< IActionResult > Update([FromBody] ChatBotUpdateRequest model, CancellationToken cancellationToken)
Updates a chat bot model .
async ValueTask< IActionResult > Create([FromBody] ChatBotCreateRequest model, CancellationToken cancellationToken)
Create a new chat bot model .
ValueTask< IActionResult > List([FromQuery] int? page, [FromQuery] int? pageSize, CancellationToken cancellationToken)
List ChatBots.
ChatController(IDatabaseContext databaseContext, IAuthenticationContext authenticationContext, ILogger< ChatController > logger, IInstanceManager instanceManager, IApiHeadersProvider apiHeaders)
Initializes a new instance of the ChatController class.
async ValueTask< IActionResult?> WithComponentInstanceNullable(Func< IInstanceCore, ValueTask< IActionResult?> > action, Models.Instance? instance=null)
Run a given action with the relevant IInstance.
readonly IInstanceManager instanceManager
The IInstanceManager for the ComponentInterfacingController.
ComponentInterfacingController for operations that require an instance.
Helper for returning paginated models.
Backend abstract implementation of IDatabaseContext.
DbSet< ChatChannel > ChatChannels
The ChatChannels in the DatabaseContext.
Task Save(CancellationToken cancellationToken)
Saves changes made to the IDatabaseContext.A Task representing the running operation.
DbSet< ChatBot > ChatBots
The ChatBots in the DatabaseContext.
const ushort DefaultChannelLimit
Default for Api.Models.Internal.ChatBotSettings.ChannelLimit.
ulong GetRight(RightsType rightsType)
Get the value of a given rightsType .The value of rightsType . Note that if InstancePermissionSet is ...
For creating and accessing authentication contexts.
ErrorCode
Types of Response.ErrorMessageResponses that the API may return.
ChatProvider
Represents a chat service provider.
ChatBotRights
Rights for chat bots.
@ List
User may list files if the Models.Instance allows it.
RightsType
The type of rights a model uses.
@ Api
The ApiHeaders.ApiVersionHeader header is missing or invalid.
@ Enabled
The OAuth Gateway is enabled.