Skip to content

Commit e4f517e

Browse files
authored
Add swagger docs for host preflights api endpoints (#2216)
1 parent 8967af3 commit e4f517e

File tree

5 files changed

+157
-4
lines changed

5 files changed

+157
-4
lines changed

api/docs/docs.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/docs/swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"components": {"schemas":{"types.APIError":{"properties":{"errors":{"items":{"$ref":"#/components/schemas/types.APIError"},"type":"array","uniqueItems":false},"field":{"type":"string"},"message":{"type":"string"},"status_code":{"type":"integer"}},"type":"object"},"types.AuthRequest":{"properties":{"password":{"type":"string"}},"type":"object"},"types.AuthResponse":{"properties":{"token":{"type":"string"}},"type":"object"},"types.Health":{"properties":{"status":{"type":"string"}},"type":"object"},"types.Install":{"properties":{"config":{"$ref":"#/components/schemas/types.InstallationConfig"},"status":{"$ref":"#/components/schemas/types.InstallationStatus"}},"type":"object"},"types.InstallationConfig":{"properties":{"adminConsolePort":{"type":"integer"},"dataDirectory":{"type":"string"},"globalCidr":{"type":"string"},"httpProxy":{"type":"string"},"httpsProxy":{"type":"string"},"localArtifactMirrorPort":{"type":"integer"},"networkInterface":{"type":"string"},"noProxy":{"type":"string"},"podCidr":{"type":"string"},"serviceCidr":{"type":"string"}},"type":"object"},"types.InstallationState":{"type":"string","x-enum-varnames":["InstallationStatePending","InstallationStateRunning","InstallationStateSucceeded","InstallationStateFailed"]},"types.InstallationStatus":{"properties":{"description":{"type":"string"},"lastUpdated":{"type":"string"},"state":{"$ref":"#/components/schemas/types.InstallationState"}},"type":"object"}},"securitySchemes":{"bearerauth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"}}},
2+
"components": {"schemas":{"types.APIError":{"properties":{"errors":{"items":{"$ref":"#/components/schemas/types.APIError"},"type":"array","uniqueItems":false},"field":{"type":"string"},"message":{"type":"string"},"status_code":{"type":"integer"}},"type":"object"},"types.AuthRequest":{"properties":{"password":{"type":"string"}},"type":"object"},"types.AuthResponse":{"properties":{"token":{"type":"string"}},"type":"object"},"types.Health":{"properties":{"status":{"type":"string"}},"type":"object"},"types.HostPreflightOutput":{"properties":{"fail":{"items":{"$ref":"#/components/schemas/types.HostPreflightRecord"},"type":"array","uniqueItems":false},"pass":{"items":{"$ref":"#/components/schemas/types.HostPreflightRecord"},"type":"array","uniqueItems":false},"warn":{"items":{"$ref":"#/components/schemas/types.HostPreflightRecord"},"type":"array","uniqueItems":false}},"type":"object"},"types.HostPreflightRecord":{"properties":{"message":{"type":"string"},"title":{"type":"string"}},"type":"object"},"types.HostPreflightState":{"type":"string","x-enum-varnames":["HostPreflightStatePending","HostPreflightStateRunning","HostPreflightStateSucceeded","HostPreflightStateFailed"]},"types.HostPreflightStatus":{"properties":{"description":{"type":"string"},"lastUpdated":{"type":"string"},"state":{"$ref":"#/components/schemas/types.HostPreflightState"}},"type":"object"},"types.HostPreflightStatusResponse":{"properties":{"output":{"$ref":"#/components/schemas/types.HostPreflightOutput"},"status":{"$ref":"#/components/schemas/types.HostPreflightStatus"}},"type":"object"},"types.Install":{"properties":{"config":{"$ref":"#/components/schemas/types.InstallationConfig"},"status":{"$ref":"#/components/schemas/types.InstallationStatus"}},"type":"object"},"types.InstallationConfig":{"properties":{"adminConsolePort":{"type":"integer"},"dataDirectory":{"type":"string"},"globalCidr":{"type":"string"},"httpProxy":{"type":"string"},"httpsProxy":{"type":"string"},"localArtifactMirrorPort":{"type":"integer"},"networkInterface":{"type":"string"},"noProxy":{"type":"string"},"podCidr":{"type":"string"},"serviceCidr":{"type":"string"}},"type":"object"},"types.InstallationState":{"type":"string","x-enum-varnames":["InstallationStatePending","InstallationStateRunning","InstallationStateSucceeded","InstallationStateFailed"]},"types.InstallationStatus":{"properties":{"description":{"type":"string"},"lastUpdated":{"type":"string"},"state":{"$ref":"#/components/schemas/types.InstallationState"}},"type":"object"},"types.RunHostPreflightResponse":{"properties":{"status":{"$ref":"#/components/schemas/types.HostPreflightStatus"}},"type":"object"}},"securitySchemes":{"bearerauth":{"bearerFormat":"JWT","scheme":"bearer","type":"http"}}},
33
"info": {"contact":{"email":"support@replicated.com","name":"API Support","url":"https://github.com/replicatedhq/embedded-cluster/issues"},"description":"This is the API for the Embedded Cluster project.","license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"},"termsOfService":"http://swagger.io/terms/","title":"Embedded Cluster API","version":"0.1"},
44
"externalDocs": {"description":"OpenAPI","url":"https://swagger.io/resources/open-api/"},
5-
"paths": {"/auth/login":{"post":{"description":"Authenticate a user","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.AuthRequest"}}},"description":"Auth Request","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.AuthResponse"}}},"description":"OK"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.APIError"}}},"description":"Unauthorized"}},"summary":"Authenticate a user","tags":["auth"]}},"/health":{"get":{"description":"get the health of the API","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.Health"}}},"description":"OK"}},"summary":"Get the health of the API","tags":["health"]}},"/install":{"get":{"description":"get the install object","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.Install"}}},"description":"OK"}},"security":[{"bearerauth":[]}],"summary":"Get the install object","tags":["install"]}}},
5+
"paths": {"/auth/login":{"post":{"description":"Authenticate a user","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.AuthRequest"}}},"description":"Auth Request","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.AuthResponse"}}},"description":"OK"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.APIError"}}},"description":"Unauthorized"}},"summary":"Authenticate a user","tags":["auth"]}},"/health":{"get":{"description":"get the health of the API","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.Health"}}},"description":"OK"}},"summary":"Get the health of the API","tags":["health"]}},"/install":{"get":{"description":"get the install object","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.Install"}}},"description":"OK"}},"security":[{"bearerauth":[]}],"summary":"Get the install object","tags":["install"]}},"/install/host-preflights":{"get":{"description":"Get the current status and results of host preflight checks","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.HostPreflightStatusResponse"}}},"description":"OK"}},"security":[{"bearerauth":[]}],"summary":"Get host preflight status","tags":["install"]},"post":{"description":"Run install host preflight checks using installation config and client-provided data","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/types.RunHostPreflightResponse"}}},"description":"OK"}},"security":[{"bearerauth":[]}],"summary":"Run install host preflight checks","tags":["install"]}}},
66
"openapi": "3.1.0",
77
"servers": [
88
{"url":"/api"}

api/docs/swagger.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,54 @@ components:
2929
status:
3030
type: string
3131
type: object
32+
types.HostPreflightOutput:
33+
properties:
34+
fail:
35+
items:
36+
$ref: '#/components/schemas/types.HostPreflightRecord'
37+
type: array
38+
uniqueItems: false
39+
pass:
40+
items:
41+
$ref: '#/components/schemas/types.HostPreflightRecord'
42+
type: array
43+
uniqueItems: false
44+
warn:
45+
items:
46+
$ref: '#/components/schemas/types.HostPreflightRecord'
47+
type: array
48+
uniqueItems: false
49+
type: object
50+
types.HostPreflightRecord:
51+
properties:
52+
message:
53+
type: string
54+
title:
55+
type: string
56+
type: object
57+
types.HostPreflightState:
58+
type: string
59+
x-enum-varnames:
60+
- HostPreflightStatePending
61+
- HostPreflightStateRunning
62+
- HostPreflightStateSucceeded
63+
- HostPreflightStateFailed
64+
types.HostPreflightStatus:
65+
properties:
66+
description:
67+
type: string
68+
lastUpdated:
69+
type: string
70+
state:
71+
$ref: '#/components/schemas/types.HostPreflightState'
72+
type: object
73+
types.HostPreflightStatusResponse:
74+
properties:
75+
output:
76+
$ref: '#/components/schemas/types.HostPreflightOutput'
77+
status:
78+
$ref: '#/components/schemas/types.HostPreflightStatus'
79+
type: object
3280
types.Install:
3381
properties:
3482
config:
@@ -75,6 +123,11 @@ components:
75123
state:
76124
$ref: '#/components/schemas/types.InstallationState'
77125
type: object
126+
types.RunHostPreflightResponse:
127+
properties:
128+
status:
129+
$ref: '#/components/schemas/types.HostPreflightStatus'
130+
type: object
78131
securitySchemes:
79132
bearerauth:
80133
bearerFormat: JWT
@@ -151,5 +204,35 @@ paths:
151204
summary: Get the install object
152205
tags:
153206
- install
207+
/install/host-preflights:
208+
get:
209+
description: Get the current status and results of host preflight checks
210+
responses:
211+
"200":
212+
content:
213+
application/json:
214+
schema:
215+
$ref: '#/components/schemas/types.HostPreflightStatusResponse'
216+
description: OK
217+
security:
218+
- bearerauth: []
219+
summary: Get host preflight status
220+
tags:
221+
- install
222+
post:
223+
description: Run install host preflight checks using installation config and
224+
client-provided data
225+
responses:
226+
"200":
227+
content:
228+
application/json:
229+
schema:
230+
$ref: '#/components/schemas/types.RunHostPreflightResponse'
231+
description: OK
232+
security:
233+
- bearerauth: []
234+
summary: Run install host preflight checks
235+
tags:
236+
- install
154237
servers:
155238
- url: /api

api/install.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,29 @@ func (a *API) getInstallStatus(w http.ResponseWriter, r *http.Request) {
7676

7777
a.json(w, r, http.StatusOK, status)
7878
}
79+
80+
// runInstallHostPreflights handler to run install host preflight checks
81+
//
82+
// @Summary Run install host preflight checks
83+
// @Description Run install host preflight checks using installation config and client-provided data
84+
// @Tags install
85+
// @Security bearerauth
86+
// @Produce json
87+
// @Success 200 {object} types.RunHostPreflightResponse
88+
// @Router /install/host-preflights [post]
89+
func (a *API) runInstallHostPreflights(w http.ResponseWriter, r *http.Request) {
90+
// TODO: implement
91+
}
92+
93+
// getInstallHostPreflightStatus handler to get host preflight status
94+
//
95+
// @Summary Get host preflight status
96+
// @Description Get the current status and results of host preflight checks
97+
// @Tags install
98+
// @Security bearerauth
99+
// @Produce json
100+
// @Success 200 {object} types.HostPreflightStatusResponse
101+
// @Router /install/host-preflights [get]
102+
func (a *API) getInstallHostPreflightStatus(w http.ResponseWriter, r *http.Request) {
103+
// TODO: implement
104+
}

0 commit comments

Comments
 (0)