File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed
BotSharp.Abstraction/Agents
BotSharp.Core/Agents/Services
ViewModels/Agents/Request Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ namespace BotSharp.Abstraction.Agents;
1010public interface IAgentService
1111{
1212 Task < Agent > CreateAgent ( Agent agent ) ;
13- Task < string > RefreshAgents ( ) ;
13+ Task < string > RefreshAgents ( IEnumerable < string > ? agentIds = null ) ;
1414 Task < PagedItems < Agent > > GetAgents ( AgentFilter filter ) ;
1515 Task < List < IdName > > GetAgentOptions ( List < string > ? agentIds = null , bool byName = false ) ;
1616 Task < IEnumerable < AgentUtility > > GetAgentUtilityOptions ( ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ namespace BotSharp.Core.Agents.Services;
66
77public partial class AgentService
88{
9- public async Task < string > RefreshAgents ( )
9+ public async Task < string > RefreshAgents ( IEnumerable < string > ? agentIds = null )
1010 {
1111 string refreshResult ;
1212 var dbSettings = _services . GetRequiredService < BotSharpDatabaseSettings > ( ) ;
@@ -28,7 +28,13 @@ public async Task<string> RefreshAgents()
2828 }
2929
3030 var refreshedAgents = new List < string > ( ) ;
31- foreach ( var dir in Directory . GetDirectories ( agentDir ) )
31+ var dirs = Directory . GetDirectories ( agentDir ) ;
32+ if ( ! agentIds . IsNullOrEmpty ( ) )
33+ {
34+ dirs = dirs . Where ( x => agentIds . Contains ( x . Split ( Path . DirectorySeparatorChar ) . Last ( ) ) ) . ToArray ( ) ;
35+ }
36+
37+ foreach ( var dir in dirs )
3238 {
3339 try
3440 {
@@ -78,7 +84,7 @@ public async Task<string> RefreshAgents()
7884 }
7985 else
8086 {
81- refreshResult = "No agent gets refreshed !" ;
87+ refreshResult = "No agent gets migrated !" ;
8288 }
8389
8490 _logger . LogInformation ( refreshResult ) ;
Original file line number Diff line number Diff line change @@ -111,9 +111,9 @@ public async Task<AgentViewModel> CreateAgent(AgentCreationModel agent)
111111
112112 [ BotSharpAuth ]
113113 [ HttpPost ( "/refresh-agents" ) ]
114- public async Task < string > RefreshAgents ( )
114+ public async Task < string > RefreshAgents ( [ FromBody ] AgentMigrationModel request )
115115 {
116- return await _agentService . RefreshAgents ( ) ;
116+ return await _agentService . RefreshAgents ( request ? . AgentIds ) ;
117117 }
118118
119119 [ HttpPut ( "/agent/file/{agentId}" ) ]
Original file line number Diff line number Diff line change 1+ using System . Text . Json . Serialization ;
2+
3+ namespace BotSharp . OpenAPI . ViewModels . Agents ;
4+
5+ public class AgentMigrationModel
6+ {
7+ [ JsonPropertyName ( "agent_ids" ) ]
8+ [ JsonIgnore ( Condition = JsonIgnoreCondition . WhenWritingNull ) ]
9+ public IEnumerable < string > ? AgentIds { get ; set ; }
10+ }
You can’t perform that action at this time.
0 commit comments