Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllProductKeys ¶
func AllProductKeys() []string
AllProductKeys returns the product keys of all registered fetchers.
func RegisterFetcher ¶
RegisterFetcher registers a fetcher factory, keyed by Namespace() + "-" + Resource().
func RegisterFetcherAny ¶
func RegisterFetcherAny(factory func() FetcherAny)
RegisterFetcherAny registers a FetcherAny factory, keyed by Namespace() + "-" + Resource().
func ShouldIgnoreError ¶
ShouldIgnoreError reports whether the error should be silently ignored (zone/region unavailable or HTTP 501).
Types ¶
type Fetcher ¶
type Fetcher[L Locality] interface { Fetch(ctx context.Context, locality L, projectID string) ([]ResourceResult, error) Namespace() string Resource() string LocalityType() LocalityType }
Fetcher is a generic interface for fetching resources. Fetchers implementations should use core.ExtractClient(ctx) to obtain the client.
type FetcherAny ¶
type FetcherAny interface {
FetchAny(ctx context.Context, zone scw.Zone, projectID string) ([]ResourceResult, error)
Namespace() string
Resource() string
LocalityType() LocalityType
ProductKey() string
}
FetcherAny is a non-generic version of Fetcher.
func GetFetcher ¶
func GetFetcher(product string) (FetcherAny, bool)
GetFetcher returns the fetcher registered for the given product key.
func WrapFetcher ¶
func WrapFetcher[L Locality](f Fetcher[L]) FetcherAny
WrapFetcher wraps a generic Fetcher[L] into a FetcherAny.
type LocalityType ¶
type LocalityType string
const ( LocalityTypeZone LocalityType = "zone" LocalityTypeRegion LocalityType = "region" )
type RegionFetcher ¶
type ResourceResult ¶
type ResourceResult struct {
Locality string `human:"locality" json:"locality"`
Product string `human:"product" json:"product"`
Resource string `human:"resource" json:"resource"`
ID string `human:"id" json:"id"`
Name string `human:"name" json:"name,omitempty"`
}
ResourceResult represents a single resource in the output.