Fixed endpoint naming and http methods
This commit is contained in:
@@ -24,7 +24,7 @@ public class EntityController : ControllerBase
|
||||
_databaseHelper = databaseHelper;
|
||||
}
|
||||
|
||||
[HttpPost("Index")]
|
||||
[HttpPut]
|
||||
public ActionResult<EntityIndexResult> Index([FromBody] List<JSONEntity>? jsonEntities)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (returnEmbeddings && !returnModels)
|
||||
@@ -109,7 +109,7 @@ public class EntityController : ControllerBase
|
||||
return Ok(entityListResults);
|
||||
}
|
||||
|
||||
[HttpGet("Delete")]
|
||||
[HttpDelete]
|
||||
public ActionResult<EntityDeleteResults> Delete(string searchdomain, string entityName)
|
||||
{
|
||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SearchdomainController : ControllerBase
|
||||
_domainManager = domainManager;
|
||||
}
|
||||
|
||||
[HttpGet("List")]
|
||||
[HttpGet("/Searchdomains")]
|
||||
public ActionResult<SearchdomainListResults> List()
|
||||
{
|
||||
List<string> results;
|
||||
@@ -40,8 +40,8 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(searchdomainListResults);
|
||||
}
|
||||
|
||||
[HttpGet("Create")]
|
||||
public ActionResult<SearchdomainCreateResults> Create(string searchdomain, string settings = "{}")
|
||||
[HttpPost]
|
||||
public ActionResult<SearchdomainCreateResults> Create(string searchdomain, [FromBody]SearchdomainSettings settings = new())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public class SearchdomainController : ControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("Delete")]
|
||||
[HttpDelete]
|
||||
public ActionResult<SearchdomainDeleteResults> Delete(string searchdomain)
|
||||
{
|
||||
bool success;
|
||||
@@ -84,22 +84,33 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(new SearchdomainDeleteResults(){Success = success, DeletedEntities = deletedEntries, Message = message});
|
||||
}
|
||||
|
||||
[HttpGet("Update")]
|
||||
public ActionResult<SearchdomainUpdateResults> Update(string searchdomain, string newName, string settings = "{}")
|
||||
[HttpPut]
|
||||
public ActionResult<SearchdomainUpdateResults> Update(string searchdomain, string newName, [FromBody]string? settings = "{}")
|
||||
{
|
||||
(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});
|
||||
Dictionary<string, dynamic> parameters = new()
|
||||
if (settings is null)
|
||||
{
|
||||
{"name", newName},
|
||||
{"settings", settings},
|
||||
{"id", searchdomain_.id}
|
||||
};
|
||||
searchdomain_.helper.ExecuteSQLNonQuery("UPDATE searchdomain set name = @name, settings = @settings WHERE id = @id", parameters);
|
||||
Dictionary<string, dynamic> parameters = new()
|
||||
{
|
||||
{"name", newName},
|
||||
{"id", searchdomain_.id}
|
||||
};
|
||||
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});
|
||||
}
|
||||
|
||||
[HttpGet("Query")]
|
||||
[HttpPost("Query")]
|
||||
public ActionResult<EntityQueryResults> Query(string searchdomain, string query, int? topN, bool returnAttributes = false)
|
||||
{
|
||||
(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 });
|
||||
}
|
||||
|
||||
[HttpPost("UpdateSettings")]
|
||||
[HttpPut("Settings")]
|
||||
public ActionResult<SearchdomainUpdateResults> UpdateSettings(string searchdomain, [FromBody] SearchdomainSettings request)
|
||||
{
|
||||
(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});
|
||||
}
|
||||
|
||||
[HttpGet("GetSearches")]
|
||||
public ActionResult<SearchdomainSearchesResults> GetSearches(string searchdomain)
|
||||
[HttpGet("Queries")]
|
||||
public ActionResult<SearchdomainSearchesResults> GetQueries(string searchdomain)
|
||||
{
|
||||
(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});
|
||||
@@ -139,8 +150,8 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(new SearchdomainSearchesResults() { Searches = searchCache, Success = true });
|
||||
}
|
||||
|
||||
[HttpDelete("Searches")]
|
||||
public ActionResult<SearchdomainDeleteSearchResult> DeleteSearch(string searchdomain, string query)
|
||||
[HttpDelete("Query")]
|
||||
public ActionResult<SearchdomainDeleteSearchResult> DeleteQuery(string searchdomain, string query)
|
||||
{
|
||||
(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});
|
||||
@@ -154,8 +165,8 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(new SearchdomainDeleteSearchResult() {Success = false, Message = "Query not found in search cache"});
|
||||
}
|
||||
|
||||
[HttpPatch("Searches")]
|
||||
public ActionResult<SearchdomainUpdateSearchResult> UpdateSearch(string searchdomain, string query, [FromBody]List<ResultItem> results)
|
||||
[HttpPatch("Query")]
|
||||
public ActionResult<SearchdomainUpdateSearchResult> UpdateQuery(string searchdomain, string query, [FromBody]List<ResultItem> results)
|
||||
{
|
||||
(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});
|
||||
@@ -171,7 +182,7 @@ public class SearchdomainController : ControllerBase
|
||||
return Ok(new SearchdomainUpdateSearchResult() {Success = false, Message = "Query not found in search cache"});
|
||||
}
|
||||
|
||||
[HttpGet("GetSettings")]
|
||||
[HttpGet("Settings")]
|
||||
public ActionResult<SearchdomainSettingsResults> GetSettings(string searchdomain)
|
||||
{
|
||||
(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 });
|
||||
}
|
||||
|
||||
[HttpGet("GetSearchCacheSize")]
|
||||
[HttpGet("SearchCache/Size")]
|
||||
public ActionResult<SearchdomainSearchCacheSizeResults> GetSearchCacheSize(string searchdomain)
|
||||
{
|
||||
(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 });
|
||||
}
|
||||
|
||||
[HttpGet("ClearSearchCache")]
|
||||
[HttpPost("SearchCache/Clear")]
|
||||
public ActionResult<SearchdomainInvalidateCacheResults> InvalidateSearchCache(string searchdomain)
|
||||
{
|
||||
(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});
|
||||
}
|
||||
|
||||
[HttpGet("GetDatabaseSize")]
|
||||
[HttpGet("Database/Size")]
|
||||
public ActionResult<SearchdomainGetDatabaseSizeResult> GetDatabaseSize(string searchdomain)
|
||||
{
|
||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ServerController : ControllerBase
|
||||
_aIProvider = aIProvider;
|
||||
}
|
||||
|
||||
[HttpGet("GetModels")]
|
||||
[HttpGet("Models")]
|
||||
public ActionResult<ServerGetModelsResult> GetModels()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -4,6 +4,8 @@ using Server.Migrations;
|
||||
using Server.Helper;
|
||||
using Server.Exceptions;
|
||||
using AdaptiveExpressions;
|
||||
using Shared.Models;
|
||||
using System.Text.Json;
|
||||
|
||||
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 = "{}")
|
||||
{
|
||||
if (searchdomains.TryGetValue(searchdomain, out Searchdomain? value))
|
||||
|
||||
@@ -745,8 +745,8 @@
|
||||
"datapoints": datapoints
|
||||
}];
|
||||
showToast("@T["Creating entity"]", "primary");
|
||||
fetch(`/Entity/Index`, {
|
||||
method: 'POST',
|
||||
fetch(`/Entity`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
@@ -778,8 +778,12 @@
|
||||
const cacheReconciliation = document.getElementById('createSearchdomainWithCacheReconciliation').checked;
|
||||
const settings = { CacheReconciliation: cacheReconciliation };
|
||||
// Implement create logic here
|
||||
fetch(`/Searchdomain/Create?searchdomain=${encodeURIComponent(name)}&settings=${JSON.stringify(settings)}`, {
|
||||
method: 'GET'
|
||||
fetch(`/Searchdomain?searchdomain=${encodeURIComponent(name)}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(settings)
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
showToast("@T["Searchdomain was created successfully"]", "success");
|
||||
@@ -800,8 +804,8 @@
|
||||
.getElementById('cacheClear')
|
||||
.addEventListener('click', () => {
|
||||
const domainKey = getSelectedDomainKey();
|
||||
fetch(`/Searchdomain/ClearSearchCache?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||
method: 'GET'
|
||||
fetch(`/Searchdomain/SearchCache/Clear?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||
method: 'POST'
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
showToast("@T["Searchdomain cache was cleared successfully"]", "success");
|
||||
@@ -823,8 +827,8 @@
|
||||
.addEventListener('click', () => {
|
||||
const domainKey = getSelectedDomainKey();
|
||||
const entityName = document.getElementById('EntityConfirmDelete').getAttribute('data-name');
|
||||
fetch(`/Entity/Delete?searchdomain=${encodeURIComponent(domains[domainKey])}&entityName=${entityName}`, {
|
||||
method: 'GET'
|
||||
fetch(`/Entity?searchdomain=${encodeURIComponent(domains[domainKey])}&entityName=${entityName}`, {
|
||||
method: 'DELETE'
|
||||
}).then(async response => {
|
||||
let result = await response.json();
|
||||
if (response.ok && result.Success) {
|
||||
@@ -870,8 +874,8 @@
|
||||
"datapoints": datapoints
|
||||
}];
|
||||
showToast("@T["Updating entity"]", "primary");
|
||||
fetch(`/Entity/Index`, {
|
||||
method: 'POST',
|
||||
fetch(`/Entity`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
@@ -897,7 +901,7 @@
|
||||
.addEventListener('click', () => {
|
||||
let searchdomain = domains[getSelectedDomainKey()];
|
||||
let query = document.getElementById('deleteQueryConfirmationModalName').textContent;
|
||||
fetch(`/Searchdomain/Searches?searchdomain=${searchdomain}&query=${query}`, {
|
||||
fetch(`/Searchdomain/Query?searchdomain=${searchdomain}&query=${query}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -924,7 +928,7 @@
|
||||
let query = document.getElementById('queryUpdateQueryName').textContent;
|
||||
let data = getQueryUpdateTableData();
|
||||
console.log()
|
||||
fetch(`/Searchdomain/Searches?searchdomain=${searchdomain}&query=${query}`, {
|
||||
fetch(`/Searchdomain/Query?searchdomain=${searchdomain}&query=${query}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -949,8 +953,8 @@
|
||||
|
||||
function deleteSearchdomain(domainKey) {
|
||||
// Implement delete logic here
|
||||
fetch(`/Searchdomain/Delete?searchdomain=${encodeURI(domains[domainKey])}`, {
|
||||
method: 'GET'
|
||||
fetch(`/Searchdomain?searchdomain=${encodeURI(domains[domainKey])}`, {
|
||||
method: 'DELETE'
|
||||
}).then(async response => {
|
||||
var result = await response.json();;
|
||||
if (response.ok && result.Success === true) {
|
||||
@@ -971,8 +975,8 @@
|
||||
|
||||
function renameSearchdomain(domainKey, newName) {
|
||||
// Implement rename logic here
|
||||
fetch(`/Searchdomain/Update?searchdomain=${encodeURI(domains[domainKey])}&newName=${newName}`, {
|
||||
method: 'GET'
|
||||
fetch(`/Searchdomain?searchdomain=${encodeURI(domains[domainKey])}&newName=${newName}`, {
|
||||
method: 'PUT'
|
||||
}).then(async response => {
|
||||
var result = await response.json();
|
||||
if (response.ok && result.Success === true) {
|
||||
@@ -996,8 +1000,8 @@
|
||||
|
||||
function updateSearchdomainConfig(domainKey, newSettings) {
|
||||
// Implement update logic here
|
||||
fetch(`/Searchdomain/UpdateSettings?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||
method: 'POST',
|
||||
fetch(`/Searchdomain/Settings?searchdomain=${encodeURIComponent(domains[domainKey])}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
@@ -1022,17 +1026,17 @@
|
||||
}
|
||||
|
||||
function getSearchdomainConfig(domainKey) {
|
||||
return fetch(`/Searchdomain/GetSettings?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
return fetch(`/Searchdomain/Settings?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
.then(r => r.json());
|
||||
}
|
||||
|
||||
function getSearchdomainCacheUtilization(domainKey) {
|
||||
return fetch(`/Searchdomain/GetSearchCacheSize?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
return fetch(`/Searchdomain/SearchCache/Size?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
.then(r => r.json());
|
||||
}
|
||||
|
||||
function getSearchdomainDatabaseUtilization(domainKey) {
|
||||
return fetch(`/Searchdomain/GetDatabaseSize?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
return fetch(`/Searchdomain/Database/Size?searchdomain=${encodeURIComponent(domains[domainKey])}`)
|
||||
.then(r => r.json());
|
||||
}
|
||||
|
||||
@@ -1054,7 +1058,7 @@
|
||||
let databaseUtilizationPromise = getSearchdomainDatabaseUtilization(getSelectedDomainKey());
|
||||
|
||||
/* ---------- 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;
|
||||
clearEntitiesTable();
|
||||
showThrobber(entitiesCard);
|
||||
@@ -1073,7 +1077,7 @@
|
||||
});
|
||||
|
||||
/* ---------- QUERIES ---------- */
|
||||
let queriesUrl = `/Searchdomain/GetSearches?searchdomain=${encodeURIComponent(domainName)}`;
|
||||
let queriesUrl = `/Searchdomain/Queries?searchdomain=${encodeURIComponent(domainName)}`;
|
||||
let queriesCard = document.querySelector("#queriesTable").parentElement;
|
||||
clearQueriesTable();
|
||||
showThrobber(queriesCard);
|
||||
|
||||
Reference in New Issue
Block a user