Skip to content

Commit 62d3bc5

Browse files
committed
feat: update API schema
1 parent 3e315a6 commit 62d3bc5

File tree

3 files changed

+74
-119
lines changed

3 files changed

+74
-119
lines changed

modules/api/pkg/handler/apihandler.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ type TerminalResponse struct {
9191
ID string `json:"id"`
9292
}
9393

94+
type JSON string
95+
9496
// CreateHTTPAPIHandler creates a new HTTP handler that handles all requests to the API of the backend.
9597
func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, error) {
9698
apiHandler := APIHandler{iManager: iManager}
@@ -882,7 +884,7 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err
882884
Param(apiV1Ws.PathParameter("kind", "kind of the resource")).
883885
Param(apiV1Ws.PathParameter("namespace", "namespace of the resource")).
884886
Param(apiV1Ws.PathParameter("name", "name of the resource")).
885-
Returns(http.StatusOK, "OK", nil))
887+
Returns(http.StatusNoContent, "", nil))
886888
apiV1Ws.Route(
887889
apiV1Ws.GET("/_raw/{kind}/namespace/{namespace}/name/{name}").To(apiHandler.handleGetResource).
888890
// docs
@@ -899,8 +901,8 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err
899901
Param(apiV1Ws.PathParameter("kind", "kind of the resource")).
900902
Param(apiV1Ws.PathParameter("namespace", "namespace of the resource")).
901903
Param(apiV1Ws.PathParameter("name", "name of the resource")).
902-
Reads(runtime.Unknown{}).
903-
Returns(http.StatusOK, "OK", runtime.Unknown{}))
904+
Reads(JSON("")).
905+
Returns(http.StatusNoContent, "", nil))
904906

905907
// Verber (non-namespaced)
906908
apiV1Ws.Route(
@@ -909,7 +911,7 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err
909911
Doc("deletes a non-namespaced resource").
910912
Param(apiV1Ws.PathParameter("kind", "kind of the resource")).
911913
Param(apiV1Ws.PathParameter("name", "name of the resource")).
912-
Returns(http.StatusOK, "OK", nil))
914+
Returns(http.StatusNoContent, "", nil))
913915
apiV1Ws.Route(
914916
apiV1Ws.GET("/_raw/{kind}/name/{name}").To(apiHandler.handleGetResource).
915917
// docs
@@ -924,8 +926,8 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err
924926
Doc("creates a non-namespaced resource").
925927
Param(apiV1Ws.PathParameter("kind", "kind of the resource")).
926928
Param(apiV1Ws.PathParameter("name", "name of the resource")).
927-
Reads(runtime.Unknown{}).
928-
Returns(http.StatusOK, "OK", runtime.Unknown{}))
929+
Reads(JSON("")).
930+
Returns(http.StatusNoContent, "", nil))
929931

930932
// Generic resource scaling
931933
apiV1Ws.Route(
@@ -2332,7 +2334,7 @@ func (apiHandler *APIHandler) handlePutResource(
23322334
return
23332335
}
23342336

2335-
response.WriteHeader(http.StatusCreated)
2337+
response.WriteHeader(http.StatusNoContent)
23362338
}
23372339

23382340
func (apiHandler *APIHandler) handleDeleteResource(
@@ -2353,7 +2355,7 @@ func (apiHandler *APIHandler) handleDeleteResource(
23532355
return
23542356
}
23552357

2356-
response.WriteHeader(http.StatusOK)
2358+
response.WriteHeader(http.StatusNoContent)
23572359
}
23582360

