lex-nautobot 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/CODEOWNERS +7 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/ci.yml +34 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.rspec_status +83 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +18 -0
- data/CLAUDE.md +33 -0
- data/Gemfile +13 -0
- data/LICENSE +21 -0
- data/README.md +78 -0
- data/lex-nautobot.gemspec +37 -0
- data/lib/legion/extensions/nautobot/client.rb +43 -0
- data/lib/legion/extensions/nautobot/errors.rb +9 -0
- data/lib/legion/extensions/nautobot/helpers/client.rb +23 -0
- data/lib/legion/extensions/nautobot/runners/circuits.rb +127 -0
- data/lib/legion/extensions/nautobot/runners/cloud.rb +109 -0
- data/lib/legion/extensions/nautobot/runners/dcim.rb +351 -0
- data/lib/legion/extensions/nautobot/runners/extras.rb +311 -0
- data/lib/legion/extensions/nautobot/runners/ipam.rb +210 -0
- data/lib/legion/extensions/nautobot/runners/tenancy.rb +80 -0
- data/lib/legion/extensions/nautobot/runners/users.rb +60 -0
- data/lib/legion/extensions/nautobot/runners/virtualization.rb +147 -0
- data/lib/legion/extensions/nautobot/runners/vpn.rb +120 -0
- data/lib/legion/extensions/nautobot/runners/wireless.rb +57 -0
- data/lib/legion/extensions/nautobot/version.rb +9 -0
- data/lib/legion/extensions/nautobot.rb +24 -0
- metadata +187 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/nautobot/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Nautobot
|
|
8
|
+
module Runners
|
|
9
|
+
module Extras
|
|
10
|
+
include Legion::Extensions::Nautobot::Helpers::Client
|
|
11
|
+
|
|
12
|
+
# Tags
|
|
13
|
+
def list_tags(url: nil, token: nil, **params)
|
|
14
|
+
resp = connection(url: url, token: token).get('/api/extras/tags/', params)
|
|
15
|
+
resp.body
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_tag(id:, url: nil, token: nil, **)
|
|
19
|
+
resp = connection(url: url, token: token).get("/api/extras/tags/#{id}/")
|
|
20
|
+
resp.body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_tag(url: nil, token: nil, read_only: false, **attrs)
|
|
24
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
25
|
+
|
|
26
|
+
resp = connection(url: url, token: token).post('/api/extras/tags/', attrs)
|
|
27
|
+
resp.body
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Statuses
|
|
31
|
+
def list_statuses(url: nil, token: nil, **params)
|
|
32
|
+
resp = connection(url: url, token: token).get('/api/extras/statuses/', params)
|
|
33
|
+
resp.body
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_status(id:, url: nil, token: nil, **)
|
|
37
|
+
resp = connection(url: url, token: token).get("/api/extras/statuses/#{id}/")
|
|
38
|
+
resp.body
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_status(url: nil, token: nil, read_only: false, **attrs)
|
|
42
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
43
|
+
|
|
44
|
+
resp = connection(url: url, token: token).post('/api/extras/statuses/', attrs)
|
|
45
|
+
resp.body
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Roles
|
|
49
|
+
def list_roles(url: nil, token: nil, **params)
|
|
50
|
+
resp = connection(url: url, token: token).get('/api/extras/roles/', params)
|
|
51
|
+
resp.body
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def get_role(id:, url: nil, token: nil, **)
|
|
55
|
+
resp = connection(url: url, token: token).get("/api/extras/roles/#{id}/")
|
|
56
|
+
resp.body
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_role(url: nil, token: nil, read_only: false, **attrs)
|
|
60
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
61
|
+
|
|
62
|
+
resp = connection(url: url, token: token).post('/api/extras/roles/', attrs)
|
|
63
|
+
resp.body
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Custom Fields
|
|
67
|
+
def list_custom_fields(url: nil, token: nil, **params)
|
|
68
|
+
resp = connection(url: url, token: token).get('/api/extras/custom-fields/', params)
|
|
69
|
+
resp.body
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def get_custom_field(id:, url: nil, token: nil, **)
|
|
73
|
+
resp = connection(url: url, token: token).get("/api/extras/custom-fields/#{id}/")
|
|
74
|
+
resp.body
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def create_custom_field(url: nil, token: nil, read_only: false, **attrs)
|
|
78
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
79
|
+
|
|
80
|
+
resp = connection(url: url, token: token).post('/api/extras/custom-fields/', attrs)
|
|
81
|
+
resp.body
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Custom Links
|
|
85
|
+
def list_custom_links(url: nil, token: nil, **params)
|
|
86
|
+
resp = connection(url: url, token: token).get('/api/extras/custom-links/', params)
|
|
87
|
+
resp.body
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Computed Fields
|
|
91
|
+
def list_computed_fields(url: nil, token: nil, **params)
|
|
92
|
+
resp = connection(url: url, token: token).get('/api/extras/computed-fields/', params)
|
|
93
|
+
resp.body
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Config Contexts
|
|
97
|
+
def list_config_contexts(url: nil, token: nil, **params)
|
|
98
|
+
resp = connection(url: url, token: token).get('/api/extras/config-contexts/', params)
|
|
99
|
+
resp.body
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def get_config_context(id:, url: nil, token: nil, **)
|
|
103
|
+
resp = connection(url: url, token: token).get("/api/extras/config-contexts/#{id}/")
|
|
104
|
+
resp.body
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def create_config_context(url: nil, token: nil, read_only: false, **attrs)
|
|
108
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
109
|
+
|
|
110
|
+
resp = connection(url: url, token: token).post('/api/extras/config-contexts/', attrs)
|
|
111
|
+
resp.body
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def update_config_context(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
115
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
116
|
+
|
|
117
|
+
resp = connection(url: url, token: token).patch("/api/extras/config-contexts/#{id}/", attrs)
|
|
118
|
+
resp.body
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def delete_config_context(id:, url: nil, token: nil, read_only: false, **)
|
|
122
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
123
|
+
|
|
124
|
+
connection(url: url, token: token).delete("/api/extras/config-contexts/#{id}/")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Config Context Schemas
|
|
128
|
+
def list_config_context_schemas(url: nil, token: nil, **params)
|
|
129
|
+
resp = connection(url: url, token: token).get('/api/extras/config-context-schemas/', params)
|
|
130
|
+
resp.body
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Dynamic Groups
|
|
134
|
+
def list_dynamic_groups(url: nil, token: nil, **params)
|
|
135
|
+
resp = connection(url: url, token: token).get('/api/extras/dynamic-groups/', params)
|
|
136
|
+
resp.body
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def get_dynamic_group(id:, url: nil, token: nil, **)
|
|
140
|
+
resp = connection(url: url, token: token).get("/api/extras/dynamic-groups/#{id}/")
|
|
141
|
+
resp.body
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Git Repositories
|
|
145
|
+
def list_git_repositories(url: nil, token: nil, **params)
|
|
146
|
+
resp = connection(url: url, token: token).get('/api/extras/git-repositories/', params)
|
|
147
|
+
resp.body
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def get_git_repository(id:, url: nil, token: nil, **)
|
|
151
|
+
resp = connection(url: url, token: token).get("/api/extras/git-repositories/#{id}/")
|
|
152
|
+
resp.body
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def sync_git_repository(id:, url: nil, token: nil, read_only: false, **)
|
|
156
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
157
|
+
|
|
158
|
+
resp = connection(url: url, token: token).post("/api/extras/git-repositories/#{id}/sync/")
|
|
159
|
+
resp.body
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Jobs
|
|
163
|
+
def list_jobs(url: nil, token: nil, **params)
|
|
164
|
+
resp = connection(url: url, token: token).get('/api/extras/jobs/', params)
|
|
165
|
+
resp.body
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def get_job(id:, url: nil, token: nil, **)
|
|
169
|
+
resp = connection(url: url, token: token).get("/api/extras/jobs/#{id}/")
|
|
170
|
+
resp.body
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def run_job(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
174
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
175
|
+
|
|
176
|
+
resp = connection(url: url, token: token).post("/api/extras/jobs/#{id}/run/", attrs)
|
|
177
|
+
resp.body
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def list_job_results(url: nil, token: nil, **params)
|
|
181
|
+
resp = connection(url: url, token: token).get('/api/extras/job-results/', params)
|
|
182
|
+
resp.body
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def get_job_result(id:, url: nil, token: nil, **)
|
|
186
|
+
resp = connection(url: url, token: token).get("/api/extras/job-results/#{id}/")
|
|
187
|
+
resp.body
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def list_scheduled_jobs(url: nil, token: nil, **params)
|
|
191
|
+
resp = connection(url: url, token: token).get('/api/extras/scheduled-jobs/', params)
|
|
192
|
+
resp.body
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Secrets
|
|
196
|
+
def list_secrets(url: nil, token: nil, **params)
|
|
197
|
+
resp = connection(url: url, token: token).get('/api/extras/secrets/', params)
|
|
198
|
+
resp.body
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def get_secret(id:, url: nil, token: nil, **)
|
|
202
|
+
resp = connection(url: url, token: token).get("/api/extras/secrets/#{id}/")
|
|
203
|
+
resp.body
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def list_secrets_groups(url: nil, token: nil, **params)
|
|
207
|
+
resp = connection(url: url, token: token).get('/api/extras/secrets-groups/', params)
|
|
208
|
+
resp.body
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Relationships
|
|
212
|
+
def list_relationships(url: nil, token: nil, **params)
|
|
213
|
+
resp = connection(url: url, token: token).get('/api/extras/relationships/', params)
|
|
214
|
+
resp.body
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def get_relationship(id:, url: nil, token: nil, **)
|
|
218
|
+
resp = connection(url: url, token: token).get("/api/extras/relationships/#{id}/")
|
|
219
|
+
resp.body
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Webhooks
|
|
223
|
+
def list_webhooks(url: nil, token: nil, **params)
|
|
224
|
+
resp = connection(url: url, token: token).get('/api/extras/webhooks/', params)
|
|
225
|
+
resp.body
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def get_webhook(id:, url: nil, token: nil, **)
|
|
229
|
+
resp = connection(url: url, token: token).get("/api/extras/webhooks/#{id}/")
|
|
230
|
+
resp.body
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def create_webhook(url: nil, token: nil, read_only: false, **attrs)
|
|
234
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
235
|
+
|
|
236
|
+
resp = connection(url: url, token: token).post('/api/extras/webhooks/', attrs)
|
|
237
|
+
resp.body
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# GraphQL
|
|
241
|
+
def graphql_query(query:, variables: nil, url: nil, token: nil, **)
|
|
242
|
+
payload = { query: query }
|
|
243
|
+
payload[:variables] = variables if variables
|
|
244
|
+
resp = connection(url: url, token: token).post('/api/graphql/', payload)
|
|
245
|
+
resp.body
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Notes
|
|
249
|
+
def list_notes(url: nil, token: nil, **params)
|
|
250
|
+
resp = connection(url: url, token: token).get('/api/extras/notes/', params)
|
|
251
|
+
resp.body
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Object Changes (changelog)
|
|
255
|
+
def list_object_changes(url: nil, token: nil, **params)
|
|
256
|
+
resp = connection(url: url, token: token).get('/api/extras/object-changes/', params)
|
|
257
|
+
resp.body
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def get_object_change(id:, url: nil, token: nil, **)
|
|
261
|
+
resp = connection(url: url, token: token).get("/api/extras/object-changes/#{id}/")
|
|
262
|
+
resp.body
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Contacts
|
|
266
|
+
def list_contacts(url: nil, token: nil, **params)
|
|
267
|
+
resp = connection(url: url, token: token).get('/api/extras/contacts/', params)
|
|
268
|
+
resp.body
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def get_contact(id:, url: nil, token: nil, **)
|
|
272
|
+
resp = connection(url: url, token: token).get("/api/extras/contacts/#{id}/")
|
|
273
|
+
resp.body
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def create_contact(url: nil, token: nil, read_only: false, **attrs)
|
|
277
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
278
|
+
|
|
279
|
+
resp = connection(url: url, token: token).post('/api/extras/contacts/', attrs)
|
|
280
|
+
resp.body
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Teams
|
|
284
|
+
def list_teams(url: nil, token: nil, **params)
|
|
285
|
+
resp = connection(url: url, token: token).get('/api/extras/teams/', params)
|
|
286
|
+
resp.body
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def get_team(id:, url: nil, token: nil, **)
|
|
290
|
+
resp = connection(url: url, token: token).get("/api/extras/teams/#{id}/")
|
|
291
|
+
resp.body
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# External Integrations
|
|
295
|
+
def list_external_integrations(url: nil, token: nil, **params)
|
|
296
|
+
resp = connection(url: url, token: token).get('/api/extras/external-integrations/', params)
|
|
297
|
+
resp.body
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def get_external_integration(id:, url: nil, token: nil, **)
|
|
301
|
+
resp = connection(url: url, token: token).get("/api/extras/external-integrations/#{id}/")
|
|
302
|
+
resp.body
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
306
|
+
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
end
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/nautobot/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Nautobot
|
|
8
|
+
module Runners
|
|
9
|
+
module Ipam
|
|
10
|
+
include Legion::Extensions::Nautobot::Helpers::Client
|
|
11
|
+
|
|
12
|
+
# Namespaces
|
|
13
|
+
def list_namespaces(url: nil, token: nil, **params)
|
|
14
|
+
resp = connection(url: url, token: token).get('/api/ipam/namespaces/', params)
|
|
15
|
+
resp.body
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_namespace(id:, url: nil, token: nil, **)
|
|
19
|
+
resp = connection(url: url, token: token).get("/api/ipam/namespaces/#{id}/")
|
|
20
|
+
resp.body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_namespace(url: nil, token: nil, read_only: false, **attrs)
|
|
24
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
25
|
+
|
|
26
|
+
resp = connection(url: url, token: token).post('/api/ipam/namespaces/', attrs)
|
|
27
|
+
resp.body
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# VRFs
|
|
31
|
+
def list_vrfs(url: nil, token: nil, **params)
|
|
32
|
+
resp = connection(url: url, token: token).get('/api/ipam/vrfs/', params)
|
|
33
|
+
resp.body
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_vrf(id:, url: nil, token: nil, **)
|
|
37
|
+
resp = connection(url: url, token: token).get("/api/ipam/vrfs/#{id}/")
|
|
38
|
+
resp.body
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_vrf(url: nil, token: nil, read_only: false, **attrs)
|
|
42
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
43
|
+
|
|
44
|
+
resp = connection(url: url, token: token).post('/api/ipam/vrfs/', attrs)
|
|
45
|
+
resp.body
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update_vrf(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
49
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
50
|
+
|
|
51
|
+
resp = connection(url: url, token: token).patch("/api/ipam/vrfs/#{id}/", attrs)
|
|
52
|
+
resp.body
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def delete_vrf(id:, url: nil, token: nil, read_only: false, **)
|
|
56
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
57
|
+
|
|
58
|
+
connection(url: url, token: token).delete("/api/ipam/vrfs/#{id}/")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Route Targets
|
|
62
|
+
def list_route_targets(url: nil, token: nil, **params)
|
|
63
|
+
resp = connection(url: url, token: token).get('/api/ipam/route-targets/', params)
|
|
64
|
+
resp.body
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# RIRs
|
|
68
|
+
def list_rirs(url: nil, token: nil, **params)
|
|
69
|
+
resp = connection(url: url, token: token).get('/api/ipam/rirs/', params)
|
|
70
|
+
resp.body
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Prefixes
|
|
74
|
+
def list_prefixes(url: nil, token: nil, **params)
|
|
75
|
+
resp = connection(url: url, token: token).get('/api/ipam/prefixes/', params)
|
|
76
|
+
resp.body
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_prefix(id:, url: nil, token: nil, **)
|
|
80
|
+
resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/")
|
|
81
|
+
resp.body
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def create_prefix(url: nil, token: nil, read_only: false, **attrs)
|
|
85
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
86
|
+
|
|
87
|
+
resp = connection(url: url, token: token).post('/api/ipam/prefixes/', attrs)
|
|
88
|
+
resp.body
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def update_prefix(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
92
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
93
|
+
|
|
94
|
+
resp = connection(url: url, token: token).patch("/api/ipam/prefixes/#{id}/", attrs)
|
|
95
|
+
resp.body
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def delete_prefix(id:, url: nil, token: nil, read_only: false, **)
|
|
99
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
100
|
+
|
|
101
|
+
connection(url: url, token: token).delete("/api/ipam/prefixes/#{id}/")
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def available_prefixes(id:, url: nil, token: nil, **)
|
|
105
|
+
resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/available-prefixes/")
|
|
106
|
+
resp.body
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# IP Addresses
|
|
110
|
+
def list_ip_addresses(url: nil, token: nil, **params)
|
|
111
|
+
resp = connection(url: url, token: token).get('/api/ipam/ip-addresses/', params)
|
|
112
|
+
resp.body
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def get_ip_address(id:, url: nil, token: nil, **)
|
|
116
|
+
resp = connection(url: url, token: token).get("/api/ipam/ip-addresses/#{id}/")
|
|
117
|
+
resp.body
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def create_ip_address(url: nil, token: nil, read_only: false, **attrs)
|
|
121
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
122
|
+
|
|
123
|
+
resp = connection(url: url, token: token).post('/api/ipam/ip-addresses/', attrs)
|
|
124
|
+
resp.body
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def update_ip_address(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
128
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
129
|
+
|
|
130
|
+
resp = connection(url: url, token: token).patch("/api/ipam/ip-addresses/#{id}/", attrs)
|
|
131
|
+
resp.body
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def delete_ip_address(id:, url: nil, token: nil, read_only: false, **)
|
|
135
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
136
|
+
|
|
137
|
+
connection(url: url, token: token).delete("/api/ipam/ip-addresses/#{id}/")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def available_ips(id:, url: nil, token: nil, **)
|
|
141
|
+
resp = connection(url: url, token: token).get("/api/ipam/prefixes/#{id}/available-ips/")
|
|
142
|
+
resp.body
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# VLANs
|
|
146
|
+
def list_vlan_groups(url: nil, token: nil, **params)
|
|
147
|
+
resp = connection(url: url, token: token).get('/api/ipam/vlan-groups/', params)
|
|
148
|
+
resp.body
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def get_vlan_group(id:, url: nil, token: nil, **)
|
|
152
|
+
resp = connection(url: url, token: token).get("/api/ipam/vlan-groups/#{id}/")
|
|
153
|
+
resp.body
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def list_vlans(url: nil, token: nil, **params)
|
|
157
|
+
resp = connection(url: url, token: token).get('/api/ipam/vlans/', params)
|
|
158
|
+
resp.body
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def get_vlan(id:, url: nil, token: nil, **)
|
|
162
|
+
resp = connection(url: url, token: token).get("/api/ipam/vlans/#{id}/")
|
|
163
|
+
resp.body
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def create_vlan(url: nil, token: nil, read_only: false, **attrs)
|
|
167
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
168
|
+
|
|
169
|
+
resp = connection(url: url, token: token).post('/api/ipam/vlans/', attrs)
|
|
170
|
+
resp.body
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def update_vlan(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
174
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
175
|
+
|
|
176
|
+
resp = connection(url: url, token: token).patch("/api/ipam/vlans/#{id}/", attrs)
|
|
177
|
+
resp.body
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def delete_vlan(id:, url: nil, token: nil, read_only: false, **)
|
|
181
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
182
|
+
|
|
183
|
+
connection(url: url, token: token).delete("/api/ipam/vlans/#{id}/")
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Services
|
|
187
|
+
def list_services(url: nil, token: nil, **params)
|
|
188
|
+
resp = connection(url: url, token: token).get('/api/ipam/services/', params)
|
|
189
|
+
resp.body
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def get_service(id:, url: nil, token: nil, **)
|
|
193
|
+
resp = connection(url: url, token: token).get("/api/ipam/services/#{id}/")
|
|
194
|
+
resp.body
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def create_service(url: nil, token: nil, read_only: false, **attrs)
|
|
198
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
199
|
+
|
|
200
|
+
resp = connection(url: url, token: token).post('/api/ipam/services/', attrs)
|
|
201
|
+
resp.body
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
205
|
+
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/nautobot/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Nautobot
|
|
8
|
+
module Runners
|
|
9
|
+
module Tenancy
|
|
10
|
+
include Legion::Extensions::Nautobot::Helpers::Client
|
|
11
|
+
|
|
12
|
+
# Tenant Groups
|
|
13
|
+
def list_tenant_groups(url: nil, token: nil, **params)
|
|
14
|
+
resp = connection(url: url, token: token).get('/api/tenancy/tenant-groups/', params)
|
|
15
|
+
resp.body
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_tenant_group(id:, url: nil, token: nil, **)
|
|
19
|
+
resp = connection(url: url, token: token).get("/api/tenancy/tenant-groups/#{id}/")
|
|
20
|
+
resp.body
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_tenant_group(url: nil, token: nil, read_only: false, **attrs)
|
|
24
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
25
|
+
|
|
26
|
+
resp = connection(url: url, token: token).post('/api/tenancy/tenant-groups/', attrs)
|
|
27
|
+
resp.body
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update_tenant_group(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
31
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
32
|
+
|
|
33
|
+
resp = connection(url: url, token: token).patch("/api/tenancy/tenant-groups/#{id}/", attrs)
|
|
34
|
+
resp.body
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def delete_tenant_group(id:, url: nil, token: nil, read_only: false, **)
|
|
38
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
39
|
+
|
|
40
|
+
connection(url: url, token: token).delete("/api/tenancy/tenant-groups/#{id}/")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Tenants
|
|
44
|
+
def list_tenants(url: nil, token: nil, **params)
|
|
45
|
+
resp = connection(url: url, token: token).get('/api/tenancy/tenants/', params)
|
|
46
|
+
resp.body
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_tenant(id:, url: nil, token: nil, **)
|
|
50
|
+
resp = connection(url: url, token: token).get("/api/tenancy/tenants/#{id}/")
|
|
51
|
+
resp.body
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def create_tenant(url: nil, token: nil, read_only: false, **attrs)
|
|
55
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
56
|
+
|
|
57
|
+
resp = connection(url: url, token: token).post('/api/tenancy/tenants/', attrs)
|
|
58
|
+
resp.body
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def update_tenant(id:, url: nil, token: nil, read_only: false, **attrs)
|
|
62
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
63
|
+
|
|
64
|
+
resp = connection(url: url, token: token).patch("/api/tenancy/tenants/#{id}/", attrs)
|
|
65
|
+
resp.body
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def delete_tenant(id:, url: nil, token: nil, read_only: false, **)
|
|
69
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
70
|
+
|
|
71
|
+
connection(url: url, token: token).delete("/api/tenancy/tenants/#{id}/")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
75
|
+
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/nautobot/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Nautobot
|
|
8
|
+
module Runners
|
|
9
|
+
module Users
|
|
10
|
+
include Legion::Extensions::Nautobot::Helpers::Client
|
|
11
|
+
|
|
12
|
+
def list_users(url: nil, token: nil, **params)
|
|
13
|
+
resp = connection(url: url, token: token).get('/api/users/users/', params)
|
|
14
|
+
resp.body
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_user(id:, url: nil, token: nil, **)
|
|
18
|
+
resp = connection(url: url, token: token).get("/api/users/users/#{id}/")
|
|
19
|
+
resp.body
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_user(url: nil, token: nil, read_only: false, **attrs)
|
|
23
|
+
raise ReadOnlyError, 'Write operations disabled (read_only mode)' if read_only
|
|
24
|
+
|
|
25
|
+
resp = connection(url: url, token: token).post('/api/users/users/', attrs)
|
|
26
|
+
resp.body
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def list_groups(url: nil, token: nil, **params)
|
|
30
|
+
resp = connection(url: url, token: token).get('/api/users/groups/', params)
|
|
31
|
+
resp.body
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_group(id:, url: nil, token: nil, **)
|
|
35
|
+
resp = connection(url: url, token: token).get("/api/users/groups/#{id}/")
|
|
36
|
+
resp.body
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def list_tokens(url: nil, token: nil, **params)
|
|
40
|
+
resp = connection(url: url, token: token).get('/api/users/tokens/', params)
|
|
41
|
+
resp.body
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def list_permissions(url: nil, token: nil, **params)
|
|
45
|
+
resp = connection(url: url, token: token).get('/api/users/permissions/', params)
|
|
46
|
+
resp.body
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_permission(id:, url: nil, token: nil, **)
|
|
50
|
+
resp = connection(url: url, token: token).get("/api/users/permissions/#{id}/")
|
|
51
|
+
resp.body
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
55
|
+
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|