socketry / cloudflare

An asynchronous Ruby wrapper for the CloudFlare V4 API.
MIT License
139 stars 88 forks source link

getting error after migration to async-rest #43

Closed dknell closed 5 years ago

dknell commented 5 years ago

I used to be able to manipulate my spectrum app with this library like this

zone = connection.zones.find_by_id(cf_config['zone_id'])
# get all apps
spectrum = zone['spectrum/apps'].get()
apps = spectrum.body[:result]
# find a spectrum app by name
found_app = apps.find {|app| app[:dns][:name] == name}

Now I get the following error from the latest version (4.0.0):

Traceback (most recent call last):
test.rb:20:in `<main>': undefined method `[]' for #<Cloudflare::Zone:0x00007fddb41085d0> (NoMethodError)

Is there a way to do this in the latest version?

FWIW - I am using this library for a chef recipe to register autoscale servers in CF DNS and Spectrum.

ioquatix commented 5 years ago

In the first instance, pin your version to 3.x - it will save you rewriting stuff in the short term.

I will investigate the issue here but it won't be right now.

ioquatix commented 5 years ago

This might help you.

https://github.com/socketry/cloudflare/issues/44

ioquatix commented 5 years ago

I've updated the README with documentation that should help you. If not, can you please make a new issue? Thanks.

ioquatix commented 5 years ago

By the way, this code won't work:

zone = connection.zones.find_by_id(cf_config['zone_id'])
# get all apps
spectrum = zone['spectrum/apps'].get()
apps = spectrum.body[:result]
# find a spectrum app by name
found_app = apps.find {|app| app[:dns][:name] == name}

In order to do this, you'll need to write something like the following:

spectrum = zone.with(path: 'spectrum/apps')
apps = spectrum.get

I don't have access to test these features though. Happy to screen share some time.