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

v2.2.0 Features & Fixes #574

Merged
merged 156 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
1a5615e
refactor: rename 'includes' directory to 'vendor'
jaredhendrickson13 Aug 31, 2024
3fc881c
chore: use autoload.php to include composer dependencies
jaredhendrickson13 Aug 31, 2024
9129231
build: don't exclude all vendor dirs in vagrant-build.sh
jaredhendrickson13 Aug 31, 2024
7e7e46c
build(deps): add webonyx/graphql-php to composer dependencies
jaredhendrickson13 Aug 31, 2024
6fe4754
style: run prettier on changed files
jaredhendrickson13 Aug 31, 2024
d346bef
feat: add to_upper_camel_case tools function with tests
jaredhendrickson13 Aug 31, 2024
de30577
feat: add ObjectField for arbitrary object types
jaredhendrickson13 Sep 4, 2024
16e3f31
feat: allow Models to indicate id type
jaredhendrickson13 Sep 4, 2024
69ab552
fix: allow Response::to_representation() to be extended
jaredhendrickson13 Sep 4, 2024
706fb7a
chore: set arg type for to_upper_camel_case
jaredhendrickson13 Sep 4, 2024
e250e66
feat: added Schema class for defining custom schemas
jaredhendrickson13 Sep 4, 2024
5b65c94
feat: add full GraphQL interface
jaredhendrickson13 Sep 4, 2024
918b03c
style: run prettier on changed files
jaredhendrickson13 Sep 4, 2024
2fc67ad
tests: add tests for GraphQL endpoints and responses
jaredhendrickson13 Sep 5, 2024
a73dbca
feat: respect privileges in GraphQL operations
jaredhendrickson13 Sep 5, 2024
8a54989
fix: ensure GraphQL error extensions are key-vals
jaredhendrickson13 Sep 5, 2024
9db1f10
docs: update documentation to include GraphQL docs
jaredhendrickson13 Sep 5, 2024
0277f97
chore: rename 'action' arg to 'resolver'
jaredhendrickson13 Sep 5, 2024
6e86c13
tests: add tests to ensure GraphQL privs are enforces
jaredhendrickson13 Sep 5, 2024
250a39c
docs: further clarify graphql documentation
jaredhendrickson13 Sep 5, 2024
edd44c6
style: run prettier on changed files
jaredhendrickson13 Sep 5, 2024
ff8c257
build: ensure build workflow uses vendor dir
jaredhendrickson13 Sep 5, 2024
ddde57c
chore: dont ignore vendor dir in resources
jaredhendrickson13 Sep 5, 2024
d494e20
refactor: move generate_docs into OpenAPISchema
jaredhendrickson13 Sep 6, 2024
4ba6764
refactor: replace generatedocs cli with buildschemas
jaredhendrickson13 Sep 6, 2024
433d424
docs: provide custom help text for graphql endpoint
jaredhendrickson13 Sep 6, 2024
a3bbf0e
docs: fix openapi schema endpoint ref in docs
jaredhendrickson13 Sep 6, 2024
b263062
docs: mention local graphql schema endpoint
jaredhendrickson13 Sep 6, 2024
d543225
docs: set GraphQL::$variables field as object in oas
jaredhendrickson13 Sep 6, 2024
4ef337a
docs: add missing phpdoc string for ObjectField::to_openapi_property
jaredhendrickson13 Sep 6, 2024
469a50e
style: ran prettier on changed files
jaredhendrickson13 Sep 6, 2024
adb4d0e
Merge branch 'master' of github.com:jaredhendrickson13/pfsense-api in…
jaredhendrickson13 Sep 7, 2024
4f1422d
fix: allow Response::to_openapi_component() to be extended
jaredhendrickson13 Sep 7, 2024
b8fe97b
refactor: allow OpenAPI responses to be extendable
jaredhendrickson13 Sep 7, 2024
24b0ed5
fix: better determine the 'Applies immediately' value
jaredhendrickson13 Sep 7, 2024
2eb7fd8
style: ran prettier on changed files
jaredhendrickson13 Sep 7, 2024
8994273
ci: fix schema url used for builds
jaredhendrickson13 Sep 7, 2024
739f345
feat: implement ca generate support #519
jaredhendrickson13 Sep 8, 2024
8f3403f
fix: better cleanup CAs after deletion
jaredhendrickson13 Sep 8, 2024
ca8a63b
feat: add ability to renew CAs
jaredhendrickson13 Sep 8, 2024
485beb9
fix: correct the verbose names for CertificateAuthorityGenerate
jaredhendrickson13 Sep 8, 2024
08fac91
tests: prevent CA tests from clobbering cpu
jaredhendrickson13 Sep 8, 2024
e3b3731
fix: use representation_only instead of write_only for x509 fields
jaredhendrickson13 Sep 8, 2024
b3bfa6f
fix: remove references to defunct CA 'method' field
jaredhendrickson13 Sep 8, 2024
d1a67e2
tests: add URLValidator to ensure field values are URLs
jaredhendrickson13 Sep 8, 2024
2fc1c36
feat: added ability to generate internal certificates
jaredhendrickson13 Sep 8, 2024
f8a44de
fix: do not allow non-renewable CAs to be renewed
jaredhendrickson13 Sep 8, 2024
11d7c6c
feat: allow existing Certificate's to be renewed
jaredhendrickson13 Sep 8, 2024
e0b8c48
style: ran prettier on changed files
jaredhendrickson13 Sep 8, 2024
38da430
feat: allow endpoints to control content handler options
jaredhendrickson13 Sep 9, 2024
0884d33
feat: allow content handlers to override OpenAPI schema
jaredhendrickson13 Sep 9, 2024
56ec5af
tests: update tests for new Endpoint functionalities
jaredhendrickson13 Sep 9, 2024
39620b9
fix: do not add accept types to response components
jaredhendrickson13 Sep 9, 2024
09fd1c9
feat: add BinaryContentHandler to handle application/octet-stream
jaredhendrickson13 Sep 9, 2024
5205c7f
feat: allow pkcs12 cert exports #470
jaredhendrickson13 Sep 9, 2024
2b2306a
style: ran prettier on changed files
jaredhendrickson13 Sep 9, 2024
47ee44f
chore: cleanup unused imports
jaredhendrickson13 Sep 9, 2024
7715eb5
docs: improve help text for pkcs12 export endpoint
jaredhendrickson13 Sep 9, 2024
4b183fe
style: run prettier on changed files
jaredhendrickson13 Sep 9, 2024
557c980
docs: allow content handlers to add model specific response schemas
jaredhendrickson13 Sep 10, 2024
8fb6b7a
fix: address openapi lint issues
jaredhendrickson13 Sep 10, 2024
66ed281
style: run prettier on changed files
jaredhendrickson13 Sep 10, 2024
e9efcd9
chore: remove unused imports
jaredhendrickson13 Sep 10, 2024
f38d613
Merge branch 'master' of github.com:jaredhendrickson13/pfsense-api in…
jaredhendrickson13 Sep 10, 2024
b9a99dd
feat: support deletion of DHCP leases #212
jaredhendrickson13 Sep 11, 2024
bd7c9ef
fix: rework the isc lease removal method
jaredhendrickson13 Sep 12, 2024
3d550fe
tests: add tests for deleting dhcp leases #212
jaredhendrickson13 Sep 12, 2024
ce0c396
feat: allow certs to be revoked via crl #166
jaredhendrickson13 Sep 13, 2024
447f1d5
feat: allow ModelSet's to be sorted
jaredhendrickson13 Sep 13, 2024
8673c14
fix: fixed an issue where NestedModelField's would overwrite write_on…
jaredhendrickson13 Sep 13, 2024
de0da20
fix: fixed issue where revoked cert attributes were overwritten
jaredhendrickson13 Sep 13, 2024
136189c
fix: unnecessary constant reference in ModelSet.inc
jaredhendrickson13 Sep 13, 2024
0368692
tests: add more crl/certificate tests
jaredhendrickson13 Sep 15, 2024
2155358
style: ran prettier on changed files
jaredhendrickson13 Sep 15, 2024
69c8a51
fix: make revoked cert reason default to 0
jaredhendrickson13 Sep 15, 2024
fac13c5
fix: correct sorting values for NestedModelFields
jaredhendrickson13 Sep 15, 2024
0a7e019
fix: ensure NestedModelField always validates empty values
jaredhendrickson13 Sep 15, 2024
927e405
tests: disabled flaky REST API sync test
jaredhendrickson13 Sep 15, 2024
3a8b636
feat: support sorting query responses
jaredhendrickson13 Sep 15, 2024
5f8603a
feat: allow sorting by multiple fields
jaredhendrickson13 Sep 15, 2024
b6a39fa
docs: fix doc consistency
jaredhendrickson13 Sep 15, 2024
94b66ec
docs: add sort parameters to OAS
jaredhendrickson13 Sep 16, 2024
e88bb62
style: ran prettier on changed files
jaredhendrickson13 Sep 16, 2024
bbfbae5
fix: fixed oas lint error in sort_order param
jaredhendrickson13 Sep 16, 2024
19b0235
tests: fixed broken Model query sort test
jaredhendrickson13 Sep 16, 2024
58f2a1e
feat: allow endpoints and clients to set sorting when writing to config
jaredhendrickson13 Sep 17, 2024
086ef39
fix: rename Model sort properties
jaredhendrickson13 Sep 17, 2024
2e53bcc
style: ran prettier on changed files
jaredhendrickson13 Sep 17, 2024
f953118
chore: fix typo in test name
jaredhendrickson13 Sep 17, 2024
5d07c05
fix: ensure model sort_by is always array
jaredhendrickson13 Sep 17, 2024
00eb57e
fix: remove leftover echo debug
jaredhendrickson13 Sep 17, 2024
066858d
feat: add sort_by and sort_order to GraphQL query schema
jaredhendrickson13 Sep 17, 2024
a3d4e16
feat: allow socket addrs in IPAddressValidator
jaredhendrickson13 Sep 18, 2024
90e7a69
feat: add LogSettings model, endpoint and tests
jaredhendrickson13 Sep 18, 2024
fe95e77
style: ran prettier on changed files
jaredhendrickson13 Sep 18, 2024
772e38c
fix: ensure GraphQL query sort_order param has sane default
jaredhendrickson13 Sep 18, 2024
a0e6a8c
fix: throw error if write lock attempts are exhausted
jaredhendrickson13 Sep 18, 2024
17d01ef
docs: add missing notes about remove control param #569
jaredhendrickson13 Sep 22, 2024
4ea2fa6
feat: add models and endpoints for BIND package #276
jaredhendrickson13 Sep 24, 2024
f74c89a
Merge branch 'master' of github.com:jaredhendrickson13/pfsense-api in…
jaredhendrickson13 Sep 24, 2024
ad8f999
fix: don't try to load model objects on construction with NestedModel…
jaredhendrickson13 Sep 24, 2024
20b40d0
fix: fixed bind config path in BINDSettings model
jaredhendrickson13 Sep 24, 2024
97f6eb1
fix: allow BINDSync remotehosts to be empty
jaredhendrickson13 Sep 24, 2024
e424e6f
fix: ensure BINDSettingsRemoteHost is not a many model
jaredhendrickson13 Sep 24, 2024
ca96a43
fix: change field 'reverse' to 'reversev4' to avoid reserve field nam…
jaredhendrickson13 Sep 24, 2024
dd173ce
fix: reference correct model in ServicesBINDSyncRemoteHostEndpoint.inc
jaredhendrickson13 Sep 24, 2024
bc0d9ac
tests: add tests for BINDSettings model
jaredhendrickson13 Sep 24, 2024
704b846
style: ran prettier on changed files
jaredhendrickson13 Sep 24, 2024
32f7530
chore: optimized imports
jaredhendrickson13 Sep 24, 2024
3bb9e02
fix: correct BINDSettings defaults
jaredhendrickson13 Sep 24, 2024
e9e2e55
tests: add tests for BINDAccessLists
jaredhendrickson13 Sep 25, 2024
95d50e1
style: ran prettier on changed files
jaredhendrickson13 Sep 25, 2024
90d8b96
tests: add tests for BINDView model
jaredhendrickson13 Sep 25, 2024
f25fe61
tests: add tests for BINDZone models
jaredhendrickson13 Sep 26, 2024
90d9f21
tests: add tests for BINDSync models
jaredhendrickson13 Sep 26, 2024
4ef1476
feat: add /api/v2/services/bind/sync/remote_hosts endpoint
jaredhendrickson13 Sep 26, 2024
d1701f9
feat: allow CSRs to be created #250
jaredhendrickson13 Sep 27, 2024
c16e63d
Merge branch 'master' of github.com:jaredhendrickson13/pfsense-api in…
jaredhendrickson13 Sep 29, 2024
d913919
fix: reload config after installing packages before tests
jaredhendrickson13 Sep 29, 2024
a867f29
refactor: separate common cert functions into trait
jaredhendrickson13 Sep 29, 2024
710eb12
feat: allow existing CSRs to be signed #250
jaredhendrickson13 Sep 29, 2024
be9deda
style: ran prettier on changed files
jaredhendrickson13 Sep 29, 2024
f0c8aa9
chore: cleanup unused imports
jaredhendrickson13 Sep 29, 2024
5abd973
feat: generate OpenVPNServer::$tls key if none was given #570
jaredhendrickson13 Sep 29, 2024
e852940
tests: only check for expected services in Service model test
jaredhendrickson13 Sep 29, 2024
05223ab
style: run prettier on changed files
jaredhendrickson13 Sep 29, 2024
92c2e0f
fix: put OpenVPNServer tls fields behind 'use_tls' condition #570
jaredhendrickson13 Sep 29, 2024
bcdf00a
style: ran prettier on changed files
jaredhendrickson13 Sep 29, 2024
6b58f5a
feat: add 'expose_sensitive_fields' field to RESTAPISettings
jaredhendrickson13 Sep 29, 2024
e89aa3d
feat: do not display sensitive fields in representation
jaredhendrickson13 Sep 29, 2024
f93c477
refactor: mark passwd/key/hash fields as sensitive
jaredhendrickson13 Sep 30, 2024
a5f37a9
style: ran prettier on changed files
jaredhendrickson13 Sep 30, 2024
d90868b
docs: update FAQ docs
jaredhendrickson13 Sep 30, 2024
35aa4e5
docs: provide more GraphQL use cases
jaredhendrickson13 Sep 30, 2024
4ba38a7
fix: correctly skip write only fields in representations
jaredhendrickson13 Sep 30, 2024
0d5e3e8
tests: add tests to ensure the 'expose_sensitive_fields' settings works
jaredhendrickson13 Sep 30, 2024
b779f2e
docs: simplify expose_sensitive_fields help text
jaredhendrickson13 Sep 30, 2024
4bf48f8
style: ran prettier on changed files
jaredhendrickson13 Sep 30, 2024
8a92787
fix: extend the RESTAPISettingsSync::$sync_data maximum length to 65535
jaredhendrickson13 Sep 30, 2024
bd02830
fix: allow internal_name and internal_namespace to be explicitly set …
jaredhendrickson13 Oct 1, 2024
e61f74d
feat: add models, endpoints and tests for IPsec statuses
jaredhendrickson13 Oct 1, 2024
0debb9e
Merge branch 'master' into next_minor
jaredhendrickson13 Oct 2, 2024
0db04a2
Merge branch 'master' into next_minor
jaredhendrickson13 Oct 2, 2024
0c07b99
fix(oas): ensure all array type schemas have items field
jaredhendrickson13 Oct 3, 2024
f3beef5
fix: extend maximum GraphQL query length
jaredhendrickson13 Oct 3, 2024
28943e9
fix: don't include the GraphQL endpoint/model equivalent in the Graph…
jaredhendrickson13 Oct 3, 2024
a4ee60f
docs: fix casing in QueryParamScalarType description
jaredhendrickson13 Oct 3, 2024
ead4d1e
ci: replace build_openapi job with build_schemas
jaredhendrickson13 Oct 3, 2024
f6163be
tests: ensure new ContentHandler OAS schema is correct in tests
jaredhendrickson13 Oct 3, 2024
7de8b48
docs: add additional info badges to README.md
jaredhendrickson13 Oct 4, 2024
da9f680
docs: add links to GraphQL schema in mkdocs site
jaredhendrickson13 Oct 4, 2024
d6fef47
docs: build/deploy graphql schema to mkdocs site
jaredhendrickson13 Oct 4, 2024
366b169
Merge branch 'next_minor' of github.com:jaredhendrickson13/pfsense-ap…
jaredhendrickson13 Oct 4, 2024
e98f4cf
docs: various documentation corrections
jaredhendrickson13 Oct 5, 2024
45ca14b
fix: don't check wg peer key format if it's empty #581
jaredhendrickson13 Oct 5, 2024
e1e4ce3
style: run prettier on README.md
jaredhendrickson13 Oct 5, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
sleep 5

