fetch

package
v2.64.0 Latest Latest
Warning

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

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

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

func RegisterFetcher[L Locality](factory func() Fetcher[L])

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

func ShouldIgnoreError(err error) bool

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 Locality

type Locality interface {
	scw.Zone | scw.Region
}

type LocalityType

type LocalityType string
const (
	LocalityTypeZone   LocalityType = "zone"
	LocalityTypeRegion LocalityType = "region"
)

type RegionFetcher

type RegionFetcher = Fetcher[scw.Region]

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.

type ZoneFetcher

type ZoneFetcher = Fetcher[scw.Zone]

Jump to

Keyboard shortcuts

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