Skip to content

Commit

Permalink
Implements IPAM::Asns
Browse files Browse the repository at this point in the history
  • Loading branch information
rihardskopans committed Dec 5, 2024
1 parent 8d0dbae commit 2d26349
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/netbox_client_ruby/api/ipam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module IPAM
services: Services,
vlans: Vlans,
vlan_groups: VlanGroups,
vrfs: Vrfs
vrfs: Vrfs,
asns: Asns
}.each_pair do |method_name, class_name|
define_method(method_name) { class_name.new }
module_function(method_name)
Expand All @@ -28,7 +29,8 @@ module IPAM
service: Service,
vlan: Vlan,
vlan_group: VlanGroup,
vrf: Vrf
vrf: Vrf,
asn: Asn
}.each_pair do |method_name, class_name|
define_method(method_name) { |id| class_name.new id }
module_function(method_name)
Expand Down
18 changes: 18 additions & 0 deletions lib/netbox_client_ruby/api/ipam/asn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module NetboxClientRuby
module IPAM
class Asn
include Entity

id id: :id
deletable true
path 'ipam/asns/:id/'
creation_path 'ipam/asns/'
object_fields(
tenant: proc { |raw_data| Tenancy::Tenant.new raw_data['id'] }
)
end

end
end
20 changes: 20 additions & 0 deletions lib/netbox_client_ruby/api/ipam/asns.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module NetboxClientRuby
module IPAM
class Asns
include Entities

path 'ipam/asns/'
data_key 'results'
count_key 'count'
entity_creator :entity_creator

private

def entity_creator(raw_entity)
Asn.new raw_entity['id']
end
end
end
end

0 comments on commit 2d26349

Please sign in to comment.