@@ -29,7 +29,7 @@ changes will be made available upon the next release.
2929Coding Conventions
3030------------------
3131Make an attempt to match the format of existing code. The basic conventions are:
32- - Comments are recommended as long as they are brief, meaningful, and short
32+ - Comments are recommended as long as they are brief, meaningful, and non-intrusive
3333- Variables should be defined using snake case (e.g. snake_case)
3434- Functions should be defined using snake case (e.g. snake_case())
3535- Constants should be defined using upper snake case (e.g. SNAKE_CASE)
@@ -45,7 +45,7 @@ a few different components. It is strongly recommended that you familiarize your
4545diving into creating endpoints. To get started writing your own endpoints, please follow the steps below:
4646
4747### Things to Know ###
48- - The API is based on REST principals. Unfortunately, pfSense does not allow any custom changes to the NGINX
48+ - The API is based on REST principals. Unfortunately, pfSense does not seem to allow any custom changes to the NGINX
4949 configuration so alternate request methods like ` PUT ` and ` DELETE ` do not appear to be possible. To accommodate this,
5050 the requested action must be defined in the endpoint path.
5151 - Create actions must be a ` POST ` request to an endpoint ending in ` /add/ `
@@ -59,7 +59,7 @@ diving into creating endpoints. To get started writing your own endpoints, pleas
5959### Writing the API model ###
6060At the core of the API endpoint is the API model. This is a class that validates client request data, writes changes
6161to the pfSense configuration file, and makes any corresponding system changes. pfSense API is distributed with a
62- custom microframework to accommodate developers wanting to contribute or create their own API models and endpoints.
62+ custom micro-framework to accommodate developers wanting to contribute or create their own API models and endpoints.
6363
6464#### Getting Started ####
6565To get started creating a new API model, you first need to create a new PHP file in ` /files/etc/inc/api/api_models ` and
@@ -76,7 +76,7 @@ class NewAPIModel extends APIBaseModel {
7676
7777#### Constructing the API Model ####
7878In order to use the APIBaseModel framework, you must add a ` __construct() ` method to your new API model class and
79- initialize the APIBaseModel class as such. Additionally, you will specify your model attribute overrides within this
79+ initialize the APIBaseModel class as such. Additionally, you may specify any model attribute overrides within this
8080method:
8181
8282``` php
@@ -111,7 +111,7 @@ privileges can be found here: https://github.com/pfsense/pfsense/blob/master/src
111111- ` $this->requires_auth ` : Specify whether authentication and authorization is required for the API model. If set to
112112` false ` clients will not have to authenticate or have privilege to access. Defaults to ` true ` .
113113
114- - ` $this->set_auth_mode ` : Allows you to statically specify the API authentication mode. For example, if you are
114+ - ` $this->set_auth_mode ` : Allows you to explicitly specify the API authentication mode. For example, if you are
115115writing a model that tests user's local database credentials and do not want the model to assume the API's configured
116116auth mode you would specify ` $this->set_auth_mode = "local"; ` to always force local authentication. Defaults to the
117117API's configured auth mode in the /api/ webConfigurator page.
@@ -286,21 +286,9 @@ Often times you will need to create functions to condense redundant tasks. You c
286286` $some_variable = APITools\your_custom_tool_function(); `
287287
288288### Adding Models and Endpoints to the Package
289- After you have written your API models and endpoint and have tested it's functionality, you must specify your endpoint
290- files in the package makefile. Otherwise, it will not be included in the package in the next release.
291-
292- 1 . Add the following lines to the ` Makefile ` located in this repo. ** Be sure to change the file paths to match the files
293- you have created** :
294- ```
295- ${MKDIR} ${STAGEDIR}${PREFIX}/www/api/v1/system/test
296- ${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/api/v1/system/test/index.php \
297- ${STAGEDIR}${PREFIX}/www/api/v1/system/test
298- ```
299- 2 . Add the following lines to the ` pkg-plist ` file located in this repo. Be sure to change the file paths to match the
300- files you have created:
301- - For each directory created, add: ` @dir /usr/local/www/api/v1/status/carp/modify `
302- - For each index.php endpoint created, add ` /usr/local/www/api/v1/status/carp/modify/index.php `
303- - For each API model file created, add ` /etc/inc/api/api_models/YourAPIModel.inc `
289+ The package Makefile and pkg-plist files are auto generated by ` tools/make_package.py ` . This simply pulls the files and
290+ directories needed to build our package from the ` files ` directory. For more information on building the package, refer
291+ to ` tools/README.md `
304292
305293
306294Questions
0 commit comments