Skip to content

Commit e14aeb8

Browse files
author
Jared Hendrickson
committed
Minor documentation adjustments, minor adjustments to unit test framework, added legal and copyright details, fixed bug that prevented client username from showing in change logs, bug fixes for use on pfSense 2.5
1 parent 34ad7c1 commit e14aeb8

239 files changed

Lines changed: 3875 additions & 139 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [2020] [Jared Hendrickson]
189+
Copyright [YYYY] [NAME]
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,10 @@ There is no limit to API calls at this time but is important to note that pfSens
284284

285285
* [STATUS/LOG](#statuslog)
286286

287-
* [Read DHCP Status Log](#1-read-dhcp-status-log)
288-
* [Read Firewall Status Log](#2-read-firewall-status-log)
289-
* [Read System Status Log](#3-read-system-status-log)
287+
* [Read Configuration History Status Log](#1-read-configuration-history-status-log)
288+
* [Read DHCP Status Log](#2-read-dhcp-status-log)
289+
* [Read Firewall Status Log](#3-read-firewall-status-log)
290+
* [Read System Status Log](#4-read-system-status-log)
290291

291292
* [SYSTEM/API](#systemapi)
292293

@@ -2762,7 +2763,35 @@ URL: https://{{$hostname}}/api/v1/status/carp
27622763

27632764

27642765

2765-
### 1. Read DHCP Status Log
2766+
### 1. Read Configuration History Status Log
2767+
2768+
2769+
Read the configuration history log.<br><br>
2770+
2771+
_Requires at least one of the following privileges:_ [`page-all`, `page-diagnostics-configurationhistory`]
2772+
2773+
2774+
***Endpoint:***
2775+
2776+
```bash
2777+
Method: GET
2778+
Type: RAW
2779+
URL: https://{{$hostname}}/api/v1/status/log/config_history
2780+
```
2781+
2782+
2783+
2784+
***Body:***
2785+
2786+
```js
2787+
{
2788+
2789+
}
2790+
```
2791+
2792+
2793+
2794+
### 2. Read DHCP Status Log
27662795

27672796

27682797
Read the dhcpd.log file.<br><br>
@@ -2790,7 +2819,7 @@ URL: https://{{$hostname}}/api/v1/status/log/dhcp
27902819

27912820

27922821

2793-
### 2. Read Firewall Status Log
2822+
### 3. Read Firewall Status Log
27942823

27952824

27962825
Read the filter.log file.<br><br>
@@ -2818,7 +2847,7 @@ URL: https://{{$hostname}}/api/v1/status/log/firewall
28182847

28192848

28202849

2821-
### 3. Read System Status Log
2850+
### 4. Read System Status Log
28222851

28232852

28242853
Read the system.log file.<br><br>
@@ -4183,3 +4212,4 @@ URL: https://{{$hostname}}/api/v1/user/privilege
41834212

41844213
---
41854214
[Back to top](#pfsense-rest-api-documentation)
4215+
> Made with &#9829; by [thedevsaddam](https://github.com/thedevsaddam) | Generated at: 2020-09-28 16:26:07 by [docgen](https://github.com/thedevsaddam/docgen)

docs/CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@ not support POST requests, you do not need to override this property.
375375
not support PUT requests, you do not need to override this property.
376376
- `delete_payloads` : A list of dictionary formatted API payloads to use when testing DELETE requests. If this endpoint does
377377
not support DELETE requests, you do not need to override this property.
378+
- `get_responses` : A list of previously executed GET requests in a dictionary format. Failing responses will not be
379+
included.
380+
- `post_responses` : A list of previously executed POST requests in a dictionary format. Failing responses will not be
381+
included.
382+
- `put_responses` : A list of previously executed PUT requests in a dictionary format. Failing responses will not be
383+
included.
384+
- `delete_responses` : A list of previously executed DELETE requests in a dictionary format. Failing responses will not be
385+
included.
378386

379387
```python
380388
import unit_test_framework
@@ -395,6 +403,20 @@ class NewAPIUnitTest(unit_test_framework.APIUnitTest):
395403
]
396404
```
397405

406+
#### Overriding Base Model Methods ####
407+
There are methods that will assist you when you need to dynamically format API request data. These are typically used
408+
when you need to add payload data that is dependent on a previous API response. The following methods may
409+
overridden:
410+
411+
- `pre_get()` : Runs before the GET request is made.
412+
- `post_get()` : Runs after the GET request is made.
413+
- `pre_post()` : Runs before the POST request is made.
414+
- `post_post()` : Runs after the POST request is made.
415+
- `pre_put()` : Runs before the PUT request is made.
416+
- `post_put()` : Runs after the PUT request is made.
417+
- `pre_delete()` : Runs before the DELETE request is made.
418+
- `post_delete()` : Runs after the DELETE request is made.
419+
398420
#### Running Unit Tests ####
399421
Once you have written your unit test class, you must ensure you create the unit test object at the end of the file
400422
you've created like so:

docs/documentation.json

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@
6363
],
6464
"body": {
6565
"mode": "raw",
66-
"raw": "{\n \n}",
67-
"options": {
68-
"raw": {}
69-
}
66+
"raw": "{\n \n}"
7067
},
7168
"url": {
7269
"raw": "https://{{$hostname}}/api/v1/user/auth_server/ldap",
@@ -100,10 +97,7 @@
10097
],
10198
"body": {
10299
"mode": "raw",
103-
"raw": "{\n\t\"name\": \"TEST_AUTHSERVER\",\n\t\"host\": \"ldap.com\",\n\t\"ldap_port\": 636,\n\t\"ldap_urltype\": \"encrypted\",\n\t\"ldap_protver\": \"3\",\n\t\"ldap_timeout\": 12,\n\t\"ldap_scope\": \"subtree\",\n\t\"ldap_basedn\": \"dc=test,dc=com\",\n \"ldap_authcn\": \"ou=people,dc=test,dc=com;ou=groups,dc=test,dc=com\",\n \"ldap_attr_user\": \"uid\",\n \"ldap_attr_group\": \"cn\",\n \"ldap_attr_member\": \"memberof\",\n \"ldap_attr_groupobj\": \"posixGroup\",\n \"ldap_binddn\": \"cn=pfsense,dc=test,dc=com\",\n \"ldap_bindpw\": \"asdf\",\n \"active\": false\n}",
104-
"options": {
105-
"raw": {}
106-
}
100+
"raw": "{\n\t\"name\": \"TEST_AUTHSERVER\",\n\t\"host\": \"ldap.com\",\n\t\"ldap_port\": 636,\n\t\"ldap_urltype\": \"encrypted\",\n\t\"ldap_protver\": \"3\",\n\t\"ldap_timeout\": 12,\n\t\"ldap_scope\": \"subtree\",\n\t\"ldap_basedn\": \"dc=test,dc=com\",\n \"ldap_authcn\": \"ou=people,dc=test,dc=com;ou=groups,dc=test,dc=com\",\n \"ldap_attr_user\": \"uid\",\n \"ldap_attr_group\": \"cn\",\n \"ldap_attr_member\": \"memberof\",\n \"ldap_attr_groupobj\": \"posixGroup\",\n \"ldap_binddn\": \"cn=pfsense,dc=test,dc=com\",\n \"ldap_bindpw\": \"asdf\",\n \"active\": false\n}"
107101
},
108102
"url": {
109103
"raw": "https://{{$hostname}}/api/v1/user/auth_server/ldap?name=string&host=string&ldap_port=string or integer&ldap_urltype=string&ldap_protver=string or integer&ldap_scope=string&ldap_basedn=string&ldap_authcn=string&ldap_extended_query=string&ldap_binddn=string&ldap_bindpw=string&ldap_attr_user=string&ldap_attr_group=string&ldap_attr_member=string&ldap_attr_groupobj=string&ldap_utf8=boolean&ldap_timeout=string or integer&active=boolean",
@@ -229,10 +223,7 @@
229223
],
230224
"body": {
231225
"mode": "raw",
232-
"raw": "{\n\t\"name\": \"LDAP_AUTHSERVER_0\"\n}",
233-
"options": {
234-
"raw": {}
235-
}
226+
"raw": "{\n\t\"name\": \"LDAP_AUTHSERVER_0\"\n}"
236227
},
237228
"url": {
238229
"raw": "https://{{$hostname}}/api/v1/user/auth_server/ldap?name=string",
@@ -273,10 +264,7 @@
273264
],
274265
"body": {
275266
"mode": "raw",
276-
"raw": "{\n\t\"name\": \"test\"\n}",
277-
"options": {
278-
"raw": {}
279-
}
267+
"raw": "{\n\t\"name\": \"test\"\n}"
280268
},
281269
"url": {
282270
"raw": "https://{{$hostname}}/api/v1/user/auth_server/radius?name=string",
@@ -317,10 +305,7 @@
317305
],
318306
"body": {
319307
"mode": "raw",
320-
"raw": "{\n\t\"name\": \"test\"\n}",
321-
"options": {
322-
"raw": {}
323-
}
308+
"raw": "{\n\t\"name\": \"test\"\n}"
324309
},
325310
"url": {
326311
"raw": "https://{{$hostname}}/api/v1/user/auth_server?name=string",
@@ -4485,6 +4470,51 @@
44854470
"description": "Read the dhcpd.log file.<br><br>\n\n_Requires at least one of the following privileges:_ [`page-all`, `page-diagnostics-logs-dhcp`]"
44864471
},
44874472
"response": []
4473+
},
4474+
{
4475+
"name": "Read Configuration History Status Log",
4476+
"protocolProfileBehavior": {
4477+
"disableBodyPruning": true
4478+
},
4479+
"request": {
4480+
"auth": {
4481+
"type": "bearer",
4482+
"bearer": [
4483+
{
4484+
"key": "token",
4485+
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwZlNlbnNlIiwiZXhwIjoxNTk4MDcwMTAzLCJuYmYiOjE1OTgwNjE3MDMsImRhdGEiOiJhZG1pbiJ9.hgvNu96Bvsehcq6ygTa9LPB8eymiLnxYu4V6J8_h0-o",
4486+
"type": "string"
4487+
}
4488+
]
4489+
},
4490+
"method": "GET",
4491+
"header": [],
4492+
"body": {
4493+
"mode": "raw",
4494+
"raw": "{\n\n}",
4495+
"options": {
4496+
"raw": {
4497+
"language": "json"
4498+
}
4499+
}
4500+
},
4501+
"url": {
4502+
"raw": "https://{{$hostname}}/api/v1/status/log/config_history",
4503+
"protocol": "https",
4504+
"host": [
4505+
"{{$hostname}}"
4506+
],
4507+
"path": [
4508+
"api",
4509+
"v1",
4510+
"status",
4511+
"log",
4512+
"config_history"
4513+
]
4514+
},
4515+
"description": "Read the configuration history log.<br><br>\n\n_Requires at least one of the following privileges:_ [`page-all`, `page-diagnostics-configurationhistory`]"
4516+
},
4517+
"response": []
44884518
}
44894519
],
44904520
"description": "API endpoints that read, update and delete pfSense logs.",

pfSense-pkg-API/files/etc/inc/api/endpoints/APIAccessToken.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIAccessToken extends APIEndpoint {

pfSense-pkg-API/files/etc/inc/api/endpoints/APIFirewallAlias.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIFirewallAlias extends APIEndpoint {

pfSense-pkg-API/files/etc/inc/api/endpoints/APIFirewallAliasEntry.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIFirewallAliasEntry extends APIEndpoint {

pfSense-pkg-API/files/etc/inc/api/endpoints/APIFirewallNAT.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIFirewallNAT extends APIEndpoint {

pfSense-pkg-API/files/etc/inc/api/endpoints/APIFirewallNATPortForward.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIFirewallNATPortForward extends APIEndpoint {

pfSense-pkg-API/files/etc/inc/api/endpoints/APIFirewallRule.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
<?php
2+
// Copyright 2020 Jared Hendrickson
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
216
require_once("api/framework/APIEndpoint.inc");
317

418
class APIFirewallRule extends APIEndpoint {

0 commit comments

Comments
 (0)