Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit aa11813

Browse files
committed
update readme wtih examples
1 parent 787b3c7 commit aa11813

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,45 @@ The first argument NetBoxClient takes is the NetBox URL. The 'token' argument is
6464
Now using the client you can make calls to the api, for example:
6565

6666
```
67-
ret = nb.dcim.sites.list()
68-
print(ret.data)
67+
# 1. List (paginated)
68+
ret = nb.dcim.sites.list(limit=3)
6969
70+
# 2. Filtered List
71+
ret = nb.dcim.sites.list(region_id="43")
72+
73+
# 3. All
74+
ret = nb.dcim.sites.all()
75+
76+
# 4. Get
77+
ret = nb.dcim.sites.get(24)
78+
79+
# 5. Create
80+
ret = nb.dcim.sites.create(name="foo3", slug="foo3")
81+
82+
# 6. Bulk Create
83+
data = [
84+
{"name": "foo4", "slug": "foo4"},
85+
{"name": "foo5", "slug": "foo5"},
86+
{"name": "foo6", "slug": "foo6"},
87+
]
88+
ret = nb.dcim.sites.create(data)
89+
90+
# 7. Update
91+
ret = nb.dcim.sites.update(26, name="foo2-new", slug="foo2-new-slug")
92+
93+
# 8. Bulk Update
94+
data = [
95+
{"id": 28, "name": "foo4-new", "slug": "foo4-new"},
96+
{"id": 29, "name": "foo5-new", "slug": "foo5-new"},
97+
]
98+
ret = nb.dcim.sites.update(data)
99+
100+
# 9. Delete
101+
ret = nb.dcim.sites.delete(37)
102+
103+
# 10. Bulk Delete
104+
data = [{"id": 25}, {"id": 27}]
105+
ret = nb.dcim.sites.delete(data)
70106
```
71107
The methods on the api's correspond to the NetBox REST API, so ('circuits', 'core', 'dcim', 'extras', 'ipam', 'plugins', 'tenancy', 'users', 'virtualization', 'wireless')
72108

0 commit comments

Comments
 (0)