Example #1
0
// GeneratePythonClientObjs generates the python client for individual objects
func (obj *Object) GeneratePythonClientObjs() (string, error) {
	goStr, err := generators.RunTemplate("pyclientObj", obj)
	if err != nil {
		return "", err
	}

	return goStr, nil
}
Example #2
0
func (obj *Object) GenerateJsViews() (string, error) {
	goStr, err := generators.RunTemplate("jsView", obj)
	if err != nil {
		return "", err
	}

	return goStr, nil
}
Example #3
0
func (prop *Property) GenerateGoStructs() (string, error) {
	var found bool

	for _, myType := range validPropertyTypes {
		if myType == prop.Type {
			found = true
		}
	}

	if !found {
		return "", errors.New("Unknown Property")
	}

	return generators.RunTemplate("propstruct", prop)
}
Example #4
0
// GenerateClient generates python client for the model
func (s *Schema) GeneratePythonClient() (string, error) {
	// Generate file headers
	goStr, err := generators.RunTemplate("pyclientHdr", s)
	if err != nil {
		return "", err
	}

	//  Generate clients for all objects
	for _, obj := range s.Objects {
		objStr, err := obj.GeneratePythonClientObjs()
		if err == nil {
			goStr = goStr + objStr
		}
	}

	return goStr, nil
}
Example #5
0
// GenerateGoStructs generates go code from a schema
func (s *Schema) GenerateGoStructs() (string, error) {
	var goStr string

	//  Generate all object definitions
	for _, obj := range s.Objects {
		objStr, err := obj.GenerateGoStructs()
		if err != nil {
			return "", err
		}

		goStr += objStr
	}

	for _, name := range []string{"gostructs", "callbacks", "init", "register"} {
		str, err := generators.RunTemplate(name, s)
		if err != nil {
			return "", err
		}

		goStr += str
	}

	return goStr, nil
}
Example #6
0
func (s *Schema) GenerateGoFuncs() (string, error) {
	// Output the functions and routes
	return generators.RunTemplate("routeFunc", s)
}
Example #7
0
// GenerateGoHdrs generates go file headers
func (s *Schema) GenerateGoHdrs() (string, error) {
	return generators.RunTemplate("hdr", s)
}
Example #8
0
func (obj *Object) GenerateGoStructs() (string, error) {
	return generators.RunTemplate("objstruct", obj)
}