7
"launchpad.net/juju-core/environs/config"
8
7
"launchpad.net/juju-core/state/api/base"
9
8
"launchpad.net/juju-core/state/api/common"
10
9
"launchpad.net/juju-core/state/api/params"
11
10
"launchpad.net/juju-core/state/api/watcher"
13
const firewallerFacade = "Firewaller"
14
15
// State provides access to the Firewaller API facade.
15
16
type State struct {
18
*common.EnvironWatcher
21
func (st *State) call(method string, params, result interface{}) error {
22
return st.caller.Call(firewallerFacade, "", method, params, result)
19
25
// NewState creates a new client-side Firewaller facade.
20
26
func NewState(caller base.Caller) *State {
29
EnvironWatcher: common.NewEnvironWatcher(firewallerFacade, caller),
24
33
// life requests the life cycle of the given entity from the server.
25
34
func (st *State) life(tag string) (params.Life, error) {
26
return common.Life(st.caller, "Firewaller", tag)
35
return common.Life(st.caller, firewallerFacade, tag)
29
38
// Unit provides access to methods of a state.Unit through the facade.
56
// WatchForEnvironConfigChanges return a NotifyWatcher waiting for the
57
// environment configuration to change.
58
func (st *State) WatchForEnvironConfigChanges() (watcher.NotifyWatcher, error) {
59
var result params.NotifyWatchResult
60
err := st.caller.Call("Firewaller", "", "WatchForEnvironConfigChanges", nil, &result)
64
if err := result.Error; err != nil {
65
return nil, result.Error
67
w := watcher.NewNotifyWatcher(st.caller, result)
71
// EnvironConfig returns the current environment configuration.
72
func (st *State) EnvironConfig() (*config.Config, error) {
73
var result params.EnvironConfigResult
74
err := st.caller.Call("Firewaller", "", "EnvironConfig", nil, &result)
78
if err := result.Error; err != nil {
81
conf, err := config.New(config.NoDefaults, result.Config)
88
65
// WatchEnvironMachines returns a StringsWatcher that notifies of
89
66
// changes to the life cycles of the top level machines in the current
91
68
func (st *State) WatchEnvironMachines() (watcher.StringsWatcher, error) {
92
69
var result params.StringsWatchResult
93
err := st.caller.Call("Firewaller", "", "WatchEnvironMachines", nil, &result)
70
err := st.call("WatchEnvironMachines", nil, &result)