ninech / netbox-client-ruby

A ruby client library for Netbox v2.
MIT License
24 stars 21 forks source link

Improved process for creating new entities #14

Closed cimnine closed 6 years ago

cimnine commented 7 years ago

The constructor can now be used to pass initial 'dirty' values:

s=NetboxClientRuby::DCIM::Site.new(name: 'Zurich', slug: 'zrh')
s.save

So, theoretically, this can be used to fetch and update a site in one operation:

s=NetboxClientRuby::DCIM::Site.new(id: 1, name: 'Zurich', slug: 'zrh')
s.save

This would update the name and slug for the site with the id 1. But the ordinal way should be preferred, because it is more explicit:

NetboxClientRuby.dcim.site(1).update(name: 'Zurich', slug: 'zrh')