Fixed endpoint naming and http methods
This commit is contained in:
@@ -36,7 +36,7 @@ public class Client
|
|||||||
|
|
||||||
public async Task<SearchdomainListResults> SearchdomainListAsync()
|
public async Task<SearchdomainListResults> SearchdomainListAsync()
|
||||||
{
|
{
|
||||||
return await GetUrlAndProcessJson<SearchdomainListResults>(GetUrl($"{baseUri}/Searchdomain", "List", apiKey, []));
|
return await GetUrlAndProcessJson<SearchdomainListResults>(GetUrl($"{baseUri}", "Searchdomains", apiKey, []));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SearchdomainDeleteResults> SearchdomainDeleteAsync()
|
public async Task<SearchdomainDeleteResults> SearchdomainDeleteAsync()
|
||||||
@@ -46,7 +46,7 @@ public class Client
|
|||||||
|
|
||||||
public async Task<SearchdomainDeleteResults> SearchdomainDeleteAsync(string searchdomain)
|
public async Task<SearchdomainDeleteResults> SearchdomainDeleteAsync(string searchdomain)
|
||||||
{
|
{
|
||||||
return await GetUrlAndProcessJson<SearchdomainDeleteResults>(GetUrl($"{baseUri}/Searchdomain", "Delete", apiKey, new Dictionary<string, string>()
|
return await DeleteUrlAndProcessJson<SearchdomainDeleteResults>(GetUrl($"{baseUri}", "Searchdomain", apiKey, new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"searchdomain", searchdomain}
|
{"searchdomain", searchdomain}
|
||||||
}));
|
}));
|
||||||
@@ -57,12 +57,12 @@ public class Client
|
|||||||
return await SearchdomainCreateAsync(searchdomain);
|
return await SearchdomainCreateAsync(searchdomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SearchdomainCreateResults> SearchdomainCreateAsync(string searchdomain)
|
public async Task<SearchdomainCreateResults> SearchdomainCreateAsync(string searchdomain, SearchdomainSettings searchdomainSettings = new())
|
||||||
{
|
{
|
||||||
return await GetUrlAndProcessJson<SearchdomainCreateResults>(GetUrl($"{baseUri}/Searchdomain", "Create", apiKey, new Dictionary<string, string>()
|
return await PostUrlAndProcessJson<SearchdomainCreateResults>(GetUrl($"{baseUri}", "Searchdomain", apiKey, new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"searchdomain", searchdomain}
|
{"searchdomain", searchdomain}
|
||||||
}));
|
}), new StringContent(JsonSerializer.Serialize(searchdomainSettings), Encoding.UTF8, "application/json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SearchdomainUpdateResults> SearchdomainUpdateAsync(string newName, string settings = "{}")
|
public async Task<SearchdomainUpdateResults> SearchdomainUpdateAsync(string newName, string settings = "{}")
|
||||||
@@ -72,14 +72,18 @@ public class Client
|
|||||||
return updateResults;
|
return updateResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<SearchdomainUpdateResults> SearchdomainUpdateAsync(string searchdomain, string newName, SearchdomainSettings settings = new())
|
||||||
|
{
|
||||||
|
return await SearchdomainUpdateAsync(searchdomain, newName, JsonSerializer.Serialize(settings));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<SearchdomainUpdateResults> SearchdomainUpdateAsync(string searchdomain, string newName, string settings = "{}")
|
public async Task<SearchdomainUpdateResults> SearchdomainUpdateAsync(string searchdomain, string newName, string settings = "{}")
|
||||||
{
|
{
|
||||||
return await GetUrlAndProcessJson<SearchdomainUpdateResults>(GetUrl($"{baseUri}/Searchdomain", "Update", apiKey, new Dictionary<string, string>()
|
return await PutUrlAndProcessJson<SearchdomainUpdateResults>(GetUrl($"{baseUri}", "Searchdomain", apiKey, new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"searchdomain", searchdomain},
|
{"searchdomain", searchdomain},
|
||||||
{"newName", newName},
|
{"newName", newName}
|
||||||
{"settings", settings}
|
}), new StringContent(settings, Encoding.UTF8, "application/json"));
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EntityQueryResults> EntityQueryAsync(string query)
|
public async Task<EntityQueryResults> EntityQueryAsync(string query)
|
||||||
@@ -89,11 +93,11 @@ public class Client
|
|||||||
|
|
||||||
public async Task<EntityQueryResults> EntityQueryAsync(string searchdomain, string query)
|
public async Task<EntityQueryResults> EntityQueryAsync(string searchdomain, string query)
|
||||||
{
|
{
|
||||||
return await GetUrlAndProcessJson<EntityQueryResults>(GetUrl($"{baseUri}/Searchdomain", "Query", apiKey, new Dictionary<string, string>()
|
return await PostUrlAndProcessJson<EntityQueryResults>(GetUrl($"{baseUri}/Searchdomain", "Query", apiKey, new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{"searchdomain", searchdomain},
|
{"searchdomain", searchdomain},
|
||||||
{"query", query}
|
{"query", query}
|
||||||
}));
|
}), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EntityIndexResult> EntityIndexAsync(List<JSONEntity> jsonEntity)
|
public async Task<EntityIndexResult> EntityIndexAsync(List<JSONEntity> jsonEntity)
|
||||||
@@ -104,7 +108,7 @@ public class Client
|
|||||||
public async Task<EntityIndexResult> EntityIndexAsync(string jsonEntity)
|
public async Task<EntityIndexResult> EntityIndexAsync(string jsonEntity)
|
||||||
{
|
{
|
||||||
var content = new StringContent(jsonEntity, Encoding.UTF8, "application/json");
|
var content = new StringContent(jsonEntity, Encoding.UTF8, "application/json");
|
||||||
return await PostUrlAndProcessJson<EntityIndexResult>(GetUrl($"{baseUri}/Entity", "Index", apiKey, []), content);//new FormUrlEncodedContent(values));
|
return await PutUrlAndProcessJson<EntityIndexResult>(GetUrl($"{baseUri}", "Entity", apiKey, []), content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<EntityListResults> EntityListAsync(bool returnEmbeddings = false)
|
public async Task<EntityListResults> EntityListAsync(bool returnEmbeddings = false)
|
||||||
@@ -114,7 +118,7 @@ public class Client
|
|||||||
|
|
||||||
public async Task<EntityListResults> EntityListAsync(string searchdomain, bool returnEmbeddings = false)
|
public async Task<EntityListResults> EntityListAsync(string searchdomain, bool returnEmbeddings = false)
|
||||||
{
|
{
|
||||||
var url = $"{baseUri}/Entity/List?apiKey={HttpUtility.UrlEncode(apiKey)}&searchdomain={HttpUtility.UrlEncode(searchdomain)}&returnEmbeddings={HttpUtility.UrlEncode(returnEmbeddings.ToString())}";
|
var url = $"{baseUri}/Entities?apiKey={HttpUtility.UrlEncode(apiKey)}&searchdomain={HttpUtility.UrlEncode(searchdomain)}&returnEmbeddings={HttpUtility.UrlEncode(returnEmbeddings.ToString())}";
|
||||||
return await GetUrlAndProcessJson<EntityListResults>(url);
|
return await GetUrlAndProcessJson<EntityListResults>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +129,8 @@ public class Client
|
|||||||
|
|
||||||
public async Task<EntityDeleteResults> EntityDeleteAsync(string searchdomain, string entityName)
|
public async Task<EntityDeleteResults> EntityDeleteAsync(string searchdomain, string entityName)
|
||||||
{
|
{
|
||||||
var url = $"{baseUri}/Entity/Delete?apiKey={HttpUtility.UrlEncode(apiKey)}&searchdomain={HttpUtility.UrlEncode(searchdomain)}&entity={HttpUtility.UrlEncode(entityName)}";
|
var url = $"{baseUri}/Entity?apiKey={HttpUtility.UrlEncode(apiKey)}&searchdomain={HttpUtility.UrlEncode(searchdomain)}&entity={HttpUtility.UrlEncode(entityName)}";
|
||||||
return await GetUrlAndProcessJson<EntityDeleteResults>(url);
|
return await DeleteUrlAndProcessJson<EntityDeleteResults>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<T> GetUrlAndProcessJson<T>(string url)
|
private static async Task<T> GetUrlAndProcessJson<T>(string url)
|
||||||
@@ -138,7 +142,8 @@ public class Client
|
|||||||
?? throw new Exception($"Failed to deserialize JSON to type {typeof(T).Name}");
|
?? throw new Exception($"Failed to deserialize JSON to type {typeof(T).Name}");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private static async Task<T> PostUrlAndProcessJson<T>(string url, HttpContent content)
|
|
||||||
|
private static async Task<T> PostUrlAndProcessJson<T>(string url, HttpContent? content)
|
||||||
{
|
{
|
||||||
using var client = new HttpClient();
|
using var client = new HttpClient();
|
||||||
var response = await client.PostAsync(url, content);
|
var response = await client.PostAsync(url, content);
|
||||||
@@ -148,6 +153,26 @@ public class Client
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task<T> PutUrlAndProcessJson<T>(string url, HttpContent content)
|
||||||
|
{
|
||||||
|
using var client = new HttpClient();
|
||||||
|
var response = await client.PutAsync(url, content);
|
||||||
|
string responseContent = await response.Content.ReadAsStringAsync();
|
||||||
|
var result = JsonSerializer.Deserialize<T>(responseContent)
|
||||||
|
?? throw new Exception($"Failed to deserialize JSON to type {typeof(T).Name}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<T> DeleteUrlAndProcessJson<T>(string url)
|
||||||
|
{
|
||||||
|
using var client = new HttpClient();
|
||||||
|
var response = await client.DeleteAsync(url);
|
||||||
|
string responseContent = await response.Content.ReadAsStringAsync();
|
||||||
|
var result = JsonSerializer.Deserialize<T>(responseContent)
|
||||||
|
?? throw new Exception($"Failed to deserialize JSON to type {typeof(T).Name}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetUrl(string baseUri, string endpoint, string apiKey, Dictionary<string, string> parameters)
|
public static string GetUrl(string baseUri, string endpoint, string apiKey, Dictionary<string, string> parameters)
|
||||||
{
|
{
|
||||||
var uriBuilder = new UriBuilder($"{baseUri}/{endpoint}");
|
var uriBuilder = new UriBuilder($"{baseUri}/{endpoint}");
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class EntityController : ControllerBase
|
|||||||
_databaseHelper = databaseHelper;
|
_databaseHelper = databaseHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("Index")]
|
[HttpPut]
|
||||||
public ActionResult<EntityIndexResult> Index([FromBody] List<JSONEntity>? jsonEntities)
|
public ActionResult<EntityIndexResult> Index([FromBody] List<JSONEntity>? jsonEntities)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -62,7 +62,7 @@ public class EntityController : ControllerBase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("List")]
|
[HttpGet("/Entities")]
|
||||||
public ActionResult<EntityListResults> List(string searchdomain, bool returnModels = false, bool returnEmbeddings = false)
|
public ActionResult<EntityListResults> List(string searchdomain, bool returnModels = false, bool returnEmbeddings = false)
|
||||||
{
|
{
|
||||||
if (returnEmbeddings && !returnModels)
|
if (returnEmbeddings && !returnModels)
|
||||||
@@ -109,7 +109,7 @@ public class EntityController : ControllerBase
|
|||||||
return Ok(entityListResults);
|
return Ok(entityListResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Delete")]
|
[HttpDelete]
|
||||||
public ActionResult<EntityDeleteResults> Delete(string searchdomain, string entityName)
|
public ActionResult<EntityDeleteResults> Delete(string searchdomain, string entityName)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
_domainManager = domainManager;
|
_domainManager = domainManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("List")]
|
[HttpGet("/Searchdomains")]
|
||||||
public ActionResult<SearchdomainListResults> List()
|
public ActionResult<SearchdomainListResults> List()
|
||||||
{
|
{
|
||||||
List<string> results;
|
List<string> results;
|
||||||
@@ -40,8 +40,8 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(searchdomainListResults);
|
return Ok(searchdomainListResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Create")]
|
[HttpPost]
|
||||||
public ActionResult<SearchdomainCreateResults> Create(string searchdomain, string settings = "{}")
|
public ActionResult<SearchdomainCreateResults> Create(string searchdomain, [FromBody]SearchdomainSettings settings = new())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -54,7 +54,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Delete")]
|
[HttpDelete]
|
||||||
public ActionResult<SearchdomainDeleteResults> Delete(string searchdomain)
|
public ActionResult<SearchdomainDeleteResults> Delete(string searchdomain)
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
@@ -84,22 +84,33 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainDeleteResults(){Success = success, DeletedEntities = deletedEntries, Message = message});
|
return Ok(new SearchdomainDeleteResults(){Success = success, DeletedEntities = deletedEntries, Message = message});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Update")]
|
[HttpPut]
|
||||||
public ActionResult<SearchdomainUpdateResults> Update(string searchdomain, string newName, string settings = "{}")
|
public ActionResult<SearchdomainUpdateResults> Update(string searchdomain, string newName, [FromBody]string? settings = "{}")
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
||||||
Dictionary<string, dynamic> parameters = new()
|
if (settings is null)
|
||||||
{
|
{
|
||||||
{"name", newName},
|
Dictionary<string, dynamic> parameters = new()
|
||||||
{"settings", settings},
|
{
|
||||||
{"id", searchdomain_.id}
|
{"name", newName},
|
||||||
};
|
{"id", searchdomain_.id}
|
||||||
searchdomain_.helper.ExecuteSQLNonQuery("UPDATE searchdomain set name = @name, settings = @settings WHERE id = @id", parameters);
|
};
|
||||||
|
searchdomain_.helper.ExecuteSQLNonQuery("UPDATE searchdomain set name = @name WHERE id = @id", parameters);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Dictionary<string, dynamic> parameters = new()
|
||||||
|
{
|
||||||
|
{"name", newName},
|
||||||
|
{"settings", settings},
|
||||||
|
{"id", searchdomain_.id}
|
||||||
|
};
|
||||||
|
searchdomain_.helper.ExecuteSQLNonQuery("UPDATE searchdomain set name = @name, settings = @settings WHERE id = @id", parameters);
|
||||||
|
}
|
||||||
return Ok(new SearchdomainUpdateResults(){Success = true});
|
return Ok(new SearchdomainUpdateResults(){Success = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("Query")]
|
[HttpPost("Query")]
|
||||||
public ActionResult<EntityQueryResults> Query(string searchdomain, string query, int? topN, bool returnAttributes = false)
|
public ActionResult<EntityQueryResults> Query(string searchdomain, string query, int? topN, bool returnAttributes = false)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
@@ -114,7 +125,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new EntityQueryResults(){Results = queryResults, Success = true });
|
return Ok(new EntityQueryResults(){Results = queryResults, Success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("UpdateSettings")]
|
[HttpPut("Settings")]
|
||||||
public ActionResult<SearchdomainUpdateResults> UpdateSettings(string searchdomain, [FromBody] SearchdomainSettings request)
|
public ActionResult<SearchdomainUpdateResults> UpdateSettings(string searchdomain, [FromBody] SearchdomainSettings request)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
@@ -129,8 +140,8 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainUpdateResults(){Success = true});
|
return Ok(new SearchdomainUpdateResults(){Success = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetSearches")]
|
[HttpGet("Queries")]
|
||||||
public ActionResult<SearchdomainSearchesResults> GetSearches(string searchdomain)
|
public ActionResult<SearchdomainSearchesResults> GetQueries(string searchdomain)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
||||||
@@ -139,8 +150,8 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainSearchesResults() { Searches = searchCache, Success = true });
|
return Ok(new SearchdomainSearchesResults() { Searches = searchCache, Success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("Searches")]
|
[HttpDelete("Query")]
|
||||||
public ActionResult<SearchdomainDeleteSearchResult> DeleteSearch(string searchdomain, string query)
|
public ActionResult<SearchdomainDeleteSearchResult> DeleteQuery(string searchdomain, string query)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
||||||
@@ -154,8 +165,8 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainDeleteSearchResult() {Success = false, Message = "Query not found in search cache"});
|
return Ok(new SearchdomainDeleteSearchResult() {Success = false, Message = "Query not found in search cache"});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("Searches")]
|
[HttpPatch("Query")]
|
||||||
public ActionResult<SearchdomainUpdateSearchResult> UpdateSearch(string searchdomain, string query, [FromBody]List<ResultItem> results)
|
public ActionResult<SearchdomainUpdateSearchResult> UpdateQuery(string searchdomain, string query, [FromBody]List<ResultItem> results)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
||||||
@@ -171,7 +182,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainUpdateSearchResult() {Success = false, Message = "Query not found in search cache"});
|
return Ok(new SearchdomainUpdateSearchResult() {Success = false, Message = "Query not found in search cache"});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetSettings")]
|
[HttpGet("Settings")]
|
||||||
public ActionResult<SearchdomainSettingsResults> GetSettings(string searchdomain)
|
public ActionResult<SearchdomainSettingsResults> GetSettings(string searchdomain)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
@@ -180,7 +191,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainSettingsResults() { Settings = settings, Success = true });
|
return Ok(new SearchdomainSettingsResults() { Settings = settings, Success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetSearchCacheSize")]
|
[HttpGet("SearchCache/Size")]
|
||||||
public ActionResult<SearchdomainSearchCacheSizeResults> GetSearchCacheSize(string searchdomain)
|
public ActionResult<SearchdomainSearchCacheSizeResults> GetSearchCacheSize(string searchdomain)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
@@ -196,7 +207,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainSearchCacheSizeResults() { SearchCacheSizeBytes = sizeInBytes, Success = true });
|
return Ok(new SearchdomainSearchCacheSizeResults() { SearchCacheSizeBytes = sizeInBytes, Success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("ClearSearchCache")]
|
[HttpPost("SearchCache/Clear")]
|
||||||
public ActionResult<SearchdomainInvalidateCacheResults> InvalidateSearchCache(string searchdomain)
|
public ActionResult<SearchdomainInvalidateCacheResults> InvalidateSearchCache(string searchdomain)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
@@ -205,7 +216,7 @@ public class SearchdomainController : ControllerBase
|
|||||||
return Ok(new SearchdomainInvalidateCacheResults(){Success = true});
|
return Ok(new SearchdomainInvalidateCacheResults(){Success = true});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetDatabaseSize")]
|
[HttpGet("Database/Size")]
|
||||||
public ActionResult<SearchdomainGetDatabaseSizeResult> GetDatabaseSize(string searchdomain)
|
public ActionResult<SearchdomainGetDatabaseSizeResult> GetDatabaseSize(string searchdomain)
|
||||||
{
|
{
|
||||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class ServerController : ControllerBase
|
|||||||
_aIProvider = aIProvider;
|
_aIProvider = aIProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetModels")]
|
[HttpGet("Models")]
|
||||||
public ActionResult<ServerGetModelsResult> GetModels()
|
public ActionResult<ServerGetModelsResult> GetModels()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ using Server.Migrations;
|
|||||||
using Server.Helper;
|
using Server.Helper;
|
||||||
using Server.Exceptions;
|
using Server.Exceptions;
|
||||||
using AdaptiveExpressions;
|
using AdaptiveExpressions;
|
||||||
|
using Shared.Models;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
||||||
@@ -87,6 +89,10 @@ public class SearchdomainManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int CreateSearchdomain(string searchdomain, SearchdomainSettings settings)
|
||||||
|
{
|
||||||
|
return CreateSearchdomain(searchdomain, JsonSerializer.Serialize(settings));
|
||||||
|
}
|
||||||
public int CreateSearchdomain(string searchdomain, string settings = "{}")
|
public int CreateSearchdomain(string searchdomain, string settings = "{}")
|
||||||
{
|
{
|
||||||
if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value))
|
if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value))
|
||||||
|
|||||||
@@ -745,8 +745,8 @@
|
|||||||
"datapoints": datapoints
|
"datapoints": datapoints
|
||||||
}];
|
}];
|
||||||
showToast("@T["Creating entity"]", "primary");
|
showToast("@T["Creating entity"]", "primary");
|
||||||
fetch(`/Entity/Index`, {
|
fetch(`/Entity`, {
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
@@ -778,8 +778,12 @@
|
|||||||
const cacheReconciliation = document.getElementById('createSearchdomainWithCacheReconciliation').checked;
|
const cacheReconciliation = document.getElementById('createSearchdomainWithCacheReconciliation').checked;
|
||||||
const settings = { CacheReconciliation: cacheReconciliation };
|
const settings = { CacheReconciliation: cacheReconciliation };
|
||||||
// Implement create logic here
|
// Implement create logic here
|
||||||
fetch(`/Searchdomain/Create?searchdomain=${encodeURIComponent(name)}&settings=${JSON.stringify(settings)}`, {
|
fetch(`/Searchdomain?searchdomain=${encodeURIComponent(name)}`, {
|
||||||
method: 'GET'
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(settings)
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
showToast("@T["Searchdomain was created successfully"]", "success");
|
showToast("@T["Searchdomain was created successfully"]", "success");
|
||||||
@@ -800,8 +804,8 @@
|
|||||||
.getElementById('cacheClear')
|
.getElementById('cacheClear')
|
||||||
.addEventListener('click', () => {
|
.addEventListener('click', () => {
|
||||||
const domainKey = getSelectedDomainKey();
|
const domainKey = getSelectedDomainKey();
|
||||||
fetch(`/Searchdomain/ClearSearchCache?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
fetch(`/Searchdomain/SearchCache/Clear?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||||
method: 'GET'
|
method: 'POST'
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
showToast("@T["Searchdomain cache was cleared successfully"]", "success");
|
showToast("@T["Searchdomain cache was cleared successfully"]", "success");
|
||||||
@@ -823,8 +827,8 @@
|
|||||||
.addEventListener('click', () => {
|
.addEventListener('click', () => {
|
||||||
const domainKey = getSelectedDomainKey();
|
const domainKey = getSelectedDomainKey();
|
||||||
const entityName = document.getElementById('EntityConfirmDelete').getAttribute('data-name');
|
const entityName = document.getElementById('EntityConfirmDelete').getAttribute('data-name');
|
||||||
fetch(`/Entity/Delete?searchdomain=${encodeURIComponent(domains[domainKey])}&entityName=${entityName}`, {
|
fetch(`/Entity?searchdomain=${encodeURIComponent(domains[domainKey])}&entityName=${entityName}`, {
|
||||||
method: 'GET'
|
method: 'DELETE'
|
||||||
}).then(async response => {
|
}).then(async response => {
|
||||||
let result = await response.json();
|
let result = await response.json();
|
||||||
if (response.ok && result.Success) {
|
if (response.ok && result.Success) {
|
||||||
@@ -870,8 +874,8 @@
|
|||||||
"datapoints": datapoints
|
"datapoints": datapoints
|
||||||
}];
|
}];
|
||||||
showToast("@T["Updating entity"]", "primary");
|
showToast("@T["Updating entity"]", "primary");
|
||||||
fetch(`/Entity/Index`, {
|
fetch(`/Entity`, {
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
@@ -897,7 +901,7 @@
|
|||||||
.addEventListener('click', () => {
|
.addEventListener('click', () => {
|
||||||
let searchdomain = domains[getSelectedDomainKey()];
|
let searchdomain = domains[getSelectedDomainKey()];
|
||||||
let query = document.getElementById('deleteQueryConfirmationModalName').textContent;
|
let query = document.getElementById('deleteQueryConfirmationModalName').textContent;
|
||||||
fetch(`/Searchdomain/Searches?searchdomain=${searchdomain}&query=${query}`, {
|
fetch(`/Searchdomain/Query?searchdomain=${searchdomain}&query=${query}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -924,7 +928,7 @@
|
|||||||
let query = document.getElementById('queryUpdateQueryName').textContent;
|
let query = document.getElementById('queryUpdateQueryName').textContent;
|
||||||
let data = getQueryUpdateTableData();
|
let data = getQueryUpdateTableData();
|
||||||
console.log()
|
console.log()
|
||||||
fetch(`/Searchdomain/Searches?searchdomain=${searchdomain}&query=${query}`, {
|
fetch(`/Searchdomain/Query?searchdomain=${searchdomain}&query=${query}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
@@ -949,8 +953,8 @@
|
|||||||
|
|
||||||
function deleteSearchdomain(domainKey) {
|
function deleteSearchdomain(domainKey) {
|
||||||
// Implement delete logic here
|
// Implement delete logic here
|
||||||
fetch(`/Searchdomain/Delete?searchdomain=${encodeURI(domains[domainKey])}`, {
|
fetch(`/Searchdomain?searchdomain=${encodeURI(domains[domainKey])}`, {
|
||||||
method: 'GET'
|
method: 'DELETE'
|
||||||
}).then(async response => {
|
}).then(async response => {
|
||||||
var result = await response.json();;
|
var result = await response.json();;
|
||||||
if (response.ok && result.Success === true) {
|
if (response.ok && result.Success === true) {
|
||||||
@@ -971,8 +975,8 @@
|
|||||||
|
|
||||||
function renameSearchdomain(domainKey, newName) {
|
function renameSearchdomain(domainKey, newName) {
|
||||||
// Implement rename logic here
|
// Implement rename logic here
|
||||||
fetch(`/Searchdomain/Update?searchdomain=${encodeURI(domains[domainKey])}&newName=${newName}`, {
|
fetch(`/Searchdomain?searchdomain=${encodeURI(domains[domainKey])}&newName=${newName}`, {
|
||||||
method: 'GET'
|
method: 'PUT'
|
||||||
}).then(async response => {
|
}).then(async response => {
|
||||||
var result = await response.json();
|
var result = await response.json();
|
||||||
if (response.ok && result.Success === true) {
|
if (response.ok && result.Success === true) {
|
||||||
@@ -996,8 +1000,8 @@
|
|||||||
|
|
||||||
function updateSearchdomainConfig(domainKey, newSettings) {
|
function updateSearchdomainConfig(domainKey, newSettings) {
|
||||||
// Implement update logic here
|
// Implement update logic here
|
||||||
fetch(`/Searchdomain/UpdateSettings?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
fetch(`/Searchdomain/Settings?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||||
method: 'POST',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
@@ -1022,17 +1026,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSearchdomainConfig(domainKey) {
|
function getSearchdomainConfig(domainKey) {
|
||||||
return fetch(`/Searchdomain/GetSettings?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
return fetch(`/Searchdomain/Settings?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||||
.then(r => r.json());
|
.then(r => r.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchdomainCacheUtilization(domainKey) {
|
function getSearchdomainCacheUtilization(domainKey) {
|
||||||
return fetch(`/Searchdomain/GetSearchCacheSize?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
return fetch(`/Searchdomain/SearchCache/Size?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||||
.then(r => r.json());
|
.then(r => r.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchdomainDatabaseUtilization(domainKey) {
|
function getSearchdomainDatabaseUtilization(domainKey) {
|
||||||
return fetch(`/Searchdomain/GetDatabaseSize?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
return fetch(`/Searchdomain/Database/Size?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||||
.then(r => r.json());
|
.then(r => r.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,7 +1058,7 @@
|
|||||||
let databaseUtilizationPromise = getSearchdomainDatabaseUtilization(getSelectedDomainKey());
|
let databaseUtilizationPromise = getSearchdomainDatabaseUtilization(getSelectedDomainKey());
|
||||||
|
|
||||||
/* ---------- ENTITIES ---------- */
|
/* ---------- ENTITIES ---------- */
|
||||||
let entitiesUrl = `/Entity/List?searchdomain=${encodeURIComponent(domainName)}&returnEmbeddings=false&returnModels=true`;
|
let entitiesUrl = `/Entities?searchdomain=${encodeURIComponent(domainName)}&returnEmbeddings=false&returnModels=true`;
|
||||||
let entitiesCard = document.querySelector("#entitiesTable").parentElement;
|
let entitiesCard = document.querySelector("#entitiesTable").parentElement;
|
||||||
clearEntitiesTable();
|
clearEntitiesTable();
|
||||||
showThrobber(entitiesCard);
|
showThrobber(entitiesCard);
|
||||||
@@ -1073,7 +1077,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* ---------- QUERIES ---------- */
|
/* ---------- QUERIES ---------- */
|
||||||
let queriesUrl = `/Searchdomain/GetSearches?searchdomain=${encodeURIComponent(domainName)}`;
|
let queriesUrl = `/Searchdomain/Queries?searchdomain=${encodeURIComponent(domainName)}`;
|
||||||
let queriesCard = document.querySelector("#queriesTable").parentElement;
|
let queriesCard = document.querySelector("#queriesTable").parentElement;
|
||||||
clearQueriesTable();
|
clearQueriesTable();
|
||||||
showThrobber(queriesCard);
|
showThrobber(queriesCard);
|
||||||
|
|||||||
Reference in New Issue
Block a user