-
-
Save ekohl/838610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PowerShellVmsResource { | |
enum Method { GET, ADD }; | |
enum Detail { | |
DISKS("$_.getmemorystatistics(); $_.getcpustatistics(); "), | |
STATISTICS("$_.getdiskimages(); "); | |
public final String powershell; | |
Detail(String powershell) { | |
this.powershell = powershell; | |
} | |
} | |
static String getProcess(Method method, Set<Detail> details) { | |
StringBuilder buf = new StringBuilder(); | |
if (details != null) { | |
for (Detail detail : details) { | |
buf.append(detail.powershell); | |
} | |
} | |
return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf); | |
} | |
private String getProcess(Method method) { | |
return getProcess(method, getDetails()); | |
} | |
private Set<Detail> getDetails() { | |
Set<Detail> details = new EnumSet<Detail>(); | |
for (Detail detail : Detail.class.getEnumConstants()) { | |
if (include(getHttpHeaders(), detail.name().toLowerCase())) { | |
details.add(detail); | |
} | |
} | |
return details; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment