Skip to content

new: Add vpc field to Instance(...).ips property method result - #379

Merged
lgarber-akamai merged 3 commits into
linode:devfrom
lgarber-akamai:new/vpc-networking-info-changes
Mar 18, 2024
Merged

new: Add vpc field to Instance(...).ips property method result#379
lgarber-akamai merged 3 commits into
linode:devfrom
lgarber-akamai:new/vpc-networking-info-changes

Conversation

@lgarber-akamai

@lgarber-akamai lgarber-akamai commented Mar 12, 2024

Copy link
Copy Markdown
Contributor

📝 Description

This change adds support for the vpc structure in the Instance(...).ips (networking information list) property method. Entries in this struct are stored as objects of the new VPCIPAddress class, which is necessary to expose certain VPC-specific fields and to prevent attempted refreshes on VPC IP addresses.

✔️ How to Test

The following test steps assume you have pulled down this PR locally and run make install.

Unit Testing

make testunit

Integration Testing

make testint

Manual Testing

  1. In a linode_api4 sandbox environment (e.g. dx-devenv), run the following:
import os

from linode_api4 import LinodeClient
from linode_api4.objects import ConfigInterface

client = LinodeClient(os.getenv("LINODE_TOKEN"))

vpc = client.vpcs.create(
    "test-vpc",
    "us-mia",
)

subnet = vpc.subnet_create(
    "test-subnet",
    ipv4="10.0.0.0/24"
)

inst, _ = client.linode.instance_create(
    "g6-nanode-1",
    "us-mia",
    label="test-instance",
    image="linode/alpine3.19",
    interfaces=[
        ConfigInterface(
            purpose="vpc",
            subnet_id=subnet.id,
        )
    ]
)

print(inst.ips.ipv4.vpc)
  1. Ensure the output looks similar to the following:
[VPCIPAddress(address='10.0.0.2', gateway='10.0.0.1', region='us-mia', subnet_mask='255.255.255.0', vpc_id=40874, subnet_id=40952, linode_id=55940621, config_id=59073074, interface_id=1190879, prefix=24, active=False, address_range=None, nat_1_1=None)]

@lgarber-akamai
lgarber-akamai marked this pull request as ready for review March 12, 2024 14:56
@lgarber-akamai
lgarber-akamai requested a review from a team as a code owner March 12, 2024 14:56
@lgarber-akamai
lgarber-akamai requested review from jriddle-linode and yec-akamai and removed request for a team March 12, 2024 14:56
@lgarber-akamai lgarber-akamai added the enhancement issues that request a enhancement label Mar 12, 2024

@yec-akamai yec-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.

Nice work! Tests passed successfully

Comment on lines +133 to +135
nat_1_1: Optional[str] = None


@lgarber-akamai lgarber-akamai Mar 18, 2024

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.

Do we think it'd make sense to implement property methods here to allow for easy access to the corresponding VPC, VPCSubnet, etc. objects from this class? The only issue is that a client isn't embedded in JSON objects as of now, although it would be a relatively straightforward change to make.

edit: Just created an internal feedback entry for this 👍

@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 on my end. Nice work!

@lgarber-akamai
lgarber-akamai merged commit 95d0b20 into linode:dev Mar 18, 2024
@jriddle-linode jriddle-linode added improvement for improvements in existing functionality in the changelog. and removed enhancement issues that request a enhancement labels Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants