Rename /api/dns/status -> /api/dns/blocking and move black- and whitelist endpoints one level up

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-06-17 00:06:29 +02:00
parent e601281eac
commit 81cc07c8a4
5 changed files with 32 additions and 32 deletions

View File

@@ -18,8 +18,8 @@ None
=== "cURL"
``` bash
curl -H "Authorization: Token <your-access-token>" \
http://pi.hole:8080/admin/api/dns/cacheinfo
curl http://pi.hole:8080/admin/api/dns/cacheinfo \
-H "Authorization: Token <your-access-token>"
```
=== "Python 3"

View File

@@ -2,7 +2,7 @@
## GET: Obtain current blocking status
Resource: `GET /admin/api/dns/status`
Resource: `GET /admin/api/dns/blocking`
Requires authorization: No
@@ -18,7 +18,7 @@ None
=== "cURL"
``` bash
curl http://pi.hole:8080/admin/api/dns/status
curl http://pi.hole:8080/admin/api/dns/blocking
```
=== "Python 3"
@@ -26,7 +26,7 @@ None
``` python
import requests
URL = 'http://pi.hole:8080/admin/api/dns/status'
URL = 'http://pi.hole:8080/admin/api/dns/blocking'
response = requests.get(URL)
@@ -39,14 +39,14 @@ None
``` json
{
"status": "enabled"
"status": "active"
}
```
<!-- markdownlint-enable code-block-style -->
## `POST`: Set/change blocking status
Resource: `POST /admin/api/dns/status`
Resource: `POST /admin/api/dns/blocking`
Requires authorization: Yes
@@ -54,8 +54,8 @@ Requires authorization: Yes
Name | Required | Type | Description | Default | Example
---- | -------- | ---- | ----------- | ------- | -------
`action` | Yes | String | Requested status | | `enable` or `disable`
`time` | Optional | Number | Requested delay until opposite status is enabled | `0` | `100` (seconds)
`status` | Yes | String | Requested status | | `active` or `inactive`
`delay` | Optional | Number | Requested delay until opposite status is active | `0` | `100` (seconds)
### Example
@@ -65,19 +65,19 @@ Name | Required | Type | Description | Default | Example
=== "cURL"
``` bash
curl -X POST \
-H "Authorization: Token <your-access-token>" \
http://pi.hole:8080/admin/api/dns/status \
-H "Content-Type: application/json" \
-d @body.json
curl http://pi.hole:8080/admin/api/dns/blocking \
-X POST \
-H "Authorization: Token <your-access-token>" \
-H "Content-Type: application/json" \
-d @body.json
```
The content of `body.json` is like,
``` json
{
"action": "enable",
"time": 30
"status": "active",
"delay": 30
}
```
@@ -86,7 +86,7 @@ Name | Required | Type | Description | Default | Example
``` python
import requests
URL = 'http://pi.hole:8080/admin/api/dns/status'
URL = 'http://pi.hole:8080/admin/api/dns/blocking'
TOKEN = '<your-access-token>'
HEADERS = {'Authorization': f'Token {TOKEN}'}
data = json.load(open('body.json', 'rb'))
@@ -104,8 +104,8 @@ Name | Required | Type | Description | Default | Example
``` json
{
"action": "enable",
"time": 30
"status": "active",
"delay": 30
}
```
@@ -115,7 +115,7 @@ Name | Required | Type | Description | Default | Example
``` json
{
"key": "enabled"
"status": "active"
}
```
<!-- markdownlint-enable code-block-style -->

View File

@@ -102,9 +102,9 @@ Name | Required | Type | Description | Default | Example
=== "cURL"
``` bash
curl -X PUT \
curl http://pi.hole:8080/admin/api/whitelist/exact \
-X PUT \
-H "Authorization: Token <your-access-token>" \
http://pi.hole:8080/admin/api/whitelist/exact \
-H "Content-Type: application/json" \
-d @body.json
```
@@ -196,18 +196,18 @@ The domain/regex to be removed is specified through the URL (`<domain>`).
**Domain**
``` bash
curl -X DELETE \
-H "Authorization: Token <your-access-token>" \
http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com
curl http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com \
-X DELETE \
-H "Authorization: Token <your-access-token>"
```
**Regular expression**
``` bash
regex="$(echo "(^|\\.)facebook.com$" | jq -sRr '@uri')"
curl -X DELETE \
-H "Authorization: Token <your-access-token>" \
http://pi.hole:8080/admin/api/whitelist/exact/${regex}
regex="$(echo -n "(^|\\.)facebook.com$" | jq -sRr '@uri')"
curl http://pi.hole:8080/admin/api/whitelist/exact/${regex} \
-X DELETE \
-H "Authorization: Token <your-access-token>"
```
=== "Python"

View File

@@ -18,8 +18,8 @@ The Authorization HTTP header can be specified with `Token <your-access-token>`
=== "cURL"
``` bash
curl -H "Authorization: Token <your-access-token>" \
http://pi.hole/admin/api/dns/status
curl http://pi.hole/admin/api/dns/status \
-H "Authorization: Token <your-access-token>"
```
=== "Python 3"

View File

@@ -121,8 +121,8 @@ nav:
- 'Overview': api/index.md
- 'DNS':
- 'Status': api/dns/status.md
- 'Domain Lists': api/dns/lists.md
- 'Cache Info': api/dns/cacheinfo.md
- 'Domain Lists': api/domainlists.md
- 'FTL':
- 'Network': api/tbd.md
- 'Logs': api/tbd.md