Skip to content

Commit 66ee8fc

Browse files
committed
Update and Expand documentation
1 parent 66b2280 commit 66ee8fc

File tree

4 files changed

+34
-42
lines changed

4 files changed

+34
-42
lines changed

docs/advanced.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ except pynetbox.core.query.ParameterValidationError as e:
138138
# Error: 'iste' is not a valid filter parameter for dcim.devices
139139
```
140140

141-
# Custom Sessions
141+
## Custom Sessions
142142

143143
Custom sessions can be used to modify the default HTTP behavior. Below are a few examples, most of them from [here](https://hodovi.ch/blog/advanced-usage-python-requests-timeouts-retries-hooks/).
144144

145-
## Headers
145+
### Headers
146146

147147
To set a custom header on all requests. These headers are automatically merged with headers pynetbox sets itself.
148148

@@ -160,7 +160,7 @@ nb = pynetbox.api(
160160
nb.http_session = session
161161
```
162162

163-
## SSL Verification
163+
### SSL Verification
164164

165165
To disable SSL verification. See [the docs](https://requests.readthedocs.io/en/stable/user/advanced/#ssl-cert-verification).
166166

@@ -178,7 +178,7 @@ nb = pynetbox.api(
178178
nb.http_session = session
179179
```
180180

181-
## Timeouts
181+
### Timeouts
182182

183183
Setting timeouts requires the use of Adapters.
184184

@@ -208,11 +208,11 @@ nb = pynetbox.api(
208208
nb.http_session = session
209209
```
210210

211-
# File Uploads (Image Attachments)
211+
## File Uploads (Image Attachments)
212212

213213
Pynetbox supports file uploads for endpoints that accept them, such as image attachments. When you pass a file-like object (anything with a `.read()` method) to `create()`, pynetbox automatically detects it and uses multipart/form-data encoding instead of JSON.
214214

215-
## Creating an Image Attachment
215+
### Creating an Image Attachment
216216

217217
```python
218218
import pynetbox
@@ -232,7 +232,7 @@ with open('/path/to/image.png', 'rb') as f:
232232
)
233233
```
234234

235-
## Using io.BytesIO
235+
### Using io.BytesIO
236236

237237
You can also use in-memory file objects:
238238

@@ -257,7 +257,7 @@ attachment = nb.extras.image_attachments.create(
257257
)
258258
```
259259

260-
## Custom Filename and Content-Type
260+
### Custom Filename and Content-Type
261261

262262
For more control, pass a tuple instead of a file object:
263263

@@ -272,11 +272,11 @@ with open('/path/to/image.png', 'rb') as f:
272272

273273
The tuple format is `(filename, file_object)` or `(filename, file_object, content_type)`.
274274

275-
# Multi-Format Responses
275+
## Multi-Format Responses
276276

277277
Some endpoints support multiple response formats. The rack elevation endpoint can return both JSON data and SVG diagrams.
278278

279-
## Getting Rack Elevation as JSON
279+
### Getting Rack Elevation as JSON
280280

281281
By default, the elevation endpoint returns JSON data as a list of rack unit objects:
282282

@@ -296,7 +296,7 @@ for unit in units:
296296
print(unit.id, unit.name)
297297
```
298298

299-
## Getting Rack Elevation as SVG
299+
### Getting Rack Elevation as SVG
300300

301301
Use the `render='svg'` parameter to get a graphical SVG diagram:
302302

docs/endpoint.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
# Endpoint
22

3+
`Endpoint` objects provide CRUD operations for NetBox API endpoints. They are automatically created when you access attributes on [App](api.md#app-class) objects.
4+
5+
## Overview
6+
7+
```python
8+
import pynetbox
9+
10+
nb = pynetbox.api('http://localhost:8000', token='your-token')
11+
12+
# Accessing an attribute on an App returns an Endpoint
13+
devices = nb.dcim.devices # This is an Endpoint instance
14+
15+
# Use Endpoint methods for CRUD operations
16+
all_devices = devices.all()
17+
device = devices.get(1)
18+
filtered = devices.filter(site='headquarters')
19+
new_device = devices.create(name='test', site=1, device_type=1, device_role=1)
20+
```
21+
322
::: pynetbox.core.endpoint.Endpoint
423
handler: python
5-
options:
6-
members: true
724
options:
825
members:
926
- all
@@ -16,14 +33,14 @@
1633
- update
1734
show_source: true
1835
show_root_heading: true
36+
heading_level: 2
1937

2038
::: pynetbox.core.endpoint.DetailEndpoint
2139
handler: python
22-
options:
23-
members: true
2440
options:
2541
members:
2642
- create
2743
- list
2844
show_source: true
2945
show_root_heading: true
46+
heading_level: 2

docs/getting-started.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -252,35 +252,9 @@ except ContentError as e:
252252
print(f"Content error: {e}")
253253
```
254254

255-
## API Reference
256-
257-
Detailed API documentation for the main classes:
258-
259-
::: pynetbox.core.api.Api
260-
handler: python
261-
options:
262-
members:
263-
- __init__
264-
- create_token
265-
- openapi
266-
- status
267-
- version
268-
- activate_branch
269-
show_source: true
270-
show_root_heading: true
271-
heading_level: 3
272-
273-
::: pynetbox.core.app.App
274-
handler: python
275-
options:
276-
members:
277-
- config
278-
show_source: true
279-
show_root_heading: true
280-
heading_level: 3
281-
282255
## Next Steps
283256

257+
- Review the [API Reference](api.md) for detailed documentation on core classes
284258
- Learn about [Threading](advanced.md#threading) for faster queries
285259
- Explore [Filter Validation](advanced.md#filter-validation) for safer queries
286260
- Review special methods documentation:

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ nav:
3030
- Installation: installation.md
3131
- Quick Start: getting-started.md
3232
- API Reference:
33+
- Core Classes: api.md
3334
- Endpoint: endpoint.md
3435
- Response: response.md
3536
- Request: request.md

0 commit comments

Comments
 (0)