- name: Fetch OpenAPI schema from pfSense
run: curl -s -k -u admin:pfsense -X GET https://${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com/api/v2/schema > openapi-${{ matrix.PFSENSE_VERSION }}.json
run: curl -s -k -u admin:pfsense -X GET https://${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com/api/v2/schema/openapi > openapi-${{ matrix.PFSENSE_VERSION }}.json

- name: Teardown pfSense VM
if: "${{ always() }}"
Expand Down
30 changes: 25 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
with:
files: pfSense-${{ matrix.PFSENSE_VERSION }}-pkg-RESTAPI.pkg

build_openapi:
build_schemas:
runs-on: self-hosted
needs: [release_pkg]
steps:
Expand Down Expand Up @@ -92,22 +92,31 @@ jobs:
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"
sleep 5

- name: Fetch OpenAPI schema from pfSense
run: curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema > openapi.json
- name: Fetch schemas from pfSense
run: |
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/openapi > openapi.json
curl -s -k -u admin:pfsense -X GET https://pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE.jaredhendrickson.com/api/v2/schema/graphql > schema.graphql

- name: Teardown pfSense VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE poweroff || true
/usr/local/bin/VBoxManage snapshot pfSense-${{ env.DEFAULT_PFSENSE_VERSION }}-RELEASE restore initial

