Skip to content

Commit

Permalink
openapi: adding watch parameter on list operations
Browse files Browse the repository at this point in the history
Related to kubevirt#582
  • Loading branch information
lukas-bednar committed Nov 27, 2017
1 parent da9b3ff commit 1fb460e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
45 changes: 42 additions & 3 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@
"description": "Get a list of Migration objects.",
"produces": [
"application/json",
"application/yaml"
"application/yaml",
"application/json;stream=watch"
],
"summary": "Get a list of Migration objects.",
"operationId": "listNamespacedMigration",
Expand All @@ -175,6 +176,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -315,6 +322,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -470,7 +483,8 @@
"description": "Get a list of VirtualMachineReplicaSet objects.",
"produces": [
"application/json",
"application/yaml"
"application/yaml",
"application/json;stream=watch"
],
"summary": "Get a list of VirtualMachineReplicaSet objects.",
"operationId": "listNamespacedVirtualMachineReplicaSet",
Expand All @@ -494,6 +508,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -634,6 +654,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -789,7 +815,8 @@
"description": "Get a list of VirtualMachine objects.",
"produces": [
"application/json",
"application/yaml"
"application/yaml",
"application/json;stream=watch"
],
"summary": "Get a list of VirtualMachine objects.",
"operationId": "listNamespacedVirtualMachine",
Expand All @@ -813,6 +840,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -953,6 +986,12 @@
"description": "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'",
"name": "exact",
"in": "query"
},
{
"type": "boolean",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"name": "watch",
"in": "query"
}
],
"responses": {
Expand Down
11 changes: 6 additions & 5 deletions pkg/rest/mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
package rest

const (
MIME_JSON string = "application/json"
MIME_JSON_PATCH string = "application/json-patch+json"
MIME_YAML string = "application/yaml"
MIME_TEXT string = "text/plain"
MIME_INI string = "text/plain"
MIME_JSON string = "application/json"
MIME_JSON_PATCH string = "application/json-patch+json"
MIME_JSON_STREAM string = "application/json;stream=watch"
MIME_YAML string = "application/yaml"
MIME_TEXT string = "text/plain"
MIME_INI string = "text/plain"
)
5 changes: 3 additions & 2 deletions pkg/virt-api/rest/kubeproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func GenericResourceProxy(ws *restful.WebService, ctx context.Context, gvr schem

ws.Route(addGetNamespacedListParams(
ws.GET(ResourceBasePath(gvr)).
Produces(mime.MIME_JSON, mime.MIME_YAML).
Produces(mime.MIME_JSON, mime.MIME_YAML, mime.MIME_JSON_STREAM).
Operation("listNamespaced"+objKind).
Writes(listExample).
To(endpoints.MakeGoRestfulWrapper(getList)).
Expand Down Expand Up @@ -241,7 +241,8 @@ func addGetParams(builder *restful.RouteBuilder, ws *restful.WebService) *restfu
func addGetNamespacedListParams(builder *restful.RouteBuilder, ws *restful.WebService) *restful.RouteBuilder {
return builder.Param(NamespaceParam(ws)).
Param(ws.QueryParameter("export", "Should this value be exported. Export strips fields that a user can not specify.").DataType("boolean")).
Param(ws.QueryParameter("exact", "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'").DataType("boolean"))
Param(ws.QueryParameter("exact", "Should the export be exact. Exact export maintains cluster-specific fields like 'Namespace'").DataType("boolean")).
Param(ws.QueryParameter("watch", "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.").DataType("boolean"))
}

func addPostParams(builder *restful.RouteBuilder, ws *restful.WebService) *restful.RouteBuilder {
Expand Down

0 comments on commit 1fb460e

Please sign in to comment.