@@ -79,12 +79,17 @@ def all(self, limit=0):
79
79
:arg int,optional limit: Overrides the max page size on
80
80
paginated returns.
81
81
82
- :Returns: List of :py:class:`.Record` objects .
82
+ :Returns: A :py:class:`.RecordSet` object .
83
83
84
84
:Examples:
85
85
86
- >>> nb.dcim.devices.all()
87
- [test1-a3-oobsw2, test1-a3-oobsw3, test1-a3-oobsw4]
86
+ >>> devices = nb.dcim.devices.all()
87
+ >>> for device in devices:
88
+ ... print(device.name)
89
+ ...
90
+ test1-leaf1
91
+ test1-leaf2
92
+ test1-leaf3
88
93
>>>
89
94
"""
90
95
req = Request (
@@ -176,33 +181,50 @@ def filter(self, *args, **kwargs):
176
181
:arg int,optional limit: Overrides the max page size on
177
182
paginated returns.
178
183
179
- :Returns: A list of :py:class:`.Record` objects .
184
+ :Returns: A :py:class:`.RecordSet` object .
180
185
181
186
:Examples:
182
187
183
188
To return a list of objects matching a named argument filter.
184
189
185
- >>> nb.dcim.devices.filter(role='leaf-switch')
186
- [test1-a3-tor1b, test1-a3-tor1c, test1-a3-tor1d, test1-a3-tor2a]
190
+ >>> devices = nb.dcim.devices.filter(role='leaf-switch')
191
+ >>> for device in devices:
192
+ ... print(device.name)
193
+ ...
194
+ test1-leaf1
195
+ test1-leaf2
196
+ test1-leaf3
187
197
>>>
188
198
189
199
Using a freeform query along with a named argument.
190
200
191
- >>> nb.dcim.devices.filter('a3', role='leaf-switch')
192
- [test1-a3-tor1b, test1-a3-tor1c, test1-a3-tor1d, test1-a3-tor2a]
201
+ >>> devices = nb.dcim.devices.filter('a3', role='leaf-switch')
202
+ >>> for device in devices:
203
+ ... print(device.name)
204
+ ...
205
+ test1-a3-leaf1
206
+ test1-a3-leaf2
193
207
>>>
194
208
195
209
Chaining multiple named arguments.
196
210
197
- >>> nb.dcim.devices.filter(role='leaf-switch', status=True)
198
- [test1-leaf2]
211
+ >>> devices = nb.dcim.devices.filter(role='leaf-switch', status=True)
212
+ >>> for device in devices:
213
+ ... print(device.name)
214
+ ...
215
+ test1-leaf2
199
216
>>>
200
217
201
218
Passing a list as a named argument adds multiple filters of the
202
219
same value.
203
220
204
- >>> nb.dcim.devices.filter(role=['leaf-switch', 'spine-switch'])
205
- [test1-a3-spine1, test1-a3-spine2, test1-a3-leaf1]
221
+ >>> device = nb.dcim.devices.filter(role=['leaf-switch', 'spine-switch'])
222
+ >>> for device in devices:
223
+ ... print(device.name)
224
+ ...
225
+ test1-a3-spine1
226
+ test1-a3-spine2
227
+ test1-a3-leaf1
206
228
>>>
207
229
"""
208
230
@@ -251,10 +273,9 @@ def create(self, *args, **kwargs):
251
273
252
274
:Examples:
253
275
254
- Creating an object on the `devices` endpoint you can lookup a
255
- device_role's name with:
276
+ Creating an object on the `devices` endpoint:
256
277
257
- >>> netbox.dcim.devices.create(
278
+ >>> device = netbox.dcim.devices.create(
258
279
... name='test',
259
280
... device_role=1,
260
281
... )
0 commit comments