diff --git a/app/MindWork AI Studio/Tools/Services/RustService.Enterprise.cs b/app/MindWork AI Studio/Tools/Services/RustService.Enterprise.cs index 6fae98af..76931c0b 100644 --- a/app/MindWork AI Studio/Tools/Services/RustService.Enterprise.cs +++ b/app/MindWork AI Studio/Tools/Services/RustService.Enterprise.cs @@ -21,6 +21,30 @@ public sealed partial class RustService Guid.TryParse(await result.Content.ReadAsStringAsync(), out var configurationId); return configurationId; } + + /// + /// Tries to read the enterprise environment for a configuration ID, which must be removed. + /// + /// + /// Removing a configuration ID is necessary when the user moved to another department or + /// left the company, or when the configuration ID is no longer valid. + /// + /// + /// Returns the empty Guid when the environment is not set or the request fails. + /// Otherwise, the configuration ID. + /// + public async Task EnterpriseEnvRemoveConfigId() + { + var result = await this.http.DeleteAsync("/system/enterprise/config/id"); + if (!result.IsSuccessStatusCode) + { + this.logger!.LogError($"Failed to query the enterprise configuration ID for removal: '{result.StatusCode}'"); + return Guid.Empty; + } + + Guid.TryParse(await result.Content.ReadAsStringAsync(), out var configurationId); + return configurationId; + } /// /// Tries to read the enterprise environment for the current user's configuration server URL. @@ -29,16 +53,16 @@ public sealed partial class RustService /// Returns null when the environment is not set or the request fails. /// Otherwise, the configuration server URL. /// - public async Task EnterpriseEnvConfigServerUrl() + public async Task EnterpriseEnvConfigServerUrl() { var result = await this.http.GetAsync("/system/enterprise/config/server"); if (!result.IsSuccessStatusCode) { this.logger!.LogError($"Failed to query the enterprise configuration server URL: '{result.StatusCode}'"); - return null; + return string.Empty; } var serverUrl = await result.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(serverUrl) ? null : serverUrl; + return string.IsNullOrWhiteSpace(serverUrl) ? string.Empty : serverUrl; } } \ No newline at end of file