/** * <p> * The ID of the security group. * </p> * * @param groupId * The ID of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupId(String groupId) { setGroupId(groupId); return this; }
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; } } } }
/** * <p> * The ID of the security group. * </p> * * @param groupId * The ID of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupId(String groupId) { setGroupId(groupId); return this; }
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; }
groupIdentifier.setGroupId(securityGroupId); list.add(groupIdentifier); securityGroupsSet.addAll(list);
groupIdentifier.setGroupId(securityGroupId); list.add(groupIdentifier); securityGroupsSet.addAll(list);
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; } } } }
group.setGroupId(group_id); groups.add(group);
group.setGroupId(group_id); groups.add(group);