23592361
func (apiHandler *APIHandler) handleGetReplicationControllerPods(request *restful.Request, response *restful.Response) {

modules/api/schema/swagger.json

Lines changed: 41 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,13 @@
141141
"in": "body",
142142
"required": true,
143143
"schema": {
144-
"$ref": "#/definitions/runtime.Unknown"
144+
"$ref": "#/definitions/handler.JSON"
145145
}
146146
}
147147
],
148148
"responses": {
149-
"200": {
150-
"description": "OK",
151-
"schema": {
152-
"$ref": "#/definitions/runtime.Unknown"
153-
}
149+
"204": {
150+
"description": ""
154151
}
155152
}
156153
},
@@ -216,8 +213,8 @@
216213
}
217214
],
218215
"responses": {
219-
"200": {
220-
"description": "OK"
216+
"204": {
217+
"description": ""
221218
}
222219
}
223220
}
@@ -372,16 +369,13 @@
372369
"in": "body",
373370
"required": true,
374371
"schema": {
375-
"$ref": "#/definitions/runtime.Unknown"
372+
"$ref": "#/definitions/handler.JSON"
376373
}
377374
}
378375
],
379376
"responses": {
380-
"200": {
381-
"description": "OK",
382-
"schema": {
383-
"$ref": "#/definitions/runtime.Unknown"
384-
}
377+
"204": {
378+
"description": ""
385379
}
386380
}
387381
},
@@ -454,8 +448,8 @@
454448
}
455449
],
456450
"responses": {
457-
"200": {
458-
"description": "OK"
451+
"204": {
452+
"description": ""
459453
}
460454
}
461455
}
@@ -9540,8 +9534,8 @@
95409534
},
95419535
"clusterrole.ClusterRoleDetail": {
95429536
"required": [
9543-
"typeMeta",
95449537
"objectMeta",
9538+
"typeMeta",
95459539
"rules",
95469540
"errors"
95479541
],
@@ -10040,13 +10034,13 @@
1004010034
},
1004110035
"cronjob.CronJobDetail": {
1004210036
"required": [
10043-
"suspend",
10044-
"active",
10045-
"lastSchedule",
1004610037
"containerImages",
1004710038
"objectMeta",
1004810039
"typeMeta",
1004910040
"schedule",
10041+
"suspend",
10042+
"active",
10043+
"lastSchedule",
1005010044
"concurrencyPolicy",
1005110045
"startingDeadlineSeconds",
1005210046
"errors"
@@ -10396,11 +10390,11 @@
1039610390
},
1039710391
"deployment.DeploymentDetail": {
1039810392
"required": [
10393+
"objectMeta",
10394+
"typeMeta",
1039910395
"pods",
1040010396
"containerImages",
1040110397
"initContainerImages",
10402-
"objectMeta",
10403-
"typeMeta",
1040410398
"selector",
1040510399
"statusInfo",
1040610400
"conditions",
@@ -10715,13 +10709,13 @@
1071510709
},
1071610710
"horizontalpodautoscaler.HorizontalPodAutoscalerDetail": {
1071710711
"required": [
10718-
"objectMeta",
1071910712
"typeMeta",
1072010713
"scaleTargetRef",
1072110714
"minReplicas",
1072210715
"maxReplicas",
1072310716
"currentCPUUtilizationPercentage",
1072410717
"targetCPUUtilizationPercentage",
10718+
"objectMeta",
1072510719
"currentReplicas",
1072610720
"desiredReplicas",
1072710721
"lastScaleTime"
@@ -10848,10 +10842,10 @@
1084810842
},
1084910843
"ingress.IngressDetail": {
1085010844
"required": [
10845+
"hosts",
1085110846
"objectMeta",
1085210847
"typeMeta",
1085310848
"endpoints",
10854-
"hosts",
1085510849
"spec",
1085610850
"status",
1085710851
"errors"
@@ -10998,13 +10992,13 @@
1099810992
},
1099910993
"job.JobDetail": {
1100010994
"required": [
10995+
"podInfo",
10996+
"containerImages",
10997+
"initContainerImages",
1100110998
"parallelism",
1100210999
"jobStatus",
1100311000
"objectMeta",
1100411001
"typeMeta",
11005-
"podInfo",
11006-
"containerImages",
11007-
"initContainerImages",
1100811002
"completions",
1100911003
"errors"
1101011004
],
@@ -11254,9 +11248,9 @@
1125411248
},
1125511249
"namespace.NamespaceDetail": {
1125611250
"required": [
11251+
"phase",
1125711252
"objectMeta",
1125811253
"typeMeta",
11259-
"phase",
1126011254
"resourceQuotaList",
1126111255
"resourceLimits",
1126211256
"errors"
@@ -11338,8 +11332,8 @@
1133811332
},
1133911333
"networkpolicy.NetworkPolicyDetail": {
1134011334
"required": [
11341-
"objectMeta",
1134211335
"typeMeta",
11336+
"objectMeta",
1134311337
"podSelector",
1134411338
"errors"
1134511339
],
@@ -11674,16 +11668,16 @@
1167411668
},
1167511669
"persistentvolume.PersistentVolumeDetail": {
1167611670
"required": [
11677-
"capacity",
11671+
"storageClass",
11672+
"claim",
11673+
"reason",
1167811674
"accessModes",
11675+
"reclaimPolicy",
11676+
"capacity",
1167911677
"mountOptions",
1168011678
"status",
1168111679
"objectMeta",
1168211680
"typeMeta",
11683-
"reclaimPolicy",
11684-
"storageClass",
11685-
"claim",
11686-
"reason",
1168711681
"message",
1168811682
"persistentVolumeSource"
1168911683
],
@@ -11801,13 +11795,13 @@
1180111795
},
1180211796
"persistentvolumeclaim.PersistentVolumeClaimDetail": {
1180311797
"required": [
11798+
"storageClass",
11799+
"objectMeta",
11800+
"typeMeta",
1180411801
"status",
1180511802
"volume",
1180611803
"capacity",
11807-
"accessModes",
11808-
"storageClass",
11809-
"objectMeta",
11810-
"typeMeta"
11804+
"accessModes"
1181111805
],
1181211806
"properties": {
1181311807
"accessModes": {
@@ -12350,11 +12344,11 @@
1235012344
},
1235112345
"replicationcontroller.ReplicationControllerDetail": {
1235212346
"required": [
12353-
"initContainerImages",
12354-
"objectMeta",
1235512347
"typeMeta",
1235612348
"podInfo",
1235712349
"containerImages",
12350+
"initContainerImages",
12351+
"objectMeta",
1235812352
"labelSelector",
1235912353
"errors"
1236012354
],
@@ -12623,8 +12617,8 @@
1262312617
},
1262412618
"rolebinding.RoleBindingDetail": {
1262512619
"required": [
12626-
"typeMeta",
1262712620
"objectMeta",
12621+
"typeMeta",
1262812622
"roleRef",
1262912623
"errors"
1263012624
],
@@ -12676,36 +12670,6 @@
1267612670
}
1267712671
}
1267812672
},
12679-
"runtime.TypeMeta": {
12680-
"properties": {
12681-
"apiVersion": {
12682-
"type": "string"
12683-
},
12684-
"kind": {
12685-
"type": "string"
12686-
}
12687-
}
12688-
},
12689-
"runtime.Unknown": {
12690-
"required": [
12691-
"ContentEncoding",
12692-
"ContentType"
12693-
],
12694-
"properties": {
12695-
"ContentEncoding": {
12696-
"type": "string"
12697-
},
12698-
"ContentType": {
12699-
"type": "string"
12700-
},
12701-
"apiVersion": {
12702-
"type": "string"
12703-
},
12704-
"kind": {
12705-
"type": "string"
12706-
}
12707-
}
12708-
},
1270912673
"scaling.ReplicaCounts": {
1271012674
"required": [
1271112675
"desiredReplicas",
@@ -12849,13 +12813,13 @@
1284912813
},
1285012814
"service.ServiceDetail": {
1285112815
"required": [
12852-
"objectMeta",
12853-
"typeMeta",
12854-
"internalEndpoint",
1285512816
"externalEndpoints",
1285612817
"selector",
1285712818
"type",
1285812819
"clusterIP",
12820+
"objectMeta",
12821+
"typeMeta",
12822+
"internalEndpoint",
1285912823
"endpointList",
1286012824
"sessionAffinity",
1286112825
"errors"
@@ -13019,11 +12983,11 @@
1301912983
},
1302012984
"statefulset.StatefulSetDetail": {
1302112985
"required": [
13022-
"initContainerImages",
13023-
"objectMeta",
1302412986
"typeMeta",
1302512987
"podInfo",
1302612988
"containerImages",
12989+
"initContainerImages",
12990+
"objectMeta",
1302712991
"errors"
1302812992
],
1302912993
"properties": {
@@ -13175,12 +13139,12 @@
1317513139
},
1317613140
"types.CustomResourceDefinitionDetail": {
1317713141
"required": [
13142+
"established",
1317813143
"objectMeta",
1317913144
"typeMeta",
1318013145
"group",
1318113146
"scope",
1318213147
"names",
13183-
"established",
1318413148
"conditions",
1318513149
"objects",
1318613150
"subresources",

0 commit comments

Comments
 (0)