github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/operator/del.go (about) 1 package operator 2 3 import ( 4 "context" 5 6 "github.com/machinefi/w3bstream/cmd/srv-applet-mgr/apis/middleware" 7 "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" 8 "github.com/machinefi/w3bstream/pkg/types" 9 ) 10 11 type RemoveOperator struct { 12 httpx.MethodDelete 13 OperatorID types.SFID `in:"path" name:"operatorID"` 14 } 15 16 func (r *RemoveOperator) Path() string { return "/data/:operatorID" } 17 18 func (r *RemoveOperator) Output(ctx context.Context) (interface{}, error) { 19 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 20 WithOperatorBySFID(ctx, r.OperatorID) 21 if err != nil { 22 return nil, err 23 } 24 pool := types.MustOperatorPoolFromContext(ctx) 25 return nil, pool.Delete(r.OperatorID) 26 }