- Move Server/Domain/DNSRecord/Bucket/StorageInstance/CDNInstance/Order/Error structs to internal/model/ - Provider interfaces now reference model.* types - Rainyun provider implementations import model package for data types - CLI commands updated to use model.DNSRecord directly Separates pure data structures from service contract interfaces, following hexagonal architecture: models (entities) live independently from ports (provider interfaces) and adapters (rainyun/* implementations).
59 lines
1.6 KiB
Go
59 lines
1.6 KiB
Go
package provider
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.yoresee.cc/nightstar/ry/internal/model"
|
|
)
|
|
|
|
type ProviderConfig struct {
|
|
APIKey string
|
|
AccessKeyID string
|
|
AccessKeySecret string
|
|
Endpoint string
|
|
}
|
|
|
|
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) ([]model.Server, error)
|
|
Get(ctx context.Context, id string) (*model.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) ([]model.Domain, error)
|
|
DNSList(ctx context.Context, domain string) ([]model.DNSRecord, error)
|
|
DNSAdd(ctx context.Context, domain string, record model.DNSRecord) error
|
|
DNSDelete(ctx context.Context, domain string, recordID string) error
|
|
}
|
|
|
|
type StorageService interface {
|
|
List(ctx context.Context) ([]model.StorageInstance, error)
|
|
BucketList(ctx context.Context, instanceID string) ([]model.Bucket, error)
|
|
BucketCreate(ctx context.Context, instanceID, name string) error
|
|
}
|
|
|
|
type CDNService interface {
|
|
List(ctx context.Context) ([]model.CDNInstance, error)
|
|
}
|
|
|
|
type BillingService interface {
|
|
Orders(ctx context.Context) ([]model.Order, error)
|
|
}
|