From 4a1e1d91673003c114022a486be622808fb4d7c3 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 25 Aug 2023 15:00:41 -0400 Subject: [PATCH] restruct response/request/schemas --- swagger.yml | 1253 +++++++++++++++++++++++++-------------------------- 1 file changed, 615 insertions(+), 638 deletions(-) diff --git a/swagger.yml b/swagger.yml index f1e319109..e2cbcdb80 100644 --- a/swagger.yml +++ b/swagger.yml @@ -67,18 +67,12 @@ paths: summary: Create a DNS entry. tags: - dns - /api/dns/{network}/{host}: + /api/dns/{network}/{hostID}: delete: operationId: deleteDNS parameters: - $ref: '#/components/parameters/networkName' - - description: Host - in: path - name: host - required: true - x-go-name: Domain - schema: - type: string + - $ref: '#/components/parameters/hostID' responses: "200": description: "deletion successful" @@ -155,7 +149,7 @@ paths: post: operationId: createEnrollmentKey requestBody: - $ref: '#/components/responses/enrollmentKey' + $ref: '#/components/requestBodies/enrollmentKey' responses: "200": $ref: '#/components/responses/enrollmentKey' @@ -182,12 +176,7 @@ paths: content: application/json: schema: - type: object - properties: - Code: - type: integer - Message: - type: string + $ref: '#components/responses/ErrorResponse' example: { "Code": 500, @@ -220,13 +209,7 @@ paths: operationId: getAllExtClients responses: "200": - description: "extclients" - content: - application/json: - schema: - type: array - items: - $ref: '#/components/responses/extClient' + $ref: '#/components/responses/extClients' summary: A separate function to get all extclients, not just extclients for a particular network. tags: - ext_client @@ -309,18 +292,13 @@ paths: - $ref: '#/components/parameters/nodeID' requestBody: $ref: '#/components/requestBodies/customExtClient' - description: Custom ExtClient - content: - application/json: - schema: required: true - x-go-name: CustomExtClient summary: Create an individual extclient. Must have valid key and be unique. - tags: - - ext_client responses: "200": $ref: '#/components/responses/extClient' + tags: + - ext_client /api/getip: get: operationId: getIP @@ -391,7 +369,7 @@ paths: parameters: - $ref: '#/components/parameters/hostID' requestBody: - $ref: '#/components/responses/host' + $ref: '#/components/requestBodies/host' responses: "200": $ref: '#/components/responses/host' @@ -453,7 +431,7 @@ paths: parameters: - $ref: '#/components/parameters/hostID' requestBody: - $ref: '#/components/responses/signal' + $ref: '#/components/requestBodies/signal' responses: "200": description: "success" @@ -528,7 +506,7 @@ paths: post: operationId: createNetwork requestBody: - $ref: '#/components/responses/network' + $ref: '#/components/requestBodies/network' required: true responses: "200": @@ -562,7 +540,7 @@ paths: parameters: - $ref: '#/components/parameters/networkName' requestBody: - $ref: '#/components/responses/network' + $ref: '#/components/requestBodies/network' responses: "200": $ref: '#/components/responses/network' @@ -660,7 +638,7 @@ paths: - $ref: '#/components/parameters/networkName' - $ref: '#/components/parameters/nodeID' requestBody: - $ref: '#/components/responses/node' + $ref: '#/components/requestBodies/node' responses: "200": $ref: '#/components/responses/node' @@ -673,7 +651,7 @@ paths: - $ref: '#/components/parameters/networkName' - $ref: '#/components/parameters/nodeID' requestBody: - $ref: '#/components/responses/node' + $ref: '#/components/requestBodies/node' responses: "200": $ref: '#/components/responses/node' @@ -698,6 +676,7 @@ paths: - $ref: '#/components/parameters/networkName' - $ref: '#/components/parameters/nodeID' requestBody: + $ref: '#components/requestBodies/egressGatewayRequest' description: Egress Gateway Request required: true content: @@ -741,6 +720,7 @@ paths: - $ref: '#/components/parameters/networkName' - $ref: '#/components/parameters/nodeID' requestBody: + $ref: '#/components/requestBodies/ingressGatewayRequest' description: Ingress Gateway Request required: true content: @@ -855,7 +835,7 @@ paths: parameters: - $ref: '#/components/parameters/networkName' requestBody: - $ref: '#/components/responses/networkUser' + $ref: '#/components/requestBodies/networkUser' responses: "200": description: "networkusers" @@ -868,7 +848,7 @@ paths: parameters: - $ref: '#/components/parameters/networkName' requestBody: - $ref: '#/components/responses/networkUser' + $ref: '#/components/requestBodies/networkUser' responses: "200": description: "networkusers" @@ -881,12 +861,7 @@ paths: operationId: getNetworkUser parameters: - $ref: '#/components/parameters/networkName' - - description: Username - in: path - name: username - required: true - schema: - type: string + - $ref: '#/components/parameters/username' responses: "200": description: "networkusers" @@ -898,12 +873,7 @@ paths: operationId: deleteNetworkUser parameters: - $ref: '#/components/parameters/networkName' - - description: Username - in: path - name: username - required: true - schema: - type: string + - $ref: '#/components/parameters/username' responses: "200": description: "networkusers" @@ -915,12 +885,7 @@ paths: delete: operationId: deleteNetworkUser parameters: - - description: Username - in: path - name: username - required: true - schema: - type: string + - $ref: '#/components/parameters/username' responses: "200": description: "networkusers" @@ -935,24 +900,9 @@ paths: - $ref: '#/components/parameters/networkName' - $ref: '#/components/parameters/nodeID' requestBody: + $ref: '#/components/requestBodies/relayRequest' description: Relay Request required: true - content: - application/json: - schema: - description: Relay Request - type: object - properties: - NodeID: - type: string - NetID: - type: string - NatEnabled: - type: boolean - Ranges: - type: array - items: - type: string responses: "200": $ref: '#/components/responses/node' @@ -1028,14 +978,469 @@ components: type: http scheme: bearer bearerFormat: JWT - parameters: - networkName: - description: Network Name - in: path - name: network - required: true - schema: + schemas: + accessKey: + type: object + properties: + Expiration: + type: string + UsesRemaining: + type: integer + value: + type: string + networks: + type: string + unlimited: + type: boolean + Tags: + type: string + Token: + type: string + + customExtClient: + type: object + properties: + ClientID: + type: string + PublicKey: + type: string + DNS: + type: string + ExtraAllowedIPs: + type: array + items: + type: string + Enabled: + type: boolean + DeniedACLs: + type: string # todo map[string]struct{} + dns: + type: object + properties: + Name: + type: string + Network: + type: string + Address: + type: string + Address6: + type: string + enrollmentKey: + type: object + properties: + Key: + type: string + Name: + type: string + Notes: + type: string + Tags: + type: string + Unlimited: + type: boolean + UsesRemaining: + type: integer + Expiration: + type: string + extClient: + type: object + properties: + ClientID: + type: string + PrivateKey: + type: string + PublicKey: + type: string + Network: + type: string + DNS: + type: string + Address: + type: string + Address6: + type: string + ExtraAllowedIPs: + type: array + items: + type: string + IngressGatewayID: + type: string + IngressGatewayEndpoint: + type: string + LastModified: + type: integer + Enabled: + type: boolean + OwnerID: + type: string + DeniedACLs: + type: string # todo map[string]struct{} + host: + type: object + properties: + ID: + type: string + Verbosity: + type: string + FirewallIInUse: + type: string + Version: + type: string + DaemonInstlled: + type: boolean + AutoUpdate: + type: boolean + HostPass: + type: string + Name: + type: string + OS: + type: string + Interface: + type: string + Debug: + type: boolean + ListenPort: + type: integer + WgPublicListenPort: + type: integer + MTU: + type: integer + PublicKey: + type: string + MacAddress: + type: string + TrafficKeyPublic: + type: string + Nodes: + type: array + items: + type: string + Interfaces: + type: array + items: + type: string + DefaultInterface: + type: string + EndpointIP: + type: string + IsDocker: + type: boolean + IsK8s: + type: boolean + IsStatic: + type: boolean + IsDefault: + type: boolean + NatType: + type: string + TurnEndpoint: + type: string + ingressGatewayRequest: + type: object + properties: + ExtClientDNS: + type: string + FailOver: + type: boolean + metric: + type: object + properties: + NodeName: + type: string + Uptime: + type: integer + TotalTime: + type: integer + Latency: + type: integer + TotalReceived: + type: integer + TotalSent: + type: integer + ActualUptime: + type: integer + PercentUp: + type: number + Connected: + type: boolean + metrics: + type: object + properties: + Network: + type: string + NodeID: + type: string + NodeName: type: string + Connectivity: + type: string # todo map[string]struct{} + FailoverPeers: + type: string # todo map[string]struct{} + + migrate: + type: object + properties: + ID: + type: string + Address: + type: string + Address6: + type: string + LocalAddress: + type: string + Interfaces: + type: array + items: + type: string + NetworkSetttings: + $ref: '#/components/responses/network' + ListenPort: + type: integer + LocalListenPort: + type: integer + PublicKey: + type: string + Endpoint: + type: string + AllowedIPs: + type: array + items: + type: string + PersistentKeepalive: + type: integer + IsHub: + type: boolean + AccessKey: + type: string + Interface: + type: string + LastModified: + type: integer + ExpirationDateTime: + type: string + LastPeerUpdate: + type: integer + MacAddress: + type: string + Password: + type: string + Network: + type: string + IsRelayed: + type: boolean + IsPending: + type: boolean + IsDocker: + type: boolean + IsK8s: + type: boolean + IsEgressGateway: + type: boolean + IsIngressGateway: + type: boolean + EgressGatewayRanges: + type: array + items: + type: string + EgressGatewayNatEnabled: + type: boolean + EgressGatewayRequest: + type: object + properties: + NodeID: + type: string + NetID: + type: string + NatEnabled: + type: boolean + Ranges: + type: array + items: + type: string + RelayAddrs: + type: array + items: + type: string + FailoverNode: + type: string + IngressGatewayRange: + type: string + IngressGatewayRange6: + type: string + IsStatic: + type: boolean + UDPHolePunch: + type: boolean + DNSOn: + type: boolean + IsServer: + type: boolean + Action: + type: string + IPForwarding: + type: boolean + OS: + type: string + MTU: + type: integer + Version: + type: string + Server: + type: string + TrafficKeys: + type: object + properties: + Private: + type: string + Public: + type: string + FirewallInUse: + type: string + InternetGateway: + type: string + Connected: + type: boolean + DefaultACL: + type: string + OwnerID: + type: string + FailOver: + type: string + networkUser: + type: object + properties: + AccessLevel: + type: integer + ClientLimit: + type: integer + NodeLimit: + type: integer + ID: + type: string + Clients: + type: array + items: + type: string + Nodes: + type: array + items: + type: string + networkUsers: + type: object + properties: + Network: + type: string + Users: + type: array + items: + $ref: '#/components/responses/networkUser' + node: + type: object + properties: + ID: + type: string + HostID: + type: string + Network: + type: string + NetworkRange: + type: string + NetworkRange6: + type: string + InternetGateway: + type: string + Server: + type: string + Connected: + type: boolean + Address: + type: string + Address6: + type: string + Action: + type: string + LocalAddress: + type: string + IsEgressGateway: + type: boolean + EgressGatewayRanges: + type: array + items: + type: string + IsIngressGateway: + type: boolean + IsRelayed: + type: boolean + RelayedBy: + type: string + RelayedNodes: + type: array + items: + type: string + IngressDNS: + type: string + DNSOn: + type: boolean + PersistentKeepaliveInterval: + type: integer + network: + type: object + properties: + AddressRange: + type: string + AddressRange6: + type: string + NetID: + type: string + NodesLastModified: + type: integer + DefaultListenPort: + type: integer + NodeLimit: + type: integer + DefaultKeepAlive: + type: integer + IsIPv4: + type: string + IsIPv6: + type: string + DefaultACL: + type: string + ProSettings: + type: string # todo promodels.ProNetwork + relayRequest: + description: Relay Request + type: object + properties: + NodeID: + type: string + NetID: + type: string + NatEnabled: + type: boolean + Ranges: + type: array + items: + type: string + signal: + type: object + properties: + Server: + type: string + FromHostPubicKey: + type: string + TurnRelayEndpoint: + type: string + Reply: + type: boolean + Action: + type: string + Timestamp: + type: integer + + + parameters: extclientID: description: Client ID in: path @@ -1051,6 +1456,13 @@ components: x-go-name: HostID schema: type: string + networkName: + description: Network Name + in: path + name: network + required: true + schema: + type: string nodeID: description: node ID in: path @@ -1058,8 +1470,15 @@ components: required: true schema: type: string - responses: + username: + description: UserName + in: path + name: username + required: true + schema: + type: string + responses: errorResponse: description: Error content: @@ -1113,45 +1532,20 @@ components: Code: 200 Message: "success" Response: "success" - - dns: - description: DNSEntry + accessKey: + description: "AccessKey" content: application/json: schema: - type: object - properties: - name: - type: string - network: - type: string - address: - type: string - address6: - type: string - accessKey: - description: "AccessKey" + $ref: '#/components/schemas/accessKey' + dns: + description: DNSEntry content: application/json: schema: - type: object - properties: - Expiration: - type: string - UsesRemaining: - type: integer - value: - type: string - networks: - type: string - unlimited: - type: boolean - Tags: - type: string - Token: - type: string + $ref: '#/components/schemas/dns' enrollmentKeys: - description: "Enrollement Keys" + description: "Enrollment Keys" content: application/json: schema: @@ -1159,26 +1553,11 @@ components: items: $ref: '#/components/responses/enrollmentKey' enrollmentKey: - description: "Enrollement Key" + description: "Enrollment Key" content: application/json: schema: - type: object - properties: - Key: - type: string - Name: - type: string - Notes: - type: string - Tags: - type: string - Unlimited: - type: boolean - UsesRemaining: - type: integer - Expiration: - type: string + $ref: '#/components/schemas/enrollmentKey' extClients: description: "ExtClients" content: @@ -1192,38 +1571,31 @@ components: content: application/json: schema: - type: object - properties: - ClientID: - type: string - PrivateKey: - type: string - PublicKey: - type: string - Network: - type: string - DNS: - type: string - Address: - type: string - Address6: - type: string - ExtraAllowedIPs: - type: array - items: - type: string - IngressGatewayID: - type: string - IngressGatewayEndpoint: - type: string - LastModified: - type: integer - Enabled: - type: boolean - OwnerID: - type: string - DeniedACLs: - type: string # todo map[string]struct{} + $ref: '#/components/schemas/extClient' + host: + description: "Host" + content: + application/json: + schema: + $ref: '#/components/schemas/host' + metric: + description: "Metric" + content: + application/json: + schema: + $ref: '#/components/schemas/metric' + metrics: + description: "Metrics" + content: + application/json: + schema: + $ref: '#/components/schemas/metrics' + network: + description: "Network" + content: + application/json: + schema: + $ref: '#components/schemas/network' networks: description: "Networks" content: @@ -1232,88 +1604,42 @@ components: type: array items: $ref: '#/components/responses/network' - network: - description: "Network" + networkMetrics: + description: "Network Metrics" content: application/json: schema: - type: object - properties: - AddressRange: - type: string - AddressRange6: - type: string - NetID: - type: string - NodesLastModified: - type: integer - DefaultListenPort: - type: integer - NodeLimit: - type: integer - DefaultKeepAlive: - type: integer - IsIPv4: - type: string - IsIPv6: - type: string - DefaultACL: - type: string - ProSettings: - type: string # todo promodels.ProNetwork + type: string # todo map[string]struct{} + networkMetricsConnectivity: + description: "Network Metrics Connectivity" + content: + application/json: + schema: + type: string # todo map[string]struct{} + networkUsers: + description: "Network Users" + content: + application/json: + schema: + type: string # todo map[string]struct{} + networkUser: + description: "Network User" + content: + application/json: + schema: + $ref: "#/components/schemas/networkUser" + allNetworkUsers: + description: "All Network Users" + content: + application/json: + schema: + $ref: "#/components/schemas/networkUsers" node: description: "Node" content: applicaton/json: schema: - type: object - properties: - ID: - type: string - HostID: - type: string - Network: - type: string - NetworkRange: - type: string - NetworkRange6: - type: string - InternetGateway: - type: string - Server: - type: string - Connected: - type: boolean - Address: - type: string - Address6: - type: string - Action: - type: string - LocalAddress: - type: string - IsEgressGateway: - type: boolean - EgressGatewayRanges: - type: array - items: - type: string - IsIngressGateway: - type: boolean - IsRelayed: - type: boolean - RelayedBy: - type: string - RelayedNodes: - type: array - items: - type: string - IngressDNS: - type: string - DNSOn: - type: boolean - PersistentKeepaliveInterval: - type: integer + $ref: '#/components/schemas/node' nodes: description: "Nodes" content: @@ -1322,442 +1648,93 @@ components: type: array items: $ref: '#/components/responses/node' - signal: description: "Signal" content: application/json: schema: - type: object - properties: - Server: - type: string - FromHostPubicKey: - type: string - TurnRelayEndpoint: - type: string - Reply: - type: boolean - Action: - type: string - Timestamp: - type: integer - - host: - description: "Host" - content: - application/json: - schema: - type: object - properties: - ID: - type: string - Verbosity: - type: string - FirewallIInUse: - type: string - Version: - type: string - DaemonInstlled: - type: boolean - AutoUpdate: - type: boolean - HostPass: - type: string - Name: - type: string - OS: - type: string - Interface: - type: string - Debug: - type: boolean - ListenPort: - type: integer - WgPublicListenPort: - type: integer - MTU: - type: integer - PublicKey: - type: string - MacAddress: - type: string - TrafficKeyPublic: - type: string - Nodes: - type: array - items: - type: string - Interfaces: - type: array - items: - type: string - DefaultInterface: - type: string - EndpointIP: - type: string - IsDocker: - type: boolean - IsK8s: - type: boolean - IsStatic: - type: boolean - IsDefault: - type: boolean - NatType: - type: string - TurnEndpoint: - type: string - metrics: - description: "Metrics" + $ref: '#/components/schemas/signal' + userGroup: + description: "User Group" content: - application/json: - schema: - type: object - properties: - Network: - type: string - NodeID: - type: string - NodeName: - type: string - Connectivity: - type: string # todo map[string]struct{} - FailoverPeers: + application/json: + schema: type: string # todo map[string]struct{} - - metric: - description: "Metric" + requestBodies: + + customExtClient: content: application/json: schema: - type: object - properties: - NodeName: - type: string - Uptime: - type: integer - TotalTime: - type: integer - Latency: - type: integer - TotalReceived: - type: integer - TotalSent: - type: integer - ActualUptime: - type: integer - PercentUp: - type: number - Connected: - type: boolean - networkMetrics: - description: "Network Metrics" + $ref: '#/components/schemas/customExtClient' + description: ExtClient + required: true + enrollmentKey: content: application/json: schema: - type: string # todo map[string]struct{} - networkMetricsConnectivity: - description: "Network Metrics Connectivity" + $ref: '#/components/schemas/enrollmentKey' + host: content: application/json: schema: - type: string # todo map[string]struct{} - networkUsers: - description: "Network Users" + $ref: '#/components/schemas/host' + ingressGatewayRequest: content: application/json: schema: - type: string # todo map[string]struct{} + $ref: '#/components/schemas/ingressGatewayRequest' + migrate: + content: + application/json: + schema: + $ref: '#/components/schemas/migrate' + network: + content: + application/json: + schema: + $ref: '#/components/schemas/network' networkUser: - description: "Network User" content: application/json: schema: - type: object - properties: - AccessLevel: - type: integer - ClientLimit: - type: integer - NodeLimit: - type: integer - ID: - type: string - Clients: - type: array - items: - type: string - Nodes: - type: array - items: - type: string - allNetworkUsers: - description: "All Network Users" + $ref: '#/components/schemas/networkUser' + node: + content: + application/json: + schema: + $ref: '#/components/schemas/node' + nodeAuth: + description: NodeAuth + required: true content: application/json: schema: type: object properties: - Network: + MacAddress: type: string - Users: - type: array - items: - $ref: '#/components/responses/networkUser' - userGroup: - description: "User Group" + ID: + type: string + Password: + type: string + relayRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/relayRequest' + signal: content: application/json: schema: - type: string # todo map[string]struct{} - requestBodies: - nodeAuth: - content: - application/json: - schema: - type: object - properties: - MacAddress: - type: string - ID: - type: string - Password: - type: string - description: NodeAuth - required: true - userAuth: - content: - application/json: - schema: - type: object - properties: - Username: - type: string - Password: - type: string - customExtClient: - content: - application/json: - schema: - type: object - properties: - ClientID: - type: string - PublicKey: - type: string - DNS: - type: string - ExtraAllowedIPs: - type: array - items: - type: string - Enabled: - type: boolean - DeniedACLs: - type: string # todo map[string]struct{} - description: ExtClient - required: true - host: - content: - application/json: - schema: - type: object - properties: - ID: - type: string - Verbosity: - type: string - FirewallIInUse: - type: string - Version: - type: string - DaemonInstlled: - type: boolean - AutoUpdate: - type: boolean - HostPass: - type: string - Name: - type: string - OS: - type: string - Interface: - type: string - Debug: - type: boolean - ListenPort: - type: integer - WgPublicListenPort: - type: integer - MTU: - type: integer - PublicKey: - type: string - MacAddress: - type: string - TrafficKeyPublic: - type: string - Nodes: - type: array - items: - type: string - Interfaces: - type: array - items: - type: string - DefaultInterface: - type: string - EndpointIP: - type: string - IsDocker: - type: boolean - IsK8s: - type: boolean - IsStatic: - type: boolean - IsDefault: - type: boolean - NatType: - type: string - TurnEndpoint: - type: string - description: Host - required: true - migrate: - content: - application/json: - schema: - type: object - properties: - ID: - type: string - Address: - type: string - Address6: - type: string - LocalAddress: - type: string - Interfaces: - type: array - items: - type: string - NetworkSetttings: - $ref: '#/components/responses/network' - ListenPort: - type: integer - LocalListenPort: - type: integer - PublicKey: - type: string - Endpoint: - type: string - AllowedIPs: - type: array - items: - type: string - PersistentKeepalive: - type: integer - IsHub: - type: boolean - AccessKey: - type: string - Interface: - type: string - LastModified: - type: integer - ExpirationDateTime: - type: string - LastPeerUpdate: - type: integer - MacAddress: - type: string - Password: - type: string - Network: - type: string - IsRelayed: - type: boolean - IsPending: - type: boolean - IsDocker: - type: boolean - IsK8s: - type: boolean - IsEgressGateway: - type: boolean - IsIngressGateway: - type: boolean - EgressGatewayRanges: - type: array - items: - type: string - EgressGatewayNatEnabled: - type: boolean - EgressGatewayRequest: - type: object - properties: - NodeID: - type: string - NetID: - type: string - NatEnabled: - type: boolean - Ranges: - type: array - items: - type: string - RelayAddrs: - type: array - items: - type: string - FailoverNode: - type: string - IngressGatewayRange: - type: string - IngressGatewayRange6: - type: string - IsStatic: - type: boolean - UDPHolePunch: - type: boolean - DNSOn: - type: boolean - IsServer: - type: boolean - Action: - type: string - IPForwarding: - type: boolean - OS: - type: string - MTU: - type: integer - Version: - type: string - Server: - type: string - TrafficKeys: + $ref: '#/components/schemas/signal' + userAuth: + content: + application/json: + schema: type: object properties: - Private: - type: string - Public: + Username: type: string - FirewallInUse: - type: string - InternetGateway: - type: string - Connected: - type: boolean - DefaultACL: - type: string - OwnerID: - type: string - FailOver: - type: string - - - - description: Migrate - required: true \ No newline at end of file + Password: + type: string \ No newline at end of file