public Filter unmarshall(StaxUnmarshallerContext context) throws Exception { Filter filter = new Filter(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return filter; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Name", targetDepth)) { filter.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Values", targetDepth)) { filter.withValues(new ArrayList<String>()); continue; } if (context.testExpression("Values/member", targetDepth)) { filter.withValues(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return filter; } } } }
public Filter unmarshall(StaxUnmarshallerContext context) throws Exception { Filter filter = new Filter(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("Name", targetDepth)) { filter.setName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Values/member", targetDepth)) { filter.withValues(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return filter; }
public Map<String, String> getDeployTags() { Map<String, String> tags = new HashMap<>(3); Optional<AutoScalingInstanceDetails> details = describeInstance(); details.ifPresent(autoScalingInstanceDetails -> { autoScalingInstanceDetails.getAutoScalingGroupName(); List<Filter> filters = Collections.singletonList( new Filter().withName("auto-scaling-group").withValues(autoScalingInstanceDetails.getAutoScalingGroupName()) ); DescribeTagsResult result = asyncClient.describeTags(new DescribeTagsRequest().withFilters(filters)); result.getTags().forEach(t -> tags.put(t.getKey(), t.getValue())); }); return tags; }