@Then("^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$")
    public void sendAppendRequest(String key, String value, String service) throws Exception {
        commonspec.runCommandAndGetResult("touch " + service + ".json && dcos marathon app show " + service + " > /dcos/" + service + ".json");
        commonspec.runCommandAndGetResult("cat /dcos/" + service + ".json");

        String configFile = commonspec.getRemoteSSHConnection().getResult();
        String myValue = commonspec.getJSONPathString(configFile, ".labels", "0");
        String myJson = commonspec.updateMarathonJson(commonspec.removeJSONPathElement(configFile, "$.labels"));

        String newValue = myValue.replaceFirst("\\{", "{\"" + key + "\": \"" + value + "\", ");
        newValue = "\"labels\":" + newValue;
        String myFinalJson = myJson.replaceFirst("\\{", "{" + newValue.replace("\\n", "\\\\n") + ",");
        if (myFinalJson.contains("uris")) {
            String test = myFinalJson.replaceAll("\"uris\"", "\"none\"");
            commonspec.runCommandAndGetResult("echo '" + test + "' > /dcos/final" + service + ".json");
        } else {
            commonspec.runCommandAndGetResult("echo '" + myFinalJson + "' > /dcos/final" + service + ".json");
        }
        commonspec.runCommandAndGetResult("dcos marathon app update " + service + " < /dcos/final" + service + ".json");

        commonspec.setCommandExitStatus(commonspec.getRemoteSSHConnection().getExitStatus());
    }
@ Then ( "^I add a new DCOS label with key '(.+?)' and value '(.+?)' to the service '(.+?)'?$" ) public void sendAppendRequest ( String key , String value , String service ) throws Exception { commonspec . runCommandAndGetResult ( "touch " + service + ".json && dcos marathon app show " + service + " > /dcos/" + service + ".json" ) ; commonspec . runCommandAndGetResult ( "cat /dcos/" + service + ".json" ) ; String configFile = commonspec . getRemoteSSHConnection ( ) . getResult ( ) ; String myValue = commonspec . getJSONPathString ( configFile , ".labels" , "0" ) ; String myJson = commonspec . updateMarathonJson ( commonspec . removeJSONPathElement ( configFile , "$.labels" ) ) ; String newValue = myValue . replaceFirst ( "\\{" , "{\"" + key + "\": \"" + value + "\", " ) ; newValue = "\"labels\":" + newValue ; String myFinalJson = myJson . replaceFirst ( "\\{" , "{" + newValue . replace ( "\\n" , "\\\\n" ) + "," ) ; if ( myFinalJson . contains ( "uris" ) ) { String test = myFinalJson . replaceAll ( "\"uris\"" , "\"none\"" ) ; commonspec . runCommandAndGetResult ( "echo '" + test + "' > /dcos/final" + service + ".json" ) ; } else { commonspec . runCommandAndGetResult ( "echo '" + myFinalJson + "' > /dcos/final" + service + ".json" ) ; } commonspec . runCommandAndGetResult ( "dcos marathon app update " + service + " < /dcos/final" + service + ".json" ) ; commonspec . setCommandExitStatus ( commonspec . getRemoteSSHConnection ( ) . getExitStatus ( ) ) ; }
A PUT request over the body value.

@param key
@param value
@param service
@throws Exception