public GroupIdentifier unmarshall(StaxUnmarshallerContext context) throws Exception { GroupIdentifier groupIdentifier = new GroupIdentifier(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return groupIdentifier; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("groupName", targetDepth)) { groupIdentifier.setGroupName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("groupId", targetDepth)) { groupIdentifier.setGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return groupIdentifier; } } } }
public GroupIdentifier unmarshall(StaxUnmarshallerContext context) throws Exception { GroupIdentifier groupIdentifier = new GroupIdentifier(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return groupIdentifier; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("groupName", targetDepth)) { groupIdentifier.setGroupName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("groupId", targetDepth)) { groupIdentifier.setGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return groupIdentifier; } } } }
public static List<GroupIdentifier> getSecurityGroupsByInstanceId(String instanceId, String esUrl) throws Exception { List<GroupIdentifier> list = new ArrayList<>(); JsonParser jsonParser = new JsonParser(); Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustNotFilter = new HashMap<>(); HashMultimap<String, Object> shouldFilter = HashMultimap.create(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.INSTANCEID), instanceId); JsonObject resultJson = RulesElasticSearchRepositoryUtil.getQueryDetailsFromES(esUrl, mustFilter, mustNotFilter, shouldFilter, null, 0, mustTermsFilter, null); if (resultJson != null && resultJson.has(PacmanRuleConstants.HITS)) { JsonObject hitsJson = (JsonObject) jsonParser.parse(resultJson.get(PacmanRuleConstants.HITS).toString()); JsonArray hitsArray = hitsJson.getAsJsonArray(PacmanRuleConstants.HITS); for (int i = 0; i < hitsArray.size(); i++) { JsonObject source = hitsArray.get(i).getAsJsonObject().get(PacmanRuleConstants.SOURCE) .getAsJsonObject(); String securitygroupid = source.get(PacmanRuleConstants.EC2_WITH_SECURITYGROUP_ID).getAsString(); GroupIdentifier groupIdentifier = new GroupIdentifier(); if (!com.amazonaws.util.StringUtils.isNullOrEmpty(securitygroupid)) { groupIdentifier.setGroupId(securitygroupid); list.add(groupIdentifier); } } } return list; }
Annotation annotation = null; Set<GroupIdentifier> securityGroupsSet = new HashSet<>(); GroupIdentifier groupIdentifier = new GroupIdentifier(); List<GroupIdentifier> list = new ArrayList<>(); String securityGroupId = ruleParam.get(PacmanSdkConstants.RESOURCE_ID);
Annotation annotation = null; Set<GroupIdentifier> securityGroupsSet = new HashSet<>(); GroupIdentifier groupIdentifier = new GroupIdentifier(); List<GroupIdentifier> list = new ArrayList<>(); String securityGroupId = ruleParam.get(PacmanSdkConstants.RESOURCE_ID);
public GroupIdentifier unmarshall(StaxUnmarshallerContext context) throws Exception { GroupIdentifier groupIdentifier = new GroupIdentifier(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return groupIdentifier; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("groupName", targetDepth)) { groupIdentifier.setGroupName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("groupId", targetDepth)) { groupIdentifier.setGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return groupIdentifier; } } } }
GroupIdentifier group = new GroupIdentifier(); group.setGroupId(group_id); groups.add(group);
@Override public DescribeInstanceAttributeResult describeInstanceAttribute(AmazonEC2Client ec2Client, DescribeInstanceAttributeRequest describeInstanceAttributeRequest) { InstanceAttribute instanceAttribute = new InstanceAttribute(); instanceAttribute.withGroups(new GroupIdentifier().withGroupId("A_TEST_SECURITY_GROUP")); return new DescribeInstanceAttributeResult().withInstanceAttribute(instanceAttribute); }
GroupIdentifier group = new GroupIdentifier(); group.setGroupId(group_id); groups.add(group);