Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 16da9b2

Browse files
Add API interface
1 parent 389d7fe commit 16da9b2

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

mgmt/rest/api/api.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package api
2+
3+
import (
4+
"github.com/julienschmidt/httprouter"
5+
)
6+
7+
type API interface {
8+
GetRoutes() []Route
9+
BindMetricManager(Metrics)
10+
BindTaskManager(Tasks)
11+
BindTribeManager(Tribe)
12+
BindConfigManager(Config)
13+
}
14+
15+
type Route struct {
16+
Method, Path string
17+
Handle httprouter.Handle
18+
}

mgmt/rest/api/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package api
2+
3+
import (
4+
"github.com/intelsdi-x/snap/core"
5+
"github.com/intelsdi-x/snap/core/cdata"
6+
)
7+
8+
type Config interface {
9+
GetPluginConfigDataNode(core.PluginType, string, int) cdata.ConfigDataNode
10+
GetPluginConfigDataNodeAll() cdata.ConfigDataNode
11+
MergePluginConfigDataNode(pluginType core.PluginType, name string, ver int, cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
12+
MergePluginConfigDataNodeAll(cdn *cdata.ConfigDataNode) cdata.ConfigDataNode
13+
DeletePluginConfigDataNodeField(pluginType core.PluginType, name string, ver int, fields ...string) cdata.ConfigDataNode
14+
DeletePluginConfigDataNodeFieldAll(fields ...string) cdata.ConfigDataNode
15+
}

mgmt/rest/api/metric.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package api
2+
3+
import (
4+
"github.com/intelsdi-x/snap/core"
5+
"github.com/intelsdi-x/snap/core/serror"
6+
)
7+
8+
type Metrics interface {
9+
MetricCatalog() ([]core.CatalogedMetric, error)
10+
FetchMetrics(core.Namespace, int) ([]core.CatalogedMetric, error)
11+
GetMetricVersions(core.Namespace) ([]core.CatalogedMetric, error)
12+
GetMetric(core.Namespace, int) (core.CatalogedMetric, error)
13+
Load(*core.RequestedPlugin) (core.CatalogedPlugin, serror.SnapError)
14+
Unload(core.Plugin) (core.CatalogedPlugin, serror.SnapError)
15+
PluginCatalog() core.PluginCatalog
16+
AvailablePlugins() []core.AvailablePlugin
17+
GetAutodiscoverPaths() []string
18+
}

mgmt/rest/api/task.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package api
2+
3+
import (
4+
"github.com/intelsdi-x/snap/core"
5+
"github.com/intelsdi-x/snap/core/serror"
6+
"github.com/intelsdi-x/snap/pkg/schedule"
7+
"github.com/intelsdi-x/snap/scheduler/wmap"
8+
)
9+
10+
type Tasks interface {
11+
CreateTask(schedule.Schedule, *wmap.WorkflowMap, bool, ...core.TaskOption) (core.Task, core.TaskErrors)
12+
GetTasks() map[string]core.Task
13+
GetTask(string) (core.Task, error)
14+
StartTask(string) []serror.SnapError
15+
StopTask(string) []serror.SnapError
16+
RemoveTask(string) error
17+
WatchTask(string, core.TaskWatcherHandler) (core.TaskWatcherCloser, error)
18+
EnableTask(string) (core.Task, error)
19+
}

mgmt/rest/api/tribe.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package api
2+
3+
import (
4+
"github.com/intelsdi-x/snap/core/serror"
5+
"github.com/intelsdi-x/snap/mgmt/tribe/agreement"
6+
)
7+
8+
type Tribe interface {
9+
GetAgreement(name string) (*agreement.Agreement, serror.SnapError)
10+
GetAgreements() map[string]*agreement.Agreement
11+
AddAgreement(name string) serror.SnapError
12+
RemoveAgreement(name string) serror.SnapError
13+
JoinAgreement(agreementName, memberName string) serror.SnapError
14+
LeaveAgreement(agreementName, memberName string) serror.SnapError
15+
GetMembers() []string
16+
GetMember(name string) *agreement.Member
17+
}

0 commit comments

Comments
 (0)