resource

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Global is the global locality.
	Global = GlobalLocality("global")
)

Variables

View Source
var ErrResourceNotFound = errors.New("store: resource not found")

ErrResourceNotFound is returned when a resource is not found.

Functions

This section is empty.

Types

type CockpitMetadata

type CockpitMetadata struct {
	// CanViewLogs is true if the logs associated with the resource can be viewed Scaleway Cockpit.
	CanViewLogs bool

	// ResourceName is the name of the resource in Scaleway Cockpit.
	ResourceName string

	// ResourceID is the ID of the resource in Scaleway Cockpit.
	ResourceID string

	// ResourceType is the type of the resource in Scaleway Cockpit.
	ResourceType string
}

type GlobalLocality

type GlobalLocality string

func (GlobalLocality) IsRegion

func (g GlobalLocality) IsRegion() bool

func (GlobalLocality) IsZone

func (g GlobalLocality) IsZone() bool

func (GlobalLocality) String

func (g GlobalLocality) String() string

type Locality

type Locality interface {
	IsRegion() bool
	IsZone() bool
	fmt.Stringer
}

type Log

type Log struct {
	Timestamp time.Time
	Line      string
}

type Metadata

type Metadata struct {
	// Name is the name of the resource.
	Name string `json:"name"`

	// ID is the unique identifier of the resource.
	ID string `json:"id"`

	// ProjectID is the unique identifier of the project the resource belongs to.
	ProjectID string `json:"project_id"`

	// Status is the status of the resource.
	// Maybe nil if not available.
	Status *Status `json:"status"`

	// Description is the description of the resource.
	// May be empty.
	Description *string `json:"description"`

	// Tags is the list of tags associated with the resource.
	Tags []string `json:"tags"`

	// Type is the type of the resource.
	Type Type `json:"type"`

	// Locality is the locality of the resource.
	Locality Locality `json:"locality,omitempty"`
}

type Monitorer

type Monitorer interface {
	// Logs returns the logs of a resource.
	Logs(ctx context.Context, r Resource) ([]Log, error)
}

type Predicate

type Predicate func(r Resource) bool

type Region

type Region scw.Region

func (Region) IsRegion

func (r Region) IsRegion() bool

func (Region) IsZone

func (r Region) IsZone() bool

func (Region) String

func (r Region) String() string

type Resource

type Resource interface {
	// Metadata returns the metadatas of the resource.
	Metadata() Metadata

	// CockpitMetadata returns the metadatas of the resource for Scaleway Cockpit.
	CockpitMetadata() CockpitMetadata

	// Delete deletes the resource.
	Delete(ctx context.Context, s Storer, client *scw.Client) error
}

type Searcher

type Searcher interface {
	// Search searches for resources. Returns a list of resource IDs that match the query.
	Search(ctx context.Context, query string) ([]string, error)

	// Index indexes a resource.
	Index(r Resource) error
}

type Status

type Status string
const (
	StatusUnknown Status = "unknown"
	StatusActive  Status = "active"
	StatusError   Status = "error"
	StatusDeleted Status = "deleted"
	StatusReady   Status = "ready"
	StatusPending Status = "pending"
)

func (*Status) Emoji

func (s *Status) Emoji() rune

type Storer

type Storer interface {
	// Store stores a resource.
	Store(ctx context.Context, r Resource) error

	// ListAllResources returns all resources.
	ListAllResources(ctx context.Context) ([]Resource, error)

	// ListResourcesByIDs returns all resources with the given IDs.
	// Used in combination of the search API to get the resources that match a query.I
	ListResourcesByIDs(ctx context.Context, ids []string) ([]Resource, error)

	// FindTypedByPredicateInProject returns all resources of a given type in a project that match a predicate.
	FindTypedByPredicateInProject(ctx context.Context, resourceType Type, projectID string, predicate Predicate) ([]Resource, error)

	// DeleteResource deletes a resource.
	DeleteResource(ctx context.Context, r Resource) error
}

type Type

type Type int
const (
	TypeProject        Type = iota
	TypeIAMApplication      // IAM Application
	TypeCockpit
	TypeFunctionNamespace // Function Namespace
	TypeFunction
	TypeContainerNamespace // Container Namespace
	TypeContainer
	TypeRegistryNamespace // Registry Namespace
	TypeRdbInstance       // RDB Instance
	NumberOfResourceTypes
)

func (Type) String

func (i Type) String() string

type Zone

type Zone scw.Zone

func (Zone) IsRegion

func (z Zone) IsRegion() bool

func (Zone) IsZone

func (z Zone) IsZone() bool

func (Zone) String

func (z Zone) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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