9
9
"launchpad.net/juju-core/charm"
10
10
"launchpad.net/juju-core/names"
11
"launchpad.net/juju-core/state/api/base"
11
12
"launchpad.net/juju-core/state/api/common"
12
13
"launchpad.net/juju-core/state/api/params"
16
const uniter = "Uniter"
15
18
// State provides access to the Uniter API facade.
16
19
type State struct {
20
*common.EnvironWatcher
18
23
// unitTag contains the authenticated unit's tag.
22
27
// NewState creates a new client-side Uniter facade.
23
func NewState(caller common.Caller, authTag string) *State {
24
return &State{caller, authTag}
28
func NewState(caller base.Caller, authTag string) *State {
30
EnvironWatcher: common.NewEnvironWatcher(uniter, caller),
27
35
// life requests the lifecycle of the given entity from the server.
28
36
func (st *State) life(tag string) (params.Life, error) {
29
var result params.LifeResults
30
args := params.Entities{
31
Entities: []params.Entity{{Tag: tag}},
33
err := st.caller.Call("Uniter", "", "Life", args, &result)
37
if len(result.Results) != 1 {
38
return "", fmt.Errorf("expected one result, got %d", len(result.Results))
40
if err := result.Results[0].Error; err != nil {
43
return result.Results[0].Life, nil
37
return common.Life(st.caller, uniter, tag)
46
40
// relation requests relation information from the server.
52
46
{Relation: relationTag, Unit: unitTag},
55
err := st.caller.Call("Uniter", "", "Relation", args, &result)
49
err := st.caller.Call(uniter, "", "Relation", args, &result)
57
51
return nothing, err
98
92
// addresses implemented fully. See also LP bug 1221798.
99
93
func (st *State) ProviderType() (string, error) {
100
94
var result params.StringResult
101
err := st.caller.Call("Uniter", "", "ProviderType", nil, &result)
95
err := st.caller.Call(uniter, "", "ProviderType", nil, &result)
139
133
args := params.RelationIds{
140
134
RelationIds: []int{id},
142
err := st.caller.Call("Uniter", "", "RelationById", args, &results)
136
err := st.caller.Call(uniter, "", "RelationById", args, &results)
167
161
// APIAddresses returns the list of addresses used to connect to the API.
168
162
func (st *State) APIAddresses() ([]string, error) {
169
163
var result params.StringsResult
170
err := st.caller.Call("Uniter", "", "APIAddresses", nil, &result)
164
err := st.caller.Call(uniter, "", "APIAddresses", nil, &result)