[Enhancement] Add missing fields / endpoints to Images + Servers
- Images have Actions
- Servers have metrics and can change it's rDNS
Server also as a bunch of more attributes:
- [x] id
- [x] created
- [x] image
- [x] server_type
- [x] datacenter
- [x] included_traffic
- [x] ingoing_traffic
- [x] outgoing_traffic
- [x] locked
- [x] name
- [x] primary_disk_size
- [x] rescue_enabled
- [x] status
- [ ] backup_window
- [ ] iso
- [ ] labels (currently hash)
- [ ] load_balancers (currently array)
- [ ] placement_group
- [ ] private_net (currently array)
- [ ] protection (
{"delete"=>false, "rebuild"=>false}) - [ ] public_net (currently hash)
- [ ] volumes (currently list)
At least load_balancers, private_net, public_net and volumes are collections of resources. The schema defined in entry_loader.rb maps the api response to objects, can't handle collections AFAIK. Either we extend the schema, create a collection resource for each one (VolumesCollection containing Volume objects) or create a generic Collection than can be initialized with the wanted resource schema(volumes: Collection(Volume)).
Went through the API docs and the code and found the following missing actions:
- Network
- change_ip_range
- Server
- Get metrics
- add_to_placement_group
- change_alias_ips
- change_dns_ptr
- remove_from_placement_group
The following attributes on existing actions are missing
- Firewall
-
labelson update
-
- Floating IPs
-
nameon create -
name,labelson update
-
- Image
-
status,include_deprecatedon get all -
labelson update
-
- Network
-
labelson update
-
- Placement Groups
-
label_selectoron get all -
labelson update
-
- Server
-
automount,firewalls,placement_group,public_net,volumeson create -
labelson update
-
- SSH key
-
fingerprinton get all -
labelson update
-
- Volume
-
statuson get all -
labelson update
-
It's probably good that the labels fields on :updatable are missing. I just checked what this does, because update(labels: {'foo': 'bar'}) works without problems. :updatable creates attr= methods, so fields can be changed with obj.name = 'new-name'. The changes can then be persisted using obj.save:
obj = client.load_balancers['old-name']
obj.name = 'new-name'
obj.save
# besides: call to save is currently broken, so nobody uses this feature
# alternative (which works):
obj.update({ name: 'new-name' })
For labels being a hash this does not work as expected (at least as I as a user would want to use it). The following code does not save the new label to the Cloud API.
obj = client.load_balancers['old-name']
obj.labels.merge({ 'label' => 'value' })
obj.save
tl;dr: I think we'll have to think a bit more about :updatable to make it work with objects (like hashes) that can be changed in other ways than assignments.