From 4eb565879494af7335461f50ae408bb307ebe116 Mon Sep 17 00:00:00 2001 From: Zhiwei Liang <121905282+zliang-akamai@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:29:38 -0400 Subject: [PATCH] Add a list VPC IPs function for a specific VPC (#488) --- .golangci.yml | 9 +- .../fixtures/TestVPC_ListAllIPAddresses.yaml | 718 ++++++++++++++++++ .../fixtures/TestVPC_ListIPAddresses.yaml | 62 +- test/integration/vpc_test.go | 31 +- vpc_ips.go | 14 +- 5 files changed, 792 insertions(+), 42 deletions(-) create mode 100644 test/integration/fixtures/TestVPC_ListAllIPAddresses.yaml diff --git a/.golangci.yml b/.golangci.yml index e37e28aed..063292f35 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,22 +7,15 @@ linters-settings: check-blank: true govet: - check-shadowing: true - enable: - atomicalign - enable-all: false - disable: - shadow + enable-all: false disable-all: false - golint: - min-confidence: 0.8 gocyclo: min-complexity: 30 gocognit: min-complexity: 30 - maligned: - suggest-new: true dupl: threshold: 100 diff --git a/test/integration/fixtures/TestVPC_ListAllIPAddresses.yaml b/test/integration/fixtures/TestVPC_ListAllIPAddresses.yaml new file mode 100644 index 000000000..630b40ec3 --- /dev/null +++ b/test/integration/fixtures/TestVPC_ListAllIPAddresses.yaml @@ -0,0 +1,718 @@ +--- +version: 1 +interactions: +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/regions + method: GET + response: + body: '{"data": [{"id": "ap-west", "label": "Mumbai, IN", "country": "in", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "GPU Linodes", "Kubernetes", + "Cloud Firewall", "Vlans", "Block Storage Migrations", "Managed Databases"], + "status": "ok", "resolvers": {"ipv4": "172.105.34.5, 172.105.35.5, 172.105.36.5, + 172.105.37.5, 172.105.38.5, 172.105.39.5, 172.105.40.5, 172.105.41.5, 172.105.42.5, + 172.105.43.5", "ipv6": "1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678"}, "site_type": + "core"}, {"id": "ca-central", "label": "Toronto, CA", "country": "ca", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Kubernetes", "Cloud + Firewall", "Vlans", "Block Storage Migrations", "Managed Databases"], "status": + "ok", "resolvers": {"ipv4": "172.105.0.5, 172.105.3.5, 172.105.4.5, 172.105.5.5, + 172.105.6.5, 172.105.7.5, 172.105.8.5, 172.105.9.5, 172.105.10.5, 172.105.11.5", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "ap-southeast", + "label": "Sydney, AU", "country": "au", "capabilities": ["Linodes", "Backups", + "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block + Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": + "172.105.166.5, 172.105.169.5, 172.105.168.5, 172.105.172.5, 172.105.162.5, + 172.105.170.5, 172.105.167.5, 172.105.171.5, 172.105.181.5, 172.105.161.5", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-iad", "label": + "Washington, DC", "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Managed Databases", "Metadata", "Premium Plans"], "status": "ok", "resolvers": + {"ipv4": "139.144.192.62, 139.144.192.60, 139.144.192.61, 139.144.192.53, 139.144.192.54, + 139.144.192.67, 139.144.192.69, 139.144.192.66, 139.144.192.52, 139.144.192.68", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-ord", "label": + "Chicago, IL", "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Managed Databases", "Metadata", "Premium Plans"], "status": "ok", "resolvers": + {"ipv4": "172.232.0.17, 172.232.0.16, 172.232.0.21, 172.232.0.13, 172.232.0.22, + 172.232.0.9, 172.232.0.19, 172.232.0.20, 172.232.0.15, 172.232.0.18", "ipv6": + "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "fr-par", "label": + "Paris, FR", "country": "fr", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Managed Databases", "Metadata", "Premium Plans"], "status": "ok", "resolvers": + {"ipv4": "172.232.32.21, 172.232.32.23, 172.232.32.17, 172.232.32.18, 172.232.32.16, + 172.232.32.22, 172.232.32.20, 172.232.32.14, 172.232.32.11, 172.232.32.12", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-sea", "label": + "Seattle, WA", "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.232.160.19, 172.232.160.21, 172.232.160.17, 172.232.160.15, 172.232.160.18, + 172.232.160.8, 172.232.160.12, 172.232.160.11, 172.232.160.14, 172.232.160.16", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "br-gru", "label": + "Sao Paulo, BR", "country": "br", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.233.0.4, 172.233.0.9, 172.233.0.7, 172.233.0.12, 172.233.0.5, 172.233.0.13, + 172.233.0.10, 172.233.0.6, 172.233.0.8, 172.233.0.11", "ipv6": "1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678"}, + "site_type": "core"}, {"id": "nl-ams", "label": "Amsterdam, NL", "country": + "nl", "capabilities": ["Linodes", "Backups", "NodeBalancers", "Block Storage", + "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", "VPCs", "Metadata", + "Premium Plans"], "status": "ok", "resolvers": {"ipv4": "172.233.33.36, 172.233.33.38, + 172.233.33.35, 172.233.33.39, 172.233.33.34, 172.233.33.33, 172.233.33.31, 172.233.33.30, + 172.233.33.37, 172.233.33.32", "ipv6": "1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678"}, "site_type": + "core"}, {"id": "se-sto", "label": "Stockholm, SE", "country": "se", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Cloud Firewall", "Vlans", "VPCs", "Metadata", "Premium Plans"], "status": "ok", + "resolvers": {"ipv4": "172.232.128.24, 172.232.128.26, 172.232.128.20, 172.232.128.22, + 172.232.128.25, 172.232.128.19, 172.232.128.23, 172.232.128.18, 172.232.128.21, + 172.232.128.27", "ipv6": "1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678"}, "site_type": + "core"}, {"id": "es-mad", "label": "Madrid, ES", "country": "es", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Cloud Firewall", "Vlans", "VPCs", "Metadata", "Premium Plans"], "status": "ok", + "resolvers": {"ipv4": "172.233.111.6, 172.233.111.17, 172.233.111.21, 172.233.111.25, + 172.233.111.19, 172.233.111.12, 172.233.111.26, 172.233.111.16, 172.233.111.18, + 172.233.111.9", "ipv6": "1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678"}, "site_type": + "core"}, {"id": "in-maa", "label": "Chennai, IN", "country": "in", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Object Storage", "Kubernetes", + "Cloud Firewall", "Vlans", "VPCs", "Metadata", "Premium Plans"], "status": "ok", + "resolvers": {"ipv4": "172.232.96.17, 172.232.96.26, 172.232.96.19, 172.232.96.20, + 172.232.96.25, 172.232.96.21, 172.232.96.18, 172.232.96.22, 172.232.96.23, 172.232.96.24", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "jp-osa", "label": + "Osaka, JP", "country": "jp", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.233.64.44, 172.233.64.43, 172.233.64.37, 172.233.64.40, 172.233.64.46, + 172.233.64.41, 172.233.64.39, 172.233.64.42, 172.233.64.45, 172.233.64.38", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "it-mil", "label": + "Milan, IT", "country": "it", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.232.192.19, 172.232.192.18, 172.232.192.16, 172.232.192.20, 172.232.192.24, + 172.232.192.21, 172.232.192.22, 172.232.192.17, 172.232.192.15, 172.232.192.23", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-mia", "label": + "Miami, FL", "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.233.160.34, 172.233.160.27, 172.233.160.30, 172.233.160.29, 172.233.160.32, + 172.233.160.28, 172.233.160.33, 172.233.160.26, 172.233.160.25, 172.233.160.31", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "id-cgk", "label": + "Jakarta, ID", "country": "id", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.232.224.23, 172.232.224.32, 172.232.224.26, 172.232.224.27, 172.232.224.21, + 172.232.224.24, 172.232.224.22, 172.232.224.20, 172.232.224.31, 172.232.224.28", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-lax", "label": + "Los Angeles, CA", "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "Kubernetes", "Cloud Firewall", "Vlans", + "VPCs", "Metadata", "Premium Plans"], "status": "ok", "resolvers": {"ipv4": + "172.233.128.45, 172.233.128.38, 172.233.128.53, 172.233.128.37, 172.233.128.34, + 172.233.128.36, 172.233.128.33, 172.233.128.39, 172.233.128.43, 172.233.128.44", + "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-central", + "label": "Dallas, TX", "country": "us", "capabilities": ["Linodes", "Backups", + "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block + Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": + "72.14.179.5, 72.14.188.5, 173.255.199.5, 66.228.53.5, 96.126.122.5, 96.126.124.5, + 96.126.127.5, 198.58.107.5, 198.58.111.5, 23.239.24.5", "ipv6": "1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678"}, "site_type": "core"}, {"id": "us-west", + "label": "Fremont, CA", "country": "us", "capabilities": ["Linodes", "Backups", + "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", "Vlans", "Block + Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": {"ipv4": + "173.230.145.5, 173.230.147.5, 173.230.155.5, 173.255.212.5, 173.255.219.5, + 173.255.241.5, 173.255.243.5, 173.255.244.5, 74.207.241.5, 74.207.242.5", "ipv6": + "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "site_type": "core"}, + {"id": "us-southeast", "label": "Atlanta, GA", "country": "us", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU + Linodes", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "74.207.231.5, 173.230.128.5, + 173.230.129.5, 173.230.136.5, 173.230.140.5, 66.228.59.5, 66.228.62.5, 50.116.35.5, + 50.116.41.5, 23.239.18.5", "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "us-east", "label": "Newark, NJ", + "country": "us", "capabilities": ["Linodes", "Backups", "NodeBalancers", "Block + Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", "Vlans", + "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + {"ipv4": "66.228.42.5, 96.126.106.5, 50.116.53.5, 50.116.58.5, 50.116.61.5, + 50.116.62.5, 66.175.211.5, 97.107.133.4, 207.192.69.4, 207.192.69.5", "ipv6": + "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "site_type": "core"}, + {"id": "eu-west", "label": "London, UK", "country": "gb", "capabilities": ["Linodes", + "Backups", "NodeBalancers", "Block Storage", "Kubernetes", "Cloud Firewall", + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + {"ipv4": "178.79.182.5, 176.58.107.5, 176.58.116.5, 176.58.121.5, 151.236.220.5, + 212.71.252.5, 212.71.253.5, 109.74.192.20, 109.74.193.20, 109.74.194.20", "ipv6": + "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "site_type": "core"}, + {"id": "ap-south", "label": "Singapore, SG", "country": "sg", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Object Storage", "GPU + Linodes", "Kubernetes", "Cloud Firewall", "Vlans", "Block Storage Migrations", + "Managed Databases"], "status": "ok", "resolvers": {"ipv4": "139.162.11.5, 139.162.13.5, + 139.162.14.5, 139.162.15.5, 139.162.16.5, 139.162.21.5, 139.162.27.5, 103.3.60.18, + 103.3.60.19, 103.3.60.20", "ipv6": "1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678"}, "site_type": "core"}, {"id": "eu-central", "label": "Frankfurt, + DE", "country": "de", "capabilities": ["Linodes", "Backups", "NodeBalancers", + "Block Storage", "Object Storage", "GPU Linodes", "Kubernetes", "Cloud Firewall", + "Vlans", "Block Storage Migrations", "Managed Databases"], "status": "ok", "resolvers": + {"ipv4": "139.162.130.5, 139.162.131.5, 139.162.132.5, 139.162.133.5, 139.162.134.5, + 139.162.135.5, 139.162.136.5, 139.162.137.5, 139.162.138.5, 139.162.139.5", + "ipv6": "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "site_type": + "core"}, {"id": "ap-northeast", "label": "Tokyo, JP", "country": "jp", "capabilities": + ["Linodes", "Backups", "NodeBalancers", "Block Storage", "Kubernetes", "Cloud + Firewall", "Vlans", "Block Storage Migrations", "Managed Databases"], "status": + "ok", "resolvers": {"ipv4": "139.162.66.5, 139.162.67.5, 139.162.68.5, 139.162.69.5, + 139.162.70.5, 139.162.71.5, 139.162.72.5, 139.162.73.5, 139.162.74.5, 139.162.75.5", + "ipv6": "1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678, + 1234::5678, 1234::5678, 1234::5678, 1234::5678, 1234::5678"}, "site_type": + "core"}], "page": 1, "pages": 1, "results": 25}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:42 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + - Accept-Encoding + X-Accepted-Oauth-Scopes: + - '*' + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"region":"us-iad","type":"g6-nanode-1","label":"go-test-ins-wo-disk-32l2mwivl348","booted":false}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances + method: POST + response: + body: '{"id": 56840095, "label": "go-test-ins-wo-disk-32l2mwivl348", "group": + "", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", + "type": "g6-nanode-1", "ipv4": ["139.144.221.98"], "ipv6": "1234::5678/128", + "image": null, "region": "us-iad", "specs": {"disk": 25600, "memory": 1024, + "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": 90, "network_in": + 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, "backups": {"enabled": + false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": + null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": + "4d538cc0e67c9f98073a079b8960199e65fdbe06", "has_user_data": false}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "737" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "10" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-conf-5j4g24jt0jt0","devices":{},"interfaces":null}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/56840095/configs + method: POST + response: + body: '{"id": 59991781, "label": "go-test-conf-5j4g24jt0jt0", "helpers": {"updatedb_disabled": + true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": + true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", + "devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null, + "sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default", + "virt_mode": "paravirt", "interfaces": []}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "539" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-vpc-1712345023171915000","region":"us-iad","subnets":[{"label":"linodego-vpc-test-1712345023172003000","ipv4":"192.168.0.0/25"}]}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/vpcs + method: POST + response: + body: '{"id": 52788, "label": "go-test-vpc-1712345023171915000", "description": + "", "region": "us-iad", "subnets": [{"id": 52456, "label": "linodego-vpc-test-1712345023172003000", + "ipv4": "192.168.0.0/25", "linodes": [], "created": "2018-01-02T03:04:05", "updated": + "2018-01-02T03:04:05"}], "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "351" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - vpc:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"label":"go-test-conf-5j4g24jt0jt0","comments":"","devices":{},"helpers":{"updatedb_disabled":true,"distro":true,"modules_dep":true,"network":true,"devtmpfs_automount":true},"interfaces":[{"purpose":"vpc","subnet_id":52456,"ipv4":{"nat_1_1":"any"}}],"memory_limit":0,"kernel":"linode/latest-64bit","init_rd":null,"root_device":"/dev/sda","run_level":"default","virt_mode":"paravirt"}' + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/56840095/configs/59991781 + method: PUT + response: + body: '{"id": 59991781, "label": "go-test-conf-5j4g24jt0jt0", "helpers": {"updatedb_disabled": + true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": + true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": + "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", + "devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null, + "sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default", + "virt_mode": "paravirt", "interfaces": [{"id": 1315043, "purpose": "vpc", "primary": + false, "active": false, "ipam_address": null, "label": null, "vpc_id": 52788, + "subnet_id": 52456, "ipv4": {"vpc": "192.168.0.2", "nat_1_1": "139.144.221.98"}, + "ip_ranges": []}]}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "759" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + X-Filter: + - '{"linode_id": 56840095}' + url: https://api.linode.com/v4beta/vpcs/ips?page=1 + method: GET + response: + body: '{"data": [{"address": "192.168.0.2", "address_range": null, "vpc_id": 52788, + "subnet_id": 52456, "region": "us-iad", "linode_id": 56840095, "config_id": + 59991781, "interface_id": 1315043, "active": false, "nat_1_1": "139.144.221.98", + "gateway": "192.168.0.1", "prefix": 25, "subnet_mask": "255.255.255.128"}], + "page": 1, "pages": 1, "results": 1}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "346" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - ips:read_only + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/linode/instances/56840095 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:44 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - linodes:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - linodego/dev https://github.com/linode/linodego + url: https://api.linode.com/v4beta/vpcs/52788 + method: DELETE + response: + body: '{}' + headers: + Access-Control-Allow-Credentials: + - "true" + Access-Control-Allow-Headers: + - Authorization, Origin, X-Requested-With, Content-Type, Accept, X-Filter + Access-Control-Allow-Methods: + - HEAD, GET, OPTIONS, POST, PUT, DELETE + Access-Control-Allow-Origin: + - '*' + Access-Control-Expose-Headers: + - X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Status + Cache-Control: + - max-age=0, no-cache, no-store + Connection: + - keep-alive + Content-Length: + - "2" + Content-Security-Policy: + - default-src 'none' + Content-Type: + - application/json + Expires: + - Fri, 05 Apr 2024 19:23:44 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000 + Vary: + - Authorization, X-Filter + X-Accepted-Oauth-Scopes: + - vpc:read_write + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + - DENY + X-Oauth-Scopes: + - '*' + X-Ratelimit-Limit: + - "400" + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: "" diff --git a/test/integration/fixtures/TestVPC_ListIPAddresses.yaml b/test/integration/fixtures/TestVPC_ListIPAddresses.yaml index b99c783f9..df8981c17 100644 --- a/test/integration/fixtures/TestVPC_ListIPAddresses.yaml +++ b/test/integration/fixtures/TestVPC_ListIPAddresses.yaml @@ -245,7 +245,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:48 GMT + - Fri, 05 Apr 2024 19:23:44 GMT Pragma: - no-cache Strict-Transport-Security: @@ -271,7 +271,7 @@ interactions: code: 200 duration: "" - request: - body: '{"region":"us-iad","type":"g6-nanode-1","label":"go-test-ins-wo-disk-9h88oq248wsp","booted":false}' + body: '{"region":"us-iad","type":"g6-nanode-1","label":"go-test-ins-wo-disk-0j8oh1xh725p","booted":false}' form: {} headers: Accept: @@ -283,15 +283,15 @@ interactions: url: https://api.linode.com/v4beta/linode/instances method: POST response: - body: '{"id": 55776057, "label": "go-test-ins-wo-disk-9h88oq248wsp", "group": + body: '{"id": 56840097, "label": "go-test-ins-wo-disk-0j8oh1xh725p", "group": "", "status": "provisioning", "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", - "type": "g6-nanode-1", "ipv4": ["172.233.227.130"], "ipv6": "1234::5678/128", + "type": "g6-nanode-1", "ipv4": ["139.144.199.177"], "ipv6": "1234::5678/128", "image": null, "region": "us-iad", "specs": {"disk": 25600, "memory": 1024, "vcpus": 1, "gpus": 0, "transfer": 1000}, "alerts": {"cpu": 90, "network_in": 10, "network_out": 10, "transfer_quota": 80, "io": 10000}, "backups": {"enabled": false, "available": false, "schedule": {"day": null, "window": null}, "last_successful": null}, "hypervisor": "kvm", "watchdog_enabled": true, "tags": [], "host_uuid": - "9e989ac55c51221c6871ec0c4853e3d84bdc25c9", "has_user_data": false}' + "7d976b01d7a02564542f5279df040f3672a62eec", "has_user_data": false}' headers: Access-Control-Allow-Credentials: - "true" @@ -314,7 +314,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:48 GMT + - Fri, 05 Apr 2024 19:23:44 GMT Pragma: - no-cache Strict-Transport-Security: @@ -338,7 +338,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-conf-94gbv7613jcf","devices":{},"interfaces":null}' + body: '{"label":"go-test-conf-11w439bzc9vl","devices":{},"interfaces":null}' form: {} headers: Accept: @@ -347,10 +347,10 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/55776057/configs + url: https://api.linode.com/v4beta/linode/instances/56840097/configs method: POST response: - body: '{"id": 58903778, "label": "go-test-conf-94gbv7613jcf", "helpers": {"updatedb_disabled": + body: '{"id": 59991783, "label": "go-test-conf-11w439bzc9vl", "helpers": {"updatedb_disabled": true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", @@ -379,7 +379,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:48 GMT + - Fri, 05 Apr 2024 19:23:44 GMT Pragma: - no-cache Strict-Transport-Security: @@ -403,7 +403,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-vpc-1709849928961931000","region":"us-iad","subnets":[{"label":"linodego-vpc-test-1709849928961973000","ipv4":"192.168.0.0/25"}]}' + body: '{"label":"go-test-vpc-1712345024899989000","region":"us-iad","subnets":[{"label":"linodego-vpc-test-1712345024900060000","ipv4":"192.168.0.0/25"}]}' form: {} headers: Accept: @@ -415,8 +415,8 @@ interactions: url: https://api.linode.com/v4beta/vpcs method: POST response: - body: '{"id": 30643, "label": "go-test-vpc-1709849928961931000", "description": - "", "region": "us-iad", "subnets": [{"id": 30774, "label": "linodego-vpc-test-1709849928961973000", + body: '{"id": 52789, "label": "go-test-vpc-1712345024899989000", "description": + "", "region": "us-iad", "subnets": [{"id": 52457, "label": "linodego-vpc-test-1712345024900060000", "ipv4": "192.168.0.0/25", "linodes": [], "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}], "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05"}' headers: @@ -441,7 +441,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:49 GMT + - Fri, 05 Apr 2024 19:23:45 GMT Pragma: - no-cache Strict-Transport-Security: @@ -465,7 +465,7 @@ interactions: code: 200 duration: "" - request: - body: '{"label":"go-test-conf-94gbv7613jcf","comments":"","devices":{},"helpers":{"updatedb_disabled":true,"distro":true,"modules_dep":true,"network":true,"devtmpfs_automount":true},"interfaces":[{"purpose":"vpc","subnet_id":30774,"ipv4":{"nat_1_1":"any"}}],"memory_limit":0,"kernel":"linode/latest-64bit","init_rd":null,"root_device":"/dev/sda","run_level":"default","virt_mode":"paravirt"}' + body: '{"label":"go-test-conf-11w439bzc9vl","comments":"","devices":{},"helpers":{"updatedb_disabled":true,"distro":true,"modules_dep":true,"network":true,"devtmpfs_automount":true},"interfaces":[{"purpose":"vpc","subnet_id":52457,"ipv4":{"nat_1_1":"any"}}],"memory_limit":0,"kernel":"linode/latest-64bit","init_rd":null,"root_device":"/dev/sda","run_level":"default","virt_mode":"paravirt"}' form: {} headers: Accept: @@ -474,18 +474,18 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/55776057/configs/58903778 + url: https://api.linode.com/v4beta/linode/instances/56840097/configs/59991783 method: PUT response: - body: '{"id": 58903778, "label": "go-test-conf-94gbv7613jcf", "helpers": {"updatedb_disabled": + body: '{"id": 59991783, "label": "go-test-conf-11w439bzc9vl", "helpers": {"updatedb_disabled": true, "distro": true, "modules_dep": true, "network": true, "devtmpfs_automount": true}, "kernel": "linode/latest-64bit", "comments": "", "memory_limit": 0, "created": "2018-01-02T03:04:05", "updated": "2018-01-02T03:04:05", "root_device": "/dev/sda", "devices": {"sda": null, "sdb": null, "sdc": null, "sdd": null, "sde": null, "sdf": null, "sdg": null, "sdh": null}, "initrd": null, "run_level": "default", - "virt_mode": "paravirt", "interfaces": [{"id": 1171150, "purpose": "vpc", "primary": - false, "active": false, "ipam_address": null, "label": null, "vpc_id": 30643, - "subnet_id": 30774, "ipv4": {"vpc": "192.168.0.2", "nat_1_1": "172.233.227.130"}, + "virt_mode": "paravirt", "interfaces": [{"id": 1315044, "purpose": "vpc", "primary": + false, "active": false, "ipam_address": null, "label": null, "vpc_id": 52789, + "subnet_id": 52457, "ipv4": {"vpc": "192.168.0.2", "nat_1_1": "139.144.199.177"}, "ip_ranges": []}]}' headers: Access-Control-Allow-Credentials: @@ -509,7 +509,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:49 GMT + - Fri, 05 Apr 2024 19:23:45 GMT Pragma: - no-cache Strict-Transport-Security: @@ -543,13 +543,13 @@ interactions: User-Agent: - linodego/dev https://github.com/linode/linodego X-Filter: - - '{"linode_id": 55776057}' - url: https://api.linode.com/v4beta/vpcs/ips?page=1 + - '{"linode_id": 56840097}' + url: https://api.linode.com/v4beta/vpcs/52789/ips?page=1 method: GET response: - body: '{"data": [{"address": "192.168.0.2", "address_range": null, "vpc_id": 30643, - "subnet_id": 30774, "region": "us-iad", "linode_id": 55776057, "config_id": - 58903778, "interface_id": 1171150, "active": false, "nat_1_1": "172.233.227.130", + body: '{"data": [{"address": "192.168.0.2", "address_range": null, "vpc_id": 52789, + "subnet_id": 52457, "region": "us-iad", "linode_id": 56840097, "config_id": + 59991783, "interface_id": 1315044, "active": false, "nat_1_1": "139.144.199.177", "gateway": "192.168.0.1", "prefix": 25, "subnet_mask": "255.255.255.128"}], "page": 1, "pages": 1, "results": 1}' headers: @@ -574,7 +574,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:49 GMT + - Fri, 05 Apr 2024 19:23:45 GMT Pragma: - no-cache Strict-Transport-Security: @@ -608,7 +608,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/linode/instances/55776057 + url: https://api.linode.com/v4beta/linode/instances/56840097 method: DELETE response: body: '{}' @@ -634,7 +634,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:50 GMT + - Fri, 05 Apr 2024 19:23:45 GMT Pragma: - no-cache Strict-Transport-Security: @@ -667,7 +667,7 @@ interactions: - application/json User-Agent: - linodego/dev https://github.com/linode/linodego - url: https://api.linode.com/v4beta/vpcs/30643 + url: https://api.linode.com/v4beta/vpcs/52789 method: DELETE response: body: '{}' @@ -693,7 +693,7 @@ interactions: Content-Type: - application/json Expires: - - Thu, 07 Mar 2024 22:18:50 GMT + - Fri, 05 Apr 2024 19:23:46 GMT Pragma: - no-cache Strict-Transport-Security: diff --git a/test/integration/vpc_test.go b/test/integration/vpc_test.go index 67abd5928..7ae47872d 100644 --- a/test/integration/vpc_test.go +++ b/test/integration/vpc_test.go @@ -230,12 +230,41 @@ func TestVPC_Update_Invalid_data(t *testing.T) { } } +func TestVPC_ListAllIPAddresses(t *testing.T) { + client, _, _, instance, config, teardown := setupInstanceWithVPCAndNATOneToOne( + t, "fixtures/TestVPC_ListAllIPAddresses", + ) + defer teardown() + + vpcIPs, err := client.ListAllVPCIPAddresses( + context.Background(), + linodego.NewListOptions(1, fmt.Sprintf("{\"linode_id\": %d}", instance.ID)), + ) + if err != nil { + t.Fatal(err) + } + + if len(vpcIPs) == 0 { + t.Fatal("expecting 1 VPC IP address, but got 0") + } + + if *vpcIPs[0].Address != config.Interfaces[0].IPv4.VPC { + t.Fatalf( + "expecting VPC IP address on Linode %d to be %q, but got %q", + instance.ID, *vpcIPs[0].Address, config.Interfaces[0].IPv4.VPC, + ) + } +} + func TestVPC_ListIPAddresses(t *testing.T) { - client, _, _, instance, config, teardown := setupInstanceWithVPCAndNATOneToOne(t, "fixtures/TestVPC_ListIPAddresses") + client, vpc, _, instance, config, teardown := setupInstanceWithVPCAndNATOneToOne( + t, "fixtures/TestVPC_ListIPAddresses", + ) defer teardown() vpcIPs, err := client.ListVPCIPAddresses( context.Background(), + vpc.ID, linodego.NewListOptions(1, fmt.Sprintf("{\"linode_id\": %d}", instance.ID)), ) if err != nil { diff --git a/vpc_ips.go b/vpc_ips.go index f21894fa5..7ccef887e 100644 --- a/vpc_ips.go +++ b/vpc_ips.go @@ -2,9 +2,19 @@ package linodego import ( "context" + "fmt" ) -// ListVPCIPAddresses gets the list of all IP addresses of all VPCs in the Linode account. -func (c *Client) ListVPCIPAddresses(ctx context.Context, opts *ListOptions) ([]VPCIP, error) { +// ListAllVPCIPAddresses gets the list of all IP addresses of all VPCs in the Linode account. +func (c *Client) ListAllVPCIPAddresses( + ctx context.Context, opts *ListOptions, +) ([]VPCIP, error) { return getPaginatedResults[VPCIP](ctx, c, "vpcs/ips", opts) } + +// ListVPCIPAddresses gets the list of all IP addresses of a specific VPC. +func (c *Client) ListVPCIPAddresses( + ctx context.Context, vpcID int, opts *ListOptions, +) ([]VPCIP, error) { + return getPaginatedResults[VPCIP](ctx, c, fmt.Sprintf("vpcs/%d/ips", vpcID), opts) +}