Protocol protocol = Protocol.Tcp;
@Override
protected ItemBase buildItemTemplate() {
NginxService nginxService = OpsContext.get().getInstance(NginxService.class);
NginxBackend nginxBackend = OpsContext.get().getInstance(NginxBackend.class);
NetworkConnection networkConnection = new NetworkConnection();
networkConnection.setDestItem(nginxBackend.backend);
networkConnection.setSourceItem(nginxService.getKey());
networkConnection.setPort(port);
networkConnection.setProtocol(protocol.toString());
Tag parentTag = Tag.buildParentTag(nginxBackend.getKey());
networkConnection.getTags().add(parentTag);
Tag uniqueTag = UniqueTag.build(nginxService, nginxBackend);
networkConnection.getTags().add(uniqueTag);
String id = nginxBackend.getId();
if (Strings.isNullOrEmpty(id)) {
id = "nginx";
}
networkConnection.key = PlatformLayerKey.fromId(id);