API Control Plane 11.0 | Developer's Guide | Agent SDK | Agent SDK Implementation Samples | AgentSDKContextManual Sample
 
AgentSDKContextManual Sample

public class AgentSDKContextManualImpl implements AgentSDKContextManual {

@Override
public SdkConfig getSdkConfig() {
AuthConfig authConfig = new AuthConfig
.Builder("John","PineTree@1234")
.build();
ControlPlaneConfig controlPlaneConfig = new ControlPlaneConfig.Builder()
.authConfig(authConfig)
.url("https://localhost:7777")
.tlsConfig(new TlsConfig
.Builder("C:\\Windows\\System32\\mytruststore.jks","jks")
.truststorePassword("softwareag").build())
.build();
RuntimeConfig runtimeConfig = new RuntimeConfig.Builder("DevGateway", "DevGateway", "WEBMETHODS_API_GATEWAY",
Runtime.DeploymentType.PUBLIC_CLOUD)
.description("auto created while registering the agent")
.region("Central Asia")
.host("https://localhost:7777/controlplane")
.location("japan")
.build();
return new SdkConfig.Builder(controlPlaneConfig, runtimeConfig)
.assetsSyncInterval(900)
.assetSyncMethod(AssetSyncMethod.POLLING)
.heartbeatInterval(65)
.logLevel(Level.ALL)
.metricsSendInterval(300)
.publishAssets(true)
.sendMetrics(true)
.syncAssets(true)
.build();
}

@Override
public SdkLogger getLogger() {
return null;
}

@Override
public SdkHttpClient getHttpClient() {
return null;
}

@Override
public Heartbeat getHeartbeat() {
return new Heartbeat.Builder("runtimeId")
.active(Heartbeat.Status.ACTIVE)
.created(System.currentTimeMillis()).build();
}

@Override
public List<API> getAPIs() {
List<API> allApis = new ArrayList<>();
// Retrieve all APIs from your Runtime and convert them as API Model
return allApis;
}

@Override
public List<Metrics> getMetrics(long fromTimestamp, long toTimestamp, long interval) {
List<Metrics> metricsList=new ArrayList<>();
// Retrieve all Metrics from your Runtime for the given time rage and convert them as Metric Model
return metricsList;
}



@Override
public List<AssetSyncAction<Asset>> getAssetSyncActions(long fromTimestamp) {
List<AssetSyncAction<Asset>> syncActions = new ArrayList<>();
AssetSyncAction syncAction = new APISyncAction(AssetType.API, AssetSyncAction.SyncType.UPDATE,
new API.Builder("api-id", API.Type.REST).build() ,
System.currentTimeMillis());
syncActions.add(syncAction);
//Identify all your API updates for the time range given and convert them as AssetSyncactions
return syncActions;
}
}