software.amazon.awscdk.services.ec2.alpha.IpamOptions Maven / Gradle / Ivy
package software.amazon.awscdk.services.ec2.alpha;
/**
* (experimental) Options for configuring an IP Address Manager (IPAM).
*
* For more information, see the {@link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipam.html}.
*
* Example:
*
*
* Stack stack = new Stack();
* Ipam ipam = Ipam.Builder.create(this, "Ipam")
* .operatingRegion(List.of("us-west-1"))
* .build();
* IIpamPool ipamPublicPool = ipam.publicScope.addPool("PublicPoolA", PoolOptions.builder()
* .addressFamily(AddressFamily.IP_V6)
* .awsService(AwsServiceName.EC2)
* .locale("us-west-1")
* .publicIpSource(IpamPoolPublicIpSource.AMAZON)
* .build());
* ipamPublicPool.provisionCidr("PublicPoolACidrA", IpamPoolCidrProvisioningOptions.builder().netmaskLength(52).build());
* IIpamPool ipamPrivatePool = ipam.privateScope.addPool("PrivatePoolA", PoolOptions.builder()
* .addressFamily(AddressFamily.IP_V4)
* .build());
* ipamPrivatePool.provisionCidr("PrivatePoolACidrA", IpamPoolCidrProvisioningOptions.builder().netmaskLength(8).build());
* VpcV2.Builder.create(this, "Vpc")
* .primaryAddressBlock(IpAddresses.ipv4("10.0.0.0/24"))
* .secondaryAddressBlocks(List.of(IpAddresses.amazonProvidedIpv6(SecondaryAddressProps.builder().cidrBlockName("AmazonIpv6").build()), IpAddresses.ipv6Ipam(IpamOptions.builder()
* .ipamPool(ipamPublicPool)
* .netmaskLength(52)
* .cidrBlockName("ipv6Ipam")
* .build()), IpAddresses.ipv4Ipam(IpamOptions.builder()
* .ipamPool(ipamPrivatePool)
* .netmaskLength(8)
* .cidrBlockName("ipv4Ipam")
* .build())))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.103.1 (build bef2dea)", date = "2024-10-11T15:56:07.918Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.ec2.alpha.$Module.class, fqn = "@aws-cdk/aws-ec2-alpha.IpamOptions")
@software.amazon.jsii.Jsii.Proxy(IpamOptions.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface IpamOptions extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) Required to set Secondary cidr block resource name in order to generate unique logical id for the resource.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull java.lang.String getCidrBlockName();
/**
* (experimental) Ipv4 or an Ipv6 IPAM pool Only required when using AWS Ipam.
*
* Default: - no pool attached to VPC secondary address
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ec2.alpha.IIpamPool getIpamPool() {
return null;
}
/**
* (experimental) CIDR Mask for Vpc Only required when using AWS Ipam.
*
* Default: - no netmask length for IPAM attached to VPC secondary address
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Number getNetmaskLength() {
return null;
}
/**
* @return a {@link Builder} of {@link IpamOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link IpamOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.String cidrBlockName;
software.amazon.awscdk.services.ec2.alpha.IIpamPool ipamPool;
java.lang.Number netmaskLength;
/**
* Sets the value of {@link IpamOptions#getCidrBlockName}
* @param cidrBlockName Required to set Secondary cidr block resource name in order to generate unique logical id for the resource. This parameter is required.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder cidrBlockName(java.lang.String cidrBlockName) {
this.cidrBlockName = cidrBlockName;
return this;
}
/**
* Sets the value of {@link IpamOptions#getIpamPool}
* @param ipamPool Ipv4 or an Ipv6 IPAM pool Only required when using AWS Ipam.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder ipamPool(software.amazon.awscdk.services.ec2.alpha.IIpamPool ipamPool) {
this.ipamPool = ipamPool;
return this;
}
/**
* Sets the value of {@link IpamOptions#getNetmaskLength}
* @param netmaskLength CIDR Mask for Vpc Only required when using AWS Ipam.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder netmaskLength(java.lang.Number netmaskLength) {
this.netmaskLength = netmaskLength;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link IpamOptions}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public IpamOptions build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link IpamOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements IpamOptions {
private final java.lang.String cidrBlockName;
private final software.amazon.awscdk.services.ec2.alpha.IIpamPool ipamPool;
private final java.lang.Number netmaskLength;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.cidrBlockName = software.amazon.jsii.Kernel.get(this, "cidrBlockName", software.amazon.jsii.NativeType.forClass(java.lang.String.class));
this.ipamPool = software.amazon.jsii.Kernel.get(this, "ipamPool", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ec2.alpha.IIpamPool.class));
this.netmaskLength = software.amazon.jsii.Kernel.get(this, "netmaskLength", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.cidrBlockName = java.util.Objects.requireNonNull(builder.cidrBlockName, "cidrBlockName is required");
this.ipamPool = builder.ipamPool;
this.netmaskLength = builder.netmaskLength;
}
@Override
public final java.lang.String getCidrBlockName() {
return this.cidrBlockName;
}
@Override
public final software.amazon.awscdk.services.ec2.alpha.IIpamPool getIpamPool() {
return this.ipamPool;
}
@Override
public final java.lang.Number getNetmaskLength() {
return this.netmaskLength;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("cidrBlockName", om.valueToTree(this.getCidrBlockName()));
if (this.getIpamPool() != null) {
data.set("ipamPool", om.valueToTree(this.getIpamPool()));
}
if (this.getNetmaskLength() != null) {
data.set("netmaskLength", om.valueToTree(this.getNetmaskLength()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-ec2-alpha.IpamOptions"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IpamOptions.Jsii$Proxy that = (IpamOptions.Jsii$Proxy) o;
if (!cidrBlockName.equals(that.cidrBlockName)) return false;
if (this.ipamPool != null ? !this.ipamPool.equals(that.ipamPool) : that.ipamPool != null) return false;
return this.netmaskLength != null ? this.netmaskLength.equals(that.netmaskLength) : that.netmaskLength == null;
}
@Override
public final int hashCode() {
int result = this.cidrBlockName.hashCode();
result = 31 * result + (this.ipamPool != null ? this.ipamPool.hashCode() : 0);
result = 31 * result + (this.netmaskLength != null ? this.netmaskLength.hashCode() : 0);
return result;
}
}
}