// Path: deployer/src/main/java/eu/seaclouds/policy/utils/SeaCloudsDcRequestDto.java
// public class SeaCloudsDcRequestDto {
// 
//     public static final String ID_SUFIX = "_ID";
//     private String id;
//     private String type;
//     private String url;
// 
//     private SeaCloudsDcRequestDto(Builder builder) {
//         id = builder.id;
//         type = builder.type;
//         url = builder.url;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public void setUrl(String url) {
//         this.url = url;
//     }
// 
//     public static class Builder {
//         private String id;
//         private String type;
//         private String url;
// 
//         public Builder type(String type) {
//             this.type = type;
//             this.id = type + ID_SUFIX;
//             return this;
//         }
// 
//         public Builder url(String url) {
//             this.url = url;
//             return this;
//         }
// 
//         public SeaCloudsDcRequestDto build() {
//             return new SeaCloudsDcRequestDto(this);
//         }
// 
//     }
// 
// }


import java.net.URI;
import java.util.List;
import java.util.Map;
import org.apache.brooklyn.api.entity.Application;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.BasicConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.flags.SetFromFlag;
import org.apache.brooklyn.util.http.HttpTool;
import org.apache.brooklyn.util.http.HttpToolResponse;
import org.apache.brooklyn.util.text.Strings;
import org.apache.http.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Optional;
import com.google.common.net.MediaType;
import eu.seaclouds.policy.utils.SeaCloudsDcRequestDto;
            if (event.getValue().equals(Lifecycle.RUNNING) && !configured) {
                configured = true;
                configureMontiroringForTargetEntities();
            }
        }

        private void configureMontiroringForTargetEntities() {

            for (String targetEntityId : getConfig(TARGET_ENTITIES)) {

                Optional<Entity> optionalChild = findChildEntityByPlanId((Application) entity, targetEntityId);
                if (optionalChild.isPresent()) {
                    Entity child = optionalChild.get();
                    configureSeaCloudDcForAEntity(child, targetEntityId);
                }
            }
            entity.sensors().set(MONITORING_CONFIGURED, true);
        }

        private void configureSeaCloudDcForAEntity(Entity child, String entityId) {
            String mainUri = getMainUri(child);
            if (!Strings.isBlank(mainUri)) {
                SeaCloudsDcRequestDto requestBody = new SeaCloudsDcRequestDto.Builder()
                        .type(entityId)
                        .url(mainUri)
                        .build();
                postSeaCloudsDcConfiguration(requestBody);
            }
        }

// Path: deployer/src/main/java/eu/seaclouds/policy/utils/SeaCloudsDcRequestDto.java
// public class SeaCloudsDcRequestDto {
// 
//     public static final String ID_SUFIX = "_ID";
//     private String id;
//     private String type;
//     private String url;
// 
//     private SeaCloudsDcRequestDto(Builder builder) {
//         id = builder.id;
//         type = builder.type;
//         url = builder.url;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     public String getType() {
//         return type;
//     }
// 
//     public void setType(String type) {
//         this.type = type;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public void setUrl(String url) {
//         this.url = url;
//     }
// 
//     public static class Builder {
//         private String id;
//         private String type;
//         private String url;
// 
//         public Builder type(String type) {
//             this.type = type;
//             this.id = type + ID_SUFIX;
//             return this;
//         }
// 
//         public Builder url(String url) {
//             this.url = url;
//             return this;
//         }
// 
//         public SeaCloudsDcRequestDto build() {
//             return new SeaCloudsDcRequestDto(this);
//         }
// 
//     }
// 
// }


// Path: deployer/src/main/java/eu/seaclouds/policy/SeaCloudsMonitoringInitializationPolicies.java
import java.net.URI;
import java.util.List;
import java.util.Map;
import org.apache.brooklyn.api.entity.Application;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.api.sensor.SensorEvent;
import org.apache.brooklyn.api.sensor.SensorEventListener;
import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.BasicConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.policy.AbstractPolicy;
import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.util.collections.MutableList;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.flags.SetFromFlag;
import org.apache.brooklyn.util.http.HttpTool;
import org.apache.brooklyn.util.http.HttpToolResponse;
import org.apache.brooklyn.util.text.Strings;
import org.apache.http.HttpHeaders;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Optional;
import com.google.common.net.MediaType;
import eu.seaclouds.policy.utils.SeaCloudsDcRequestDto;

            if (event.getValue().equals(Lifecycle.RUNNING) && !configured) {
                configured = true;
                configureMontiroringForTargetEntities();
            }
        }

        private void configureMontiroringForTargetEntities() {

            for (String targetEntityId : getConfig(TARGET_ENTITIES)) {

                Optional<Entity> optionalChild = findChildEntityByPlanId((Application) entity, targetEntityId);
                if (optionalChild.isPresent()) {
                    Entity child = optionalChild.get();
                    configureSeaCloudDcForAEntity(child, targetEntityId);
                }
            }
            entity.sensors().set(MONITORING_CONFIGURED, true);
        }

        private void configureSeaCloudDcForAEntity(Entity child, String entityId) {
            String mainUri = getMainUri(child);
            if (!Strings.isBlank(mainUri)) {
                SeaCloudsDcRequestDto requestBody = new SeaCloudsDcRequestDto.Builder()
                        .type(entityId)
                        .url(mainUri)
                        .build();
                postSeaCloudsDcConfiguration(requestBody);
            }
        }

        private void postSeaCloudsDcConfiguration(SeaCloudsDcRequestDto requestBody) {