Package org.jclouds.scriptbuilder.domain
Class Statements
- java.lang.Object
-
- org.jclouds.scriptbuilder.domain.Statements
-
public class Statements extends Object
Statements used in shell scripts.
-
-
Constructor Summary
Constructors Constructor Description Statements()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StatementappendFile(String path, Iterable<String> lines)static StatementappendFile(String path, Iterable<String> lines, String delimiter)static StatementappendFile(String path, String line, String delimiter)static Statementcall(String function, String... args)static StatementcreateOrOverwriteFile(String path, Iterable<String> lines)static StatementcreateOrOverwriteFile(String path, Iterable<String> lines, String delimiter)static CreateRunScriptcreateRunScript(String instanceName, Iterable<String> exports, String pwd, Iterable<Statement> statements)static Statementexec(String portableStatement)interprets and adds a newline to the statementstatic StatementextractTargzAndFlattenIntoDirectory(URI tgz, String dest)likeextractTargzIntoDirectory(URI, String)except that it flattens the first directory in the archive For example,apache-maven-3.0.4-bin.tar.gznormally extracts directories like./apache-maven-3.0.4/bin.static StatementextractTargzIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)untar, ungzip the data received from the request parameters.static StatementextractTargzIntoDirectory(URI targz, String directory)static StatementextractZipIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)unzip the data received from the request parameters.static StatementfindPid(String args)Stores the pid into the variableFOUND_PIDif successful.static Statementforget(String instanceName, String script, String logDir)Runs the script in a way that it can be matched later withfindPid(java.lang.String)static Statementinterpret(String... portableStatements)statement can have multiple newlines, note you should uselfto be portablestatic Statementkill()Kills the pid and subprocesses related to the variableFOUND_PIDif set.static Statementliteral(String literalStatement)sends statement only appending a newlinestatic StatementnewStatementList(Statement... statements)static StatementpipeHttpResponseToBash(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers)exec the data received from the request parameters.static Statementrm(String path)static StatementsaveHttpResponseTo(URI source, String dir, String file)static StatementswitchArg(int arg, Map<String,Statement> valueToActions)
-
-
-
Method Detail
-
appendFile
public static Statement appendFile(String path, Iterable<String> lines, String delimiter)
-
createOrOverwriteFile
public static Statement createOrOverwriteFile(String path, Iterable<String> lines)
-
createOrOverwriteFile
public static Statement createOrOverwriteFile(String path, Iterable<String> lines, String delimiter)
-
createRunScript
public static CreateRunScript createRunScript(String instanceName, Iterable<String> exports, String pwd, Iterable<Statement> statements)
- Parameters:
exports- variable names to export in UPPER_UNDERSCORE case format
-
findPid
public static Statement findPid(String args)
Stores the pid into the variableFOUND_PIDif successful.- Parameters:
args- - what to search for in the process tree.
-
forget
public static Statement forget(String instanceName, String script, String logDir)
Runs the script in a way that it can be matched later withfindPid(java.lang.String)- Parameters:
instanceName- - what to match the process onscript- - what to run in the backgroundlogDir- - where to write the following logs:- stdout.log
- stderr.log
-
kill
public static Statement kill()
Kills the pid and subprocesses related to the variableFOUND_PIDif set.- See Also:
findPid(java.lang.String)
-
interpret
public static Statement interpret(String... portableStatements)
statement can have multiple newlines, note you should uselfto be portable- See Also:
ShellToken
-
literal
public static Statement literal(String literalStatement)
sends statement only appending a newline
-
exec
public static Statement exec(String portableStatement)
interprets and adds a newline to the statement
-
extractTargzIntoDirectory
public static Statement extractTargzIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)
untar, ungzip the data received from the request parameters.- Parameters:
method- http method: ex GETendpoint- uri corresponding to the requestheaders- request headers to senddirectory-
-
extractTargzAndFlattenIntoDirectory
public static Statement extractTargzAndFlattenIntoDirectory(URI tgz, String dest)
likeextractTargzIntoDirectory(URI, String)except that it flattens the first directory in the archive For example,apache-maven-3.0.4-bin.tar.gznormally extracts directories like./apache-maven-3.0.4/bin. This command eliminates the intermediate directory, in the example./apache-maven-3.0.4/- Parameters:
tgz- remote ref to downloaddest- path where the files in the intermediate directory will end
-
extractTargzIntoDirectory
public static Statement extractTargzIntoDirectory(URI targz, String directory)
-
extractZipIntoDirectory
public static Statement extractZipIntoDirectory(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers, String directory)
unzip the data received from the request parameters.- Parameters:
method- http method: ex GETendpoint- uri corresponding to the requestheaders- request headers to senddirectory-
-
pipeHttpResponseToBash
public static Statement pipeHttpResponseToBash(String method, URI endpoint, com.google.common.collect.Multimap<String,String> headers)
exec the data received from the request parameters.- Parameters:
method- http method: ex GETendpoint- uri corresponding to the requestheaders- request headers to send
-
-