- uses: actions/upload-artifact@v4
- name: Upload OpenAPI schema
uses: actions/upload-artifact@v4
with:
name: openapi.json
path: openapi.json

- name: Upload GraphQL schema
uses: actions/upload-artifact@v4
with:
name: schema.graphql
path: schema.graphql

release_docs:
needs: [build_openapi]
needs: [build_schemas]
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
environment:
Expand Down Expand Up @@ -139,6 +148,12 @@ jobs:
name: openapi.json
path: openapi.json

- name: Download GraphQL schema
uses: actions/download-artifact@v4
with:
name: schema.graphql
path: schema.graphql

- name: Build Swagger UI
run: |
mkdir -p ./www/api-docs/
Expand Down Expand Up @@ -166,6 +181,11 @@ jobs:
});
};' > ./www/api-docs/swagger-initializer.js

- name: Write GraphQL schema
run: |
mkdir -p ./www/graphql-docs/
cp schema.graphql/schema.graphql ./www/graphql-docs/schema.graphql

- name: Build PHP reference documentation
run: |
mkdir ./www/php-docs
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tests/e2e_test_framework/__pycache__/
.phplint-cache
*.pyc
venv/
vendor/
/vendor/
.vagrant
*.pkg
node_modules
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

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

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

## Key Features

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

