Fixed check asset connection ID
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
- "/api/assets/{id}/connection/check": {
+ "/api/assets/connectors/:id/connection/check": {
"get": {
"security": [
{
"description": "Check the asset connection",
"parameters": [
{
- "$ref": "#/components/parameters/assetID"
+ "in": "query",
+ "name": "ID",
+ "description": "Asset connection ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
}
],
"tags": [

ADD
src/assets/server/rest/v1/schemas/asset/asset-check-connection.json
+{
+ "title": "Check an Asset Connection Request",
+ "type": "object",
+ "properties": {
+ "ID": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ },
+ "required": [
+ "ID"
+ ]
+}

MODIFY
src/server/rest/v1/service/AssetService.ts
src/server/rest/v1/service/AssetService.ts
@@ -196,7 +196,7 @@ export default class AssetService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ASSET,
Action.CHECK_CONNECTION, Entity.ASSET, MODULE_NAME, 'handleCheckAssetConnection');
// Filter request
- const filteredRequest = AssetValidator.getInstance().validateAssetGetReq(req.query);
+ const filteredRequest = AssetValidator.getInstance().validateAssetCheckConnectionReq(req.query);
// Get asset connection type
const assetImpl = await AssetFactory.getAssetImpl(req.tenant, filteredRequest.ID);
// Asset has unknown connection type

MODIFY
src/server/rest/v1/validator/AssetValidator.ts
src/server/rest/v1/validator/AssetValidator.ts
-import { HttpAssetConsumptionRequest, HttpAssetRequest, HttpAssetsRequest } from '../../../../types/requests/HttpAssetRequest';
+import { HttpAssetCheckConnection, HttpAssetConsumptionRequest, HttpAssetRequest, HttpAssetsRequest } from '../../../../types/requests/HttpAssetRequest';
import Asset from '../../../../types/Asset';
import Consumption from '../../../../types/Consumption';
@@ -15,6 +15,7 @@ export default class AssetValidator extends SchemaValidator {
private assetCreate: Schema;
private assetUpdate: Schema;
private assetGetConsumptions: Schema;
+ private assetCheckConnection: Schema;
private constructor() {
super('AssetValidator');
@@ -24,6 +25,7 @@ export default class AssetValidator extends SchemaValidator {
this.assetCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-create.json`, 'utf8'));
this.assetUpdate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-update.json`, 'utf8'));
this.assetGetConsumptions = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-get-consumptions.json`, 'utf8'));
+ this.assetCheckConnection = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/asset/asset-check-connection.json`, 'utf8'));
}
public static getInstance(): AssetValidator {
@@ -68,4 +70,10 @@ export default class AssetValidator extends SchemaValidator {
this.validate(this.assetGetConsumptions, data);
return data;
}
+
+ public validateAssetCheckConnectionReq(data: any): HttpAssetCheckConnection {
+ // Validate schema
+ this.validate(this.assetCheckConnection, data);
+ return data;
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -528,7 +528,7 @@ export enum ServerRoute {
REST_ASSETS = 'assets',
REST_ASSET = 'assets/:id',
REST_ASSETS_IN_ERROR = 'assets/status/in-error',
- REST_ASSET_CHECK_CONNECTION = 'assets/:id/connector/connection/check',
+ REST_ASSET_CHECK_CONNECTION = 'assets/connectors/:id/connection/check',
REST_ASSET_RETRIEVE_CONSUMPTION = 'assets/:id/connector/consumption/retrieve-last',
REST_ASSET_CONSUMPTIONS = 'assets/:id/consumptions',
REST_ASSET_IMAGE = 'assets/:id/image',

MODIFY
src/types/requests/HttpAssetRequest.ts
src/types/requests/HttpAssetRequest.ts
@@ -27,3 +27,7 @@ export interface HttpAssetImageRequest extends HttpByIDRequest {
ID: string;
TenantID: string;
}
+
+export interface HttpAssetCheckConnection extends HttpByIDRequest {
+ ID: string;
+}

Fixed check asset connection ID