Skip to content

Commit ff622a7

Browse files
committed
templateversion.go in progress
1 parent 250982a commit ff622a7

File tree

8 files changed

+528
-15
lines changed

8 files changed

+528
-15
lines changed

coderd/apidoc/docs.go

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,79 @@ const docTemplate = `{
971971
}
972972
}
973973
},
974+
"/templateversions/{id}": {
975+
"get": {
976+
"security": [
977+
{
978+
"CoderSessionToken": []
979+
}
980+
],
981+
"produces": [
982+
"application/json"
983+
],
984+
"tags": [
985+
"Templates"
986+
],
987+
"summary": "Get template version by ID",
988+
"operationId": "get-template-version-by-id",
989+
"parameters": [
990+
{
991+
"type": "string",
992+
"format": "uuid",
993+
"description": "Template version ID",
994+
"name": "id",
995+
"in": "path",
996+
"required": true
997+
}
998+
],
999+
"responses": {
1000+
"200": {
1001+
"description": "OK",
1002+
"schema": {
1003+
"$ref": "#/definitions/codersdk.TemplateVersion"
1004+
}
1005+
}
1006+
}
1007+
}
1008+
},
1009+
"/templateversions/{id}/schema": {
1010+
"get": {
1011+
"security": [
1012+
{
1013+
"CoderSessionToken": []
1014+
}
1015+
],
1016+
"produces": [
1017+
"application/json"
1018+
],
1019+
"tags": [
1020+
"Templates"
1021+
],
1022+
"summary": "Get template version schema by template version ID",
1023+
"operationId": "get-template-version-schema-by-template-version-id",
1024+
"parameters": [
1025+
{
1026+
"type": "string",
1027+
"format": "uuid",
1028+
"description": "Template version ID",
1029+
"name": "id",
1030+
"in": "path",
1031+
"required": true
1032+
}
1033+
],
1034+
"responses": {
1035+
"200": {
1036+
"description": "OK",
1037+
"schema": {
1038+
"type": "array",
1039+
"items": {
1040+
"$ref": "#/definitions/codersdk.ParameterSchema"
1041+
}
1042+
}
1043+
}
1044+
}
1045+
}
1046+
},
9741047
"/updatecheck": {
9751048
"get": {
9761049
"produces": [
@@ -2270,7 +2343,8 @@ const docTemplate = `{
22702343
"properties": {
22712344
"copy_from_parameter": {
22722345
"description": "CloneID allows copying the value of another parameter.\nThe other param must be related to the same template_id for this to\nsucceed.\nNo other fields are required if using this, as all fields will be copied\nfrom the other parameter.",
2273-
"type": "string"
2346+
"type": "string",
2347+
"format": "uuid"
22742348
},
22752349
"destination_scheme": {
22762350
"type": "string",
@@ -2964,6 +3038,78 @@ const docTemplate = `{
29643038
}
29653039
}
29663040
},
3041+
"codersdk.ParameterSchema": {
3042+
"type": "object",
3043+
"properties": {
3044+
"allow_override_destination": {
3045+
"type": "boolean"
3046+
},
3047+
"allow_override_source": {
3048+
"type": "boolean"
3049+
},
3050+
"created_at": {
3051+
"type": "string",
3052+
"format": "date-time"
3053+
},
3054+
"default_destination_scheme": {
3055+
"type": "string",
3056+
"enum": [
3057+
"none",
3058+
"environment_variable",
3059+
"provisioner_variable"
3060+
]
3061+
},
3062+
"default_refresh": {
3063+
"type": "string"
3064+
},
3065+
"default_source_scheme": {
3066+
"type": "string",
3067+
"enum": [
3068+
"none",
3069+
"data"
3070+
]
3071+
},
3072+
"default_source_value": {
3073+
"type": "string"
3074+
},
3075+
"description": {
3076+
"type": "string"
3077+
},
3078+
"id": {
3079+
"type": "string",
3080+
"format": "uuid"
3081+
},
3082+
"job_id": {
3083+
"type": "string",
3084+
"format": "uuid"
3085+
},
3086+
"name": {
3087+
"type": "string"
3088+
},
3089+
"redisplay_value": {
3090+
"type": "boolean"
3091+
},
3092+
"validation_condition": {
3093+
"type": "string"
3094+
},
3095+
"validation_contains": {
3096+
"description": "This is a special array of items provided if the validation condition\nexplicitly states the value must be one of a set.",
3097+
"type": "array",
3098+
"items": {
3099+
"type": "string"
3100+
}
3101+
},
3102+
"validation_error": {
3103+
"type": "string"
3104+
},
3105+
"validation_type_system": {
3106+
"type": "string"
3107+
},
3108+
"validation_value_type": {
3109+
"type": "string"
3110+
}
3111+
}
3112+
},
29673113
"codersdk.PostWorkspaceAgentVersionRequest": {
29683114
"type": "object",
29693115
"properties": {

coderd/apidoc/swagger.json

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,71 @@
843843
}
844844
}
845845
},
846+
"/templateversions/{id}": {
847+
"get": {
848+
"security": [
849+
{
850+
"CoderSessionToken": []
851+
}
852+
],
853+
"produces": ["application/json"],
854+
"tags": ["Templates"],
855+
"summary": "Get template version by ID",
856+
"operationId": "get-template-version-by-id",
857+
"parameters": [
858+
{
859+
"type": "string",
860+
"format": "uuid",
861+
"description": "Template version ID",
862+
"name": "id",
863+
"in": "path",
864+
"required": true
865+
}
866+
],
867+
"responses": {
868+
"200": {
869+
"description": "OK",
870+
"schema": {
871+
"$ref": "#/definitions/codersdk.TemplateVersion"
872+
}
873+
}
874+
}
875+
}
876+
},
877+
"/templateversions/{id}/schema": {
878+
"get": {
879+
"security": [
880+
{
881+
"CoderSessionToken": []
882+
}
883+
],
884+
"produces": ["application/json"],
885+
"tags": ["Templates"],
886+
"summary": "Get template version schema by template version ID",
887+
"operationId": "get-template-version-schema-by-template-version-id",
888+
"parameters": [
889+
{
890+
"type": "string",
891+
"format": "uuid",
892+
"description": "Template version ID",
893+
"name": "id",
894+
"in": "path",
895+
"required": true
896+
}
897+
],
898+
"responses": {
899+
"200": {
900+
"description": "OK",
901+
"schema": {
902+
"type": "array",
903+
"items": {
904+
"$ref": "#/definitions/codersdk.ParameterSchema"
905+
}
906+
}
907+
}
908+
}
909+
}
910+
},
846911
"/updatecheck": {
847912
"get": {
848913
"produces": ["application/json"],
@@ -2008,7 +2073,8 @@
20082073
"properties": {
20092074
"copy_from_parameter": {
20102075
"description": "CloneID allows copying the value of another parameter.\nThe other param must be related to the same template_id for this to\nsucceed.\nNo other fields are required if using this, as all fields will be copied\nfrom the other parameter.",
2011-
"type": "string"
2076+
"type": "string",
2077+
"format": "uuid"
20122078
},
20132079
"destination_scheme": {
20142080
"type": "string",
@@ -2666,6 +2732,71 @@
26662732
}
26672733
}
26682734
},
2735+
"codersdk.ParameterSchema": {
2736+
"type": "object",
2737+
"properties": {
2738+
"allow_override_destination": {
2739+
"type": "boolean"
2740+
},
2741+
"allow_override_source": {
2742+
"type": "boolean"
2743+
},
2744+
"created_at": {
2745+
"type": "string",
2746+
"format": "date-time"
2747+
},
2748+
"default_destination_scheme": {
2749+
"type": "string",
2750+
"enum": ["none", "environment_variable", "provisioner_variable"]
2751+
},
2752+
"default_refresh": {
2753+
"type": "string"
2754+
},
2755+
"default_source_scheme": {
2756+
"type": "string",
2757+
"enum": ["none", "data"]
2758+
},
2759+
"default_source_value": {
2760+
"type": "string"
2761+
},
2762+
"description": {
2763+
"type": "string"
2764+
},
2765+
"id": {
2766+
"type": "string",
2767+
"format": "uuid"
2768+
},
2769+
"job_id": {
2770+
"type": "string",
2771+
"format": "uuid"
2772+
},
2773+
"name": {
2774+
"type": "string"
2775+
},
2776+
"redisplay_value": {
2777+
"type": "boolean"
2778+
},
2779+
"validation_condition": {
2780+
"type": "string"
2781+
},
2782+
"validation_contains": {
2783+
"description": "This is a special array of items provided if the validation condition\nexplicitly states the value must be one of a set.",
2784+
"type": "array",
2785+
"items": {
2786+
"type": "string"
2787+
}
2788+
},
2789+
"validation_error": {
2790+
"type": "string"
2791+
},
2792+
"validation_type_system": {
2793+
"type": "string"
2794+
},
2795+
"validation_value_type": {
2796+
"type": "string"
2797+
}
2798+
}
2799+
},
26692800
"codersdk.PostWorkspaceAgentVersionRequest": {
26702801
"type": "object",
26712802
"properties": {

coderd/templateversions.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ import (
2828
"github.com/coder/coder/examples"
2929
)
3030

31+
// @Summary Get template version by ID
32+
// @ID get-template-version-by-id
33+
// @Security CoderSessionToken
34+
// @Produce json
35+
// @Tags Templates
36+
// @Param id path string true "Template version ID" format(uuid)
37+
// @Success 200 {object} codersdk.TemplateVersion
38+
// @Router /templateversions/{id} [get]
3139
func (api *API) templateVersion(rw http.ResponseWriter, r *http.Request) {
3240
ctx := r.Context()
3341
var (
@@ -116,6 +124,14 @@ func (api *API) patchCancelTemplateVersion(rw http.ResponseWriter, r *http.Reque
116124
})
117125
}
118126

127+
// @Summary Get template version schema by template version ID
128+
// @ID get-template-version-schema-by-template-version-id
129+
// @Security CoderSessionToken
130+
// @Produce json
131+
// @Tags Templates
132+
// @Param id path string true "Template version ID" format(uuid)
133+
// @Success 200 {array} codersdk.ParameterSchema
134+
// @Router /templateversions/{id}/schema [get]
119135
func (api *API) templateVersionSchema(rw http.ResponseWriter, r *http.Request) {
120136
ctx := r.Context()
121137
var (

codersdk/parameters.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
type ComputedParameter struct {
4545
Parameter
4646
SourceValue string `json:"source_value"`
47-
SchemaID uuid.UUID `json:"schema_id"`
47+
SchemaID uuid.UUID `json:"schema_id" format:"uuid"`
4848
DefaultSourceValue bool `json:"default_source_value"`
4949
}
5050

@@ -63,15 +63,15 @@ type Parameter struct {
6363
}
6464

6565
type ParameterSchema struct {
66-
ID uuid.UUID `json:"id"`
67-
CreatedAt time.Time `json:"created_at"`
68-
JobID uuid.UUID `json:"job_id"`
66+
ID uuid.UUID `json:"id" format:"uuid"`
67+
CreatedAt time.Time `json:"created_at" format:"date-time"`
68+
JobID uuid.UUID `json:"job_id" format:"uuid"`
6969
Name string `json:"name"`
7070
Description string `json:"description"`
71-
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme"`
71+
DefaultSourceScheme ParameterSourceScheme `json:"default_source_scheme" enums:"none,data"`
7272
DefaultSourceValue string `json:"default_source_value"`
7373
AllowOverrideSource bool `json:"allow_override_source"`
74-
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme"`
74+
DefaultDestinationScheme ParameterDestinationScheme `json:"default_destination_scheme" enums:"none,environment_variable,provisioner_variable"`
7575
AllowOverrideDestination bool `json:"allow_override_destination"`
7676
DefaultRefresh string `json:"default_refresh"`
7777
RedisplayValue bool `json:"redisplay_value"`
@@ -94,7 +94,7 @@ type CreateParameterRequest struct {
9494
// succeed.
9595
// No other fields are required if using this, as all fields will be copied
9696
// from the other parameter.
97-
CloneID uuid.UUID `json:"copy_from_parameter,omitempty" validate:""`
97+
CloneID uuid.UUID `json:"copy_from_parameter,omitempty" validate:"" format:"uuid"`
9898

9999
Name string `json:"name" validate:"required"`
100100
SourceValue string `json:"source_value" validate:"required"`

0 commit comments

Comments
 (0)