Added routing
MODIFY
src/server/rest/v1/router/api/OCPIEndpointRouter.ts
src/server/rest/v1/router/api/OCPIEndpointRouter.ts
@@ -30,6 +30,7 @@ export default class OCPIEndpointRouter {
this.buildRouteOcpiEndpointUpdate();
this.buildRouteOcpiEndpointRegister();
this.buildRouteOcpiEndpointUnregister();
+ this.buildRouteOcpiEndpointCredentialsUpdate();
this.buildRouteOcpiEndpointDelete();
return this.router;
}
@@ -151,6 +152,13 @@ export default class OCPIEndpointRouter {
});
}
+ private buildRouteOcpiEndpointCredentialsUpdate(): void {
+ this.router.put(`/${RESTServerRoute.REST_OCPI_ENDPOINT_CREDENTIALS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.id = req.params.id;
+ await RouterUtils.handleRestServerAction(OCPIEndpointService.handleUpdateCredentialsOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_CREDENTIALS, req, res, next);
+ });
+ }
+
private buildRouteOcpiEndpointDelete(): void {
this.router.delete(`/${RESTServerRoute.REST_OCPI_ENDPOINT}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.ID = req.params.id;

MODIFY
src/server/rest/v1/service/OCPIEndpointService.ts
src/server/rest/v1/service/OCPIEndpointService.ts
@@ -687,6 +687,60 @@ export default class OCPIEndpointService {
next();
}
+ public static async handleUpdateCredentialsOcpiEndpoint(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
+ // // Check if component is active
+ // UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OCPI,
+ // Action.READ, Entity.OCPI_ENDPOINT, MODULE_NAME, 'handleUnregisterOcpiEndpoint');
+ // // Check auth
+ // if (!await Authorizations.canRegisterOcpiEndpoint(req.user)) {
+ // throw new AppAuthError({
+ // errorCode: HTTPAuthError.FORBIDDEN,
+ // user: req.user,
+ // action: Action.REGISTER, entity: Entity.OCPI_ENDPOINT,
+ // module: MODULE_NAME, method: 'handleUnregisterOcpiEndpoint'
+ // });
+ // }
+ // // Filter
+ // const filteredRequest = OCPIEndpointValidator.getInstance().validateOCPIEndpointByIdReq(req.body);
+ // // Get OcpiEndpoint
+ // const ocpiEndpoint = await OCPIEndpointStorage.getOcpiEndpoint(req.tenant, filteredRequest.id);
+ // UtilsService.assertObjectExists(action, ocpiEndpoint, `OCPI Endpoint ID '${filteredRequest.id}' does not exist`,
+ // MODULE_NAME, 'handleUnregisterOcpiEndpoint', req.user);
+ // // Build OCPI Client
+ // const ocpiClient = await OCPIClientFactory.getOcpiClient(req.tenant, ocpiEndpoint);
+ // // Try to register
+ // const result = await ocpiClient.unregister();
+ // // Check ping result
+ // if (result.statusCode === StatusCodes.OK) {
+ // await Logging.logInfo({
+ // tenantID: req.tenant.id,
+ // user: req.user, module: MODULE_NAME, method: 'handleUnregisterOcpiEndpoint',
+ // message: `Ocpi Endpoint '${ocpiEndpoint.name}' can be reached successfully`,
+ // action,
+ // detailedMessages: { result }
+ // });
+ // } else {
+ // // Already unregistered
+ // if (result.statusCode === 405) {
+ // throw new AppError({
+ // module: MODULE_NAME, method: 'handleUnregisterOcpiEndpoint',
+ // action,
+ // errorCode: HTTPError.OCPI_ENDPOINT_ALREADY_UNREGISTERED,
+ // message: 'Ocpi Endpoint is already unregistered',
+ // });
+ // }
+ // throw new AppError({
+ // module: MODULE_NAME, method: 'handleUnregisterOcpiEndpoint',
+ // action,
+ // errorCode: HTTPError.GENERAL_ERROR,
+ // message: `${result.statusText} (${result.statusCode})`,
+ // });
+ // }
+ // res.json(Object.assign(result, Constants.REST_RESPONSE_SUCCESS));
+ res.json(Constants.REST_RESPONSE_SUCCESS);
+ next();
+ }
+
public static async handleUnregisterOcpiEndpoint(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OCPI,

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -145,6 +145,7 @@ export enum ServerAction {
OCPI_ENDPOINT_UPDATE = 'OcpiEndpointUpdate',
OCPI_ENDPOINT_REGISTER = 'OcpiEndpointRegister',
OCPI_ENDPOINT_UNREGISTER = 'OcpiEndpointUnregister',
+ OCPI_ENDPOINT_CREDENTIALS = 'OcpiEndpointCredentials',
OCPI_ENDPOINT_DELETE = 'OcpiEndpointDelete',
OCPI_ENDPOINTS = 'OcpiEndpoints',
OCPI_ENDPOINT = 'OcpiEndpoint',
@@ -615,6 +616,7 @@ export enum RESTServerRoute {
REST_OCPI_ENDPOINT = 'ocpi/endpoints/:id',
REST_OCPI_ENDPOINT_REGISTER = 'ocpi/endpoints/:id/register',
REST_OCPI_ENDPOINT_UNREGISTER = 'ocpi/endpoints/:id/unregister',
+ REST_OCPI_ENDPOINT_CREDENTIALS = 'ocpi/endpoints/:id/credentials',
REST_OICP_ENDPOINTS = 'oicp/endpoints',
REST_OICP_ENDPOINT = 'oicp/endpoints/:id',

Added routing