Documentation
¶
Overview ¶
internal/discovery/client.go
Index ¶
- Constants
- Variables
- func CacheAge(cacheDir, name string) time.Duration
- func ContainsCSV(csv, val string) bool
- func LoadCache[T any](cacheDir, name string, ttl time.Duration) (T, bool)
- func LoadCacheStale[T any](cacheDir, name string) (T, bool)
- func ResolveGuidanceContent(cacheDir string, force bool, id string, client *Client) (string, error)
- func SaveCache[T any](cacheDir, name string, data T) error
- func SearchCacheKey(query string, filters SearchFilters) string
- type Categories
- type Client
- func (c *Client) FetchCategories() (*Categories, error)
- func (c *Client) FetchFacets() (*Facets, error)
- func (c *Client) FetchGuidanceContent(id string) (string, error)
- func (c *Client) FetchGuidanceTree() ([]GuidanceNode, error)
- func (c *Client) FetchMissions() ([]MissionCatalogGroup, error)
- func (c *Client) FetchServices() ([]Service, error)
- func (c *Client) SearchMissions(query string, f SearchFilters) ([]Mission, error)
- type FacetItem
- type Facets
- type GuidanceNode
- type Mission
- type MissionCatalogGroup
- type ProductCategory
- type SearchFilters
- type Service
Constants ¶
const ( CacheTTL = 7 * 24 * time.Hour // 7 days SearchCacheTTL = 1 * time.Hour )
Variables ¶
var CategoryMapping = map[string]string{
"appdev": "Application Development and Automation",
"intgn": "Integration",
"dataanalytics": "Data and Analytics",
"aicatg": "Artificial Intelligence",
}
var EffortLabels = map[string]string{
"0": "<1h",
"1": "1h",
"2": "2h",
"3": "3h+",
}
Functions ¶
func ContainsCSV ¶
func LoadCache ¶
LoadCache reads a cached JSON file and unmarshals it into T. Returns the zero value of T and false if the cache is missing or older than ttl.
func LoadCacheStale ¶
LoadCacheStale reads a cached JSON file ignoring TTL. Used as fallback when the network is unavailable.
func ResolveGuidanceContent ¶
func SearchCacheKey ¶
func SearchCacheKey(query string, filters SearchFilters) string
SearchCacheKey returns a deterministic cache name for a search query + filters.
Types ¶
type Categories ¶
type Categories struct {
Products []ProductCategory `json:"products"`
}
Categories wraps the GetProductsCategories response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Discovery Center OData V2 services.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client ready to call Discovery Center APIs.
func (*Client) FetchCategories ¶
func (c *Client) FetchCategories() (*Categories, error)
FetchCategories calls GetProductsCategories.
func (*Client) FetchFacets ¶
FetchFacets calls GetApplicationFocusTagsIndustryLob.
func (*Client) FetchGuidanceContent ¶
FetchGuidanceContent calls GetGuidanceFrameworkContentById for a single node.
func (*Client) FetchGuidanceTree ¶
func (c *Client) FetchGuidanceTree() ([]GuidanceNode, error)
FetchGuidanceTree calls GetGuidanceFrameworkTree.
func (*Client) FetchMissions ¶
func (c *Client) FetchMissions() ([]MissionCatalogGroup, error)
FetchMissions calls GetMissionCatalogContentV2 and returns grouped missions.
func (*Client) FetchServices ¶
FetchServices calls GET /servicecatalog/ServiceDetailss (no batch needed).
func (*Client) SearchMissions ¶
func (c *Client) SearchMissions(query string, f SearchFilters) ([]Mission, error)
SearchMissions calls GetViewFuzzySearchesCustomV3 with the given query and filters.
type Facets ¶
type Facets struct {
FocusTags []FacetItem `json:"focusTags"`
Industries []FacetItem `json:"industries"`
Lobs []FacetItem `json:"lobs"`
}
Facets wraps the GetApplicationFocusTagsIndustryLob response.
type GuidanceNode ¶
type GuidanceNode struct {
ID string `json:"id"`
Name string `json:"name"`
Domain *string `json:"domain"`
Order int `json:"order"`
Children []GuidanceNode `json:"children"`
}
GuidanceNode is one node in the guidance framework tree.
func ResolveGuidanceTree ¶
type Mission ¶
type Mission struct {
ID int `json:"Id"`
Name string `json:"Name"`
Category string `json:"Category"`
SubCategory string `json:"SubCategory"`
Product string `json:"Product"`
Industry string `json:"Industry"`
LoB string `json:"LoB"`
FocusTags string `json:"FocusTags"`
Type string `json:"Type"`
PartnerCompany string `json:"PartnerCompany"`
ReferenceCustomers string `json:"ReferenceCustomers"`
UCId int `json:"UCId"`
UCLongDescription string `json:"UCLongDescription"`
UCRibbonText string `json:"UCRibbonText"`
Effort string `json:"Effort"`
MissionCount int `json:"MissionCount"`
}
Mission represents a single mission from GetMissionCatalogContentV2 or search.
func ResolveMissions ¶
func ResolveMissions( refs []content.DiscoveryMissionRef, filters content.DiscoveryProfileFilters, cacheDir string, force bool, client *Client, ) ([]Mission, error)
type MissionCatalogGroup ¶
type MissionCatalogGroup struct {
Name string `json:"name"`
Desc string `json:"desc"`
Missions []Mission `json:"missions"`
}
MissionCatalogGroup is a named group returned by GetMissionCatalogContentV2.
type ProductCategory ¶
type ProductCategory struct {
ID string `json:"id"`
Name string `json:"name"`
Products []ProductCategory `json:"products,omitempty"`
}
ProductCategory is one entry in the products/categories taxonomy.
type SearchFilters ¶
type SearchFilters struct {
Category string
Product string
LoB string
Industry string
FocusTags string
Partners string
Top int
}
SearchFilters controls server-side filtering for GetViewFuzzySearchesCustomV3.
type Service ¶
type Service struct {
ID string `json:"Id"`
Name string `json:"Name"`
ShortName string `json:"ShortName"`
Category string `json:"Category"`
ShortDescription string `json:"ShortDescription"`
LicenseModelType string `json:"LicenseModelType"`
IsDeprecatedService bool `json:"IsDeprecatedService"`
}
Service represents a BTP service from /servicecatalog/ServiceDetailss.
func ResolveServices ¶
func ResolveServices( refs []content.DiscoveryServiceRef, filters content.DiscoveryProfileFilters, cacheDir string, force bool, showDeprecated bool, client *Client, ) ([]Service, error)