Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging v2.0 development into mainline #1145

Merged
merged 214 commits into from
May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
062a5bf
Initial work on API v2.0
jeremystretch Jan 24, 2017
0b228ed
Merge branch 'develop' into api2
jeremystretch Jan 25, 2017
c5fba24
Merge branch 'develop' into api2
jeremystretch Jan 26, 2017
791a641
Created CircuitDetailSerializer
jeremystretch Jan 26, 2017
0f9fe86
Converted static URL definitions to routers
jeremystretch Jan 26, 2017
b31c097
Removed Swagger
jeremystretch Jan 26, 2017
b8ca530
Added an endpoint for CircuitTerminations
jeremystretch Jan 26, 2017
acfba41
Standardized implementation of nested ViewSets
jeremystretch Jan 26, 2017
ddc2c8d
Cleaned up device component nested serializers
jeremystretch Jan 27, 2017
fa900d5
Converted nested serializers to HyperlinkedModelSerializer
jeremystretch Jan 27, 2017
12d2639
Introduced WritableSerializerMixin
jeremystretch Jan 27, 2017
a3d0d4a
Enabled pagination
jeremystretch Jan 27, 2017
c0dac13
Fix retrieval of model under viewsets without a statically defined qu…
jeremystretch Jan 27, 2017
0cf029e
Added Service serializers
jeremystretch Jan 27, 2017
78cd448
Merge branch 'develop' into api2
jeremystretch Jan 30, 2017
f0fef94
Re-implemented interface/connection serializers
jeremystretch Jan 30, 2017
7beac0b
Converted device component views to a router
jeremystretch Jan 30, 2017
d9e4017
Moved graph views into model viewsets
jeremystretch Jan 30, 2017
173a6ee
Moved rack units and device LLDP neighbors views into model viewsets
jeremystretch Jan 30, 2017
1fcc2b0
Namespaced all API URLs
jeremystretch Jan 31, 2017
e1cd846
Enabled creation of device components
jeremystretch Jan 31, 2017
bb1f97a
Implemented static writable ModelSerializers for all models
jeremystretch Jan 31, 2017
0dd857f
Merge branch 'develop' into api2
jeremystretch Feb 1, 2017
f52c247
Re-implemented Swagger now that URL resolution has been fixed
jeremystretch Feb 1, 2017
6e10fea
Started API documentation
jeremystretch Feb 1, 2017
77e5450
Removed all device-specific API endpoints
jeremystretch Feb 1, 2017
ea51f1c
Removed circuit-specific endpoint for CircuitTerminations
jeremystretch Feb 1, 2017
06e5966
Include API routers directly where possible
jeremystretch Feb 1, 2017
4f8a5eb
Moved secret views into a ViewSet (no write ability yet)
jeremystretch Feb 1, 2017
2408d78
Introduced ability to decrypt secrets by sending the user's private k…
jeremystretch Feb 1, 2017
cf66f67
Initial work on using session-based master key ciphers
jeremystretch Feb 3, 2017
a42eeb1
Implemented SessionKeys for secrets
jeremystretch Feb 3, 2017
a9fe394
Merge branch 'develop' into api2
jeremystretch Feb 3, 2017
616ca4f
Adapted the web UI to work with the new secrets API
jeremystretch Feb 3, 2017
35f3108
Standardize API URL inclusions
jeremystretch Feb 3, 2017
37f250d
Corrected API URL names
jeremystretch Feb 3, 2017
6f3c3b6
Added API endpoints for device type components
jeremystretch Feb 3, 2017
7040086
Introduced ChoiceFieldSerializer for choice fields
jeremystretch Feb 8, 2017
0e04d20
Re-implemented CustomFieldSerializer (read-only for now)
jeremystretch Feb 9, 2017
b71566f
Merge branch 'develop' into api2
jeremystretch Feb 16, 2017
2128178
Tweaked ChoiceFieldSerializer to display a field as (value, label)
jeremystretch Feb 16, 2017
f151822
Merge branch 'develop' into api2
jeremystretch Feb 17, 2017
8f42f59
Merge branch 'develop' into api2
jeremystretch Feb 27, 2017
c015294
Merged develop
jeremystretch Feb 28, 2017
90fe556
Corrected region serializers
jeremystretch Feb 28, 2017
9b39ba1
Merge branch 'develop' into api2
jeremystretch Mar 2, 2017
a7a7b95
Enable API versioning
jeremystretch Mar 2, 2017
02e89d7
Merge branch 'develop' into api2
jeremystretch Mar 7, 2017
be0a3fb
Corrected merge conflict
jeremystretch Mar 7, 2017
0b10d98
Initial work on token authentication
jeremystretch Mar 7, 2017
fd55360
Suppress default permissions for Token model
jeremystretch Mar 8, 2017
26225af
Shorten key length to 20 bytes
jeremystretch Mar 8, 2017
6be465f
Addded is_expired property to Token
jeremystretch Mar 8, 2017
d58a8eb
Initial work on user control panel for tokens
jeremystretch Mar 8, 2017
4f6d2a8
Finished user control panel for tokens
jeremystretch Mar 8, 2017
68c099a
Merge branch 'develop' into api2
jeremystretch Mar 8, 2017
f43fbff
Moved TopologyMaps from DCIM to extras
jeremystretch Mar 8, 2017
a6ceaf8
Moved custom field serializers to their own module to avoid circular …
jeremystretch Mar 8, 2017
c197255
Cleanup
jeremystretch Mar 8, 2017
7e6d061
Converted GetSessionKey and RSAKeyGeneratorView to ViewSets
jeremystretch Mar 8, 2017
ddec424
Replaced RelatedConnectionsView with views.ConnectedDeviceViewSet
jeremystretch Mar 9, 2017
6c2ed1b
Standardized API URL definitions
jeremystretch Mar 9, 2017
0ed13f6
Removed browsable API login/logout
jeremystretch Mar 9, 2017
41826fc
Fixed serialization of CustomFieldChoices
jeremystretch Mar 9, 2017
9dfda83
Closes #855: Added an API endpoint for recent activity
jeremystretch Mar 9, 2017
94a29be
Removed deprecated GraphListView
jeremystretch Mar 9, 2017
7e51ca9
Provided a root API view
jeremystretch Mar 9, 2017
4d44412
APIRootView tweaks
jeremystretch Mar 9, 2017
9e4e3a8
Updated API docs
jeremystretch Mar 13, 2017
dd27950
Simplify SessionKey usage
jeremystretch Mar 14, 2017
105d177
Secrets UI work
jeremystretch Mar 14, 2017
04aedcc
Merge branch 'develop' into api2
jeremystretch Mar 14, 2017
b868de8
Updated user URLs
jeremystretch Mar 14, 2017
4cb30f1
Relate SessionKey to UserKey rather than User
jeremystretch Mar 14, 2017
3dc1506
Allow user to delete session key
jeremystretch Mar 14, 2017
3d76a98
Removed old API doc
jeremystretch Mar 15, 2017
07a2b13
Refactored SecretViewSet
jeremystretch Mar 15, 2017
e3ae013
Implemented full read/write support for secrets
jeremystretch Mar 15, 2017
0312016
Wrote tests for circuits API
jeremystretch Mar 16, 2017
d58f903
Wrote tests for tenancy API
jeremystretch Mar 16, 2017
bbc355d
Improved create/update validation
jeremystretch Mar 16, 2017
f33269e
First batch of DCIM API tests
jeremystretch Mar 16, 2017
be2faaa
Fixed bug interpreting facility_id as a required field
jeremystretch Mar 16, 2017
abdfc5c
Finished DCIM API model tests
jeremystretch Mar 17, 2017
8825a03
Removed unneeded services endpoint from DCIM API
jeremystretch Mar 17, 2017
a6f4de5
Wrote tests for IPAM API
jeremystretch Mar 17, 2017
c5308d5
Make RackReservation.rack editble for API compatability
jeremystretch Mar 17, 2017
79a9ac3
Assign RackReservation user from request context
jeremystretch Mar 17, 2017
130ff27
Wrote tests for secrets API
jeremystretch Mar 17, 2017
e544f1f
Removed extraneous 'id' field from all WritableSerializers
jeremystretch Mar 17, 2017
f02dd2f
Merge branch 'develop' into api2
jeremystretch Mar 17, 2017
c08fae8
Restore not-so-extraneous 'id' field to all WritableSerializers
jeremystretch Mar 17, 2017
97710a4
Make CI happy
jeremystretch Mar 17, 2017
671d538
Python3 fixes
jeremystretch Mar 18, 2017
36bbcc8
Fix API JS to read response.results for new API
jeremystretch Mar 20, 2017
1f78462
Updated RackViewSet() to be compatible with paginated API
jeremystretch Mar 20, 2017
517eaa8
Expanded API documentation
jeremystretch Mar 20, 2017
1988c02
Enforce API versioning
jeremystretch Mar 20, 2017
42fd14f
Introduced HttpStatusMixin to provide more detail on HTTP response st…
jeremystretch Mar 20, 2017
266f9cc
Added API endpoint, tests for Graphs
jeremystretch Mar 20, 2017
b04fe21
Wrote API endpoints, tests for ExportTemplates
jeremystretch Mar 20, 2017
2bd4623
Converted ChoiceFieldSerializer to display an object
jeremystretch Mar 20, 2017
ffde2c9
Fixed custom renderers to work with paginated data
jeremystretch Mar 20, 2017
4a2206e
Removed custom renderers
jeremystretch Mar 20, 2017
f743410
Renamed rack-units API and added a test
jeremystretch Mar 21, 2017
925afe0
Added test case for ConnectedDeviceViewSet
jeremystretch Mar 21, 2017
6cb36a6
Fixed browsable API breadcrumbs
jeremystretch Mar 21, 2017
122526a
Custom name for ConnectedDeviceViewSet
jeremystretch Mar 21, 2017
22768ff
Renamed Module to InventoryItem (prep for #824)
jeremystretch Mar 21, 2017
01f5435
Tweak how we set the API version
jeremystretch Mar 21, 2017
54468ab
Include the API version in responses
jeremystretch Mar 21, 2017
7ba6e32
Fixes #843: Implemented CORS headers for API
jeremystretch Mar 21, 2017
93c748b
Merge branch 'develop' into api2
jeremystretch Mar 21, 2017
5c4741c
Added section on pagination
jeremystretch Mar 21, 2017
6d30fdb
Finished work on secrets views; removed path from cookie assignment
jeremystretch Mar 21, 2017
a36b138
Added API doc for working with secrets
jeremystretch Mar 21, 2017
a5419ec
RPC API fixes
jeremystretch Mar 21, 2017
3e6a99f
Allow editing of platform RPC client
jeremystretch Mar 21, 2017
1791a5b
Added has_primary_ip filter for Devices
jeremystretch Mar 22, 2017
04e09c0
Merge branch 'develop' into api2
jeremystretch Mar 22, 2017
f5f9491
v2.0 Beta 1 release
jeremystretch Mar 22, 2017
007fe6a
Markdown fixes
jeremystretch Mar 22, 2017
0899a10
Only attempt to process session key if user is authenticated
jeremystretch Mar 22, 2017
516372e
Update Dockerfile
alejojo Mar 23, 2017
0f2bbd7
Merge pull request #986 from alejojo/patch-1
jeremystretch Mar 23, 2017
93a4327
Merge branch 'api2' into v2-develop
jeremystretch Mar 23, 2017
576e21e
Merge branch 'develop' into v2-develop
jeremystretch Mar 23, 2017
48141c0
Fixes #996
Mar 24, 2017
066a3b8
update `api_url` with new interfaces endpoint.
Mar 24, 2017
22bfac7
fix remaining legacy api url paths.
Mar 24, 2017
cf3e7f9
Merge pull request #997 from digitalocean/livesearch-fix
jeremystretch Mar 27, 2017
5d022a5
Closes #985: Added preserve_key to get-session-key endpoint
jeremystretch Mar 28, 2017
116ceb6
Added tests for get-session-key API endpoint
jeremystretch Mar 28, 2017
69e54ab
Token admin form improvements
jeremystretch Mar 28, 2017
58e4bf1
Closes #973: Removed extraneous admin UI functions
jeremystretch Mar 28, 2017
afdb246
Initial work on global search
jeremystretch Mar 29, 2017
6542b8b
Base64 decoding tweaks
jeremystretch Mar 29, 2017
d04436a
Search form improvements
jeremystretch Mar 29, 2017
a5dc91c
Introduced SearchTable for improved performance
jeremystretch Mar 29, 2017
66615f1
Prettied things up a bit
jeremystretch Mar 29, 2017
aefc6ff
Merge branch 'global-search' into v2-develop
jeremystretch Mar 29, 2017
998f892
Updated the docstring for Device
jeremystretch Mar 30, 2017
f6ea09e
Removed duplicate 'Regions' section
jeremystretch Mar 30, 2017
3ed3e93
Appended a version flag to all CSS/JS references to invalidate browse…
jeremystretch Mar 30, 2017
b643939
Initial work on #152: Image attachments
jeremystretch Mar 31, 2017
1c38f70
Fixes #1021: Corrected evaluation of API token expiration time
jeremystretch Mar 31, 2017
50d7fd7
Added image attachments to sites and devices
jeremystretch Mar 31, 2017
6bbdc2b
Enable serving static media through Django
jeremystretch Mar 31, 2017
a67fc64
Fixes #1025: Applied missing API view filters
jeremystretch Apr 3, 2017
2c1fa62
Implemented API endpoints for ImageAttachments
jeremystretch Apr 3, 2017
2cde9a8
Merge pull request #1026 from digitalocean/image-attachments
jeremystretch Apr 3, 2017
8799a15
What would we do without you, PEP8?
jeremystretch Apr 3, 2017
51725d3
Added a search box to the navigation menu
jeremystretch Apr 3, 2017
36c31a2
Fixed deprecated references to ImageAttachment.obj
jeremystretch Apr 3, 2017
80267aa
Documented image attachments
jeremystretch Apr 3, 2017
ea1d4e7
Updated static CSS/JS libraries
jeremystretch Apr 3, 2017
ca293dc
Corrected topology map link
jeremystretch Apr 3, 2017
2bb6387
Fixes #1028: Corrected API endpoint URL name in IPAddressForm
jeremystretch Apr 3, 2017
5187138
Refactored custom field serializers
jeremystretch Apr 4, 2017
409c9c4
Merge branch 'develop' into v2-develop
jeremystretch Apr 4, 2017
1dcb0b5
#1033: Disable the debug toolbar templates panel by default due to a …
jeremystretch Apr 4, 2017
d2bd4a2
#1033: Convert ColorSelect to a templatized widget
jeremystretch Apr 4, 2017
99a3e0c
Corrected CustomFieldModelSerializer behavior when serializing lists …
jeremystretch Apr 4, 2017
c09473f
#1033: Convert SelectWithDisabled to a templatized widget
jeremystretch Apr 4, 2017
1ae0820
#1033: Update ArrayFieldSelectMultiple for Django 1.11
jeremystretch Apr 4, 2017
ae5bf74
#1033: Tweak SelectWithDisabled option template
jeremystretch Apr 4, 2017
280d98b
#1033: Updated requirements.txt for Django 1.11
jeremystretch Apr 4, 2017
0d7ee6f
Merge branch 'develop' into v2-develop
jeremystretch Apr 4, 2017
bde1f6d
Bump migration index due to a new migration in 1.9.4-r1
jeremystretch Apr 4, 2017
f34a8ff
Extend upgrade script to remove cached bytecode
jeremystretch Apr 5, 2017
178f7b4
Added API endpoints for console and power connections
jeremystretch Apr 5, 2017
f000df1
Release v2.0-beta2
jeremystretch Apr 5, 2017
1a34830
Merge pull request #1042 from digitalocean/v2-develop
jeremystretch Apr 5, 2017
91d3590
Reset version
jeremystretch Apr 5, 2017
d4ac6db
Fixes #1043: Corrected queryset in WritableDeviceSerializer validation
jeremystretch Apr 5, 2017
369d3aa
Rearranged URL namespaces to satisfy deprecation warnings
jeremystretch Apr 5, 2017
d98e9e1
Resolved RemovedInDjango20Warning deprecation warnings
jeremystretch Apr 5, 2017
e7cf7d5
Fixes #1045
Apr 5, 2017
fc46f70
Closes #430: Include circuits when rendering topology maps
jeremystretch Apr 5, 2017
4accdf7
Closes #578: Show topology maps not assigned to a site on the home view
jeremystretch Apr 5, 2017
bcdf9ac
Merge pull request #1046 from digitalocean/component-filter-by-name
jeremystretch Apr 6, 2017
ee11775
Fixes #1051: Upgraded django-rest-swagger
jeremystretch Apr 6, 2017
82d53a8
Fixes #1049: Prompt user if missing session key when adding/editing a…
jeremystretch Apr 6, 2017
9f67da0
Colored nodes in topology maps
jeremystretch Apr 6, 2017
57fc6a3
Merge branch 'develop' into v2-develop
jeremystretch Apr 6, 2017
d21b674
Pointing Dockerfile to 'v2-beta' branch
eliezerlp Apr 10, 2017
863cbb7
Merge pull request #1064 from eliezerlp/v2-develop
jeremystretch Apr 10, 2017
2d52b9f
Fixes #1059: Allow filtering of interface connections via API
jeremystretch Apr 10, 2017
b01bf60
Merge branch 'develop' into v2-develop
jeremystretch Apr 13, 2017
8032aa1
Fixes #1078: Increase default limit for number of objects returned by…
jeremystretch Apr 17, 2017
a98c9ed
Corrected invalid API URL name
jeremystretch Apr 17, 2017
864fa17
Closes #1008: Moved Docker components into their own repository
jeremystretch Apr 19, 2017
13cc29c
Closes #951: Provide a side-by-side view of rack elevations
jeremystretch Apr 20, 2017
f736932
Merge branch 'develop' into v2-develop
jeremystretch Apr 21, 2017
10823e1
Got rudimentary custom field creates/updates working
jeremystretch Apr 25, 2017
1c86b00
Added custom field API tests
jeremystretch Apr 25, 2017
d17efce
Fixes #1111: Correct database ordering of SessionKey model
jeremystretch Apr 27, 2017
01da46f
Fixes #1107: Corrected exception on creating/deleting image attachments
jeremystretch Apr 27, 2017
117da33
Corrected tests and improved validation
jeremystretch Apr 27, 2017
c174c0c
Converted all necessary serializers to CustomFieldModelSerializers
jeremystretch Apr 27, 2017
b82f25c
Merge branch 'writable-custom-fields' into v2-develop
jeremystretch Apr 27, 2017
4b2e762
Switched user nav menu with search form
jeremystretch Apr 27, 2017
8e0580f
Improved upgrade script
jeremystretch Apr 27, 2017
616f109
Merge branch 'develop' into v2-develop
jeremystretch Apr 27, 2017
e4ca887
Release v2.0-beta3
jeremystretch Apr 27, 2017
b8b912b
Post-release version adjustment
jeremystretch Apr 27, 2017
010f6c7
Fixes #1113: Fixes server error when attempting to delete an image at…
jeremystretch Apr 28, 2017
de58d0e
Fixes #1114: Suppress OSError when attempting to access a delete imag…
jeremystretch Apr 28, 2017
16c582e
Enable stale .pyc cleanup in upgrade.sh
jeremystretch May 1, 2017
9d9de6b
Fixes #1126: Fix error when editing a user key via admin UI
jeremystretch May 2, 2017
7eb9c82
Fixes #1132: Prompt user to unlock session key when importing secrets
jeremystretch May 3, 2017
77247cc
Closes #154: Expand device status field options
jeremystretch May 8, 2017
af4edff
Related to #1144: Allow multiple status selections when filtering dev…
jeremystretch May 8, 2017
5ca87c0
Merge branch 'develop' into v2-develop
jeremystretch May 8, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Please see [the documentation](http://netbox.readthedocs.io/en/stable/) for inst

## Alternative Installations

* [Docker container](http://netbox.readthedocs.io/en/stable/installation/docker/)
* [Docker container](https://github.com/digitalocean/netbox-docker)
* [Heroku deployment](https://heroku.com/deploy?template=https://github.com/BILDQUADRAT/netbox/tree/heroku) (via [@mraerino](https://github.com/BILDQUADRAT/netbox/tree/heroku))
53 changes: 0 additions & 53 deletions docker-compose.yml

This file was deleted.

22 changes: 0 additions & 22 deletions docker/docker-entrypoint.sh

This file was deleted.

5 changes: 0 additions & 5 deletions docker/gunicorn_config.py

This file was deleted.

35 changes: 0 additions & 35 deletions docker/nginx.conf

This file was deleted.

19 changes: 0 additions & 19 deletions docs/api-integration.md

This file was deleted.

48 changes: 48 additions & 0 deletions docs/api/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
The NetBox API employs token-based authentication. For convenience, cookie authentication can also be used when navigating the browsable API.

# Tokens

A token is a unique identifier that identifies a user to the API. Each user in NetBox may have one or more tokens which he or she can use to authenticate to the API. To create a token, navigate to the API tokens page at `/user/api-tokens/`.

Each token contains a 160-bit key represented as 40 hexadecimal characters. When creating a token, you'll typically leave the key field blank so that a random key will be automatically generated. However, NetBox allows you to specify a key in case you need to restore a previously deleted token to operation.

By default, a token can be used for all operations available via the API. Deselecting the "write enabled" option will restrict API requests made with the token to read operations (e.g. GET) only.

Additionally, a token can be set to expire at a specific time. This can be useful if an external client needs to be granted temporary access to NetBox.

# Authenticating to the API

By default, read operations will be available without authentication. In this case, a token may be included in the request, but is not necessary.

```
$ curl -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/
{
"count": 10,
"next": null,
"previous": null,
"results": [...]
}
```

However, if the [`LOGIN_REQUIRED`](../configuration/optional-settings/#login_required) configuration setting has been set to `True`, all requests must be authenticated.

```
$ curl -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/
{
"detail": "Authentication credentials were not provided."
}
```

To authenticate to the API, set the HTTP `Authorization` header to the string `Token ` (note the trailing space) followed by the token key.

```
$ curl -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/
{
"count": 10,
"next": null,
"previous": null,
"results": [...]
}
```

Additionally, the browsable interface to the API (which can be seen by navigating to the API root `/api/` in a web browser) will attempt to authenticate requests using the same cookie that the normal NetBox front end uses. Thus, if you have logged into NetBox, you will be logged into the browsable API as well.
138 changes: 138 additions & 0 deletions docs/api/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# API Examples

Supported HTTP methods:

* `GET`: Retrieve an object or list of objects
* `POST`: Create a new object
* `PUT`: Update an existing object
* `DELETE`: Delete an existing object

To authenticate a request, attach your token in an `Authorization` header:

```
curl -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0"
```

### Retrieving a list of sites

Send a `GET` request to the object list endpoint. The response contains a paginated list of JSON objects.

```
$ curl -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/
{
"count": 14,
"next": null,
"previous": null,
"results": [
{
"id": 6,
"name": "Corporate HQ",
"slug": "corporate-hq",
"region": null,
"tenant": null,
"facility": "",
"asn": null,
"physical_address": "742 Evergreen Terrace, Springfield, USA",
"shipping_address": "",
"contact_name": "",
"contact_phone": "",
"contact_email": "",
"comments": "",
"custom_fields": {},
"count_prefixes": 108,
"count_vlans": 46,
"count_racks": 8,
"count_devices": 254,
"count_circuits": 6
},
...
]
}
```

### Retrieving a single site by ID

Send a `GET` request to the object detail endpoint. The response contains a single JSON object.

```
$ curl -H "Accept: application/json; indent=4" http://localhost/api/dcim/sites/6/
{
"id": 6,
"name": "Corporate HQ",
"slug": "corporate-hq",
"region": null,
"tenant": null,
"facility": "",
"asn": null,
"physical_address": "742 Evergreen Terrace, Springfield, USA",
"shipping_address": "",
"contact_name": "",
"contact_phone": "",
"contact_email": "",
"comments": "",
"custom_fields": {},
"count_prefixes": 108,
"count_vlans": 46,
"count_racks": 8,
"count_devices": 254,
"count_circuits": 6
}
```

### Creating a new site

Send a `POST` request to the site list endpoint with token authentication and JSON-formatted data. Only mandatory fields are required.

```
$ curl -X POST -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/ --data '{"name": "My New Site", "slug": "my-new-site"}'
{
"id": 16,
"name": "My New Site",
"slug": "my-new-site",
"region": null,
"tenant": null,
"facility": "",
"asn": null,
"physical_address": "",
"shipping_address": "",
"contact_name": "",
"contact_phone": "",
"contact_email": "",
"comments": ""
}
```

### Modify an existing site

Make an authenticated `PUT` request to the site detail endpoint. As with a create (POST) request, all mandatory fields must be included.

```
$ curl -X PUT -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/16/ --data '{"name": "Renamed Site", "slug": "renamed-site"}'
```

### Delete an existing site

Send an authenticated `DELETE` request to the site detail endpoint.

```
$ curl -v X DELETE -H "Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost:8000/api/dcim/sites/16/
* Connected to localhost (127.0.0.1) port 8000 (#0)
> DELETE /api/dcim/sites/16/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8000
> Authorization: Token d2f763479f703d80de0ec15254237bc651f9cdc0
> Content-Type: application/json
> Accept: application/json; indent=4
>
* HTTP 1.0, assume close after body
< HTTP/1.0 204 No Content
< Date: Mon, 20 Mar 2017 16:13:08 GMT
< Server: WSGIServer/0.1 Python/2.7.6
< Vary: Accept, Cookie
< X-Frame-Options: SAMEORIGIN
< Allow: GET, PUT, PATCH, DELETE, OPTIONS
<
* Closing connection 0
```

The response to a successfull `DELETE` request will have code 204 (No Content); the body of the response will be empty.
Loading