54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package access
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"sub2api-cn-relay-manager/internal/host/sub2api"
|
|
)
|
|
|
|
const (
|
|
ModeSubscription = "subscription"
|
|
ModeSelfService = "self_service"
|
|
|
|
ProbeKeySourceRequestedProbeAPIKey = "requested_probe_api_key"
|
|
ProbeKeySourceManagedSubscription = "managed_subscription"
|
|
|
|
gatewayCompletionRetryAttempts = 3
|
|
gatewayCompletionRetryDelay = 300 * time.Millisecond
|
|
)
|
|
|
|
type SubscriptionTarget struct {
|
|
UserID string
|
|
DurationDays int
|
|
}
|
|
|
|
type ClosureRequest struct {
|
|
Mode string
|
|
ProbeAPIKey string
|
|
Subscriptions []SubscriptionTarget
|
|
GroupID string
|
|
AccountIDs []string
|
|
ExpectedModel string
|
|
Prompt string
|
|
MaxTokens int
|
|
ResponsesCapabilitySuspect bool
|
|
}
|
|
|
|
type Host interface {
|
|
EnsureSubscriptionAccess(ctx context.Context, req sub2api.EnsureSubscriptionAccessRequest) (sub2api.SubscriptionAccessRef, error)
|
|
AssignSubscription(ctx context.Context, req sub2api.AssignSubscriptionRequest) (sub2api.SubscriptionRef, error)
|
|
CheckGatewayAccess(ctx context.Context, req sub2api.GatewayAccessCheckRequest) (sub2api.GatewayAccessResult, error)
|
|
CheckGatewayCompletion(ctx context.Context, req sub2api.GatewayCompletionCheckRequest) (sub2api.GatewayCompletionResult, error)
|
|
DisableOpenAIResponsesAPI(ctx context.Context, accountIDs []string) error
|
|
ClearTempUnschedulable(ctx context.Context, accountIDs []string) error
|
|
}
|
|
|
|
type Service struct {
|
|
host Host
|
|
}
|
|
|
|
func NewService(host Host) *Service {
|
|
return &Service{host: host}
|
|
}
|