Skip to content

Commit

Permalink
correcting docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
shikha372 committed Aug 1, 2024
1 parent 086958e commit 2f35dc1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 41 deletions.
38 changes: 18 additions & 20 deletions packages/@aws-cdk/aws-vpcv2-alpha/lib/ipam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { Lazy, Names, Resource, Stack } from 'aws-cdk-lib';

/**
* Represents the address family for IP addresses in an IPAM pool.
*
* @enum {string}
* @property {string} IP_V4 - Represents the IPv4 address family.
* @property {string} IP_V6 - Represents the IPv6 address family.
* IP_V4 - Represents the IPv4 address family.
* IP_V6 - Represents the IPv6 address family.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html#cfn-ec2-ipampool-addressfamily
*/
export enum AddressFamily {
Expand Down Expand Up @@ -76,13 +74,6 @@ export interface IpamProps{
* Options for configuring an IPAM pool.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html
*
* @interface PoolOptions
* @property {AddressFamily} addressFamily - The address family of the pool (ipv4 or ipv6).
* @property {CfnIPAMPool.ProvisionedCidrProperty[]} [provisionedCidrs] - Information about the CIDRs provisioned to the pool.
* @property {string} [locale] - The locale (AWS Region) of the pool.
* @property {IpamPoolPublicIpSource} [publicIpSource] - The IP address source for pools in the public scope.
* @property {string} [awsService] - Limits which AWS service can use the pool.
*/
export interface PoolOptions{

Expand All @@ -92,7 +83,7 @@ export interface PoolOptions{
readonly addressFamily: AddressFamily;

/**
* [provisionedCidrs] - Information about the CIDRs provisioned to the pool.
* Information about the CIDRs provisioned to the pool.
* @default - No CIDRs are provisioned
* @see CfnIPAMPool.ProvisionedCidrProperty
*/
Expand All @@ -109,7 +100,7 @@ export interface PoolOptions{
readonly locale?: string;

/**
* [publicIpSource] - The IP address source for pools in the public scope.
* The IP address source for pools in the public scope.
* Only used for IPv6 address
* Only allowed values to this are 'byoip' or 'amazon'
* @default amazon
Expand All @@ -130,12 +121,7 @@ export interface PoolOptions{

/**
* Properties for creating an IPAM pool.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipampool.html
*
* @interface IpamPoolProps
* @extends {PoolOptions}
* @property {string} ipamScopeId - The ID of the IPAM scope.
*/
interface IpamPoolProps extends PoolOptions {
/**
Expand Down Expand Up @@ -194,7 +180,6 @@ export interface IIpamPool{
/**
* IPAM scope is the highest-level container within IPAM. An IPAM contains two default scopes.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-ipamscope.html
* @property {ipamId}
*/
export interface IpamScopeProps {
/**
Expand Down Expand Up @@ -380,6 +365,7 @@ class IpamScope extends Resource implements IIpamScopeBase {
this.scopeId = this._ipamScope.attrIpamScopeId;
this.scope = scope;
this.props = props;
this.n;
}

/**
Expand Down Expand Up @@ -444,6 +430,11 @@ export class Ipam extends Resource {
*/
public readonly operatingRegions: string[];

/**
* List of custom scopes created under this IPAM
*/
public readonly customScopes: IIpamScopeBase[] = [];

constructor(scope: Construct, id: string, props?: IpamProps) {
super(scope, id);

Expand All @@ -464,18 +455,25 @@ export class Ipam extends Resource {
ipamScopeId: this._ipam.attrPrivateDefaultScopeId,
});

this.node.defaultChild = this.publicScope.scope;
this.node.defaultChild = this.privateScope.scope;
this.customScopes.forEach(customScope => {
this.node.defaultChild = customScope.scope;
});
}

/**
* Function to add custom scope to an existing IPAM
* Custom scopes can only be private
*/
public addScope(scope: Construct, id: string, options: IpamScopeOptions): IIpamScopeBase {
return new IpamScope(scope, id, {
const ipamScope = new IpamScope(scope, id, {
...options,
ipamId: this.ipamId,
ipamOperatingRegions: this.operatingRegions,
});
this.customScopes.push(ipamScope);
return ipamScope;
}
}

Expand Down
26 changes: 5 additions & 21 deletions packages/@aws-cdk/aws-vpcv2-alpha/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ export class NetworkUtils {
/**
* Converts a string representation of an IPv4 address to its corresponding numerical value.
*
* @param ipAddress The IPv4 address string to be converted.
* @returns The numerical value of the IPv4 address.
* @throws Error if the provided IPv4 address string is invalid.
* Converts a string IPv4 to a number
*
* Uses the formula:
* (first octet * 256³) + (second octet * 256²) + (third octet * 256) +
* (fourth octet)
*
* @param {string} the IP address (e.g. 174.66.173.168)
* @returns {number} the integer value of the IP address (e.g 2923605416)
* @param ipAddress the IP address (e.g. 174.66.173.168)
* @returns the integer value of the IP address (e.g 2923605416)
*/
public static ipToNum(ipAddress: string): number {
if (!this.validIp(ipAddress)) {
Expand All @@ -93,8 +88,8 @@ export class NetworkUtils {
* Takes a number (e.g 2923605416) and converts it to an IPv4 address string
* currently only supports IPv4
*
* @param {number} the integer value of the IP address (e.g 2923605416)
* @returns {string} the IPv4 address (e.g. 174.66.173.168)
* @param ipNum integer value of the IP address (e.g 2923605416)
* @returns IPv4 address (e.g. 174.66.173.168)
*/
public static numToIp(ipNum: number): string {
// this all because bitwise math is signed
Expand Down Expand Up @@ -152,18 +147,8 @@ export class CidrBlock {
return 2 ** (32 - mask);
}

/*
* The CIDR Block represented as a string e.g. '10.0.0.0/21'
*/
/**
* Creates a new CidrBlock instance representing an IPv4 CIDR block.
*
* @param cidrOrIpAddress The CIDR notation string (e.g., '10.0.0.0/16') or the IP address number to be used as the base address.
* @param mask The CIDR prefix length (between 0 and 32) if providing an IP address number as the first argument.
*/
/**
* The total number of IP addresses in the CIDR block.
* This is calculated as 2^(32 - mask).
* IP address in the CIDR block.
*/
public readonly cidr: string;

Expand Down Expand Up @@ -381,7 +366,6 @@ export class CidrBlockIpv6 {
}

/**
*
* @param ipv6Address
* @returns Converts given ipv6 address range to big int number
*/
Expand Down

0 comments on commit 2f35dc1

Please sign in to comment.