Skip to content

Commit 8668101

Browse files
Merge pull request #574 from jaredhendrickson13/next_minor
v2.2.0 Features & Fixes
2 parents b31f84a + e1e4ce3 commit 8668101

168 files changed

Lines changed: 11421 additions & 759 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.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
sleep 5
8787
8888
- name: Fetch OpenAPI schema from pfSense
89-
run: curl -s -k -u admin:pfsense -X GET https://${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com/api/v2/schema > openapi-${{ matrix.PFSENSE_VERSION }}.json
89+
run: curl -s -k -u admin:pfsense -X GET https://${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com/api/v2/schema/openapi > openapi-${{ matrix.PFSENSE_VERSION }}.json
9090

9191
- name: Teardown pfSense VM
9292
if: "${{ always() }}"

.github/workflows/release.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
with:
6363
files: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg
6464

65-
build_openapi:
65+
build_schemas:
6666
runs-on: self-hosted
6767
needs: [release_pkg]
6868
steps:
@@ -92,22 +92,31 @@ jobs:
9292
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com "pkg -C /dev/null add /tmp/pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-pkg-RESTAPI.pkg"
9393
sleep 5
9494
95-
- name: Fetch OpenAPI schema from pfSense
96-
run: curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema > openapi.json
95+
- name: Fetch schemas from pfSense
96+
run: |
97+
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/openapi > openapi.json
98+
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/graphql > schema.graphql
9799
98100
- name: Teardown pfSense VM
99101
if: "${{ always() }}"
100102
run: |
101103
/usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true
102104
/usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial
103105
104-
- uses: actions/upload-artifact@v4
106+
- name: Upload OpenAPI schema
107+
uses: actions/upload-artifact@v4
105108
with:
106109
name: openapi.json
107110
path: openapi.json
108111

112+
- name: Upload GraphQL schema
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: schema.graphql
116+
path: schema.graphql
117+
109118
release_docs:
110-
needs: [build_openapi]
119+
needs: [build_schemas]
111120
runs-on: ubuntu-latest
112121
if: ${{ !github.event.release.prerelease }}
113122
environment:
@@ -139,6 +148,12 @@ jobs:
139148
name: openapi.json
140149
path: openapi.json
141150

