Added userExport endpoint + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"description": "Return Charging Station CSV file",
"content": {
"text/csv": {
- "example": "Name\tCreated On\tNumber of Connectors\tSite Area\tLatitude\tLongitude\tCharge Point S/N\tModel\tCharge Box S/N\tVendor\tFirmware\tVersion\tOCPP Version\tOCPP Protocol\tLast Seen\tLast Reboot\tMaximum Power (Watt)\tPower Limit\tUnit\n####\t####\t2\t####\t49\t-0.3\t####\tMONOBLOCK\t####\t####\t3\t1.6\tjson\t12/20/2020 11:54 PM\t12/09/2020 7:00 PM\t44160\tA"
+ "example": "Name,Created On,Number of Connectors,Site Area,Latitude,Longitude,Charge Point S/N,Model,Charge Box S/N,Vendor,Firmware,Version,OCPP Version,OCPP Protocol,Last Seen,Last Reboot,Maximum Power (Watt),Power Limit,Unit,####,####,2,####,49,-0.3,####,MONOBLOCK,####,####,3,1.6,json,12/20/2020 11:54 PM,12/09/2020 7:00 PM,44160,A"
}
}
},
"$ref": "#/components/parameters/UserRoles"
},
{
- "in": "query",
- "name": "Status",
- "description": "Status attribute",
- "schema": {
- "type": "string",
- "enum": [
- "P",
- "A",
- "I",
- "B",
- "L"
- ]
- }
+ "$ref": "#/components/parameters/UserStatuses"
},
{
- "in": "query",
- "name": "ExcludeSiteID",
- "required": false,
- "description": "Site ID to exclude",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/UserExcludeSiteID"
},
{
- "in": "query",
- "name": "ExcludeUserIDs",
- "description": "Pipe separated user IDs to exclude",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/UserExcludeUserIDs"
},
{
- "in": "query",
- "name": "IncludeCarUserIDs",
- "description": "Pipe separated car IDs",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/UserIncludeCarUserIDs"
},
{
- "in": "query",
- "name": "NotAssignedToCarID",
- "description": "Car ID",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/UserNotAssignedToCarID"
},
{
"$ref": "#/components/parameters/Skip"
}
}
},
+ "/api/users/action/export": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Export users",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/Issuer"
+ },
+ {
+ "$ref": "#/components/parameters/Search"
+ },
+ {
+ "$ref": "#/components/parameters/SiteIDs"
+ },
+ {
+ "$ref": "#/components/parameters/UserIDs"
+ },
+ {
+ "$ref": "#/components/parameters/UserRoles"
+ },
+ {
+ "$ref": "#/components/parameters/UserStatuses"
+ },
+ {
+ "$ref": "#/components/parameters/UserExcludeSiteID"
+ },
+ {
+ "$ref": "#/components/parameters/UserExcludeUserIDs"
+ },
+ {
+ "$ref": "#/components/parameters/UserIncludeCarUserIDs"
+ },
+ {
+ "$ref": "#/components/parameters/UserNotAssignedToCarID"
+ },
+ {
+ "$ref": "#/components/parameters/Skip"
+ },
+ {
+ "$ref": "#/components/parameters/Limit"
+ },
+ {
+ "$ref": "#/components/parameters/SortFields"
+ },
+ {
+ "$ref": "#/components/parameters/OnlyRecordCount"
+ },
+ {
+ "$ref": "#/components/parameters/ProjectFields"
+ }
+ ],
+ "tags": [
+ "Users"
+ ],
+ "responses": {
+ "200": {
+ "description": "Users exported successfully",
+ "content": {
+ "text/csv": {
+ "example": "id,name,firstName,locale,role,status,email,eulaAcceptedOn,createdOn,changedOn,changedBy\n\"60828e80cbb186935c6fbfd3\",\"DEMO\",\"User\",\"en_EN\",\"B\",\"P\",\"user.deeeeeemo@sap.com\",\"2021-06-09\",\"2021-04-23\",\"2021-06-09\",\"\""
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "583": {
+ "description": "Invalid file format"
+ },
+ "584": {
+ "description": "Invalid CSV header format"
+ }
+ }
+ }
+ },
"/api/tags": {
"get": {
"security": [
"schema": {
"type": "string"
}
+ },
+ "UserStatuses": {
+ "in": "query",
+ "name": "Status",
+ "description": "Pipe separated status attributes (P, A, I, B, L)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "UserExcludeSiteID": {
+ "in": "query",
+ "name": "ExcludeSiteID",
+ "required": false,
+ "description": "Site ID to exclude",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "UserExcludeUserIDs": {
+ "in": "query",
+ "name": "ExcludeUserIDs",
+ "description": "Pipe separated user IDs to exclude",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "UserIncludeCarUserIDs": {
+ "in": "query",
+ "name": "IncludeCarUserIDs",
+ "description": "Pipe separated car IDs",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "UserNotAssignedToCarID": {
+ "in": "query",
+ "name": "NotAssignedToCarID",
+ "description": "Car ID",
+ "schema": {
+ "type": "string"
+ }
}
}
}

MODIFY
src/server/rest/v1/router/api/UserRouter.ts
src/server/rest/v1/router/api/UserRouter.ts
@@ -23,6 +23,7 @@ export default class UserRouter {
this.buildRouteUserSiteAssign();
this.buildRouteUserInError();
this.buildRouteUserImport();
+ this.buildRouteUserExport();
return this.router;
}
@@ -90,4 +91,10 @@ export default class UserRouter {
await RouterUtils.handleServerAction(UserService.handleImportUsers.bind(this), ServerAction.USERS_IMPORT, req, res, next);
});
}
+
+ protected buildRouteUserExport(): void {
+ this.router.get(`/${ServerRoute.REST_USERS_EXPORT}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(UserService.handleExportUsers.bind(this), ServerAction.USERS_EXPORT, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -500,6 +500,7 @@ export enum ServerRoute {
REST_USER_SITES = 'users/:id/sites',
REST_USERS_IN_ERROR = 'users/status/in-error',
REST_USERS_IMPORT = 'users/action/import',
+ REST_USERS_EXPORT = 'users/action/export',
REST_TAGS = 'tags',
REST_TAG = 'tags/:id',

MODIFY
test/api/client/UserApi.ts
test/api/client/UserApi.ts
@@ -16,7 +16,7 @@ export default class UserApi extends CrudApi {
}
public async readAllInError(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return super.readAll(params, paging, ordering, `/v1/api/${ServerRoute.REST_USERS_IN_ERROR}`);
+ return super.readAll(params, paging, ordering, this.buildRestEndpointUrl(ServerRoute.REST_USERS_IN_ERROR));
}
public async create(data) {
@@ -58,4 +58,8 @@ export default class UserApi extends CrudApi {
public async exportTags(params) {
return await super.read(params, '/client/api/TagsExport');
}
+
+ public async exportUsers(params) {
+ return await super.read(params, this.buildRestEndpointUrl(ServerRoute.REST_USERS_EXPORT));
+ }
}

Added userExport endpoint + doc