diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd045d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/target +/.idea +/.idea/.gitignore +/.idea/compiler.xml +/.idea/encodings.xml +/.idea/jarRepositories.xml +/.idea/misc.xml +/.idea/vcs.xml +.DS_Store diff --git a/README.md b/README.md index 609fe3a..3d61960 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ -# sample-code-java \ No newline at end of file +# Java Sample Code + +## About + +This repository includes code samples to use EnOS™ APIs in Java. To learn more about EnOS™ APIs, see [EnOS API Documentation](https://support.envisioniot.com/docs/api/en/2.4.0/overview.html). + + +## Prerequisites + +Before using the code samples, complete the tasks described in [Using Java SDK](https://support.envisioniot.com/docs/api/en/2.4.0/gettingstarted.html#using-java-sdk). + + +## Using the Code Samples + +You need to replace the [environment variables](environment_variables.md) with the actual values you want to use. + +## Release Notes + +2022/12/30 diff --git a/SampleFirmwareFile.bin b/SampleFirmwareFile.bin new file mode 100644 index 0000000..e69de29 diff --git a/UploadFileSample.txt b/UploadFileSample.txt new file mode 100644 index 0000000..e9544dd --- /dev/null +++ b/UploadFileSample.txt @@ -0,0 +1,8 @@ +Envision Digital is committed to becoming the world’s leading net zero technology partner for enterprises, governments, +and cities alike. Its world-class AIoT technology helps governments and companies across the world accelerate progress +toward a net zero future and improve their citizens’ quality of life. Having established itself as a leading solutions +provider for intelligent renewable energy generation, consumption efficiency and smart and flexible storage, +Envision Digital has extended its capabilities beyond energy to enable and optimise applications +– notably in smart renewables, city infrastructure and carbon management solutions. + +test diff --git a/environment_variables.md b/environment_variables.md new file mode 100644 index 0000000..4ef95b2 --- /dev/null +++ b/environment_variables.md @@ -0,0 +1,3 @@ +|Parameter Name|Description|Type|Default Value|Mandatory/Optional|How to get|Note| +| --- | ---| ---| --- | ---| ---|---| +|orgId|The organization ID.| Integer| N/A | Mandatory | In the left navigation bar of the EnOS Management Console, click IAM > Organization Profile . The Organization ID is the orgld.| None| diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0ef4c19 --- /dev/null +++ b/pom.xml @@ -0,0 +1,191 @@ + + + + 4.0.0 + + com.envisioniot.example + Sample1 + 1.0-SNAPSHOT + + Sample1 + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + com.envisioniot + enos-dm-api-pojo + 2.4.2-SNAPSHOT + + + + com.envisioniot + enos-mqtt + 2.2.15 + + + + junit + junit + 4.11 + test + + + junit + junit + 4.13.2 + compile + + + com.fasterxml.jackson.core + jackson-databind + 2.12.3 + + + + com.google.code.gson + gson + 2.8.9 + + + + com.envisioniot + enos-core + 0.2.0 + + + com.squareup.okhttp3 + okhttp + 3.12.3 + + + com.vaadin.external.google + android-json + 0.0.20131108.vaadin1 + test + + + org.testng + testng + 6.11 + test + + + org.apache.commons + commons-io + 1.3.2 + test + + + com.envisioniot + enos-http-integration + 0.1.3 + + + org.slf4j + slf4j-api + 2.0.0-alpha5 + + + org.slf4j + slf4j-simple + 2.0.0-alpha5 + + + ch.qos.logback + logback-classic + 1.2.3 + + + com.envisioniot + apim-poseidon + 0.1.14 + + + com.envisioniot + enos-app-portal-sdk + 0.0.15-SNAPSHOT + + + + com.envisioniot.enos + amc-api-pojo + 0.0.5-SNAPSHOT + + + apim-poseidon + com.envisioniot + + + enos-commons-api-pojo + com.envisioniot + + + + + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + diff --git a/src/main/java/com/envisioniot/example/sample/App.java b/src/main/java/com/envisioniot/example/sample/App.java new file mode 100644 index 0000000..5581a63 --- /dev/null +++ b/src/main/java/com/envisioniot/example/sample/App.java @@ -0,0 +1,147 @@ +package com.envisioniot.example.sample; + +import java.io.IOException; + +import com.envisioniot.example.sample.connection.devicedata.ConnectionDeviceDataApp; +import com.envisioniot.example.sample.onboarding.AmcApp; +import com.envisioniot.example.sample.utility.PropertyUtil; + +/** + * API 2.3.0 testing + */ +public class App { + private static String accessKey; + private static String secretKey; + private static String orgId; + private static String url; + + public static void main(String[] args) { + // Preconfiguration + PropertyUtil pptfile = null; + try { + pptfile = new PropertyUtil("env.properties"); + } catch (IOException e) { + e.printStackTrace(); + } + accessKey = pptfile.getProperty("accessKey"); + secretKey = pptfile.getProperty("secretKey"); + orgId = pptfile.getProperty("orgId"); + url = pptfile.getProperty("url"); + + /* Run GetThings */ + // https://support.envisioniot.com/docs/model-api/en/2.3.0/overview.html + /* + ModelApp model = new ModelApp(); + model.modelappGeneral(accessKey, secretKey, orgId, url); + */ + + /* Connection Service */ + + // Connection Service - Product + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/overview.html + /* + ConnectionProductApp product = new ConnectionProductApp(); + product.connectionProductAppGeneral(accessKey, secretKey, orgId, url); + */ + + // Connection Service - Device + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_device.html + /* + ConnectionDeviceApp device = new ConnectionDeviceApp(); + device.connectionDeviceAppGeneral(accessKey, secretKey, orgId, url); + */ + + // Connection Service - Certificate + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_certificate.html + /* + ConnectionCertificateApp certificate = new ConnectionCertificateApp(); + certificate.connectionCertificateAppGeneral(accessKey, secretKey, orgId, url); + */ + + // Connection Services - Gateway and Sub-Device + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_gateway_subdevice.html + /* + ConnectionGatewayAndSubdeviceApp gatewayandsubdevice = new ConnectionGatewayAndSubdeviceApp(); + gatewayandsubdevice.connectionGatewayAndSubdeviceAppGeneral(accessKey, secretKey, orgId, url); + */ + + // Connection Services - Device Data + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_device_data.html + +// ConnectionDeviceDataApp devicedata = new ConnectionDeviceDataApp(); +// devicedata.connectionDeviceDataAppGeneral(accessKey, secretKey, orgId, url); + + // Connection Services - HTTP Message Integration + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_integration.html + /* + ConnectionHttpApp http = new ConnectionHttpApp(); + http.connectionHttpApp(accessKey,secretKey,orgId,url); + */ + + // Connection Services - Firmware Management + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_firmware.html + /* + ConnectionFirmwareManagementApp firmwaremanagement = new ConnectionFirmwareManagementApp(); + firmwaremanagement.connectionFirmwareManagement(accessKey, secretKey, orgId, url); + */ + + // Connection Services - Firmware OTA upgrade Management + // https://support.envisioniot.com/docs/connection-api/en/2.3.0/index_ota.html + + /* ConnectionFirmwareOTAupgradeManagementApp firmwareotaupgrademanagement = new ConnectionFirmwareOTAupgradeManagementApp(); + firmwareotaupgrademanagement.firmwareOTAupgradeManagement(accessKey, secretKey, orgId, url);*/ + + // Asset Service + // https://support.envisioniot.com/docs/asset-api/en/2.3.0/overview.html + + /* AssetApp asset = new AssetApp(); + asset.assetAppGeneral(accessKey, secretKey, orgId, url);*/ + + // Alert + // https://support.envisioniot.com/docs/alert-api/en/2.3.0/overview.html + /* + AlertApp alert = new AlertApp(); + alert.alertAppGeneral(accessKey, secretKey, orgId, url); + */ + + /* //Stream Processing Services, Get Stage State + + StreamProcessingApp streamprocessingapp = new StreamProcessingApp(); + streamprocessingapp.streamProcessingAppGeneral(accessKey, secretKey, orgId, url);*/ + + // TSDP Policy + /* TSDBPolicyApp tsdbpolicyapp = new TSDBPolicyApp(); + tsdbpolicyapp.tsdbPolicyAppGeneral(accessKey, secretKey, orgId, url);*/ + + // TSDBDataApp tsdbdataapp = new TSDBDataApp(); + // tsdbdataapp.tsdbDataAppGeneral(accessKey, secretKey, orgId, url); + + // Data Federation + /* DataFederationApp datafederationapp = new DataFederationApp(); + datafederationapp.dataFederationAppGeneral(accessKey, secretKey, orgId, url);*/ + + /* // Batch Processing + BatchProcessingApp batchprocessingapp = new BatchProcessingApp(); + batchprocessingapp.batchProcessingAppGeneral(accessKey, secretKey, orgId, url);*/ + + /* AppPortalApp appPortalApp = new AppPortalApp(); + appPortalApp.appPortalGeneral(accessKey, secretKey, orgId, url);*/ + + /* + BpmApp bpmApp = new BpmApp(); + bpmApp.bpmAppGeneral(accessKey, secretKey, orgId, url); + */ + + /* IAMApp iamApp = new IAMApp(); + iamApp.IAMAppGeneral(accessKey, secretKey, orgId, url);*/ + + /* NotificationManagementApp notificationManagementApp = new NotificationManagementApp(); + notificationManagementApp.notificationManagementApp(accessKey, secretKey, orgId, url);*/ + + // EnOS Onboarding Tool API Overview + AmcApp amcApp = new AmcApp(); + amcApp.amcAppGeneral(accessKey, secretKey, orgId, url); + + } + +} diff --git a/src/main/java/com/envisioniot/example/sample/PropertyUtil.java b/src/main/java/com/envisioniot/example/sample/PropertyUtil.java new file mode 100644 index 0000000..4b19535 --- /dev/null +++ b/src/main/java/com/envisioniot/example/sample/PropertyUtil.java @@ -0,0 +1,38 @@ +/** + * Copyright (C), 2015-2021, Envision + * FileName: PropertyUtil + * Author: xibin.song + * Date: 11/30/2021 1:49 PM + * Description: + * History: + *