jx/internal/resource/resource.go
2024-03-22 10:39:06 -07:00

55 lines
913 B
Go

// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
// The resource package handles CRUD operations on resources and YAML (de)serialization
package resource
import (
"context"
_ "fmt"
_ "gopkg.in/yaml.v3"
_ "net/url"
)
type Resource interface {
Type() string
URI() string
//SetURI(string) error
ResolveId(context.Context) string
ResourceLoader
StateTransformer
ResourceReader
}
// validate the type/uri
type ResourceValidator interface {
Validate() error
}
type ResourceCreator interface {
Create(context.Context) error
}
type ResourceReader interface {
Read(context.Context) ([]byte, error)
}
type ResourceUpdater interface {
Update() error
}
type ResourceDeleter interface {
Delete() error
}
type ResourceDecoder struct {
}
func NewResource(uri string) Resource {
r,e := ResourceTypes.New(uri)
if e == nil {
return r
}
return nil
}