public Parameter unmarshall(StaxUnmarshallerContext context) throws Exception { Parameter parameter = new Parameter(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; parameter.setParameterKey(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; parameter.setParameterValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; parameter.setUsePreviousValue(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; parameter.setResolvedValue(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getParameterKey() == null) ? 0 : getParameterKey().hashCode()); hashCode = prime * hashCode + ((getParameterValue() == null) ? 0 : getParameterValue().hashCode()); hashCode = prime * hashCode + ((getUsePreviousValue() == null) ? 0 : getUsePreviousValue().hashCode()); hashCode = prime * hashCode + ((getResolvedValue() == null) ? 0 : getResolvedValue().hashCode()); return hashCode; }
public Collection<Parameter> getCloudFormationParameters() { Collection<Parameter> parameters = new ArrayList<>(); for (Map.Entry<Object, Object> e : properties.entrySet()) { parameters.add(new Parameter().withParameterKey((String) e.getKey()).withParameterValue((String) e.getValue())); } return parameters; }
/** * Allows you to add any number of nested preconfigured StackParameter * elements. * * @param stackParameter * a preconfigured StackParameter object. */ public void addConfiguredStackParameter(StackParameter parameter) { parameters.add(new Parameter().withParameterKey(parameter.getKey()) .withParameterValue(parameter.getValue()) .withUsePreviousValue(parameter.getUsePreviousValue())); }
private static Collection<Parameter> parseKeepParams(String[] params) { if (params == null) { return Collections.emptyList(); } return Arrays.stream(params).map(param -> new Parameter().withParameterKey(param).withUsePreviousValue(true)).collect(Collectors.toList()); }
Set<String> existingParameterNames = this.parameters.stream().map(x -> x.getParameterKey()).collect(Collectors.toSet()); this.parameters.add(new com.amazonaws.services.cloudformation.model.Parameter().withParameterKey(requiredParameter).withUsePreviousValue(true));
public String replaceParameters(String original, Collection<Parameter> parameters) { String result = original; for (final Parameter param : parameters) { logger.debug("Replace '{}' with '{}'", param.getParameterKey(), param.getParameterValue()); result = result.replace("${" + param.getParameterKey() + "}", param.getParameterValue()); } return result; } }
private List<Parameter> parameters(Map<String, String> parameters) { if (parameters == null || parameters.values().size() == 0) { return null; } List<Parameter> result = Lists.newArrayList(); Parameter parameter = null; for (String name : parameters.keySet()) { parameter = new Parameter(); parameter.setParameterKey(name); parameter.setParameterValue(parameters.get(name)); result.add(parameter); } return result; }
public String findStackParameterValue(String stackName, String key) { Optional<Parameter> param = getStackParameters(stackName).stream() .filter(p -> p.getParameterKey().equals(key)) .findAny(); if (param.isPresent() == false) { logger.warn("WARN: param {} for stack {} is not found", key, stackName); } return param.map(Parameter::getParameterValue).orElse(null); }
/** * <p> * The input value associated with the parameter. * </p> * * @param parameterValue * The input value associated with the parameter. * @return Returns a reference to this object so that method calls can be chained together. */ public Parameter withParameterValue(String parameterValue) { setParameterValue(parameterValue); return this; }
/** * <p> * The key associated with the parameter. If you don't specify a key and value for a particular parameter, AWS * CloudFormation uses the default value that is specified in your template. * </p> * * @param parameterKey * The key associated with the parameter. If you don't specify a key and value for a particular parameter, * AWS CloudFormation uses the default value that is specified in your template. * @return Returns a reference to this object so that method calls can be chained together. */ public Parameter withParameterKey(String parameterKey) { setParameterKey(parameterKey); return this; }
private List<Parameter> convertMapToParams() { List<Parameter> cloudformationParameters = new ArrayList<>(); for(Map.Entry entry : params.entrySet()) { Parameter temp = new Parameter() .withParameterKey(entry.getKey().toString()) .withParameterValue(entry.getValue().toString()); cloudformationParameters.add(temp); } return cloudformationParameters; }
/** * Allows you to add any number of nested preconfigured StackParameter * elements. * * @param stackParameter * a preconfigured StackParameter object. */ public void addConfiguredStackParameter(StackParameter stackParameter) { parameters.add(new Parameter() .withParameterKey(stackParameter.getKey()) .withParameterValue(stackParameter.getValue()) .withUsePreviousValue(stackParameter.getUsePreviousValue())); }
public Map<String, String> getStackParameters(String stackName) { DescribeStacksRequest describeStacksRequest = new DescribeStacksRequest(); describeStacksRequest.setStackName(stackName); DescribeStacksResult describeStacksResult = client .describeStacks(describeStacksRequest); List<Stack> stacks = describeStacksResult.getStacks(); Stack stack = stacks.get(0); List<Parameter> parameters = stack.getParameters(); Map<String, String> map = new LinkedHashMap<String, String>(); for (Parameter parameter : parameters) { map.put(parameter.getParameterKey(), parameter.getParameterValue()); } return map; }
private List<Parameter> toArrayOfParameters(final String parameters) { if ( StringUtils.isEmpty(parameters)) { return new ArrayList<>(); } final List<Parameter> parametersList = new ArrayList<>(); for (String line : parameters.split(StringUtils.LF)) { final ParametersLine paramLine = new ParametersLine(line); if (paramLine.isValid()) { final Parameter parameter = new Parameter(); parameter.setParameterKey(paramLine.getKey()); parameter.setParameterValue(paramLine.getValue()); parametersList.add(parameter); } } return parametersList; }
/** * <p> * The input value associated with the parameter. * </p> * * @param parameterValue * The input value associated with the parameter. * @return Returns a reference to this object so that method calls can be chained together. */ public Parameter withParameterValue(String parameterValue) { setParameterValue(parameterValue); return this; }
/** * <p> * The key associated with the parameter. If you don't specify a key and value for a particular parameter, AWS * CloudFormation uses the default value that is specified in your template. * </p> * * @param parameterKey * The key associated with the parameter. If you don't specify a key and value for a particular parameter, * AWS CloudFormation uses the default value that is specified in your template. * @return Returns a reference to this object so that method calls can be chained together. */ public Parameter withParameterKey(String parameterKey) { setParameterKey(parameterKey); return this; }
private static Collection<Parameter> parseParams(List<String> params) { Collection<Parameter> parameters = new ArrayList<>(); for (String param : params) { int i = param.indexOf('='); if (i < 0) { throw new IllegalArgumentException("Missing = in param " + param); } String key = param.substring(0, i); String value = param.substring(i + 1); parameters.add(new Parameter().withParameterKey(key).withParameterValue(value)); } return parameters; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Parameter == false) return false; Parameter other = (Parameter) obj; if (other.getParameterKey() == null ^ this.getParameterKey() == null) return false; if (other.getParameterKey() != null && other.getParameterKey().equals(this.getParameterKey()) == false) return false; if (other.getParameterValue() == null ^ this.getParameterValue() == null) return false; if (other.getParameterValue() != null && other.getParameterValue().equals(this.getParameterValue()) == false) return false; if (other.getUsePreviousValue() == null ^ this.getUsePreviousValue() == null) return false; if (other.getUsePreviousValue() != null && other.getUsePreviousValue().equals(this.getUsePreviousValue()) == false) return false; if (other.getResolvedValue() == null ^ this.getResolvedValue() == null) return false; if (other.getResolvedValue() != null && other.getResolvedValue().equals(this.getResolvedValue()) == false) return false; return true; }
@Override public Collection<Parameter> parseParams(InputStream fileContent) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(fileContent); Collection<Parameter> parameters = new ArrayList<>(); if (tree instanceof ArrayNode) { ArrayNode jsonNodes = (ArrayNode) tree; for (JsonNode node : jsonNodes) { Parameter param = new Parameter(); param.withParameterKey(node.get("ParameterKey").asText()); if (node.has("ParameterValue")) { param.withParameterValue(node.get("ParameterValue").asText()); } if (node.has("UsePreviousValue")) { param.withUsePreviousValue(node.get("UsePreviousValue").booleanValue()); } parameters.add(param); } } return parameters; }