OLD | NEW |
1 package params | 1 package params |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "encoding/json" | 5 "encoding/json" |
6 "fmt" | 6 "fmt" |
7 "launchpad.net/juju-core/constraints" | 7 "launchpad.net/juju-core/constraints" |
8 ) | 8 ) |
9 | 9 |
10 // DestroyRelation holds the parameters for making the DestroyRelation call. | 10 // DestroyRelation holds the parameters for making the DestroyRelation call. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 EntityId string | 147 EntityId string |
148 Pairs map[string]string | 148 Pairs map[string]string |
149 } | 149 } |
150 | 150 |
151 // SetServiceConstraints stores parameters for making the SetServiceConstraints
call. | 151 // SetServiceConstraints stores parameters for making the SetServiceConstraints
call. |
152 type SetServiceConstraints struct { | 152 type SetServiceConstraints struct { |
153 ServiceName string | 153 ServiceName string |
154 Constraints constraints.Value | 154 Constraints constraints.Value |
155 } | 155 } |
156 | 156 |
| 157 // CharmInfo stores parameters for a CharmInfo call. |
| 158 type CharmInfo struct { |
| 159 CharmURL string |
| 160 } |
| 161 |
157 // Delta holds details of a change to the environment. | 162 // Delta holds details of a change to the environment. |
158 type Delta struct { | 163 type Delta struct { |
159 // If Removed is true, the entity has been removed; | 164 // If Removed is true, the entity has been removed; |
160 // otherwise it has been created or changed. | 165 // otherwise it has been created or changed. |
161 Removed bool | 166 Removed bool |
162 // Entity holds data about the entity that has changed. | 167 // Entity holds data about the entity that has changed. |
163 Entity EntityInfo | 168 Entity EntityInfo |
164 } | 169 } |
165 | 170 |
166 // MarshalJSON implements json.Marshaler. | 171 // MarshalJSON implements json.Marshaler. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 211 } |
207 switch entityKind { | 212 switch entityKind { |
208 case "machine": | 213 case "machine": |
209 d.Entity = new(MachineInfo) | 214 d.Entity = new(MachineInfo) |
210 case "service": | 215 case "service": |
211 d.Entity = new(ServiceInfo) | 216 d.Entity = new(ServiceInfo) |
212 case "unit": | 217 case "unit": |
213 d.Entity = new(UnitInfo) | 218 d.Entity = new(UnitInfo) |
214 case "relation": | 219 case "relation": |
215 d.Entity = new(RelationInfo) | 220 d.Entity = new(RelationInfo) |
| 221 case "annotation": |
| 222 d.Entity = new(AnnotationInfo) |
216 default: | 223 default: |
217 return fmt.Errorf("Unexpected entity name %q", entityKind) | 224 return fmt.Errorf("Unexpected entity name %q", entityKind) |
218 } | 225 } |
219 if err := json.Unmarshal(elements[2], &d.Entity); err != nil { | 226 if err := json.Unmarshal(elements[2], &d.Entity); err != nil { |
220 return err | 227 return err |
221 } | 228 } |
222 return nil | 229 return nil |
223 } | 230 } |
224 | 231 |
225 // EntityInfo is implemented by all entity Info types. | 232 // EntityInfo is implemented by all entity Info types. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 func (i *UnitInfo) EntityId() interface{} { return i.Name } | 271 func (i *UnitInfo) EntityId() interface{} { return i.Name } |
265 func (i *UnitInfo) EntityKind() string { return "unit" } | 272 func (i *UnitInfo) EntityKind() string { return "unit" } |
266 | 273 |
267 type RelationInfo struct { | 274 type RelationInfo struct { |
268 Key string `bson:"_id"` | 275 Key string `bson:"_id"` |
269 } | 276 } |
270 | 277 |
271 func (i *RelationInfo) EntityId() interface{} { return i.Key } | 278 func (i *RelationInfo) EntityId() interface{} { return i.Key } |
272 func (i *RelationInfo) EntityKind() string { return "relation" } | 279 func (i *RelationInfo) EntityKind() string { return "relation" } |
273 | 280 |
274 // CharmInfo stores parameters for a CharmInfo call. | 281 type AnnotationInfo struct { |
275 type CharmInfo struct { | 282 » // TODO(rog) GlobalKey should not be necessary here, but is |
276 » CharmURL string | 283 » // until there's a level of indirection between mgo documents |
| 284 » // and StateWatcher results. We ensure that it's not serialised |
| 285 » // for the API by specifying the json tag. |
| 286 » GlobalKey string `bson:"_id" json:"-"` |
| 287 » EntityName string |
| 288 » Annotations map[string]string |
277 } | 289 } |
| 290 |
| 291 func (i *AnnotationInfo) EntityId() interface{} { return i.GlobalKey } |
| 292 func (i *AnnotationInfo) EntityKind() string { return "annotation" } |
OLD | NEW |