/
templates.go
45 lines (36 loc) · 1.57 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"github.com/TranscendComputing/mciaas/store"
"github.com/ant0ine/go-json-rest"
"path/filepath"
)
type JSONTemplates struct {
BasePath string
}
func (this *JSONTemplates) ListTemplateTypes(w *rest.ResponseWriter, r *rest.Request) {
store.SendJSONFile(w, r, filepath.Join(this.BasePath, "list.json"))
}
func (this *JSONTemplates) ListBuilderTemplates(w *rest.ResponseWriter, r *rest.Request) {
store.SendJSONFile(w, r, filepath.Join(this.BasePath, "builders", "list.json"))
}
func (this *JSONTemplates) GetBuilderTemplate(w *rest.ResponseWriter, r *rest.Request) {
builder := r.PathParam("type")
jsonPath := filepath.Join(this.BasePath, "builders", builder+".json")
store.SendJSONFile(w, r, jsonPath)
}
func (this *JSONTemplates) ListProvisionerTemplates(w *rest.ResponseWriter, r *rest.Request) {
store.SendJSONFile(w, r, filepath.Join(this.BasePath, "provisioners", "list.json"))
}
func (this *JSONTemplates) GetProvisionerTemplate(w *rest.ResponseWriter, r *rest.Request) {
provisioner := r.PathParam("type")
jsonPath := filepath.Join(this.BasePath, "provisioners", provisioner+".json")
store.SendJSONFile(w, r, jsonPath)
}
func (this *JSONTemplates) ListPostprocessorTemplates(w *rest.ResponseWriter, r *rest.Request) {
store.SendJSONFile(w, r, filepath.Join(this.BasePath, "postprocessors", "list.json"))
}
func (this *JSONTemplates) GetPostprocessorTemplate(w *rest.ResponseWriter, r *rest.Request) {
postprocessor := r.PathParam("type")
jsonPath := filepath.Join(this.BasePath, "postprocessors", postprocessor+".json")
store.SendJSONFile(w, r, jsonPath)
}