Module: Legion::Extensions::Nautobot::Runners::Ipam

Includes:
Helpers::Lex, Helpers::Client
Included in:
Client
Defined in:
lib/legion/extensions/nautobot/runners/ipam.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#connection

Instance Method Details

#available_ips(id:, url: nil, token: nil) ⇒ Object



140
141
142
143
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 140

def available_ips(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/available-ips/")
  resp.body
end

#available_prefixes(id:, url: nil, token: nil) ⇒ Object



104
105
106
107
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 104

def available_prefixes(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/available-prefixes/")
  resp.body
end

#create_ip_address(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



120
121
122
123
124
125
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 120

def create_ip_address(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/ip-addresses/', attrs)
  resp.body
end

#create_namespace(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



23
24
25
26
27
28
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 23

def create_namespace(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/namespaces/', attrs)
  resp.body
end

#create_prefix(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



84
85
86
87
88
89
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 84

def create_prefix(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/prefixes/', attrs)
  resp.body
end

#create_service(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



197
198
199
200
201
202
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 197

def create_service(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/services/', attrs)
  resp.body
end

#create_vlan(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



166
167
168
169
170
171
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 166

def create_vlan(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/vlans/', attrs)
  resp.body
end

#create_vrf(url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



41
42
43
44
45
46
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 41

def create_vrf(url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).post('/api/ipam/vrfs/', attrs)
  resp.body
end

#delete_ip_address(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



134
135
136
137
138
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 134

def delete_ip_address(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/ipam/ip-addresses/#{id}/")
end

#delete_prefix(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



98
99
100
101
102
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 98

def delete_prefix(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/ipam/prefixes/#{id}/")
end

#delete_vlan(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



180
181
182
183
184
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 180

def delete_vlan(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/ipam/vlans/#{id}/")
end

#delete_vrf(id:, url: nil, token: nil, read_only: false) ⇒ Object

Raises:



55
56
57
58
59
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 55

def delete_vrf(id:, url: nil, token: nil, read_only: false, **)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  connection(url: url, token: token).delete("/api/ipam/vrfs/#{id}/")
end

#get_ip_address(id:, url: nil, token: nil) ⇒ Object



115
116
117
118
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 115

def get_ip_address(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/ip-addresses/#{id}/")
  resp.body
end

#get_namespace(id:, url: nil, token: nil) ⇒ Object



18
19
20
21
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 18

def get_namespace(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/namespaces/#{id}/")
  resp.body
end

#get_prefix(id:, url: nil, token: nil) ⇒ Object



79
80
81
82
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 79

def get_prefix(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/")
  resp.body
end

#get_service(id:, url: nil, token: nil) ⇒ Object



192
193
194
195
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 192

def get_service(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/services/#{id}/")
  resp.body
end

#get_vlan(id:, url: nil, token: nil) ⇒ Object



161
162
163
164
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 161

def get_vlan(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/vlans/#{id}/")
  resp.body
end

#get_vlan_group(id:, url: nil, token: nil) ⇒ Object



151
152
153
154
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 151

def get_vlan_group(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/vlan-groups/#{id}/")
  resp.body
end

#get_vrf(id:, url: nil, token: nil) ⇒ Object



36
37
38
39
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 36

def get_vrf(id:, url: nil, token: nil, **)
  resp = connection(url: url, token: token).get("/api/ipam/vrfs/#{id}/")
  resp.body
end

#list_ip_addresses(url: nil, token: nil, **params) ⇒ Object

IP Addresses



110
111
112
113
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 110

def list_ip_addresses(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/ip-addresses/', params)
  resp.body
end

#list_namespaces(url: nil, token: nil, **params) ⇒ Object

Namespaces



13
14
15
16
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 13

def list_namespaces(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/namespaces/', params)
  resp.body
end

#list_prefixes(url: nil, token: nil, **params) ⇒ Object

Prefixes



74
75
76
77
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 74

def list_prefixes(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/prefixes/', params)
  resp.body
end

#list_rirs(url: nil, token: nil, **params) ⇒ Object

RIRs



68
69
70
71
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 68

def list_rirs(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/rirs/', params)
  resp.body
end

#list_route_targets(url: nil, token: nil, **params) ⇒ Object

Route Targets



62
63
64
65
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 62

def list_route_targets(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/route-targets/', params)
  resp.body
end

#list_services(url: nil, token: nil, **params) ⇒ Object

Services



187
188
189
190
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 187

def list_services(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/services/', params)
  resp.body
end

#list_vlan_groups(url: nil, token: nil, **params) ⇒ Object

VLANs



146
147
148
149
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 146

def list_vlan_groups(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/vlan-groups/', params)
  resp.body
end

#list_vlans(url: nil, token: nil, **params) ⇒ Object



156
157
158
159
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 156

def list_vlans(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/vlans/', params)
  resp.body
end

#list_vrfs(url: nil, token: nil, **params) ⇒ Object

VRFs



31
32
33
34
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 31

def list_vrfs(url: nil, token: nil, **params)
  resp = connection(url: url, token: token).get('/api/ipam/vrfs/', params)
  resp.body
end

#update_ip_address(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



127
128
129
130
131
132
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 127

def update_ip_address(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/ipam/ip-addresses/#{id}/", attrs)
  resp.body
end

#update_prefix(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



91
92
93
94
95
96
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 91

def update_prefix(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/ipam/prefixes/#{id}/", attrs)
  resp.body
end

#update_vlan(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



173
174
175
176
177
178
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 173

def update_vlan(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/ipam/vlans/#{id}/", attrs)
  resp.body
end

#update_vrf(id:, url: nil, token: nil, read_only: false, **attrs) ⇒ Object

Raises:



48
49
50
51
52
53
# File 'lib/legion/extensions/nautobot/runners/ipam.rb', line 48

def update_vrf(id:, url: nil, token: nil, read_only: false, **attrs)
  raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only

  resp = connection(url: url, token: token).patch("/api/ipam/vrfs/#{id}/", attrs)
  resp.body
end