@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackResources() == null) ? 0 : getStackResources().hashCode()); return hashCode; }
/** * <p> * A list of <code>StackResource</code> structures. * </p> * * @param stackResources * A list of <code>StackResource</code> structures. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeStackResourcesResult withStackResources(java.util.Collection<StackResource> stackResources) { setStackResources(stackResources); return this; }
public DescribeStackResourcesResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeStackResourcesResult describeStackResourcesResult = new DescribeStackResourcesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeStackResourcesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("StackResources", targetDepth)) { describeStackResourcesResult.withStackResources(new ArrayList<StackResource>()); continue; } if (context.testExpression("StackResources/member", targetDepth)) { describeStackResourcesResult.withStackResources(StackResourceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeStackResourcesResult; } } } }
public DescribeStackResourcesResult unmarshall(StaxUnmarshallerContext context) throws Exception { DescribeStackResourcesResult describeStackResourcesResult = new DescribeStackResourcesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return describeStackResourcesResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("StackResources", targetDepth)) { describeStackResourcesResult.withStackResources(new ArrayList<StackResource>()); continue; } if (context.testExpression("StackResources/member", targetDepth)) { describeStackResourcesResult.withStackResources(StackResourceStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return describeStackResourcesResult; } } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeStackResourcesResult == false) return false; DescribeStackResourcesResult other = (DescribeStackResourcesResult) obj; if (other.getStackResources() == null ^ this.getStackResources() == null) return false; if (other.getStackResources() != null && other.getStackResources().equals(this.getStackResources()) == false) return false; return true; }
/** * <p> * A list of <code>StackResource</code> structures. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setStackResources(java.util.Collection)} or {@link #withStackResources(java.util.Collection)} if you want * to override the existing values. * </p> * * @param stackResources * A list of <code>StackResource</code> structures. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeStackResourcesResult withStackResources(StackResource... stackResources) { if (this.stackResources == null) { setStackResources(new com.amazonaws.internal.SdkInternalList<StackResource>(stackResources.length)); } for (StackResource ele : stackResources) { this.stackResources.add(ele); } return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStackResources() != null) sb.append("StackResources: ").append(getStackResources()); sb.append("}"); return sb.toString(); }
/** * <p> * A list of <code>StackResource</code> structures. * </p> * * @param stackResources * A list of <code>StackResource</code> structures. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeStackResourcesResult withStackResources(java.util.Collection<StackResource> stackResources) { setStackResources(stackResources); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DescribeStackResourcesResult == false) return false; DescribeStackResourcesResult other = (DescribeStackResourcesResult) obj; if (other.getStackResources() == null ^ this.getStackResources() == null) return false; if (other.getStackResources() != null && other.getStackResources().equals(this.getStackResources()) == false) return false; return true; }
/** * <p> * A list of <code>StackResource</code> structures. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setStackResources(java.util.Collection)} or {@link #withStackResources(java.util.Collection)} if you want * to override the existing values. * </p> * * @param stackResources * A list of <code>StackResource</code> structures. * @return Returns a reference to this object so that method calls can be chained together. */ public DescribeStackResourcesResult withStackResources(StackResource... stackResources) { if (this.stackResources == null) { setStackResources(new com.amazonaws.internal.SdkInternalList<StackResource>(stackResources.length)); } for (StackResource ele : stackResources) { this.stackResources.add(ele); } return this; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getStackResources() == null) ? 0 : getStackResources().hashCode()); return hashCode; }
public static String getStackResourcesToJson(DescribeStackResourcesResult describeStackResources) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, describeStackResources.getStackResources()); final byte[] stackResources = out.toByteArray(); return new String(stackResources); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getStackResources() != null) sb.append("StackResources: ").append(getStackResources()); sb.append("}"); return sb.toString(); }
private String autoDetectStackName(String instanceId) { Assert.notNull(instanceId, "No valid instance id defined"); DescribeStackResourcesResult describeStackResourcesResult = this.amazonCloudFormationClient.describeStackResources(new DescribeStackResourcesRequest().withPhysicalResourceId(instanceId)); if (describeStackResourcesResult != null && describeStackResourcesResult.getStackResources() != null && !describeStackResourcesResult.getStackResources().isEmpty()) { return describeStackResourcesResult.getStackResources().get(0).getStackName(); } if (this.amazonEc2Client != null) { DescribeTagsResult describeTagsResult = this.amazonEc2Client.describeTags(new DescribeTagsRequest().withFilters( new Filter("resource-id", Collections.singletonList(instanceId)), new Filter("resource-type", Collections.singletonList("instance")), new Filter("key", Collections.singletonList("aws:cloudformation:stack-name")))); if (describeTagsResult != null && describeTagsResult.getTags() != null && !describeTagsResult.getTags().isEmpty()) { return describeTagsResult.getTags().get(0).getValue(); } } return null; } }
private String autoDetectStackName(String instanceId) { Assert.notNull(instanceId, "No valid instance id defined"); DescribeStackResourcesResult describeStackResourcesResult = this.amazonCloudFormationClient.describeStackResources(new DescribeStackResourcesRequest().withPhysicalResourceId(instanceId)); if (describeStackResourcesResult != null && describeStackResourcesResult.getStackResources() != null && !describeStackResourcesResult.getStackResources().isEmpty()) { return describeStackResourcesResult.getStackResources().get(0).getStackName(); } if (this.amazonEc2Client != null) { DescribeTagsResult describeTagsResult = this.amazonEc2Client.describeTags(new DescribeTagsRequest().withFilters( new Filter("resource-id", Collections.singletonList(instanceId)), new Filter("resource-type", Collections.singletonList("instance")), new Filter("key", Collections.singletonList("aws:cloudformation:stack-name")))); if (describeTagsResult != null && describeTagsResult.getTags() != null && !describeTagsResult.getTags().isEmpty()) { return describeTagsResult.getTags().get(0).getValue(); } } return null; } }
public List<StackResource> getStackResources(String stackName) { if (getProject().getGradle().getStartParameter().isOffline() == false) { try { DescribeStackResourcesResult describeStackResourcesResult = getClient().describeStackResources(new DescribeStackResourcesRequest() .withStackName(stackName)); return describeStackResourcesResult.getStackResources(); } catch (AmazonCloudFormationException e) { if ("ValidationError".equals(e.getErrorCode())) { return Collections.emptyList(); } else { throw new GradleException(e.getMessage(), e); } } } logger.info("offline mode: return empty resources"); return Collections.emptyList(); }
results.put(Outputs.STACK_RESOURCES_RESULT,stackBuilder.describeStackResources(stackResourceRequest).getStackResources().toString());