last split GetConfiguration + Error on others
MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-change-configuration.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-change-configuration.json
"properties": {
"key": {
"type": "string",
- "sanitize": "mongo"
+ "sanitize": "mongo",
+ "maxLength": 50
},
"value": {
"type": "string",
- "sanitize": "mongo"
+ "sanitize": "mongo",
+ "maxLength": 500
}
},
"required": [

ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-get-configuration.json
+{
+ "title": "Get Configuration",
+ "type": "object",
+ "properties": {
+ "chargingStationID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "args": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "array",
+ "sanitize": "mongo",
+ "items": {
+ "type": "string",
+ "maxLength": 50
+ }
+ }
+ }
+ }
+ },
+ "required": [
+ "chargingStationID"
+ ]
+}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1208,6 +1208,12 @@ export default class ChargingStationService {
filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionStartTransactionReq(req.body);
result = await ChargingStationService.executeChargingStationStartTransaction(action, chargingStation, command, filteredRequest, req, res, next);
break;
+ // Get Configuration
+ case Command.GET_CONFIGURATION:
+ filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionGetConfigurationReq(req.body);
+ result = await ChargingStationService.executeChargingStationCommand(
+ req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
+ break;
// Get the Charging Plans
case Command.GET_COMPOSITE_SCHEDULE:
filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionGetCompositeScheduleReq(req.body);
@@ -1240,7 +1246,7 @@ export default class ChargingStationService {
// Other commands
default:
// Log Specific Schema has not been verified yet:
- await Logging.logWarning({
+ await Logging.logError({
tenantID: req.tenant.id,
siteID: chargingStation.siteID,
siteAreaID: chargingStation.siteAreaID,
@@ -1253,10 +1259,13 @@ export default class ChargingStationService {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
message: `Command '${command}' has not yet its own validation schema.`
});
- // Execute it
- result = await ChargingStationService.executeChargingStationCommand(
- req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
- break;
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ errorCode: HTTPError.GENERAL_ERROR,
+ message: `Command '${command}' has not yet its own validation schema.`,
+ module: MODULE_NAME,
+ method: 'handleAction'
+ });
}
res.json(result);
next();

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingProfilesRequest, HttpChargingStationChangeAvailabilityRequest, HttpChargingStationChangeConfigurationRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandDataTransferRequest, HttpChargingStationCommandRequest, HttpChargingStationCommandUnlockConnectorRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingProfilesRequest, HttpChargingStationChangeAvailabilityRequest, HttpChargingStationChangeConfigurationRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandDataTransferRequest, HttpChargingStationCommandGetConfigurationRequest, HttpChargingStationCommandRequest, HttpChargingStationCommandUnlockConnectorRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
import { ChargingProfile } from '../../../../types/ChargingProfile';
import HttpDatabaseRequest from '../../../../types/requests/HttpDatabaseRequest';
@@ -19,6 +19,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationActionDataTransfer: Schema;
private chargingStationActionStartTransaction: Schema;
private chargingStationActionStopTransaction: Schema;
+ private chargingStationActionGetConfiguration: Schema;
private chargingStationActionGetCompositeSchedule: Schema;
private chargingStationActionUnlockConnector: Schema;
private chargingStationActionUpdateFirmware: Schema;
@@ -51,6 +52,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationActionDataTransfer = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-data-transfer.json`, 'utf8'));
this.chargingStationActionStartTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-start-transaction.json`, 'utf8'));
this.chargingStationActionStopTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-stop-transaction.json`, 'utf8'));
+ this.chargingStationActionGetConfiguration = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-get-configuration.json`, 'utf8'));
this.chargingStationActionGetCompositeSchedule = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-get-composite-schedule.json`, 'utf8'));
this.chargingStationActionUnlockConnector = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-unlock-connector.json`, 'utf8'));
this.chargingStationActionUpdateFirmware = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-update-firmware.json`, 'utf8'));
@@ -139,6 +141,12 @@ export default class ChargingStationValidator extends SchemaValidator {
return data;
}
+ public validateChargingStationActionGetConfigurationReq(data: any): HttpChargingStationCommandGetConfigurationRequest {
+ // Validate schema for Get Configuration
+ this.validate(this.chargingStationActionGetConfiguration, data);
+ return data;
+ }
+
public validateChargingStationActionGetCompositeScheduleReq(data: any): HttpChargingStationGetCompositeScheduleRequest {
// Validate schema for Get Composite Schedule
this.validate(this.chargingStationActionGetCompositeSchedule, data);

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -158,6 +158,13 @@ export interface HttpChargingStationStopTransactionRequest {
}
}
+export interface HttpChargingStationCommandGetConfigurationRequest {
+ chargingStationID: string,
+ args: {
+ key: string[]
+ }
+}
+
export interface HttpChargingStationGetCompositeScheduleRequest {
chargingStationID: string,
args: {

last split GetConfiguration + Error on others