## Quickstart

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require": {
"firebase/php-jwt": "v6.10.*"
"firebase/php-jwt": "v6.10.*",
"webonyx/graphql-php": "^15.13"
}
}
71 changes: 70 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/AUTHENTICATION_AND_AUTHORIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ curl -H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxx" https://pfsense.example.
### Custom Authentication

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

## Authorization

Expand Down
5 changes: 3 additions & 2 deletions docs/BUILDING_CUSTOM_ENDPOINT_CLASSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ classes are also responsible for following:
- Defining the URL path for the endpoint.
- Specifying which request methods are allowed.
- Adding additional documentation to the endpoint's OpenAPI definition.
- Defining an associated GraphQL query/mutation type.
- Generating the PHP file in the pfSense web root to expose the endpoint.

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

## Generating Documentation

To regenerate the OpenAPI documentation for all Endpoint classes, run the following command:
To regenerate the OpenAPI and GraphQL schemas for all Endpoint classes, run the following command:

```shell
pfsense-restapi generatedocs
pfsense-restapi buildschemas
```

## Examples
Expand Down
22 changes: 11 additions & 11 deletions docs/BUILDING_CUSTOM_MODEL_CLASSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,40 +232,40 @@ $this->unique_together_fields = ['name', 'port'];
- The `unique_together_fields` property is only applicable when the `many` property is set to `true`.
- The fields defined in the `unique_together_fields` property must be defined in the Model's Field objects.

