/
interface.go
68 lines (56 loc) · 2.1 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2022 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package action
import (
"github.com/juju/names/v5"
"github.com/juju/juju/state"
)
// State provides the subset of global state required by the
// action facade.
type State interface {
AllApplications() ([]*state.Application, error)
AllMachines() ([]*state.Machine, error)
Application(name string) (*state.Application, error)
FindEntity(tag names.Tag) (state.Entity, error)
GetBlockForType(t state.BlockType) (state.Block, bool, error)
Model() (Model, error)
WatchActionLogs(actionId string) state.StringsWatcher
}
// Model describes model state used by the action facade.
type Model interface {
ActionByTag(tag names.ActionTag) (state.Action, error)
AddAction(receiver state.ActionReceiver, operationID, name string, payload map[string]interface{}, parallel *bool, executionGroup *string) (state.Action, error)
EnqueueOperation(summary string, count int) (string, error)
FailOperationEnqueuing(operationID, failMessage string, count int) error
FindActionsByName(name string) ([]state.Action, error)
ListOperations(actionNames []string, actionReceivers []names.Tag, operationStatus []state.ActionStatus,
offset, limit int,
) ([]state.OperationInfo, bool, error)
ModelTag() names.ModelTag
OperationWithActions(id string) (*state.OperationInfo, error)
Type() state.ModelType
}
type stateShim struct {
st *state.State
}
func (s *stateShim) AllApplications() ([]*state.Application, error) {
return s.st.AllApplications()
}
func (s *stateShim) AllMachines() ([]*state.Machine, error) {
return s.st.AllMachines()
}
func (s *stateShim) Application(name string) (*state.Application, error) {
return s.st.Application(name)
}
func (s *stateShim) FindEntity(tag names.Tag) (state.Entity, error) {
return s.st.FindEntity(tag)
}
func (s *stateShim) GetBlockForType(t state.BlockType) (state.Block, bool, error) {
return s.st.GetBlockForType(t)
}
func (s *stateShim) Model() (Model, error) {
return s.st.Model()
}
func (s *stateShim) WatchActionLogs(actionId string) state.StringsWatcher {
return s.st.WatchActionLogs(actionId)
}