This commit is contained in:
@@ -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 |
|
| 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) |
|
| 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") |
|
| 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 |
|
| 2010 | Object not found - API could not find the object requested |
|
||||||
| 2020 | PUT Id mismatch - object Id does not match route Id |
|
| 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 |
|
| 2030 | Invalid operation - operation could not be completed, not valid, details in message property |
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
UNKNOWN = 0,
|
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>
|
///<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,
|
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>
|
///<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>
|
///<summary>Open for all users (default). Can be set by Ops user</summary>
|
||||||
Open = 3
|
Open = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerState _currentState = ServerState.Closed;
|
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");
|
throw new System.NotSupportedException("ApiServerState:ApiErrorCode - No error code is associated with server state OPEN");
|
||||||
case ServerState.OpsOnly:
|
case ServerState.OpsOnly:
|
||||||
return ApiErrorCode.API_OPS_ONLY;
|
return ApiErrorCode.API_OPS_ONLY;
|
||||||
|
case ServerState.MigrateMode:
|
||||||
|
return ApiErrorCode.API_MIGRATE_MODE;
|
||||||
case ServerState.Closed:
|
case ServerState.Closed:
|
||||||
return ApiErrorCode.API_CLOSED;
|
return ApiErrorCode.API_CLOSED;
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set server state
|
/// Set server state
|
||||||
/// Valid parameters:
|
/// Valid parameters:
|
||||||
/// One of "OpsOnly" or "Open"
|
/// One of "OpsOnly", "MigrateMode" or "Open"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="state">{"serverState":"Open"}</param>
|
/// <param name="state">{"serverState":"Open"}</param>
|
||||||
/// <returns>New server state</returns>
|
/// <returns>New server state</returns>
|
||||||
@@ -73,11 +73,11 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
ApiServerState.ServerState desiredState;
|
ApiServerState.ServerState desiredState;
|
||||||
if (!Enum.TryParse<ApiServerState.ServerState>(state.ServerState, true, out 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
|
//don't allow a server to be set to closed, that's for internal ops only
|
||||||
if (desiredState == ApiServerState.ServerState.Closed)
|
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}\"");
|
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
|
public class ServerStateModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "OpsOnly" or "Open"
|
/// "OpsOnly", "MigrateMode" or "Open"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Required]
|
[Required]
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace AyaNova.Biz
|
|||||||
API_SERVER_ERROR = 2002,
|
API_SERVER_ERROR = 2002,
|
||||||
AUTHENTICATION_FAILED = 2003,
|
AUTHENTICATION_FAILED = 2003,
|
||||||
NOT_AUTHORIZED = 2004,
|
NOT_AUTHORIZED = 2004,
|
||||||
CONCURRENCY_CONFLICT=2005,
|
CONCURRENCY_CONFLICT = 2005,
|
||||||
|
API_MIGRATE_MODE = 2006,
|
||||||
NOT_FOUND = 2010,
|
NOT_FOUND = 2010,
|
||||||
PUT_ID_MISMATCH = 2020,
|
PUT_ID_MISMATCH = 2020,
|
||||||
INVALID_OPERATION = 2030,
|
INVALID_OPERATION = 2030,
|
||||||
@@ -29,27 +30,27 @@ namespace AyaNova.Biz
|
|||||||
VALIDATION_REFERENTIAL_INTEGRITY = 2208,
|
VALIDATION_REFERENTIAL_INTEGRITY = 2208,
|
||||||
VALIDATION_NOT_CHANGEABLE = 2209,
|
VALIDATION_NOT_CHANGEABLE = 2209,
|
||||||
CHILD_OBJECT_ERROR = 2210
|
CHILD_OBJECT_ERROR = 2210
|
||||||
/*
|
/*
|
||||||
|
|
||||||
| 2000 | API closed - Server is running but access to the API has been closed to all users |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |
|
| 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") |
|
| 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 |
|
| 2010 | Object not found - API could not find the object requested |
|
||||||
| 2020 | PUT Id mismatch - object Id does not match route Id |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 | */
|
| 2209 | Validation error - Indicates the attempted property change is invalid because the value is fixed and cannot be changed | */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1779,6 +1779,7 @@
|
|||||||
"ServerState": "Serverstatus",
|
"ServerState": "Serverstatus",
|
||||||
"ServerStateOpen": "Öffnen",
|
"ServerStateOpen": "Öffnen",
|
||||||
"ServerStateOps": "Nur Systembetrieb",
|
"ServerStateOps": "Nur Systembetrieb",
|
||||||
|
"ServerStateMigrateMode": "Server-Migrationsmodus",
|
||||||
"ServerStateReason": "Grund",
|
"ServerStateReason": "Grund",
|
||||||
"TooManyResults": "Zu viele Ergebnisse, um alle anzuzeigen",
|
"TooManyResults": "Zu viele Ergebnisse, um alle anzuzeigen",
|
||||||
"NoResults": "Keine Ergebnisse",
|
"NoResults": "Keine Ergebnisse",
|
||||||
|
|||||||
@@ -1779,6 +1779,7 @@
|
|||||||
"ServerState": "Server state",
|
"ServerState": "Server state",
|
||||||
"ServerStateOpen": "Open",
|
"ServerStateOpen": "Open",
|
||||||
"ServerStateOps": "Server operations only",
|
"ServerStateOps": "Server operations only",
|
||||||
|
"ServerStateMigrateMode": "Server migration mode",
|
||||||
"ServerStateReason": "Reason",
|
"ServerStateReason": "Reason",
|
||||||
"TooManyResults": "Too many results to show all",
|
"TooManyResults": "Too many results to show all",
|
||||||
"NoResults": "No results",
|
"NoResults": "No results",
|
||||||
|
|||||||
@@ -1779,6 +1779,7 @@
|
|||||||
"ServerState": "Estado del servidor",
|
"ServerState": "Estado del servidor",
|
||||||
"ServerStateOpen": "Abrir",
|
"ServerStateOpen": "Abrir",
|
||||||
"ServerStateOps": "Solo operaciones del sistema",
|
"ServerStateOps": "Solo operaciones del sistema",
|
||||||
|
"ServerStateMigrateMode": "Modo de migración del servidor",
|
||||||
"ServerStateReason": "Razón",
|
"ServerStateReason": "Razón",
|
||||||
"TooManyResults": "Demasiados resultados para mostrar todos",
|
"TooManyResults": "Demasiados resultados para mostrar todos",
|
||||||
"NoResults": "No hay resultados",
|
"NoResults": "No hay resultados",
|
||||||
|
|||||||
@@ -1779,6 +1779,7 @@
|
|||||||
"ServerState": "État du serveur",
|
"ServerState": "État du serveur",
|
||||||
"ServerStateOpen": "Ouvrir",
|
"ServerStateOpen": "Ouvrir",
|
||||||
"ServerStateOps": "Opérations système uniquement",
|
"ServerStateOps": "Opérations système uniquement",
|
||||||
|
"ServerStateMigrateMode": "Mode de migration du serveur",
|
||||||
"ServerStateReason": "Objectif",
|
"ServerStateReason": "Objectif",
|
||||||
"TooManyResults": "Trop de résultats pour tout montrer",
|
"TooManyResults": "Trop de résultats pour tout montrer",
|
||||||
"NoResults": "Aucun résultat",
|
"NoResults": "Aucun résultat",
|
||||||
|
|||||||
Reference in New Issue
Block a user