### sort_by_field
### sort_by

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

Example:

```php
$this->sort_by_field = 'name';
$this->sort_by = ['name'];
```

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

### sort_option
### sort_order

The `sort_option` property is used to define the PHP sorting option for objects of the Model. When this property is set,
The `sort_order` property is used to define the PHP sorting option for objects of the Model. When this property is set,
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
[PHP multi-sort function type flags](https://www.php.net/manual/en/function.array-multisort.php).

Example:

```php
$this->sort_option = SORT_ASC;
$this->sort_order = SORT_ASC;
```

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

### subsystem

Expand Down
33 changes: 30 additions & 3 deletions docs/COMMON_CONTROL_PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ parameters you can use:
immediately.

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

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

!!! Warning
If you set this parameter to `true`, it will apply to all array fields. You can't choose to remove to some array
fields and replace others at the same time. To work around this, first make a request with the data for the fields
you want to remove from. Then, make another request for the fields you want to replace.

!!! Notes
- This parameter is only available for `PATCH` requests.
- This parameter is only applicable to array fields.
- 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.

## reverse

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

!!! Note
This parameter is only available for `GET` requests to [plural endpoints](ENDPOINT_TYPES.md#plural-many-endpoints).
## sort_by

- Type: String or Array
- Default: _Defaults to the primary sort attribute for the endpoint, typically `null`._
- Description: This parameters allows you to select the fields to use to sort the objects related to the endpoint. The
behavior of this parameter varies based on the request method and endpoint type. Refer to the
[Sorting](QUERIES_FILTERS_AND_SORTING.md#sorting) section for more information.

## sort_order

- Type: String
- Default: `SORT_ASC`
- Choices:
- `SORT_ASC`
- `SORT_DESC`
- Description: This parameter allows you to control the order in which the objects are sorted. The default value is
`SORT_ASC` which sorts the objects in ascending order. Setting this parameter to `SORT_DESC` will sort the objects in
descending order. The behavior of this parameter varies based on the request method and endpoint type. Refer to the
[Sorting](QUERIES_FILTERS_AND_SORTING.md#sorting) section for more information.
17 changes: 15 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ While not a PHP namespace, this directory contains common resources and tools us

Contains the cache files for the REST API package. Cache files are typically JSON datasets populated by [\RESTAPI\Core\Cache](https://pfrest.org/php-docs/classes/RESTAPI-Core-Cache.html) child classes and are refreshed on the schedule defined in the class.

#### includes/
#### vendor/

Contains additional PHP libraries and classes required by the REST API package. Because pfSense does not include a PHP package manager, these libraries are installed to this directory via composer when the package is built.

Expand Down Expand Up @@ -319,5 +319,18 @@ REST API > Documentation'. If you make changes to the package's codebase, you ca
to include the changes by running the following command on your pfSense instance:

```bash
pfsense-restapi generatedocs
pfsense-restapi buildschemas
```

### GraphQL

The GraphQL schema provides accurate documentation for the various GraphQL queries and mutations available in the package.
The GraphQL schema is automatically generated by the package using properties defined in Endpoint, Models, and Fields.
Each of these classes have properties that map to GraphQL properties and are used to generate the GraphQL schema. The
GraphQL schema is automatically generated when the package is initially installed and the GraphQL schema is accessible
at /api/v2/graphql/schema. If you make changes to the package's codebase, you can regenerate the GraphQL schema to include
the changes by running the following command on your pfSense instance:

```bash
pfsense-restapi buildschemas
```
Loading