Search in sources :

Example 1 with GetAssetPropertyValueResponse

use of software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class SiteWiseClientTest method testGetAssetPropertyValue.

/**
 ******GetAssetHierarchiesIdList API tests**********
 */
@Test
public void testGetAssetPropertyValue() {
    // when
    when(ioTSiteWiseClient.getAssetPropertyValue((GetAssetPropertyValueRequest) any())).thenReturn(getAssetPropertyValueResponse);
    // then
    GetAssetPropertyValueResponse response = siteWiseClient.getAssetPropertyValue(SITE_WISE_ASSET_ID, SITE_WISE_PROPERTY_ID);
    // verify
    assertEquals(response.propertyValue().value().stringValue(), SITE_WISE_PROPERTY_VALUE);
}
Also used : GetAssetPropertyValueResponse(software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse) Test(org.junit.jupiter.api.Test)

Example 2 with GetAssetPropertyValueResponse

use of software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class SiteWiseManager method buildEdgeConnectorForKVSConfiguration.

private EdgeConnectorForKVSConfiguration buildEdgeConnectorForKVSConfiguration(String cameraSiteWiseAssetId) throws IllegalAccessException {
    DescribeAssetResponse assetResponse = siteWiseClient.describeAsset(cameraSiteWiseAssetId);
    EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = new EdgeConnectorForKVSConfiguration();
    edgeConnectorForKVSConfiguration.setSiteWiseAssetId(cameraSiteWiseAssetId);
    for (AssetProperty assetProperty : assetResponse.assetProperties()) {
        GetAssetPropertyValueResponse result;
        Field[] fields = edgeConnectorForKVSConfiguration.getClass().getDeclaredFields();
        for (Field field : fields) {
            if (field.getName().equalsIgnoreCase(assetProperty.name())) {
                result = siteWiseClient.getAssetPropertyValue(cameraSiteWiseAssetId, assetProperty.id());
                if (result != null && result.propertyValue() != null) {
                    if (field.getType() == String.class) {
                        field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().stringValue());
                        break;
                    } else if (field.getType() == Integer.TYPE || field.getType() == Integer.class) {
                        field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().integerValue());
                        break;
                    }
                }
            }
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOADED_TIME_RANGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setVideoUploadedTimeRangePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_RECORDED_TIME_RANGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setVideoRecordedTimeRangePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_CACHED_VIDEO_AGE_OUT_ON_EDGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setCachedVideoAgeOutOnEdgePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOAD_REQUEST_MEASUREMENT_NAME)) {
            if (assetProperty.notification().state() == PropertyNotificationState.ENABLED) {
                edgeConnectorForKVSConfiguration.setVideoUploadRequestMqttTopic(assetProperty.notification().topic());
            } else {
                log.warn("Video Upload Request MQTT Notification Disabled for Asset Id " + cameraSiteWiseAssetId);
            }
        }
    }
    return edgeConnectorForKVSConfiguration;
}
Also used : Field(java.lang.reflect.Field) DescribeAssetResponse(software.amazon.awssdk.services.iotsitewise.model.DescribeAssetResponse) GetAssetPropertyValueResponse(software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse) AssetProperty(software.amazon.awssdk.services.iotsitewise.model.AssetProperty) EdgeConnectorForKVSConfiguration(com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)

Aggregations

GetAssetPropertyValueResponse (software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse)2 EdgeConnectorForKVSConfiguration (com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)1 Field (java.lang.reflect.Field)1 Test (org.junit.jupiter.api.Test)1 AssetProperty (software.amazon.awssdk.services.iotsitewise.model.AssetProperty)1 DescribeAssetResponse (software.amazon.awssdk.services.iotsitewise.model.DescribeAssetResponse)1