Skip to content

Commit 4ee59e7

Browse files
committed
add remove client async and remove plugin async functions to the RPC server
1 parent 5096870 commit 4ee59e7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/kiota/Rpc/IServer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ internal interface IServer
1414
Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken);
1515
Task<List<LogEntry>> GeneratePluginAsync(string openAPIFilePath, string outputPath, PluginType[] pluginTypes, string[] includePatterns, string[] excludePatterns, string clientClassName, bool cleanOutput, bool clearCache, string[] disabledValidationRules, ConsumerOperation operation, CancellationToken cancellationToken);
1616
Task<List<LogEntry>> MigrateFromLockFileAsync(string lockDirectoryPath, CancellationToken cancellationToken);
17+
Task<List<LogEntry>> RemoveClientAsync(string clientName, bool cleanOutput, CancellationToken cancellationToken);
18+
Task<List<LogEntry>> RemovePluginAsync(string pluginName, bool cleanOutput, CancellationToken cancellationToken);
1719
}

src/kiota/Rpc/Server.cs

+34
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,38 @@ private static string NormalizeSlashesInPath(string path)
299299
return path.Replace('/', '\\');
300300
return path.Replace('\\', '/');
301301
}
302+
303+
public async Task<List<LogEntry>> RemoveClientAsync(string clientName, bool cleanOutput, CancellationToken cancellationToken)
304+
{
305+
ArgumentException.ThrowIfNullOrEmpty(clientName);
306+
var logger = new ForwardedLogger<KiotaBuilder>();
307+
try
308+
{
309+
var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value);
310+
await workspaceManagementService.RemoveClientAsync(clientName, cleanOutput, cancellationToken).ConfigureAwait(false);
311+
logger.LogInformation($"Client {clientName} removed successfully!");
312+
}
313+
catch (Exception ex)
314+
{
315+
logger.LogCritical(ex, "error removing the plugin: {exceptionMessage}", ex.Message);
316+
}
317+
return logger.LogEntries;
318+
}
319+
320+
public async Task<List<LogEntry>> RemovePluginAsync(string pluginName, bool cleanOutput, CancellationToken cancellationToken)
321+
{
322+
ArgumentException.ThrowIfNullOrEmpty(pluginName);
323+
var logger = new ForwardedLogger<KiotaBuilder>();
324+
try
325+
{
326+
var workspaceManagementService = new WorkspaceManagementService(logger, httpClient, IsConfigPreviewEnabled.Value);
327+
await workspaceManagementService.RemovePluginAsync(pluginName, cleanOutput, cancellationToken).ConfigureAwait(false);
328+
logger.LogInformation($"Plugin {pluginName} removed successfully!");
329+
}
330+
catch (Exception ex)
331+
{
332+
logger.LogCritical(ex, "error removing the plugin: {exceptionMessage}", ex.Message);
333+
}
334+
return logger.LogEntries;
335+
}
302336
}

0 commit comments

Comments
 (0)