Closed zliang-akamai closed 5 months ago
closes #483
ListVPCIPAddresses
ListAllVPCIPAddresses
/v4/vpcs/:id/ips
make ARGS="-run TestVPC_List" fixtures
import ( "context" "encoding/json" "fmt" "os" "github.com/linode/linodego" ) func main() { client := linodego.NewClient(nil) client.SetToken(os.Getenv("LINODE_TOKEN")) ctx := context.Background() region := "us-mia" vpc, err := client.CreateVPC( ctx, linodego.VPCCreateOptions{ Label: "test-vpc-ips", Region: region, Subnets: []linodego.VPCSubnetCreateOptions{ { Label: "test-vpc-ips-subnet", IPv4: "10.0.0.0/24", }, }, }, ) if err != nil { panic(err) } anyNAT11 := "any" instance, err := client.CreateInstance( ctx, linodego.InstanceCreateOptions{ Region: region, Image: "linode/ubuntu22.04", Type: "g6-nanode-1", RootPass: "this-is-an-UNSAFE-password", Interfaces: []linodego.InstanceConfigInterfaceCreateOptions{ { Purpose: linodego.InterfacePurposeVPC, SubnetID: &vpc.Subnets[0].ID, IPv4: &linodego.VPCIPv4{ NAT1To1: &anyNAT11, }, }, }, }, ) if err != nil { panic(err) } VPCAllIPs, err := client.ListAllVPCIPAddresses(ctx, linodego.NewListOptions(0, "")) if err != nil { panic(err) } VPCIPs, err := client.ListVPCIPAddresses(ctx, vpc.ID, linodego.NewListOptions(0, "")) if err != nil { panic(err) } VPCAllIPsJson, err := json.Marshal(VPCAllIPs) if err != nil { panic(err) } VPCIPsJson, err := json.Marshal(VPCIPs) if err != nil { panic(err) } fmt.Println(string(VPCAllIPsJson)) fmt.Println(string(VPCIPsJson)) client.DeleteInstance(ctx, instance.ID) client.DeleteVPC(ctx, vpc.ID) }
📝 Description
closes #483
ListVPCIPAddresses
function toListAllVPCIPAddresses
.ListVPCIPAddresses
function to call/v4/vpcs/:id/ips
API endpoint.✔️ How to Test