linode / linode-api-docs

Source for the Linode API v4 Docs
https://www.linode.com/docs/api/
Apache License 2.0
23 stars 65 forks source link

fix: Correct ipv4.vpc attribute in /linode/instances/{linodeId}/ips response #938

Closed lgarber-akamai closed 4 months ago

lgarber-akamai commented 4 months ago

📖 Description

This pull request corrects the ipv4.vpc attribute in the response body for the GET /linode/instances/{linodeId}/ips endpoint. Previously this attribute was treated as a nested paginated envelope which does not match with the API's actual response:

        "vpc": [
            {
                "address": "10.0.0.2",
                "address_range": null,
                "vpc_id": 59993,
                "subnet_id": 59054,
                "region": "us-mia",
                "linode_id": 57960023,
                "config_id": 61155218,
                "interface_id": 1455573,
                "active": false,
                "nat_1_1": "172.235.141.238",
                "gateway": "10.0.0.1",
                "prefix": 24,
                "subnet_mask": "255.255.255.0"
            }
        ]

Additionally, this mismatch was causing the CLI to raise the following error when attempting to list IPs for a Linode:

# linode-cli linodes ips-list 45794198
Traceback (most recent call last):
  File "/home/test/.local/bin/linode-cli", line 8, in <module>
    sys.exit(main())
  File "/home/test/.local/lib/python3.8/site-packages/linodecli/__init__.py", line 256, in main
    cli.handle_command(parsed.command, parsed.action, args)
  File "/home/test/.local/lib/python3.8/site-packages/linodecli/cli.py", line 133, in handle_command
    operation.process_response_json(result, self.output_handler)
  File "/home/test/.local/lib/python3.8/site-packages/linodecli/baked/operation.py", line 427, in process_response_json
    handler.print_response(self.response_model, json)
  File "/home/test/.local/lib/python3.8/site-packages/linodecli/output.py", line 160, in print_response
    self.print(
  File "/home/test/.local/lib/python3.8/site-packages/linodecli/output.py", line 101, in print
    raise ValueError(
ValueError: Expected a non-zero number of columns.This is always an error in the OpenAPI spec.

Testing CLI Compatiblity

  1. Clone the Linode CLI locally:
git clone https://github.com/linode/linode-cli.git && cd linode-cli
  1. Run the following command to build and install the CLI from this PR's OpenAPI spec:
make SPEC=https://raw.githubusercontent.com/lgarber-akamai/linode-api-docs/fix/networking-info-vpc/openapi.yaml install
  1. Attempt to use the linodes ips-list command on an existing Linode:
linode-cli linodes ips-list 12345
  1. Ensure no error is raised.
lgarber-akamai commented 4 months ago

Closing in favor of creating an internal docs ticket