Skip to content

Commit 7300136

Browse files
committed
add swagger annotations to policy template
1 parent b91eb8c commit 7300136

22 files changed

Lines changed: 2833 additions & 688 deletions

modules/api/cmd/kubermatic-api/swagger.json

Lines changed: 182 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7216,7 +7216,40 @@
72167216
}
72177217
},
72187218
"/api/v2/policytemplate": {
7219-
"put": {
7219+
"get": {
7220+
"description": "List all Policy Templates. Only available in Kubermatic Enterprise Edition",
7221+
"produces": [
7222+
"application/json"
7223+
],
7224+
"tags": [
7225+
"admin"
7226+
],
7227+
"operationId": "listPolicyTemplate",
7228+
"responses": {
7229+
"200": {
7230+
"description": "PolicyTemplate",
7231+
"schema": {
7232+
"type": "array",
7233+
"items": {
7234+
"$ref": "#/definitions/PolicyTemplate"
7235+
}
7236+
}
7237+
},
7238+
"401": {
7239+
"$ref": "#/responses/empty"
7240+
},
7241+
"403": {
7242+
"$ref": "#/responses/empty"
7243+
},
7244+
"default": {
7245+
"description": "errorResponse",
7246+
"schema": {
7247+
"$ref": "#/definitions/errorResponse"
7248+
}
7249+
}
7250+
}
7251+
},
7252+
"post": {
72207253
"description": "Create Policy Template. Only available in Kubermatic Enterprise Edition",
72217254
"consumes": [
72227255
"application/json"
@@ -7227,11 +7260,147 @@
72277260
"tags": [
72287261
"admin"
72297262
],
7230-
"operationId": "createKyvernoPolicyTemplate",
7263+
"operationId": "createPolicyTemplate",
7264+
"parameters": [
7265+
{
7266+
"type": "string",
7267+
"x-go-name": "Name",
7268+
"name": "name",
7269+
"in": "query"
7270+
}
7271+
],
72317272
"responses": {
72327273
"200": {
7274+
"description": "PolicyTemplate",
7275+
"schema": {
7276+
"$ref": "#/definitions/PolicyTemplate"
7277+
}
7278+
},
7279+
"401": {
7280+
"$ref": "#/responses/empty"
7281+
},
7282+
"403": {
72337283
"$ref": "#/responses/empty"
72347284
},
7285+
"default": {
7286+
"description": "errorResponse",
7287+
"schema": {
7288+
"$ref": "#/definitions/errorResponse"
7289+
}
7290+
}
7291+
}
7292+
}
7293+
},
7294+
"/api/v2/policytemplate/{template_name}": {
7295+
"get": {
7296+
"description": "Get Policy Template. Only available in Kubermatic Enterprise Edition",
7297+
"produces": [
7298+
"application/json"
7299+
],
7300+
"tags": [
7301+
"admin"
7302+
],
7303+
"operationId": "getPolicyTemplate",
7304+
"parameters": [
7305+
{
7306+
"type": "string",
7307+
"x-go-name": "PolicyTemplateName",
7308+
"name": "template_name",
7309+
"in": "path",
7310+
"required": true
7311+
}
7312+
],
7313+
"responses": {
7314+
"200": {
7315+
"description": "PolicyTemplate",
7316+
"schema": {
7317+
"$ref": "#/definitions/PolicyTemplate"
7318+
}
7319+
},
7320+
"401": {
7321+
"$ref": "#/responses/empty"
7322+
},
7323+
"403": {
7324+
"$ref": "#/responses/empty"
7325+
},
7326+
"default": {
7327+
"description": "errorResponse",
7328+
"schema": {
7329+
"$ref": "#/definitions/errorResponse"
7330+
}
7331+
}
7332+
}
7333+
},
7334+
"delete": {
7335+
"description": "Delete Policy Template. Only available in Kubermatic Enterprise Edition",
7336+
"produces": [
7337+
"application/json"
7338+
],
7339+
"tags": [
7340+
"admin"
7341+
],
7342+
"operationId": "deletePolicyTemplate",
7343+
"parameters": [
7344+
{
7345+
"type": "string",
7346+
"x-go-name": "PolicyTemplateName",
7347+
"name": "template_name",
7348+
"in": "path",
7349+
"required": true
7350+
}
7351+
],
7352+
"responses": {
7353+
"200": {
7354+
"$ref": "#/responses/empty"
7355+
},
7356+
"401": {
7357+
"$ref": "#/responses/empty"
7358+
},
7359+
"403": {
7360+
"$ref": "#/responses/empty"
7361+
},
7362+
"default": {
7363+
"description": "errorResponse",
7364+
"schema": {
7365+
"$ref": "#/definitions/errorResponse"
7366+
}
7367+
}
7368+
}
7369+
},
7370+
"patch": {
7371+
"description": "Patch Policy Template. Only available in Kubermatic Enterprise Edition",
7372+
"consumes": [
7373+
"application/json"
7374+
],
7375+
"produces": [
7376+
"application/json"
7377+
],
7378+
"tags": [
7379+
"admin"
7380+
],
7381+
"operationId": "patchpolicyTemplate",
7382+
"parameters": [
7383+
{
7384+
"type": "string",
7385+
"x-go-name": "Name",
7386+
"name": "name",
7387+
"in": "query"
7388+
},
7389+
{
7390+
"type": "string",
7391+
"x-go-name": "PolicyTemplateName",
7392+
"name": "template_name",
7393+
"in": "path",
7394+
"required": true
7395+
}
7396+
],
7397+
"responses": {
7398+
"200": {
7399+
"description": "PolicyTemplate",
7400+
"schema": {
7401+
"$ref": "#/definitions/PolicyTemplate"
7402+
}
7403+
},
72357404
"401": {
72367405
"$ref": "#/responses/empty"
72377406
},
@@ -37657,6 +37826,17 @@
3765737826
},
3765837827
"x-go-package": "k8s.io/api/rbac/v1"
3765937828
},
37829+
"PolicyTemplate": {
37830+
"type": "object",
37831+
"title": "PolicyTemplate defines a reusable blueprint of a Kyverno policy.",
37832+
"properties": {
37833+
"name": {
37834+
"type": "string",
37835+
"x-go-name": "Name"
37836+
}
37837+
},
37838+
"x-go-package": "k8c.io/dashboard/v2/pkg/api/v2"
37839+
},
3766037840
"PolicyType": {
3766137841
"description": "PolicyType string describes the NetworkPolicy type\nThis type is beta-level in 1.8\n+enum",
3766237842
"type": "string",

modules/api/pkg/api/v2/types.go

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,40 +2293,13 @@ type BackupDownloadUrl struct {
22932293
}
22942294

22952295
// PolicyTemplate defines a reusable blueprint of a Kyverno policy.
2296+
// swagger:model PolicyTemplate
22962297
type PolicyTemplate struct {
2297-
Name string `json:"name,omitempty"`
2298+
Name string `json:"name,omitempty"`
2299+
// swagger:ignore
22982300
Spec kubermaticv1.PolicyTemplateSpec `json:"spec,omitempty"`
22992301
}
23002302

2301-
// type PolicyTemplateSpec struct {
2302-
// // the title of the policy, specified as an annotation in the Kyverno policy
2303-
// Title string `json:"title,omitempty"`
2304-
// // the category of the policy, specified as an annotation in the Kyverno policy
2305-
// Category string `json:"category,omitempty"`
2306-
// // the description of the policy, specified as an annotation in the Kyverno policy
2307-
// Description string `json:"description,omitempty"`
2308-
// // Severity indicates the severity level of the policy
2309-
// Severity string `json:"severity,omitempty"`
2310-
2311-
// // Visibility specifies where the policy is visible.
2312-
// // Can be one of: global, project, or cluster
2313-
// Visibility string `json:"visibility"`
2314-
2315-
// // ProjectID is the ID of the project for which the policy template is created
2316-
// // Relevant only for project visibility policies
2317-
// ProjectID string `json:"projectID,omitempty"`
2318-
2319-
// // Default determines whether we apply the policy (create policy binding)
2320-
// Default bool `json:"default,omitempty"`
2321-
2322-
// // Enforced indicates whether this policy is mandatory
2323-
// // If true, this policy is mandatory
2324-
// // A PolicyBinding referencing it cannot disable it
2325-
// Enforced bool `json:"enforced"`
2326-
// // the Kyverno specification
2327-
// kyvernov1.Spec `json:"kyvernoSpec,omitempty"`
2328-
// }
2329-
23302303
// PolicyInstanceSpec describes how and where to apply the referenced PolicyTemplate.
23312304
type PolicyInstance struct {
23322305
Name string `json:"name,omitempty"`

0 commit comments

Comments
 (0)