tonobo / hcloud-ruby

Native ruby client for HetznerCloud
MIT License
32 stars 11 forks source link

add missing features to existing resources #60

Closed ghost closed 1 year ago

ghost commented 1 year ago

Implementing the missing features of existing resources (new actions, new attributes) in this PR.

List of requirements compiled from #30

Some server attributes have already been implemented before this PR.

(!) = Blocked by other PR

TODO after #55 merged:

Closes #30

ghost commented 1 year ago

Solved the problematic firewalls: [{ id: 12345, status: "applied" }] with a raw_data on our Future object.

Accessing the Firewall object with server.public_net[:firewalls][0][:id] # type Firewall would be weird. A user can expect to get the firewall on server.public_net[:firewalls][0]. But then we lose the applied status information.

Luckily, server.public_net[:firewalls][0] does not really hold a Firewall object, it holds a Future which transparently forwards every method to a Firewall object. I added a method raw_data to this Future, which returns the actual Hash/JSON data.

Users can now request the hidden data (e.g. applied status) like this:

# basically a Firewall object (in reality a Future, but forwards everything to Firewall)
server.public_net[:firewalls][0]

# get the { id: 12345, status: 'applied' } hash
server.public_net[:firewalls][0].raw_data
ghost commented 1 year ago

Since this is still an MR from my fork and tests do not run. I think all tests should be green, at least they are locally: