Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: List ips under a specific VPC #391

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Conversation

yec-akamai
Copy link
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 zliang-akamai and ykim-1 and removed request for a team April 5, 2024 18:01
@@ -316,22 +316,6 @@ def create_vpc_with_subnet_and_linode(
instance.delete()


@pytest.fixture(scope="session")
Copy link
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.

Copy link
Member

@zliang-akamai zliang-akamai left a comment

Choose a reason for hiding this comment

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

Works well, nice job!

Copy link
Contributor

@ykim-1 ykim-1 left a comment

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
9 checks passed
@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