Added unregister/delete endpoints
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"bearerAuth": []
}
],
- "description": "Retrieve an OCPI Endpoints",
+ "description": "Retrieve an OCPI Endpoint",
"parameters": [
{
"$ref": "#/components/parameters/OCPIEndpointID"
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
+ },
+ "delete": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Delete an OCPI Endpoint",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/OCPIEndpointID"
+ }
+ ],
+ "tags": [
+ "OCPI"
+ ],
+ "responses": {
+ "200": {
+ "description": "OCPI Endpoint deleted"
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
}
},
"/api/ocpi/endpoints/{id}/ping": {
}
}
}
+ },
+ "/api/ocpi/endpoints/:id/unregister": {
+ "put": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Unregister OCPI Endpoint",
+ "tags": [
+ "OCPI"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/OCPIEndpointID"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OCPI Endpoint unregistered",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success",
+ "statusCode": 200,
+ "statusText": "OK"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
}
},
"components": {

MODIFY
src/server/rest/v1/router/api/OCPIRouter.ts
src/server/rest/v1/router/api/OCPIRouter.ts
@@ -29,6 +29,8 @@ export default class OCPIRouter {
this.buildRouteOcpiEndpoint();
this.buildRouteOcpiEndpointUpdate();
this.buildRouteOcpiEndpointRegister();
+ this.buildRouteOcpiEndpointUnregister();
+ this.buildRouteOcpiEndpointDelete();
return this.router;
}
@@ -141,4 +143,18 @@ export default class OCPIRouter {
await RouterUtils.handleServerAction(OCPIEndpointService.handleRegisterOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_REGISTER, req, res, next);
});
}
+
+ protected buildRouteOcpiEndpointUnregister(): void {
+ this.router.put(`/${ServerRoute.REST_OCPI_ENDPOINT_UNREGISTER}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.id = req.params.id;
+ await RouterUtils.handleServerAction(OCPIEndpointService.handleUnregisterOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_UNREGISTER, req, res, next);
+ });
+ }
+
+ protected buildRouteOcpiEndpointDelete(): void {
+ this.router.delete(`/${ServerRoute.REST_OCPI_ENDPOINT}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(OCPIEndpointService.handleDeleteOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_DELETE, req, res, next);
+ });
+ }
}

MODIFY
test/api/client/OCPIEndpointApi.ts
test/api/client/OCPIEndpointApi.ts
@@ -9,7 +9,7 @@ export default class OCPIEndpointApi extends CrudApi {
super(authenticatedApi);
}
- public async readById(id) {
+ public async readById(id: string) {
return super.readById(id, this.buildRestEndpointUrl(ServerRoute.REST_OCPI_ENDPOINT, { id }));
}
@@ -25,7 +25,7 @@ export default class OCPIEndpointApi extends CrudApi {
return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_OCPI_ENDPOINT, { id: data.id }));
}
- public async delete(id) {
- return super.delete(id, '/client/api/OcpiEndpointDelete');
+ public async delete(id: string) {
+ return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_OCPI_ENDPOINT, { id }));
}
}

Added unregister/delete endpoints