Skip to content

Instantly share code, notes, and snippets.

@ekohl
Forked from markmc/PowerShellVmsResource.java
Created February 22, 2011 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekohl/838610 to your computer and use it in GitHub Desktop.
Save ekohl/838610 to your computer and use it in GitHub Desktop.
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