2026-09-26 18:49:17 +08:00
|
|
|
package serviceadapter
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"forgejo.riotpiao.com/rock/homelab-frontend/internal/temporal"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewPoimenAdapter creates a ServiceAdapter for the Poimen orchestrator service.
|
|
|
|
|
func NewPoimenAdapter(h *temporal.Handler) *ServiceAdapter {
|
|
|
|
|
return &ServiceAdapter{
|
|
|
|
|
Namespace: "poimen",
|
|
|
|
|
ServiceName: "poimen",
|
|
|
|
|
Handler: temporal.NewPoimenHandler(h),
|
|
|
|
|
Spec: *GetPoimenSpec(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetPoimenSpec returns the ServiceAdapter spec for the Poimen service.
|
|
|
|
|
func GetPoimenSpec() *Spec {
|
|
|
|
|
return &Spec{
|
|
|
|
|
ServiceName: "poimen",
|
|
|
|
|
Upstream: Upstream{
|
|
|
|
|
URL: "internal://poimen",
|
|
|
|
|
TimeoutSeconds: 60,
|
|
|
|
|
},
|
|
|
|
|
Auth: Auth{
|
|
|
|
|
Required: true,
|
|
|
|
|
Capability: "workflow:read",
|
|
|
|
|
},
|
|
|
|
|
Resources: []Resource{
|
|
|
|
|
{
|
|
|
|
|
Name: "plan",
|
|
|
|
|
Methods: []Method{{
|
|
|
|
|
Verb: "POST",
|
|
|
|
|
UpstreamPath: "/v1/poimen/plan",
|
|
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "execute",
|
|
|
|
|
Methods: []Method{{
|
|
|
|
|
Verb: "POST",
|
|
|
|
|
UpstreamPath: "/v1/poimen/execute",
|
|
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "executions",
|
|
|
|
|
Methods: []Method{
|
|
|
|
|
{
|
|
|
|
|
Verb: "GET",
|
|
|
|
|
UpstreamPath: "/v1/poimen/executions",
|
|
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-09-26 12:52:19 +00:00
|
|
|
// Note: workflow_id is passed as ?workflow_id=xxx query param,
|
|
|
|
|
// not as a path segment. The ServiceAdapter dispatcher does not
|
|
|
|
|
// substitute path parameters.
|
2026-09-26 18:49:17 +08:00
|
|
|
{
|
|
|
|
|
Name: "execution-detail",
|
|
|
|
|
Methods: []Method{
|
|
|
|
|
{
|
|
|
|
|
Verb: "GET",
|
2026-09-26 12:52:19 +00:00
|
|
|
UpstreamPath: "/v1/poimen/executions/detail",
|
2026-09-26 18:49:17 +08:00
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Verb: "DELETE",
|
2026-09-26 12:52:19 +00:00
|
|
|
UpstreamPath: "/v1/poimen/executions/detail",
|
2026-09-26 18:49:17 +08:00
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "execution-history",
|
|
|
|
|
Methods: []Method{{
|
|
|
|
|
Verb: "GET",
|
2026-09-26 12:52:19 +00:00
|
|
|
UpstreamPath: "/v1/poimen/executions/history",
|
2026-09-26 18:49:17 +08:00
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "execution-stream",
|
|
|
|
|
Methods: []Method{{
|
|
|
|
|
Verb: "GET",
|
2026-09-26 12:52:19 +00:00
|
|
|
UpstreamPath: "/v1/poimen/executions/stream",
|
2026-09-26 18:49:17 +08:00
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:read"},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Name: "execution-signal",
|
|
|
|
|
Methods: []Method{{
|
|
|
|
|
Verb: "POST",
|
2026-09-26 12:52:19 +00:00
|
|
|
UpstreamPath: "/v1/poimen/executions/signal",
|
2026-09-26 18:49:17 +08:00
|
|
|
Auth: &Auth{Required: true, Capability: "workflow:execute"},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|