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

@@ -14,7 +14,8 @@ namespace AyaNova.Biz
API_SERVER_ERROR = 2002,
AUTHENTICATION_FAILED = 2003,
NOT_AUTHORIZED = 2004,
CONCURRENCY_CONFLICT=2005,
CONCURRENCY_CONFLICT = 2005,
API_MIGRATE_MODE = 2006,
NOT_FOUND = 2010,
PUT_ID_MISMATCH = 2020,
INVALID_OPERATION = 2030,
@@ -29,27 +30,27 @@ namespace AyaNova.Biz
VALIDATION_REFERENTIAL_INTEGRITY = 2208,
VALIDATION_NOT_CHANGEABLE = 2209,
CHILD_OBJECT_ERROR = 2210
/*
/*
| 2000 | API closed - Server is running but access to the API has been closed to all users |
| 2001 | API closed all non OPS routes - Server is running but access to the API has been restricted to only server maintenance operations related functionality |
| 2002 | Internal error from the API server, details in [server log](common-log.md) file |
| 2003 | Authentication failed, bad login or password, user not found |
| 2004 | Not authorized - 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") |
| 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 |
| 2200 | Validation error - general issue with object overall not valid, specifics in "details" property |
| 2201 | Validation error - Field is required but is empty or null |
| 2202 | Validation error - Field length exceeded. The limit will be returned in the `message` property of the validation error |
| 2203 | Validation error - invalid value. Usually an type mismatch or a logical or business rule mismatch (i.e. only certain values are valid for current state of object) |
| 2204 | Validation error - Customized form property is set to required but has an empty value |
| 2205 | Validation error - Required property is missing entirely. Usually a development or communications error |
| 2206 | Validation error - A text property is required to be unique but an existing record with an identical value was found in the database |
| 2207 | Validation error - When an object requires a start and end date the start date must be earlier than the end date |
| 2208 | Validation error - Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity |
| 2209 | Validation error - Indicates the attempted property change is invalid because the value is fixed and cannot be changed | */
| 2000 | API closed - Server is running but access to the API has been closed to all users |
| 2001 | API closed all non OPS routes - Server is running but access to the API has been restricted to only server maintenance operations related functionality |
| 2002 | Internal error from the API server, details in [server log](common-log.md) file |
| 2003 | Authentication failed, bad login or password, user not found |
| 2004 | Not authorized - 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") |
| 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 |
| 2200 | Validation error - general issue with object overall not valid, specifics in "details" property |
| 2201 | Validation error - Field is required but is empty or null |
| 2202 | Validation error - Field length exceeded. The limit will be returned in the `message` property of the validation error |
| 2203 | Validation error - invalid value. Usually an type mismatch or a logical or business rule mismatch (i.e. only certain values are valid for current state of object) |
| 2204 | Validation error - Customized form property is set to required but has an empty value |
| 2205 | Validation error - Required property is missing entirely. Usually a development or communications error |
| 2206 | Validation error - A text property is required to be unique but an existing record with an identical value was found in the database |
| 2207 | Validation error - When an object requires a start and end date the start date must be earlier than the end date |
| 2208 | Validation error - Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity |
| 2209 | Validation error - Indicates the attempted property change is invalid because the value is fixed and cannot be changed | */
}

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",