From 5f929e031d7cc091a039be5092e44c71c5ca2969 Mon Sep 17 00:00:00 2001 From: Alexander Mattoni <5110855+mattoni@users.noreply.github.com> Date: Mon, 10 Mar 2025 08:50:46 -0700 Subject: [PATCH] Add virtual machine gateways endpoint --- internal/api.yml | 7 ++- internal/paths/virtual-machine/gateways.yml | 65 +++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 internal/paths/virtual-machine/gateways.yml diff --git a/internal/api.yml b/internal/api.yml index 3b41f6a7..bfffe91d 100644 --- a/internal/api.yml +++ b/internal/api.yml @@ -10,8 +10,8 @@ info: name: Apache-2.0 url: http://www.apache.org/licenses/LICENSE-2.0 title: Cycle Internal API - description: - Inside every container running on Cycle, there is a Unix socket mounted at /var/run/cycle/api/api.sock. You can send HTTP requests over this socket to access information about the local environment, access secrets, and much more. + description: | + Inside every container running on Cycle, there is a Unix socket mounted at *`/var/run/cycle/api/api.sock`*. You can send HTTP requests over this socket to access information about the local environment, access secrets, and much more. The way this internal API functions is very similar to how Cycle's main API works, though the purpose is different. The internal API is primarily used by instances to learn about their environment, and dynamically update as deployments change. In the future, we expect you'll be able to use the internal API to register service containers and much more. The internal API returns identical JSON responses to the main API. There is also a websocket based API that you can tune into for streaming platform updates. version: 1.0.0 @@ -103,6 +103,9 @@ paths: $ref: paths/virtual-machine/virtual-machine.yml /v1/virtual-machine/domains: $ref: paths/virtual-machine/domains.yml + /v1/virtual-machine/gateways: + $ref: paths/virtual-machine/gateways.yml + # Object Cache /v1/object-cache: diff --git a/internal/paths/virtual-machine/gateways.yml b/internal/paths/virtual-machine/gateways.yml new file mode 100644 index 00000000..d56c2f03 --- /dev/null +++ b/internal/paths/virtual-machine/gateways.yml @@ -0,0 +1,65 @@ +get: + operationId: "getVirtualMachineGateways" + summary: Get Virtual Machine Gateways + description: | + Returns a list of gateways applicable to the specified virtual machine. + tags: + - Virtual Machines + parameters: + - name: virtual-machine-id + in: query + required: true + description: The ID of the virtual machine. + schema: + type: string + responses: + default: + $ref: ../../../components/responses/errors/DefaultError.yml + 200: + description: Returns a list of gateways applicable to the specified virtual machine. + content: + application/json: + schema: + type: object + required: + - data + properties: + data: + type: array + items: + type: object + required: + - virtual_machine_id + - gateway_instance_id + properties: + virtual_machine_id: + $ref: ../../../components/schemas/ID.yml + gateway_instance_id: + $ref: ../../../components/schemas/ID.yml + ips: + type: array + items: + type: object + required: + - kind + - public_ip + properties: + kind: + type: string + description: The type of IP protocol this IP is. + enum: + - ipv4 + - ipv6 + public_ip: + type: string + description: The public IP attached to the gateway. + gateway_private_ip: + type: + - string + - "null" + description: The private IP of the gateway. + gateway_nat_ip: + type: + - string + - "null" + description: The NAT IP of the gateway.