discovery

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

internal/discovery/client.go

Index

Constants

View Source
const (
	CacheTTL       = 7 * 24 * time.Hour // 7 days
	SearchCacheTTL = 1 * time.Hour
)

Variables

View Source
var CategoryMapping = map[string]string{
	"appdev":        "Application Development and Automation",
	"intgn":         "Integration",
	"dataanalytics": "Data and Analytics",
	"aicatg":        "Artificial Intelligence",
}
View Source
var EffortLabels = map[string]string{
	"0": "<1h",
	"1": "1h",
	"2": "2h",
	"3": "3h+",
}

Functions

func CacheAge

func CacheAge(cacheDir, name string) time.Duration

CacheAge returns the age of a cache file, or -1 if it doesn't exist.

func ContainsCSV

func ContainsCSV(csv, val string) bool

func LoadCache

func LoadCache[T any](cacheDir, name string, ttl time.Duration) (T, bool)

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

func LoadCacheStale[T any](cacheDir, name string) (T, bool)

LoadCacheStale reads a cached JSON file ignoring TTL. Used as fallback when the network is unavailable.

func ResolveGuidanceContent

func ResolveGuidanceContent(
	cacheDir string,
	force bool,
	id string,
	client *Client,
) (string, error)

func SaveCache

func SaveCache[T any](cacheDir, name string, data T) error

SaveCache marshals data to JSON and writes it to the cache directory.

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

func (c *Client) FetchFacets() (*Facets, error)

FetchFacets calls GetApplicationFocusTagsIndustryLob.

func (*Client) FetchGuidanceContent

func (c *Client) FetchGuidanceContent(id string) (string, error)

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

func (c *Client) FetchServices() ([]Service, error)

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 FacetItem

type FacetItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

FacetItem is a single tag/industry/LOB entry.

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

func ResolveGuidanceTree(
	cacheDir string,
	force bool,
	domainFilter string,
	client *Client,
) ([]GuidanceNode, error)

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)

Jump to

Keyboard shortcuts

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