60 lines
1.6 KiB
Go
60 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
|
|
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) ([]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)
|
|
}
|