package provider import ( "context" "fmt" "time" ) type ProviderConfig struct { APIKey string AccessKeyID string AccessKeySecret string Endpoint string Debug bool } type Provider interface { Name() string DisplayName() string ValidateAuth(ctx context.Context) error Server() ServerService Domain() DomainService Storage() StorageService CDN() CDNService Billing() BillingService } type ServerService interface { List(ctx context.Context) ([]Server, error) Get(ctx context.Context, id string) (*Server, error) Start(ctx context.Context, id string) error Stop(ctx context.Context, id string) error Reboot(ctx context.Context, id string) error Reinstall(ctx context.Context, id, osTemplate string) error ResetPassword(ctx context.Context, id string) error GetVNC(ctx context.Context, id string) (string, error) Upgrade(ctx context.Context, id, plan string) error } type DomainService interface { List(ctx context.Context) ([]Domain, error) DNSList(ctx context.Context, domain string) ([]DNSRecord, error) DNSAdd(ctx context.Context, domain string, record DNSRecord) error DNSDelete(ctx context.Context, domain string, recordID string) error } type StorageService interface { List(ctx context.Context) ([]StorageInstance, error) BucketList(ctx context.Context, instanceID string) ([]Bucket, error) BucketCreate(ctx context.Context, instanceID, name string) error } type CDNService interface { List(ctx context.Context) ([]CDNInstance, error) } type BillingService interface { Orders(ctx context.Context) ([]Order, error) } type Server struct { ID string `json:"id" table:"ID"` Name string `json:"name" table:"NAME"` Status string `json:"status" table:"STATUS"` IP string `json:"ip" table:"IP"` CPU int `json:"cpu" table:"CPU"` Memory int `json:"memory" table:"MEM"` Disk int `json:"disk" table:"DISK"` OS string `json:"os" table:"OS"` Region string `json:"region" table:"REGION"` ExpireAt time.Time `json:"expires" table:"EXPIRES"` Raw any `json:"-"` } type Domain struct { ID string `json:"id" table:"ID"` Name string `json:"name" table:"DOMAIN"` Status string `json:"status" table:"STATUS"` ExpireAt time.Time `json:"expires" table:"EXPIRES"` Raw any `json:"-"` } type DNSRecord struct { ID string `json:"id" table:"ID"` Type string `json:"type" table:"TYPE"` Name string `json:"name" table:"NAME"` Value string `json:"value" table:"VALUE"` TTL int `json:"ttl" table:"TTL"` } type StorageInstance struct { ID string `json:"id" table:"ID"` Name string `json:"name" table:"NAME"` Status string `json:"status" table:"STATUS"` Raw any `json:"-"` } type Bucket struct { ID string `json:"id" table:"ID"` Name string `json:"name" table:"NAME"` Region string `json:"region" table:"REGION"` } type CDNInstance struct { ID string `json:"id" table:"ID"` Domain string `json:"domain" table:"DOMAIN"` Status string `json:"status" table:"STATUS"` Raw any `json:"-"` } type Order struct { ID string `json:"id" table:"ID"` Product string `json:"product" table:"PRODUCT"` Amount float64 `json:"amount" table:"AMOUNT"` Status string `json:"status" table:"STATUS"` Created time.Time `json:"created" table:"CREATED"` Raw any `json:"-"` } type Error struct { Code int Message string Detail string Raw []byte } func (e *Error) Error() string { return e.Message } func (e *Error) Debug() string { return fmt.Sprintf("%s\n%s", e.Detail, string(e.Raw)) }