Skip to content

new: List ips under a specific VPC - #391

Merged
yec-akamai merged 2 commits into
devfrom
TPT-2791/support-ips-under-vpc
Apr 8, 2024
Merged

new: List ips under a specific VPC#391
yec-akamai merged 2 commits into
devfrom
TPT-2791/support-ips-under-vpc

Conversation

@yec-akamai

Copy link
Copy Markdown
Contributor

📝 Description

This change supports the endpoint GET /vpcs/{vpc_id}/ips to list the ips under a specific VPC.

✔️ How to Test

tox
make TEST_CASE=test_create_vpc testint

Manual Test:

  1. In a sandbox environment, run the following script
import os

from linode_api4 import LinodeClient
from linode_api4.objects import ConfigInterface

def main():
    client = LinodeClient(os.getenv("LINODE_TOKEN"))

    vpc = client.vpcs.create(
        "pythonsdk-test-vpc-123",
        "us-mia",
        description="test description",
    )
    
    subnet = vpc.subnet_create("test-subnet", ipv4="10.0.0.0/24")
    
    linode1, _ = client.linode.instance_create(
        "g6-nanode-1",
        "us-mia",
        label="test-vpc-instance-1",
        image="linode/alpine3.19",
        interfaces=[
            ConfigInterface(
                purpose="vpc",
                subnet_id=subnet.id,
            )
        ]
    )
    
    linode2, _ = client.linode.instance_create(
        "g6-nanode-1",
        "us-mia",
        label="test-vpc-instance-2",
        image="linode/alpine3.19",
        interfaces=[
            ConfigInterface(
                purpose="vpc",
                subnet_id=subnet.id,
            )
        ]
    )

    vpc_ips = vpc.ips

    assert len(vpc_ips) > 0
    assert vpc_ips[0].vpc_id == vpc.id
    assert vpc_ips[0].subnet_id == subnet.id
    
    print(*vpc_ips)
    
    linode1.delete()
    linode2.delete()
    subnet.delete()
    vpc.delete()


if __name__ == "__main__":
    main()
  1. Observe the the list of ips under this VPC is printed and no error is raised.

@yec-akamai
yec-akamai requested a review from a team as a code owner April 5, 2024 18:01
@yec-akamai
yec-akamai requested review from ykim-akamai and zliang-akamai and removed request for a team April 5, 2024 18:01
instance.delete()


@pytest.fixture(scope="session")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a duplicated fixture. Not related to this change.

@zliang-akamai zliang-akamai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well, nice job!

@ykim-akamai ykim-akamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good works well locally

@yec-akamai
yec-akamai merged commit c8f4bd5 into dev Apr 8, 2024
@yec-akamai
yec-akamai deleted the TPT-2791/support-ips-under-vpc branch April 8, 2024 15:57
@zliang-akamai zliang-akamai added the new-feature for new features in the changelog. label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants