Added delete/getImage endpoints + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"description": "Cannot set site to private as one or several charging stations under site are public"
}
}
+ },
+ "delete": {
+ "description": "Delete a site",
+ "tags": [
+ "Sites"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteID"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Site deleted successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
}
},
"/api/sites/{id}/users": {
}
}
},
+ "/api/sites/{id}/image": {
+ "get": {
+ "description": "Retrieve site's image",
+ "tags": [
+ "Sites"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteID"
+ },
+ {
+ "in": "query",
+ "name": "TenantID",
+ "description": "Tenant ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Return site's image"
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
"/api/loggings": {
"get": {
"security": [

MODIFY
src/server/rest/v1/router/api/SiteRouter.ts
src/server/rest/v1/router/api/SiteRouter.ts
@@ -23,6 +23,8 @@ export default class SiteRouter {
this.buildRouteSetSiteAdmin();
this.buildRouteSetSiteOwner();
this.buildRouteUpdateSite();
+ this.buildRouteDeleteSite();
+ this.buildRouteGetSiteImage();
return this.router;
}
@@ -47,14 +49,14 @@ export default class SiteRouter {
private buildRouteSiteAssignUsers(): void {
this.router.put(`/${ServerRoute.REST_SITE_ADD_USERS}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.body.siteID = req.params.id;
await RouterUtils.handleServerAction(SiteService.handleAssignUsersToSite.bind(this), ServerAction.ADD_USERS_TO_SITE, req, res, next);
});
}
private buildRouteSiteUnassignUsers(): void {
this.router.put(`/${ServerRoute.REST_SITE_REMOVE_USERS}`, async (req: Request, res: Response, next: NextFunction) => {
- req.body.id = req.params.id;
+ req.body.siteID = req.params.id;
await RouterUtils.handleServerAction(SiteService.handleAssignUsersToSite.bind(this), ServerAction.REMOVE_USERS_FROM_SITE, req, res, next);
});
}
@@ -86,4 +88,18 @@ export default class SiteRouter {
await RouterUtils.handleServerAction(SiteService.handleUpdateSite.bind(this), ServerAction.SITE_UPDATE, req, res, next);
});
}
+
+ private buildRouteDeleteSite(): void {
+ this.router.delete(`/${ServerRoute.REST_SITE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SiteService.handleDeleteSite.bind(this), ServerAction.SITE_DELETE, req, res, next);
+ });
+ }
+
+ private buildRouteGetSiteImage(): void {
+ this.router.get(`/${ServerRoute.REST_SITE_IMAGE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SiteService.handleGetSiteImage.bind(this), ServerAction.SITE_IMAGE, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -616,6 +616,7 @@ export enum ServerRoute {
REST_SITE_REMOVE_USERS = 'sites/:id/users/unassign',
REST_SITE_ADMIN = 'sites/:id/users/admin',
REST_SITE_OWNER = 'sites/:id/users/owner',
+ REST_SITE_IMAGE = 'sites/:id/image',
// BILLING URLs for CRUD operations on PAYMENT METHODS
REST_BILLING_PAYMENT_METHODS = 'users/:userID/payment-methods',

MODIFY
test/api/client/SiteApi.ts
test/api/client/SiteApi.ts
@@ -56,8 +56,8 @@ export default class SiteApi extends CrudApi {
return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_SITE, { id: data.id }));
}
- public async delete(id) {
- return super.delete(id, '/client/api/SiteDelete');
+ public async delete(id: string) {
+ return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_SITE, { id }));
}
public async assignSiteAdmin(siteID: string, userID: string) {

Added delete/getImage endpoints + doc