Rolled back IDs in chargingstations routes
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
- "/api/chargingstations/cache/clear": {
+ "/api/chargingstations/{id}/cache/clear": {
"put": {
"security": [
{
}
],
"description": "Clear a Charging Station cache",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- }
- }
- }
- }
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
}
- },
+ ],
"tags": [
"Charging Stations"
],
}
}
},
- "/api/chargingstations/configuration/retrieve": {
+ "/api/chargingstations/{id}/configuration/retrieve": {
"put": {
"security": [
{
}
],
"description": "Get the Charging Station's configuration",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
}
- },
- "required": [
- "chargeBoxID"
- ]
+ }
}
}
}
}
}
},
- "/api/chargingstations/remote/start": {
+ "/api/chargingstations/{id}/remote/start": {
"put": {
"security": [
{
}
],
"description": "Start a remote transaction",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"carID": {
"type": "string",
"example": ""
}
}
},
- "/api/chargingstations/remote/stop": {
+ "/api/chargingstations/{id}/remote/stop": {
"put": {
"security": [
{
}
],
"description": "Stop a remote transaction",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
},
- "/api/chargingstations/connectors/unlock": {
+ "/api/chargingstations/{id}/connectors/{connectorId}/unlock": {
"put": {
"security": [
{
}
],
"description": "Unlock a connector",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
- "args": {
- "type": "object",
- "properties": {
- "connectorId": {
- "type": "integer",
- "description": "Required. This contains the identifier of the connector to be unlocked.",
- "minimum": 1,
- "example": 1
- }
- },
- "required": [
- "connectorId"
- ]
- }
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
},
- "required": [
- "args"
- ]
- }
- }
+ {
+ "$ref": "#/components/parameters/connectorID"
}
- },
+ ],
"tags": [
"Charging Stations"
],
}
}
},
- "/api/chargingstations/compositeschedule": {
+ "/api/chargingstations/{id}/compositeschedule": {
"put": {
"security": [
{
}
],
"description": "Get Charging Station composite schedule",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
},
- "/api/chargingstations/diagnostics": {
+ "/api/chargingstations/{id}/diagnostics": {
"put": {
"security": [
{
}
],
"description": "Get Charging Station diagnostics",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
},
- "/api/chargingstations/firmware/update": {
+ "/api/chargingstations/{id}/firmware/update": {
"put": {
"security": [
{
}
],
"description": "Update Charging Station firmware",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
},
- "/api/chargingstations/availability/change": {
+ "/api/chargingstations/{id}/availability/change": {
"put": {
"security": [
{
}
],
"description": "Update Charging Station availability",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "chargeBoxID": {
- "$ref": "#/components/schemas/ocppChargeBoxID"
- },
"args": {
"type": "object",
"properties": {
}
}
},
- "/api/chargingstations/parameters": {
+ "/api/chargingstations/{id}/parameters": {
"put": {
"security": [
{
}
],
"description": "Update Charging Station parameters",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
- "id": {
- "type": "string",
- "example": ""
- },
"maximumPower": {
"type": "number",
"example": 50000
}
}
},
- "/api/chargingstations/power/limit": {
+ "/api/chargingstations/{id}/power/limit": {
"put": {
"security": [
{
}
],
"description": "Limit Charging Station power",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
- "chargeBoxID",
"chargePointID",
"ampLimitValue",
"forceUpdateChargingPlan"
],
"properties": {
- "chargeBoxID": {
- "type": "string",
- "example": ""
- },
"chargePointID": {
"type": "string",
"example": 1

MODIFY
src/server/rest/v1/router/api/ChargingStationRouter.ts
src/server/rest/v1/router/api/ChargingStationRouter.ts
@@ -73,54 +73,64 @@ export default class ChargingStationRouter {
protected buildRouteChargingStationClearCache(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_CACHE_CLEAR}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_CLEAR_CACHE, req, res, next);
});
}
protected buildRouteChargingStationRetrieveConfiguration(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_RETRIEVE_CONFIGURATION}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_GET_CONFIGURATION, req, res, next);
});
}
protected buildRouteChargingStationRemoteStart(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_REMOTE_START}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_REMOTE_START_TRANSACTION, req, res, next);
});
}
protected buildRouteChargingStationRemoteStop(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_REMOTE_STOP}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_REMOTE_STOP_TRANSACTION, req, res, next);
});
}
protected buildRouteChargingStationUnlockConnector(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_UNLOCK_CONNECTOR}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
+ req.body.connectorId = req.params.connectorId;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_UNLOCK_CONNECTOR, req, res, next);
});
}
protected buildRouteChargingStationGetCompositeSchedule(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_GET_COMPOSITE_SCHEDULE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_GET_COMPOSITE_SCHEDULE, req, res, next);
});
}
protected buildRouteChargingStationGetDiagnostics(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_GET_DIAGNOSTICS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_GET_DIAGNOSTICS, req, res, next);
});
}
protected buildRouteChargingStationUpdateFirmware(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_FIRMWARE_UPDATE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_UPDATE_FIRMWARE, req, res, next);
});
}
protected buildRouteChargingStationChangeAvailability(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_CHANGE_AVAILABILITY}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleAction.bind(this), ServerAction.CHARGING_STATION_CHANGE_AVAILABILITY, req, res, next);
});
}
@@ -172,6 +182,7 @@ export default class ChargingStationRouter {
protected buildRouteChargingStationLimitPower(): void {
this.router.put(`/${ServerRoute.REST_CHARGING_STATIONS_POWER_LIMIT}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.chargeBoxID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleChargingStationLimitPower.bind(this), ServerAction.CHARGING_STATION_LIMIT_POWER, req, res, next);
});
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -44,7 +44,7 @@ const MODULE_NAME = 'ChargingStationService';
export default class ChargingStationService {
public static async handleUpdateChargingStationParams(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationParamsUpdateRequest(req.body);
+ const filteredRequest = ChargingStationSecurity.filterChargingStationParamsUpdateRequest({ ...req.params, ...req.body });
// Check the Charging Station
const chargingStation = await ChargingStationStorage.getChargingStation(req.user.tenantID, filteredRequest.id);
UtilsService.assertObjectExists(action, chargingStation, `Charging Station '${filteredRequest.id}' does not exist.`,

MODIFY
src/server/rest/v1/service/security/ChargingStationSecurity.ts
src/server/rest/v1/service/security/ChargingStationSecurity.ts
@@ -213,7 +213,7 @@ export default class ChargingStationSecurity {
filteredRequest.args.custom = UtilsSecurity.filterBoolean(request.args.custom);
}
if (Utils.objectHasProperty(request.args, 'connectorId')) {
- filteredRequest.args.connectorId = sanitize(request.args.connectorId);
+ filteredRequest.args.connectorId = sanitize(request.connectorId);
}
if (Utils.objectHasProperty(request.args, 'duration')) {
filteredRequest.args.duration = sanitize(request.args.duration);

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -407,15 +407,15 @@ export enum ServerRoute {
REST_CHARGING_STATION = 'chargingstations/:id',
REST_CHARGING_STATIONS_RESET = 'chargingstations/reset',
- REST_CHARGING_STATIONS_CACHE_CLEAR = 'chargingstations/cache/clear',
- REST_CHARGING_STATIONS_RETRIEVE_CONFIGURATION = 'chargingstations/configuration/retrieve',
- REST_CHARGING_STATIONS_REMOTE_START = 'chargingstations/remote/start',
- REST_CHARGING_STATIONS_REMOTE_STOP = 'chargingstations/remote/stop',
- REST_CHARGING_STATIONS_UNLOCK_CONNECTOR = 'chargingstations/connectors/unlock',
- REST_CHARGING_STATIONS_GET_COMPOSITE_SCHEDULE = 'chargingstations/compositeschedule',
- REST_CHARGING_STATIONS_GET_DIAGNOSTICS = 'chargingstations/diagnostics',
- REST_CHARGING_STATIONS_FIRMWARE_UPDATE = 'chargingstations/firmware/update',
- REST_CHARGING_STATIONS_CHANGE_AVAILABILITY = 'chargingstations/availability/change',
+ REST_CHARGING_STATIONS_CACHE_CLEAR = 'chargingstations/:id/cache/clear',
+ REST_CHARGING_STATIONS_RETRIEVE_CONFIGURATION = 'chargingstations/:id/configuration/retrieve',
+ REST_CHARGING_STATIONS_REMOTE_START = 'chargingstations/:id/remote/start',
+ REST_CHARGING_STATIONS_REMOTE_STOP = 'chargingstations/:id/remote/stop',
+ REST_CHARGING_STATIONS_UNLOCK_CONNECTOR = 'chargingstations/:id/connectors/:connectorId/unlock',
+ REST_CHARGING_STATIONS_GET_COMPOSITE_SCHEDULE = 'chargingstations/:id/compositeschedule',
+ REST_CHARGING_STATIONS_GET_DIAGNOSTICS = 'chargingstations/:id/diagnostics',
+ REST_CHARGING_STATIONS_FIRMWARE_UPDATE = 'chargingstations/:id/firmware/update',
+ REST_CHARGING_STATIONS_CHANGE_AVAILABILITY = 'chargingstations/:id/availability/change',
REST_CHARGING_STATIONS_DOWNLOAD_FIRMWARE = 'chargingstations/firmware/download',
REST_CHARGING_STATIONS_QRCODE_GENERATE = 'chargingstations/:id/connectors/:connectorId/qrcode/generate',
@@ -425,8 +425,8 @@ export enum ServerRoute {
REST_CHARGING_STATIONS_REQUEST_OCPP_PARAMETERS = 'chargingstations/ocpp/parameters',
REST_CHARGING_STATIONS_EXPORT_OCPP_PARAMETERS = 'chargingstations/:id/ocpp/parameters/export',
- REST_CHARGING_STATIONS_UPDATE_PARAMETERS = 'chargingstations/parameters',
- REST_CHARGING_STATIONS_POWER_LIMIT = 'chargingstations/power/limit',
+ REST_CHARGING_STATIONS_UPDATE_PARAMETERS = 'chargingstations/:id/parameters',
+ REST_CHARGING_STATIONS_POWER_LIMIT = 'chargingstations/:id/power/limit',
REST_CHARGING_STATIONS_TRANSACTIONS = 'chargingstations/:id/transactions',
REST_CHARGING_STATIONS_IN_ERROR = 'chargingstations/in-error',
REST_CHARGING_STATIONS_EXPORT = 'chargingstations/export',

Rolled back IDs in chargingstations routes