generator

package
v1.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SoftLayerMetadataAPIURL = "https://api.softlayer.com/metadata/v3.1"

Variables

View Source
var IterTemplate = `` /* 1092-byte string literal not displayed */

Not Used, but could be added to the Service template if you want ALL methods that accept a resultLimit to page through results

Functions

func AddComplexType

func AddComplexType(dataType *Type)

Special case for ensuring we can set a complexType on product orders.

func CombineMethods

func CombineMethods(baseMethods map[string]Method, subclassMethods map[string]Method) map[string]Method

func ConvertType

func ConvertType(args ...interface{}) string

ConvertType takes the name of the type to convert, and the package context.

func CreateGetters

func CreateGetters(service *Type)

func Desnake

func Desnake(args ...interface{}) string

Remove '_' from Snake_Case values

func Execute

func Execute() error

func FixDatatype

func FixDatatype(t *Type, meta map[string]Type)

Special case for fixing some datatype properties in the metadata so that these properties can be set in their base

func FixReturnType

func FixReturnType(service *Type)

Special case for fixing some broken return types in the metadata

func GenerateAPI

func GenerateAPI(metaPath string, outputDir string)

func GetBaseMethods

func GetBaseMethods(s Type, typeMap map[string]Type) map[string]Method

func GetMetaFromFile

func GetMetaFromFile(file string) ([]byte, error)

func GetMetaFromURL

func GetMetaFromURL(url string) ([]byte, error)

func GetSortedKeys

func GetSortedKeys(m map[string]Type) []string

func GoDoc

func GoDoc(args ...interface{}) string

Formats a string into a comment. For now, just each comment line with "//"

func NilParam

func NilParam(params []Parameter) string

func RemovePrefix

func RemovePrefix(args ...interface{}) string

func RemoveReservedWords

func RemoveReservedWords(args ...interface{}) string

func Tags

func Tags(args ...interface{}) string

Remove omitempty tags if required

func WriteGoFile

func WriteGoFile(base string, pkg string, name string, meta []Type, ts string) error

Executes a template against the metadata structure, and generates a go source file with the result

func WritePackage

func WritePackage(base string, pkg string, meta []Type, ts string) error

Types

type Method

type Method struct {
	Name       string      `json:"name"`
	Type       string      `json:"type"`
	TypeArray  bool        `json:"typeArray"`
	Doc        string      `json:"doc"`
	Static     bool        `json:"static"`
	NoAuth     bool        `json:"noauth"`
	Limitable  bool        `json:"limitable"`
	Filterable bool        `json:"filterable"`
	Maskable   bool        `json:"maskable"`
	Parameters []Parameter `json:"parameters"`
	Overview   string      `json:"docOverview"`
	Deprecated bool        `json:"deprecated"`
}

type Parameter

type Parameter struct {
	Name         string      `json:"name"`
	Type         string      `json:"type"`
	TypeArray    bool        `json:"typeArray"`
	Doc          string      `json:"doc"`
	DefaultValue interface{} `json:"defaultValue"`
	ParentMethod string
}

type Property

type Property struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	TypeArray  bool   `json:"typeArray"`
	Form       string `json:"form"`
	Doc        string `json:"doc"`
	Overview   string `json:"docOverview"`
	Deprecated bool   `json:"deprecated"`
}

type Type

type Type struct {
	Name         string              `json:"name"`
	Base         string              `json:"base"`
	TypeDoc      string              `json:"typeDoc"`
	Properties   map[string]Property `json:"properties"`
	ServiceDoc   string              `json:"serviceDoc"`
	Methods      map[string]Method   `json:"methods"`
	NoService    bool                `json:"noservice"`
	Overview     string              `json:"docOverview"`
	Deprecated   bool                `json:"deprecated"`
	ServiceGroup string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL