Documentation
¶
Index ¶
- func GenerateInitConfig(clusters []Cluster, wadlPath, base, output string, depth int) string
- func ValidateConfig(cfg *SplitConfig, allClusters []Cluster) error
- type Cluster
- type Doc
- type Extractor
- func (e *Extractor) Extract(pathPrefix string) *WADLApplication
- func (e *Extractor) ExtractCluster(c Cluster) *WADLApplication
- func (e *Extractor) ExtractClusters(clusters []Cluster) *WADLApplication
- func (e *Extractor) ExtractMany(prefixes []string) *WADLApplication
- func (e *Extractor) Save(app *WADLApplication, outputPath string) error
- func (e *Extractor) SuggestClusters(prefix string, depth int) []Cluster
- type Grammars
- type GroupConfig
- type Include
- type Method
- type Param
- type Representation
- type Request
- type Resource
- type Resources
- type Response
- type SampleParam
- type SplitConfig
- type WADLApplication
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateInitConfig ¶
GenerateInitConfig returns YAML text for a starter config file with all clusters listed under an "# unassigned" stub, ready for the user to move into named groups.
func ValidateConfig ¶
func ValidateConfig(cfg *SplitConfig, allClusters []Cluster) error
ValidateConfig checks that:
- every cluster key referenced in the config exists in allClusters
- no cluster key appears in more than one group
- every cluster in allClusters is assigned to exactly one group
Returns a non-nil error listing all problems found.
Types ¶
type Cluster ¶
type Cluster struct {
// Name is the distinguishing segment (or "core" for shallow paths).
Name string
Resources []Resource
}
Cluster groups resources that share a common sub-path key.
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor extracts WADL resources by path prefix
func NewExtractor ¶
NewExtractor creates a new WADL extractor from a file
func NewExtractorFromReader ¶
NewExtractorFromReader creates a new WADL extractor from a reader
func (*Extractor) Extract ¶
func (e *Extractor) Extract(pathPrefix string) *WADLApplication
Extract extracts all resources starting with the given path prefix. For multiple prefixes use ExtractMany.
func (*Extractor) ExtractCluster ¶
func (e *Extractor) ExtractCluster(c Cluster) *WADLApplication
ExtractCluster builds a WADLApplication from the resources in a single Cluster.
func (*Extractor) ExtractClusters ¶
func (e *Extractor) ExtractClusters(clusters []Cluster) *WADLApplication
ExtractClusters builds a WADLApplication combining resources from multiple clusters. Resources are returned in WADL document order.
func (*Extractor) ExtractMany ¶
func (e *Extractor) ExtractMany(prefixes []string) *WADLApplication
ExtractMany extracts all resources whose SamplePath starts with any of the given prefixes. Resources are returned in WADL document order.
func (*Extractor) Save ¶
func (e *Extractor) Save(app *WADLApplication, outputPath string) error
Save writes the extracted WADL to a file preserving raw resource XML
func (*Extractor) SuggestClusters ¶
SuggestClusters analyses all resources whose SamplePath starts with prefix and groups them by the distinguishing segment at the given depth. The returned slice is sorted by cluster name, with "core" first.
type Grammars ¶
type Grammars struct {
Includes []Include `xml:"include"`
}
Grammars represents WADL grammars section
type GroupConfig ¶
type GroupConfig struct {
Clusters []string `yaml:"clusters"`
}
GroupConfig describes one logical service group within a SplitConfig.
type Include ¶
type Include struct {
Href string `xml:"href,attr"`
}
Include represents a schema include
type Method ¶
type Method struct {
XMLName xml.Name `xml:"method"`
ID string `xml:"id,attr"`
Name string `xml:"name,attr"`
Request *Request `xml:"request,omitempty"`
Response []Response `xml:"response"`
Attrs []xml.Attr `xml:",any,attr"`
}
Method represents a WADL method element
type Param ¶
type Param struct {
XMLName xml.Name `xml:"param"`
Name string `xml:"name,attr"`
Style string `xml:"style,attr"`
Type string `xml:"type,attr"`
Required string `xml:"required,attr"`
Doc *Doc `xml:"doc,omitempty"`
Attrs []xml.Attr `xml:",any,attr"`
}
Param represents a WADL param element
type Representation ¶
type Representation struct {
XMLName xml.Name `xml:"representation"`
MediaType string `xml:"mediaType,attr"`
Element string `xml:"element,attr"`
Attrs []xml.Attr `xml:",any,attr"`
}
Representation represents a WADL representation element
type Request ¶
type Request struct {
XMLName xml.Name `xml:"request"`
Params []Param `xml:"param"`
Reps []Representation `xml:"representation"`
}
Request represents a WADL request element
type Resource ¶
type Resource struct {
XMLName xml.Name `xml:"resource"`
ID string `xml:"id,attr"`
SamplePath string `xml:"samplePath,attr"`
Doc *Doc `xml:"doc,omitempty"`
Methods []Method `xml:"method"`
SampleParam []SampleParam `xml:"sampleParam"`
Attrs []xml.Attr `xml:",any,attr"`
RawXML string `xml:"-"`
}
Resource represents a WADL resource element
func (*Resource) UnmarshalXML ¶
UnmarshalXML custom unmarshaler to handle namespaced attributes
type Resources ¶
type Resources struct {
SampleBase string `xml:"sampleBase,attr"`
Resources []Resource `xml:"resource"`
Attrs []xml.Attr `xml:",any,attr"`
}
Resources represents WADL resources section
type Response ¶
type Response struct {
XMLName xml.Name `xml:"response"`
Status string `xml:"status,attr"`
Params []Param `xml:"param"`
Reps []Representation `xml:"representation"`
Attrs []xml.Attr `xml:",any,attr"`
}
Response represents a WADL response element
type SampleParam ¶
type SampleParam struct {
XMLName xml.Name `xml:"sampleParam"`
Name string `xml:"name,attr"`
Style string `xml:"style,attr"`
Type string `xml:"type,attr"`
Attrs []xml.Attr `xml:",any,attr"`
}
SampleParam represents a WADL sample parameter
type SplitConfig ¶
type SplitConfig struct {
WADL string `yaml:"wadl"`
Base string `yaml:"base"`
Depth int `yaml:"depth"`
Output string `yaml:"output"`
Groups map[string]GroupConfig `yaml:"groups"`
}
SplitConfig is the top-level structure of a wadl-extract grouping config file.
func LoadSplitConfig ¶
func LoadSplitConfig(path string) (*SplitConfig, error)
LoadSplitConfig reads and unmarshals a YAML config file.
type WADLApplication ¶
type WADLApplication struct {
XMLName xml.Name `xml:"application"`
Doc *Doc `xml:"doc,omitempty"`
Grammars *Grammars `xml:"grammars,omitempty"`
Resources *Resources `xml:"resources,omitempty"`
Attrs []xml.Attr `xml:",any,attr"`
}
WADLApplication represents the root WADL element
func (*WADLApplication) GetResourceCount ¶
func (app *WADLApplication) GetResourceCount() int
GetResourceCount returns the number of resources in the application
func (*WADLApplication) GetResourcePaths ¶
func (app *WADLApplication) GetResourcePaths() []string
GetResourcePaths returns all resource paths in the application