Skip to content

Commit 6b5de7b

Browse files
Added query_get_data function to APIEndpoint class to allow clients to query specific data from GET requests, minor updates to APIModel class to allow nested API calls, updated APIServicesUnboundHostOverride models to follow REST principals, updated documentation
1 parent e03ada3 commit 6b5de7b

12 files changed

Lines changed: 493 additions & 373 deletions

README.md

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ There is no limit to API calls at this time but is important to note that pfSens
214214
* [Read Unbound Host Override](#3-read-unbound-host-override)
215215
* [Update Unbound Host Override](#4-update-unbound-host-override)
216216

217+
* [SERVICES/UNBOUND/HOST_OVERRIDE/ALIAS](#servicesunboundhost_overridealias)
218+
219+
* [Create Unbound Host Override Alias](#1-create-unbound-host-override-alias)
220+
217221
* [STATUS/CARP](#statuscarp)
218222

219223
* [Read CARP Status](#1-read-carp-status)
@@ -2441,6 +2445,7 @@ URL: https://{{$hostname}}/api/v1/services/unbound/host_override
24412445
| ip | string | IPv4 or IPv6 of new DNS A record |
24422446
| descr | string | Description of host override (optional) |
24432447
| aliases | array | Hostname aliases (CNAME) for host override (optional) |
2448+
| apply | boolean | Apply this host override upon creation. Defaults to false. If not set to true, you may apply these changes later by calling upon the /api/v1/services/unbound/apply endpoint. (optional) |
24442449

24452450

24462451

@@ -2486,10 +2491,8 @@ URL: https://{{$hostname}}/api/v1/services/unbound/host_override
24862491

24872492
| Key | Value | Description |
24882493
| --- | ------|-------------|
2489-
| host | string | Hostname of host override(s) to delete. This may be combined with a domain name and/or IP address for more specific deletions, or it may be used standalone to delete all host overrides that match the specified hostname |
2490-
| domain | string | Domain of host override(s) to delete. This may be combined with a hostname and/or IP address for more specific deletions, or it may be used standalone to delete all host overrides that match the specified domain |
2491-
| ip | string | IPv4/IPv6 address of host override(s) to delete. This may be combined with a hostname and/or domain name for more specific deletions, or it may be used standalone to delete all host overrides that match the specified IPv4/IPv6 address |
2492-
| aliases | boolean | Delete aliases upon host and/or domain match (optional) |
2494+
| id | integer | Specify the ID of the host override to delete |
2495+
| apply | boolean | Apply this host override upon modification. Defaults to false. If not set to true, you may apply these changes later by calling upon the /api/v1/services/unbound/apply endpoint. (optional) |
24932496

24942497

24952498

@@ -2545,27 +2548,84 @@ URL: https://{{$hostname}}/api/v1/services/unbound/host_override
25452548

25462549
| Key | Value | Description |
25472550
| --- | ------|-------------|
2548-
| host | string | Hostname of host override to modify. If specified, a `domain` value must be specified. |
2549-
| domain | string | Domain of host override to modify. Only necessary if a `host` value was provided. |
2550-
| ip | string | IPv4/IPv6 address of host overrides to update IP. If specified, a `new_ip`value must be specified. If `host` and `domain` value are specified, this value will be ignored. |
2551-
| descr | string | Specify a new host override description. Only available if a `host` value was provided. (optional) |
2552-
| new_host | string | Specify a new hostname for the host override. Only available if a `host` value was provided. (optional) |
2553-
| new_domain | string | Specify a new domain for the host override. Only available if a `host` value was provided. (optional) |
2554-
| new_ip | string | Specify a new IPv4/IPv6 for the host override. Required if `ip` value was provided. |
2551+
| id | integer | Specify the ID of the host override to update |
2552+
| host | string | Update the hostname of this host override (optional) |
2553+
| domain | string | Update the domain name of this host override (optional) |
2554+
| ip | string | Update the IPv4/IPv6 address of this host override (optional) |
2555+
| descr | string | Update the description of this host override (optional) |
2556+
| aliases | array | Update the aliases for this host override. This will replace any existing entries. (optional) |
2557+
| apply | boolean | Apply this host override upon modification. Defaults to false. If not set to true, you may apply these changes later by calling upon the /api/v1/services/unbound/apply endpoint. (optional) |
25552558

25562559

25572560

25582561
***Body:***
25592562

25602563
```js
25612564
{
2562-
"host": "test",
2565+
"host": "updated_test",
25632566
"domain": "example.com",
2564-
"ip": "127.0.0.1",
2565-
"descr": "This is a test host override added via pfSense API!",
2566-
"new_host": "new_test",
2567-
"new_domain": "newdomain.com",
2568-
"new_ip": "123.123.123.123"
2567+
"ip": "127.0.0.2",
2568+
"descr": "This is a test host override update via pfSense API!",
2569+
"aliases": [
2570+
{
2571+
"host": "test2",
2572+
"domain": "example.com",
2573+
"descr": "This is an updated host override alias that will also resolve to this IP!"
2574+
},
2575+
{
2576+
"host": "updated_to_add",
2577+
"domain": "example.com",
2578+
"descr": "This is a test host override alias that was also added during the update!"
2579+
}
2580+
]
2581+
}
2582+
```
2583+
2584+
2585+
2586+
## SERVICES/UNBOUND/HOST_OVERRIDE/ALIAS
2587+
2588+
2589+
2590+
### 1. Create Unbound Host Override Alias
2591+
2592+
2593+
Add a new host override alias to DNS Resolver (Unbound).<br><br>
2594+
2595+
_Requires at least one of the following privileges:_ [`page-all`, `page-services-dnsresolver-edithost`]
2596+
2597+
2598+
***Endpoint:***
2599+
2600+
```bash
2601+
Method: POST
2602+
Type: RAW
2603+
URL: https://{{$hostname}}/api/v1/services/unbound/host_override/alias
2604+
```
2605+
2606+
2607+
2608+
***Query params:***
2609+
2610+
| Key | Value | Description |
2611+
| --- | ------|-------------|
2612+
| id | integer | Specify the ID of the host override to apply this alias to. |
2613+
| host | string | Specify the hostname of the alias |
2614+
| domain | string | Specify the domain name of the alias |
2615+
| description | string | Description of alias (optional) |
2616+
| apply | boolean | Apply this host override upon creation. Defaults to false. If not set to true, you may apply these changes later by calling upon the /api/v1/services/unbound/apply endpoint. (optional) |
2617+
2618+
2619+
2620+
***Body:***
2621+
2622+
```js
2623+
{
2624+
"id": 0,
2625+
"host": "alias",
2626+
"domain": "example.com",
2627+
"descr": "This is a test host override alias added via pfSense API!",
2628+
"apply": true
25692629
}
25702630
```
25712631

@@ -4066,4 +4126,3 @@ URL: https://{{$hostname}}/api/v1/user/privilege
40664126

40674127
---
40684128
[Back to top](#pfsense-rest-api-documentation)
4069-
> Made with &#9829; by [thedevsaddam](https://github.com/thedevsaddam) | Generated at: 2020-09-25 17:03:56 by [docgen](https://github.com/thedevsaddam/docgen)

docs/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ custom API model:
116116
- `$this->config` : Our pfSense configuration array. You may read current configuration values using this array or write
117117
changes to the configuration by updating it's values. If you do make changes to the configuration, you must use call
118118
`$this->write_config()` to apply them.
119+
- `$this->id` : A property to track the current instances configuration ID. This is primarily helpful for updating and
120+
deleting objects.
121+
- `$this->validate_id` : A boolean to dictate whether the model object should require validation of the configuraiton ID.
122+
This defaults to true, but can be useful for nested model object calls where you would like to validate a payload before
123+
it's parent is created. It is entirely up to you to implement this property if desired.
119124

120125
#### Reading and Writing to pfSense's XML Configuration ####
121126
Included in the API framework are properties and methods to read and write to pfSense's XML configuration. Please note

0 commit comments

Comments
 (0)