using System; using xModels.Dtos; using xModels.Base; using xIdentityHelper; using System.Threading; using xCommons.Providers; using xAiModels.Models.Dtos; using System.Threading.Tasks; using xCommons.Configurations; using Microsoft.AspNetCore.Mvc; using xAiModels.Interfaces.Dtos; using System.Collections.Generic; using xIdentityService.Interfaces; using Microsoft.Extensions.Logging; using xIdentityService.Controllers; using Microsoft.AspNetCore.Authorization; namespace xAiApi.Controllers { [Authorize] public class McpServerController : XBaseIdentityApiV1Controller { public McpServerController( XAppConfiguration appConfiguration, ILogger logger, IXIdentityProvider identityProvider, XValidationProvider validationProvider, IXAiMcpServerRepositoryService repositoryService ) : base( logger, appConfiguration, identityProvider, validationProvider ) { } // #region Provider ... [HttpPost] [Authorize(Policy = XPolicies.EnabledUser)] public static async Task> AddMcpServer( [FromBody] XAiMcpServerDto item, CancellationToken cancellationToken = default ) { // try { // // Validate ... if (!files.HasChild()) { XException.InvalidArgs.Throw(); } // var userInfo = await GetUserInfo(); var connectionId = GetConnectionId(); // var result = await ragService.IngestAsync( files: files, userInfo: userInfo, connectionId: connectionId, replaceExisting: replaceExisting, cancellationToken: cancellationToken, scope: BuildScope(scope, scopeId, knowledgeType) ); // return Ok(result); } catch (Exception ex) { // var result = GetExceptionActionResult(ex); return result; } } #endregion // #region Actions ... // #region Add ... /// /// Add Specified Item ... /// /// /// /// /// /// [HttpPost] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> Add( [FromBody] XAiMcpServerDto item, CancellationToken cancellationToken = default ) { // var result = await base.Add( item: item, cancellationToken: cancellationToken ); // return result; } /// /// Add or Update Specified Item ... /// /// /// /// /// /// [HttpPost("AddOrUpdate")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> AddOrUpdate( [FromBody] XAiMcpServerDto item, CancellationToken cancellationToken = default ) { // var result = await base.AddOrUpdate( item: item, cancellationToken: cancellationToken ); // return result; } /// /// Add a Collection of Items ... /// /// /// /// /// /// [HttpPost("AddMany")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task AddMany( [FromBody] XBaseRangeRequest request, CancellationToken cancellationToken = default ) { // var result = await base.AddMany( request: request, cancellationToken: cancellationToken ); // return result; } #endregion // #region Retrieve ... /// /// Get Specified Item ... /// /// /// /// /// /// /// /// [HttpGet("{id}")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> Get( [FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool useDefaultIncludes = false, CancellationToken cancellationToken = default ) { // var result = await base.Get( id: id, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds, useDefaultIncludes: useDefaultIncludes ); // return result; } /// /// Get All Items ... /// /// /// /// /// /// /// /// [HttpGet] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task>> GetAll( [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool useDefaultOrders = false, [FromQuery] bool useDefaultIncludes = false, CancellationToken cancellationToken = default ) { // var result = await base.GetAll( useDefaultOrders: useDefaultOrders, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds, useDefaultIncludes: useDefaultIncludes ); // return result; } /// /// Find Specified Item ... /// /// /// /// /// /// /// /// [HttpGet("FindOne/{query}")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> FindOne( [FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool useDefaultIncludes = false, CancellationToken cancellationToken = default ) { // var result = await base.FindOne( query: query, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds, useDefaultIncludes: useDefaultIncludes ); // return result; } /// /// Find Many Items ... /// /// /// /// /// /// /// /// /// [HttpGet("FindMany/{query}")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task>> FindMany( [FromRoute] string query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool useDefaultOrders = false, [FromQuery] bool useDefaultIncludes = false, CancellationToken cancellationToken = default ) { // var result = await base.FindMany( query: query, useDefaultOrders: useDefaultOrders, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds, useDefaultIncludes: useDefaultIncludes ); // return result; } /// /// Retrieve Items Based on Query Mechanism ... /// /// /// /// /// /// /// /// /// [HttpGet("Query")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task>> Query( [FromQuery] XQuery query, [FromQuery] bool ignoreSoftDeleteds = true, [FromQuery] bool useDefaultOrders = false, [FromQuery] bool useDefaultIncludes = false, CancellationToken cancellationToken = default ) { // var result = await base.Query( query: query, useDefaultOrders: useDefaultOrders, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds, useDefaultIncludes: useDefaultIncludes ); // return result; } #endregion // #region Update ... /// /// Update Item ... /// /// /// /// /// /// /// [HttpPut("{id}")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> Update( [FromRoute] Guid id, [FromBody] XAiMcpServerDto item, CancellationToken cancellationToken = default ) { // var result = await base.Update( id: id, item: item, cancellationToken: cancellationToken ); // return result; } /// /// Update a Collection of items ... /// /// /// /// /// /// [HttpPost("UpdateMany")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> UpdateMany( [FromBody] XBaseRangeRequest request, CancellationToken cancellationToken = default ) { // var result = await base.UpdateMany( request: request, cancellationToken: cancellationToken ); // return result; } #endregion // #region Exists ... /// ///Check an Item Exists or not ... /// /// /// /// /// /// /// [HttpGet("{id}/IsExists")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> IsExists( [FromRoute] Guid id, [FromQuery] bool ignoreSoftDeleteds = true, CancellationToken cancellationToken = default ) { // var result = await base.IsExists( id: id, cancellationToken: cancellationToken, ignoreSoftDeleteds: ignoreSoftDeleteds ); // return result; } #endregion // #region Remove ... /// /// Remove an Items ... /// /// /// /// /// /// /// [HttpDelete("{id}")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task> Remove( [FromRoute] Guid id, [FromQuery] bool softDelete = false, CancellationToken cancellationToken = default ) { // var result = await base.Remove( id: id, softDelete: softDelete, cancellationToken: cancellationToken ); // return result; } /// /// Remove Many Items ... /// /// /// /// /// /// /// [HttpPost("RemoveMany")] [Authorize(Policy = XPolicies.EnabledAdmin)] public override async Task RemoveMany( [FromBody] XBaseRangeRequest request, [FromQuery] bool softDelete = false, CancellationToken cancellationToken = default ) { // var result = await base.RemoveMany( request: request, softDelete: softDelete, cancellationToken: cancellationToken ); // return result; } #endregion #endregion } }