package org.opentosca.toscana.plugins.cloudfoundry;

import java.util.HashSet;
import java.util.Set;

import org.opentosca.toscana.core.plugin.lifecycle.ToscanaPlugin;
import org.opentosca.toscana.core.transformation.TransformationContext;
import org.opentosca.toscana.core.transformation.platform.Platform;
import org.opentosca.toscana.core.transformation.properties.PlatformInput;
import org.opentosca.toscana.core.transformation.properties.PropertyType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class CloudFoundryPlugin extends ToscanaPlugin<CloudFoundryLifecycle> {

    public final static String CF_PROPERTY_KEY_USERNAME = "username";
    public final static String CF_PROPERTY_KEY_PASSWORD = "password";
    public final static String CF_PROPERTY_KEY_API = "apiHost";
    public final static String CF_PROPERTY_KEY_SPACE = "space";
    public final static String CF_PROPERTY_KEY_ORGANIZATION = "organization";

    private final static Logger logger = LoggerFactory.getLogger(CloudFoundryPlugin.class);

    public CloudFoundryPlugin() {
        super(getPlatformDetails());
    }

    private static Platform getPlatformDetails() {
        String platformId = "cloud-foundry";
        String platformName = "CloudFoundry";
        Set<PlatformInput> platformProperties = new HashSet<>();

        PlatformInput cfUserName = new PlatformInput(CF_PROPERTY_KEY_USERNAME, PropertyType.TEXT,
            "Username of CloudFoundry provideraccount",
            false);
        PlatformInput cfUserPw = new PlatformInput(CF_PROPERTY_KEY_PASSWORD, PropertyType.SECRET,
            "Password of CloudFoundry provideraccount",
            false);
        PlatformInput cfEndpoint = new PlatformInput(CF_PROPERTY_KEY_API, PropertyType.TEXT,
            "The endpoint of the provider",
            false);
        PlatformInput cfSpace = new PlatformInput(CF_PROPERTY_KEY_SPACE, PropertyType.TEXT,
            "The space of the useraccount which should be used to deploy",
            false);
        PlatformInput cfOrganization = new PlatformInput(CF_PROPERTY_KEY_ORGANIZATION, PropertyType.TEXT,
            "The space of the useraccount which should be used to deploy",
            false);

        platformProperties.add(cfUserName);
        platformProperties.add(cfUserPw);
        platformProperties.add(cfEndpoint);
        platformProperties.add(cfSpace);
        platformProperties.add(cfOrganization);

        return new Platform(platformId, platformName, platformProperties);
    }

    @Override
    public CloudFoundryLifecycle getInstance(TransformationContext context) throws Exception {
        return new CloudFoundryLifecycle(context);
    }
}

@@ -708,17 +708,29 @@
 NAME = %22
-u
+CF_Instance_U
 sername%22
@@ -790,17 +790,29 @@
 WORD = %22
-p
+CF_Instance_P
 assword%22
@@ -871,15 +871,23 @@
  = %22
-apiHost
+CF_Instance_Api
 %22;%0A 
@@ -941,17 +941,29 @@
 PACE = %22
-s
+CF_Instance_S
 pace%22;%0A 
@@ -1024,17 +1024,29 @@
 TION = %22
-o
+CF_Instance_O
 rganizat
@@ -1589,36 +1589,35 @@
 t%22,%0A            
-fals
+tru
 e);%0A        Plat
@@ -1762,36 +1762,35 @@
 t%22,%0A            
-fals
+tru
 e);%0A        Plat
@@ -1918,36 +1918,35 @@
 r%22,%0A            
-fals
+tru
 e);%0A        Plat
@@ -2108,28 +2108,27 @@
             
-fals
+tru
 e);%0A        
@@ -2234,37 +2234,44 @@
            %22The 
-space
+organization
  of the useracco
@@ -2323,12 +2323,11 @@
     
-fals
+tru
 e);%0A

Set platform properties to required (#578)