This commit is contained in:
2021-03-02 23:03:11 +00:00
parent ddf0017e93
commit 1b07953f59
8 changed files with 41 additions and 32 deletions

View File

@@ -16,7 +16,7 @@ Here are all the API level error codes that can be returned by the API server:
| 2003 | Authentication failed (HTTP STATUS 401), bad login or password, user not found |
| 2004 | Not authorized (HTTP STATUS 403) - current user is not authorized for operation attempted on the resource (insufficient rights) |
| 2005 | Object was changed by another user since retrieval (concurrency token mismatch). A record was attempted to be saved but another user has just modified it so it's invalid. (first save "wins") |
| 2006 | Authentication token replaced - A valid JWT token was presented, but it has been replaced by a more recent login |
| 2006 | API closed to allow migration from v7 using V8Migrate utility, SuperUser only login |
| 2010 | Object not found - API could not find the object requested |
| 2020 | PUT Id mismatch - object Id does not match route Id |
| 2030 | Invalid operation - operation could not be completed, not valid, details in message property |

View File

@@ -19,10 +19,12 @@ namespace AyaNova.Api.ControllerHelpers
UNKNOWN = 0,
///<summary>No access for anyone API completely locked down. Not set by user but rather by internal server operations like importing or backup.</summary>
Closed = 1,
///<summary>Access only to SuperUser account for migration from AyaNova 7</summary>
MigrateMode = 2,
///<summary>Access only to API Operations routes. Can be set by Ops user</summary>
OpsOnly = 2,
OpsOnly = 3,
///<summary>Open for all users (default). Can be set by Ops user</summary>
Open = 3
Open = 4
}
private ServerState _currentState = ServerState.Closed;
@@ -121,6 +123,8 @@ namespace AyaNova.Api.ControllerHelpers
throw new System.NotSupportedException("ApiServerState:ApiErrorCode - No error code is associated with server state OPEN");
case ServerState.OpsOnly:
return ApiErrorCode.API_OPS_ONLY;
case ServerState.MigrateMode:
return ApiErrorCode.API_MIGRATE_MODE;
case ServerState.Closed:
return ApiErrorCode.API_CLOSED;

View File

@@ -55,7 +55,7 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Set server state
/// Valid parameters:
/// One of "OpsOnly" or "Open"
/// One of "OpsOnly", "MigrateMode" or "Open"
/// </summary>
/// <param name="state">{"serverState":"Open"}</param>
/// <returns>New server state</returns>
@@ -73,11 +73,11 @@ namespace AyaNova.Api.Controllers
ApiServerState.ServerState desiredState;
if (!Enum.TryParse<ApiServerState.ServerState>(state.ServerState, true, out desiredState))
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\" or \"Open\""));
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\", \"MigrateMode\" or \"Open\""));
//don't allow a server to be set to closed, that's for internal ops only
if (desiredState == ApiServerState.ServerState.Closed)
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\" or \"Open\""));
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\", \"MigrateMode\" or \"Open\""));
log.LogInformation($"ServerState change request by user {UserNameFromContext.Name(HttpContext.Items)} from current state of \"{serverState.GetState().ToString()}\" to \"{desiredState.ToString()}-{state.Reason}\"");
@@ -97,7 +97,7 @@ namespace AyaNova.Api.Controllers
public class ServerStateModel
{
/// <summary>
/// "OpsOnly" or "Open"
/// "OpsOnly", "MigrateMode" or "Open"
/// </summary>
/// <returns></returns>
[Required]

View File

@@ -15,6 +15,7 @@ namespace AyaNova.Biz
AUTHENTICATION_FAILED = 2003,
NOT_AUTHORIZED = 2004,
CONCURRENCY_CONFLICT = 2005,
API_MIGRATE_MODE = 2006,
NOT_FOUND = 2010,
PUT_ID_MISMATCH = 2020,
INVALID_OPERATION = 2030,

View File

@@ -1779,6 +1779,7 @@
"ServerState": "Serverstatus",
"ServerStateOpen": "Öffnen",
"ServerStateOps": "Nur Systembetrieb",
"ServerStateMigrateMode": "Server-Migrationsmodus",
"ServerStateReason": "Grund",
"TooManyResults": "Zu viele Ergebnisse, um alle anzuzeigen",
"NoResults": "Keine Ergebnisse",

View File

@@ -1779,6 +1779,7 @@
"ServerState": "Server state",
"ServerStateOpen": "Open",
"ServerStateOps": "Server operations only",
"ServerStateMigrateMode": "Server migration mode",
"ServerStateReason": "Reason",
"TooManyResults": "Too many results to show all",
"NoResults": "No results",

View File

@@ -1779,6 +1779,7 @@
"ServerState": "Estado del servidor",
"ServerStateOpen": "Abrir",
"ServerStateOps": "Solo operaciones del sistema",
"ServerStateMigrateMode": "Modo de migración del servidor",
"ServerStateReason": "Razón",
"TooManyResults": "Demasiados resultados para mostrar todos",
"NoResults": "No hay resultados",

View File

@@ -1779,6 +1779,7 @@
"ServerState": "État du serveur",
"ServerStateOpen": "Ouvrir",
"ServerStateOps": "Opérations système uniquement",
"ServerStateMigrateMode": "Mode de migration du serveur",
"ServerStateReason": "Objectif",
"TooManyResults": "Trop de résultats pour tout montrer",
"NoResults": "Aucun résultat",