LEFT | RIGHT |
1 package state | 1 package state |
2 | 2 |
3 import () | 3 import () |
4 | 4 |
5 type actionDoc struct { | 5 type actionDoc struct { |
6 » Id string `bson:"_id"` | 6 » Id string `bson:"_id"` |
7 » Name string | 7 |
| 8 » // Name identifies the action; it should match an action defined by |
| 9 » // the unit's charm. |
| 10 » Name string |
| 11 |
| 12 » // Payload holds the action's parameters, if any; it should validate |
| 13 » // against the schema defined by the named action in the unit's charm |
8 Payload map[string]interface{} | 14 Payload map[string]interface{} |
9 } | 15 } |
10 | 16 |
11 // Action represents an instruction to do some "action" and is expected to match | 17 // Action represents an instruction to do some "action" and is expected |
12 // an action definition in a charm. | 18 // to match an action definition in a charm. |
13 type Action struct { | 19 type Action struct { |
14 st *State | 20 st *State |
15 doc actionDoc | 21 doc actionDoc |
16 } | 22 } |
17 | 23 |
18 func newAction(st *State, adoc actionDoc) *Action { | 24 func newAction(st *State, adoc actionDoc) *Action { |
19 return &Action{ | 25 return &Action{ |
20 st: st, | 26 st: st, |
21 doc: adoc, | 27 doc: adoc, |
22 } | 28 } |
23 } | 29 } |
24 | 30 |
25 // Name returns the name of the Action | 31 // Name returns the name of the Action |
26 func (a *Action) Name() string { | 32 func (a *Action) Name() string { |
27 return a.doc.Name | 33 return a.doc.Name |
28 } | 34 } |
29 | 35 |
30 // Id returns the id of the Action | 36 // Id returns the id of the Action |
31 func (a *Action) Id() string { | 37 func (a *Action) Id() string { |
32 return a.doc.Id | 38 return a.doc.Id |
33 } | 39 } |
34 | 40 |
35 // Payload will contain a structure representing arguments or parameters to | 41 // Payload will contain a structure representing arguments or parameters to |
36 // an action, and is expected to be validated by the Unit using the Charm | 42 // an action, and is expected to be validated by the Unit using the Charm |
37 // definition of the Action | 43 // definition of the Action |
38 func (a *Action) Payload() map[string]interface{} { | 44 func (a *Action) Payload() map[string]interface{} { |
39 return a.doc.Payload | 45 return a.doc.Payload |
40 } | 46 } |
LEFT | RIGHT |