/** * @see SecurityGroup#delegate() */ public T role(IpPermission role) { this.ipPermissions.add(role); return self(); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText.setLength(0); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText.setLength(0); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText = new StringBuilder(); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText.setLength(0); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText = new StringBuilder(); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText.setLength(0); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText.setLength(0); }
/** * {@inheritDoc} */ @Override public void endElement(String uri, String name, String qName) throws SAXException { if (equalsOrSuffix(qName, "item")) { endItem(uri, name, qName); itemDepth--; } else if (equalsOrSuffix(qName, "ipPermissions")) { inIpPermissions = false; itemDepth = 0; } else if (inIpPermissions) { ipPermissionHandler.endElement(uri, name, qName); } else if (equalsOrSuffix(qName, "groupName")) { builder.name(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupId")) { builder.id(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "ownerId")) { builder.ownerId(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "groupDescription")) { builder.description(currentOrNull(currentText)); } currentText = new StringBuilder(); }
@Test public void testApply() { IpPermissions authorization = IpPermissions.permitAnyProtocol(); org.jclouds.ec2.domain.SecurityGroup origGroup = org.jclouds.ec2.domain.SecurityGroup.builder() .region("us-east-1") .id("some-id") .name("some-group") .ownerId("some-owner") .description("some-description") .ipPermission(authorization) .build(); EC2SecurityGroupToSecurityGroup parser = createGroupParser(ImmutableSet.of(provider)); SecurityGroup group = parser.apply(origGroup); assertEquals(group.getLocation(), provider); assertEquals(group.getId(), provider.getId() + "/" + origGroup.getName()); assertEquals(group.getProviderId(), origGroup.getId()); assertEquals(group.getName(), origGroup.getName()); assertEquals(group.getIpPermissions(), (Set<IpPermission>)origGroup); assertEquals(group.getOwnerId(), origGroup.getOwnerId()); }
@Test public void testApply() { IpPermissions authorization = IpPermissions.permitAnyProtocol(); org.jclouds.ec2.domain.SecurityGroup origGroup = org.jclouds.ec2.domain.SecurityGroup.builder() .region("us-east-1") .id("some-id") .name("some-group") .ownerId("some-owner") .description("some-description") .ipPermission(authorization) .build(); AWSEC2SecurityGroupToSecurityGroup parser = createGroupParser(ImmutableSet.of(provider)); SecurityGroup group = parser.apply(origGroup); assertEquals(group.getLocation(), provider); assertEquals(group.getId(), provider.getId() + "/" + origGroup.getId()); assertEquals(group.getProviderId(), origGroup.getId()); assertEquals(group.getName(), origGroup.getName()); assertEquals(group.getIpPermissions(), (Set<IpPermission>)origGroup); assertEquals(group.getOwnerId(), origGroup.getOwnerId()); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
public Set<SecurityGroup> expected() { return ImmutableSet.of(SecurityGroup.builder() .region(defaultRegion) .ownerId("123123123123") .id("sg-11111111") .name("default") .description("default VPC security group") // .vpcId("vpc-99999999") .ipPermission(IpPermission.builder() .ipProtocol(IpProtocol.ALL) .tenantIdGroupNamePair("123123123123", "sg-11111111").build()) // .ipPermissionEgress(IpPermission.builder() // .ipProtocol(IpProtocol.ALL) // .ipRange("0.0.0.0/0").build()) .build()); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }
protected SecurityGroup.Builder<?> builder() { return SecurityGroup.builder().region(region); }