-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
I'm currently importing a larger number of configurations from different sources into Netbox, and this causes a lot of (unnecessary) PATCH requests.
Let's say I've got this device role, created by a previous import run:
role = NetboxClientRuby.dcim.device_roles.find_by(slug: "access-point")
#=> #<NetboxClientRuby::DCIM::DeviceRole @data={"id"=>6, "name"=>"Access Point", "slug"=>"access-point", "color"=>"009688", "vm_role"=>false}, @dirty_data={}, @id=6>
When setting its attributes, it gets tracked:
role.name = role.name
role.send :dirty_data
#=> {"name"=>"Access Point"}
Should NetboxClientRuby::Entity#method_missing
track dirty attributes when the value did not change?
The patch should be relatively easy:
@@ lib/netbox_client_ruby/entity.rb @@
def method_missing(name_as_symbol, *args, &block)
if name.end_with?('=')
...
+ dirty_data[name[0..-2]] = args[0] unless dirty_data[name[0..-2]] == args[0]
- dirty_data[name[0..-2]] = args[0]
return arg[0]
cimnine and TvL2386
Metadata
Metadata
Assignees
Labels
No labels