Documentation
¶
Index ¶
- Constants
- Variables
- func JoinSkippingEmpty(elems []string, sep string) string
- type FilterType
- type FoundEntry
- type FoundSource
- type FoundVersion
- type Index
- type IndexEntry
- type IndexMeta
- type IndexToSearchResultMapper
- type IndexVersion
- type InventoryResponseToSearchResultMapper
- func (m *InventoryResponseToSearchResultMapper) ToFoundEntry(e server.InventoryEntry) FoundEntry
- func (m *InventoryResponseToSearchResultMapper) ToFoundVersionLinks(v server.InventoryEntryVersion) map[string]string
- func (m *InventoryResponseToSearchResultMapper) ToFoundVersions(versions []server.InventoryEntryVersion) []FoundVersion
- func (m *InventoryResponseToSearchResultMapper) ToSearchResult(inv server.InventoryResponse) SearchResult
- type Link
- type LinkType
- type Links
- type RelType
- type RepoSpec
- type Resource
- type ResourceFilter
- type ResourceType
- type SchemaAuthor
- type SchemaManufacturer
- type SearchOptions
- type SearchParams
- type SearchResult
- type TMID
- type TMVersion
- type ThingModel
- type Version
Constants ¶
View Source
const ( TMFileExtension = ".tm.json" PseudoVersionTimestampFormat = "20060102150405" )
View Source
const DefaultListSeparator = ","
View Source
const TMLinkRel = "content"
Variables ¶
View Source
var ( ErrInvalidVersion = errors.New("invalid version string") ErrInvalidPseudoVersion = errors.New("no valid pseudo-version found") ErrInvalidId = errors.New("TM id invalid") ErrVersionDiffers = errors.New("id has a differing version from given ThingModel") )
View Source
var EmptySpec, _ = NewSpec("", "")
View Source
var ErrInvalidSpec = errors.New("illegal repo spec: both local directory and repo name given")
Functions ¶
func JoinSkippingEmpty ¶
Types ¶
type FoundEntry ¶
type FoundEntry struct { Name string Manufacturer SchemaManufacturer Mpn string Author SchemaAuthor Versions []FoundVersion }
func (FoundEntry) Merge ¶
func (r FoundEntry) Merge(other FoundEntry) FoundEntry
type FoundSource ¶
func (FoundSource) String ¶
func (s FoundSource) String() string
type FoundVersion ¶
type FoundVersion struct { IndexVersion FoundIn FoundSource }
func MergeFoundVersions ¶
func MergeFoundVersions(vs1, vs2 []FoundVersion) []FoundVersion
type Index ¶
type Index struct { Meta IndexMeta `json:"meta"` Data []*IndexEntry `json:"data"` }
func (*Index) Delete ¶
Delete deletes the record for the given id. Returns TM name to be removed from names file if no more versions are left
func (*Index) Filter ¶
func (idx *Index) Filter(search *SearchParams)
type IndexEntry ¶
type IndexEntry struct { Name string `json:"name"` Manufacturer SchemaManufacturer `json:"schema:manufacturer" validate:"required"` Mpn string `json:"schema:mpn" validate:"required"` Author SchemaAuthor `json:"schema:author" validate:"required"` Versions []IndexVersion `json:"versions"` }
func (*IndexEntry) MatchesSearchText ¶
func (e *IndexEntry) MatchesSearchText(searchQuery string) bool
type IndexToSearchResultMapper ¶
type IndexToSearchResultMapper struct {
// contains filtered or unexported fields
}
func NewIndexToFoundMapper ¶
func NewIndexToFoundMapper(s FoundSource) *IndexToSearchResultMapper
func (*IndexToSearchResultMapper) ToFoundEntry ¶
func (m *IndexToSearchResultMapper) ToFoundEntry(e *IndexEntry) FoundEntry
func (*IndexToSearchResultMapper) ToFoundVersions ¶
func (m *IndexToSearchResultMapper) ToFoundVersions(versions []IndexVersion) []FoundVersion
func (*IndexToSearchResultMapper) ToSearchResult ¶
func (m *IndexToSearchResultMapper) ToSearchResult(idx Index) SearchResult
type IndexVersion ¶
type InventoryResponseToSearchResultMapper ¶
type InventoryResponseToSearchResultMapper struct {
// contains filtered or unexported fields
}
func NewInventoryResponseToSearchResultMapper ¶
func NewInventoryResponseToSearchResultMapper(s FoundSource, linksMapper func(links server.InventoryEntryVersion) map[string]string) *InventoryResponseToSearchResultMapper
func (*InventoryResponseToSearchResultMapper) ToFoundEntry ¶
func (m *InventoryResponseToSearchResultMapper) ToFoundEntry(e server.InventoryEntry) FoundEntry
func (*InventoryResponseToSearchResultMapper) ToFoundVersionLinks ¶
func (m *InventoryResponseToSearchResultMapper) ToFoundVersionLinks(v server.InventoryEntryVersion) map[string]string
func (*InventoryResponseToSearchResultMapper) ToFoundVersions ¶
func (m *InventoryResponseToSearchResultMapper) ToFoundVersions(versions []server.InventoryEntryVersion) []FoundVersion
func (*InventoryResponseToSearchResultMapper) ToSearchResult ¶
func (m *InventoryResponseToSearchResultMapper) ToSearchResult(inv server.InventoryResponse) SearchResult
type RepoSpec ¶
type RepoSpec struct {
// contains filtered or unexported fields
}
func NewDirSpec ¶
func NewRepoSpec ¶
func NewSpecFromFoundSource ¶
func NewSpecFromFoundSource(s FoundSource) RepoSpec
func (RepoSpec) ToFoundSource ¶
func (r RepoSpec) ToFoundSource() FoundSource
type ResourceFilter ¶
type ResourceFilter struct { Types []ResourceType Names []string }
type SchemaAuthor ¶
type SchemaAuthor struct {
Name string `json:"schema:name" validate:"required"`
}
type SchemaManufacturer ¶
type SchemaManufacturer struct {
Name string `json:"schema:name" validate:"required"`
}
type SearchOptions ¶
type SearchOptions struct { // NameFilterType specifies whether SearchParams.Name must match a prefix or the full length of a TM name // Note that using FullMatch effectively limits the search result to at most one FoundEntry NameFilterType FilterType }
type SearchParams ¶
type SearchParams struct { Author []string Manufacturer []string Mpn []string Name string Query string Options SearchOptions }
func ToSearchParams ¶
func ToSearchParams(author, manufacturer, mpn, name, query *string, opts *SearchOptions) *SearchParams
func (*SearchParams) Sanitize ¶
func (p *SearchParams) Sanitize()
type SearchResult ¶
type SearchResult struct {
Entries []FoundEntry
}
func (*SearchResult) Merge ¶
func (sr *SearchResult) Merge(other *SearchResult)
type TMID ¶
func MustParseTMID ¶
type ThingModel ¶
type ThingModel struct { ID string `json:"id,omitempty"` Description string `json:"description"` Manufacturer SchemaManufacturer `json:"schema:manufacturer" validate:"required"` Mpn string `json:"schema:mpn" validate:"required"` Author SchemaAuthor `json:"schema:author" validate:"required"` Version Version `json:"version"` Links `json:"links"` }
ThingModel is a model for unmarshalling a Thing Model to be imported. It contains only the fields required to be accepted into the catalog.
Click to show internal directories.
Click to hide internal directories.