151+
- name: Download GraphQL schema
152+
uses: actions/download-artifact@v4
153+
with:
154+
name: schema.graphql
155+
path: schema.graphql
156+
142157
- name: Build Swagger UI
143158
run: |
144159
mkdir -p ./www/api-docs/
@@ -166,6 +181,11 @@ jobs:
166181
});
167182
};' > ./www/api-docs/swagger-initializer.js
168183
184+
- name: Write GraphQL schema
185+
run: |
186+
mkdir -p ./www/graphql-docs/
187+
cp schema.graphql/schema.graphql ./www/graphql-docs/schema.graphql
188+
169189
- name: Build PHP reference documentation
170190
run: |
171191
mkdir ./www/php-docs

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tests/e2e_test_framework/__pycache__/
44
.phplint-cache
55
*.pyc
66
venv/
7-
vendor/
7+
/vendor/
88
.vagrant
99
*.pkg
1010
node_modules

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
[![Build](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/build.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/build.yml)
44
[![Quality](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/quality.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/quality.yml)
5-
[![Release](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/release.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/release.yml)
5+
[![Release](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/release.yml/badge.svg)](https://github.com/jaredhendrickson13/pfsense-api/actions/workflows/release.yml)<br>
6+
![Downloads](https://img.shields.io/github/downloads/jaredhendrickson13/pfsense-api/total?label=Downloads)
7+
![License](https://img.shields.io/github/license/jaredhendrickson13/pfsense-api?label=License)
8+
![Docs](https://img.shields.io/website?url=https%3A%2F%2Fpfrest.org&label=Documentation)
69

7-
The pfSense REST API package is an unofficial, open-source REST API for pfSense CE and pfSense Plus firewalls. This package is
8-
designed to be light-weight, fast, and easy to use. This guide will help you get started with the REST API package and
9-
provide you with the information you need to configure and use the package effectively.
10+
The pfSense REST API package is an unofficial, open-source REST and GraphQL API for pfSense CE and pfSense Plus
11+
firewalls.It is designed to be light-weight, fast, and easy to use. This guide will help you get started with the REST
12+
API package and provide you with the information you need to configure and use the package effectively.
1013

1114
## Key Features
1215

13-
- 100+ endpoints available for managing your firewall and associated services
16+
- 200+ REST endpoints available for managing your firewall and associated services
17+
- A GraphQL API for flexible data retrieval and mutation
1418
- Easy to use querying and filtering
1519
- Configurable security settings
1620
- Supports HATEOAS driven development
@@ -22,7 +26,7 @@ provide you with the information you need to configure and use the package effec
2226
- [Installation and Configuration](https://pfrest.org/INSTALL_AND_CONFIG/)
2327
- [Authentication and Authorization](https://pfrest.org/AUTHENTICATION_AND_AUTHORIZATION/)
2428
- [Swagger and OpenAPI](https://pfrest.org/SWAGGER_AND_OPENAPI/)
25-
- [Queries and Filters](https://pfrest.org/QUERIES_AND_FILTERS/)
29+
- [Queries, Filters, and Sorting](https://pfrest.org/QUERIES_FILTERS_AND_SORTING/)
2630

2731
## Quickstart
2832

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"require": {
3-
"firebase/php-jwt": "v6.10.*"
3+
"firebase/php-jwt": "v6.10.*",
4+
"webonyx/graphql-php": "^15.13"
45
}
56
}

composer.lock

Lines changed: 70 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/AUTHENTICATION_AND_AUTHORIZATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ curl -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxx" https://pfsense.example.
8484
### Custom Authentication
8585

8686
For advanced users, the REST API's framework allows for custom authentication methods to be added using PHP. See
87-
[Building Custom Authentication](./BUILDING_CUSTOM_AUTH_CLASSES.md) for more information.
87+
[Building Custom Authentication](BUILDING_CUSTOM_AUTH_CLASSES.md) for more information.
8888

8989
## Authorization
9090

docs/BUILDING_CUSTOM_ENDPOINT_CLASSES.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ classes are also responsible for following:
77
- Defining the URL path for the endpoint.
88
- Specifying which request methods are allowed.
99
- Adding additional documentation to the endpoint's OpenAPI definition.
10+
- Defining an associated GraphQL query/mutation type.
1011
- Generating the PHP file in the pfSense web root to expose the endpoint.
1112

1213
## Getting Started
@@ -240,10 +241,10 @@ and the endpoint will be accessible via the REST API.
240241

241242
## Generating Documentation
242243

243-
To regenerate the OpenAPI documentation for all Endpoint classes, run the following command:
244+
To regenerate the OpenAPI and GraphQL schemas for all Endpoint classes, run the following command:
244245

245246
```shell
246-
pfsense-restapi generatedocs
247+
pfsense-restapi buildschemas
247248
```
248249

249250
## Examples

docs/BUILDING_CUSTOM_MODEL_CLASSES.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,40 +232,40 @@ $this->unique_together_fields = ['name', 'port'];
232232
- The `unique_together_fields` property is only applicable when the `many` property is set to `true`.
233233
- The fields defined in the `unique_together_fields` property must be defined in the Model's Field objects.
234234

235-
### sort_by_field
235+
### sort_by
236236

237-
The `sort_by_field` property is used to define the field that objects of the Model will be sorted by. When this property is
238-
set, objects created and updated will be sorted according to the assigned field using the assigned `sort_option`.
237+
The `sort_by` property is used to define the fields that objects of the Model will be sorted by. When this property is
238+
set, objects created and updated will be sorted according to the assigned field using the assigned `sort_order`.
239239

240240
Example:
241241

242242
```php
243-
$this->sort_by_field = 'name';
243+
$this->sort_by = ['name'];
244244
```
245245

246246
!!! Warning
247247
The use of sorting in a Model may cause IDs to be re-ordered when objects are created or updated.
248248
!!! Notes
249-
- The `sort_by_field` property is only applicable when the `many` property is set to `true`.
250-
- The field defined in the `sort_by_field` property must be defined in the Model's Field objects.
249+
- The `sort_by` property is only applicable when the `many` property is set to `true`.
250+
- The field defined in the `sort_by` property must be defined in the Model's Field objects.
251251

252-
### sort_option
252+
### sort_order
253253

254-
The `sort_option` property is used to define the PHP sorting option for objects of the Model. When this property is set,
254+
The `sort_order` property is used to define the PHP sorting option for objects of the Model. When this property is set,
255255
objects created and updated will be sorted according to the assigned option. For valid sorting options, refer to: For valid value options for this property, refer to the
256256
[PHP multi-sort function type flags](https://www.php.net/manual/en/function.array-multisort.php).
257257

258258
Example:
259259

260260
```php
261-
$this->sort_option = SORT_ASC;
261+
$this->sort_order = SORT_ASC;
262262
```
263263

264264
!!! Warning
265265
The use of sorting in a Model may cause IDs to be re-ordered when objects are created or updated.
266266
!!! Notes
267-
- The `sort_option` property is only applicable when the `many` property is set to `true`.
268-
- The `sort_option` property is only applicable when a `sort_by_field` is defined.
267+
- The `sort_order` property is only applicable when the `many` property is set to `true`.
268+
- The `sort_order` property is only applicable when a `sort_by` is defined.
269269

270270
### subsystem
271271

docs/COMMON_CONTROL_PARAMETERS.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ parameters you can use:
3434
immediately.
3535

3636
!!! Tip
37-
The [Swagger documentation](./SWAGGER_AND_OPENAPI.md#swagger-documentation) will indicate if an endpoint applies
37+
The [Swagger documentation](SWAGGER_AND_OPENAPI.md#swagger-documentation) will indicate if an endpoint applies
3838
changes immediately or requires a separate apply call. If an endpoint applies changes immediately, this parameter
3939
will have no effect.
4040

@@ -75,6 +75,16 @@ parameters you can use:
7575
submitted in your request will be removed from the existing array values. This is useful when you want to remove
7676
specific values from an array field without needing to retrieve the existing values first.
7777

78+
!!! Warning
79+
If you set this parameter to `true`, it will apply to all array fields. You can't choose to remove to some array
80+
fields and replace others at the same time. To work around this, first make a request with the data for the fields
81+
you want to remove from. Then, make another request for the fields you want to replace.
82+
83+
!!! Notes
84+
- This parameter is only available for `PATCH` requests.
85+
- This parameter is only applicable to array fields.
86+
- If the submitted array values match the existing array values exactly, the API will not make any changes to that field to avoid removing all values unintentionally.
87+
7888
## reverse
7989

8090
- Type: Boolean
@@ -84,5 +94,22 @@ parameters you can use:
8494
looking for an object near the end of the list. Additionally, it is helpful for time-sorted objects, such as logs,
8595
where you may want to view the most recent entries first.
8696

87-
!!! Note
88-
This parameter is only available for `GET` requests to [plural endpoints](ENDPOINT_TYPES.md#plural-many-endpoints).
97+
## sort_by
98+
99+
- Type: String or Array
100+
- Default: _Defaults to the primary sort attribute for the endpoint, typically `null`._
101+
- Description: This parameters allows you to select the fields to use to sort the objects related to the endpoint. The
102+
behavior of this parameter varies based on the request method and endpoint type. Refer to the
103+
[Sorting](QUERIES_FILTERS_AND_SORTING.md#sorting) section for more information.
104+
105+
## sort_order
106+
107+
- Type: String
108+
- Default: `SORT_ASC`
109+
- Choices:
110+
- `SORT_ASC`
111+
- `SORT_DESC`
112+
- Description: This parameter allows you to control the order in which the objects are sorted. The default value is
113+
`SORT_ASC` which sorts the objects in ascending order. Setting this parameter to `SORT_DESC` will sort the objects in
114+
descending order. The behavior of this parameter varies based on the request method and endpoint type. Refer to the
115+
[Sorting](QUERIES_FILTERS_AND_SORTING.md#sorting) section for more information.

0 commit comments

Comments
 (0)