Skip to content

Firewall

firewall-rule related things

AliasTypes

Bases: str, Enum

types for firewall aliases

Source code in pfsense_api_client/firewall.py
67
68
69
70
71
72
class AliasTypes(str, Enum):
    """types for firewall aliases"""

    host = "host"  # pylint: disable=invalid-name
    network = "network"  # pylint: disable=invalid-name
    port = "port"  # pylint: disable=invalid-name

FirewallAliasUpdate

Bases: pydantic.BaseModel

validating the firewall alias update

Source code in pfsense_api_client/firewall.py
76
77
78
79
80
81
82
83
84
class FirewallAliasUpdate(pydantic.BaseModel):
    """validating the firewall alias update"""

    name: str
    type: AliasTypes
    descr: Optional[str]
    address: Union[str, List[str]]
    detail: Union[str, List[str]]
    apply: bool

FirewallMixin

Bases: BasePFSenseAPIClient

mixin class for firewall functions

Source code in pfsense_api_client/firewall.py
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
class FirewallMixin(BasePFSenseAPIClient):
    """ mixin class for firewall functions """

    def get_firewall_alias(
        self, **kwargs: Any
    ) -> requests.Response:
        """get a list of firewall aliases
        https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-aliases
        """
        url = "/api/v1/firewall/alias"
        return self.call(url=url, payload=dict(kwargs))


    # pylint: disable=too-many-arguments
    @pydantic.validate_arguments()
    def create_firewall_alias(
        self,
        name: str,
        alias_type: str,
        descr: str,
        address: Union[str, List[str]],
        detail: Union[str, List[str]],
        apply: bool = True,
    ) -> requests.Response:
        """Add a new host, network or port firewall alias.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-aliases
        """
        url = "/api/v1/firewall/alias"
        method = "POST"
        payload = {}

        class FirewallAlias(pydantic.BaseModel):
            """validating the firewall alias"""

            name: str
            type: AliasTypes
            descr: str
            address: Union[str, List[str]]
            detail: Union[str, List[str]]
            apply: bool

        payload = FirewallAlias(
            name=name,
            type=alias_type,
            descr=descr,
            address=address,
            detail=detail,
            apply=apply,
        ).dict()

        return self.call(
            url=url,
            method=method,
            payload=payload,
        )


    @pydantic.validate_arguments()
    def delete_firewall_alias(
        self,
        name: str,
        apply: bool = True,
    ) -> requests.Response:
        """Delete an existing alias and (optionally) reload filter.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-aliases

            field: id in the API is 'name' because 'id' is reserved in python.
        """
        url = "/api/v1/firewall/alias"
        method = "DELETE"
        payload = {"id": name, "apply": apply}
        return self.call(url=url, method=method, payload=payload)



    @pydantic.validate_arguments
    def update_firewall_alias(
        self, *args: FirewallAliasUpdate
    ) -> requests.Response:
        """Modify an existing firewall alias.

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-aliases
        """
        method = "PUT"
        url = "/api/v1/firewall/alias"

        payload = FirewallAliasUpdate(*args).dict()

        return self.call(url=url, method=method, payload=payload)


    def create_firewall_alias_entry(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add new entries to an existing firewall alias.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-alias-entries
        """

        method = "POST"
        url = "/api/v1/firewall/alias/entry"
        return self.call(url=url, method=method, payload=args)


    def delete_firewall_alias_entry(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete existing entries from an existing firewall alias.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-alias-entries"""
        method = "DELETE"
        url = "/api/v1/firewall/alias/entry"
        return self.call(url=url, method=method, payload=args)


    def apply_firewall_changes(self) -> requests.Response:
        """Apply pending firewall changes. This will reload all filter items. This endpoint returns no data.

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-apply-firewall
        """

        url = "/api/v1/firewall/apply"
        method = "POST"
        return self.call(url, method)


    def create_firewall_nat_one_to_one(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a new NAT 1:1 Mapping.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-nat-1-to-1-mappings"""
        method = "POST"
        url = "/api/v1/firewall/nat/one_to_one"
        return self.call(url=url, method=method, payload=args)


    def delete_firewall_nat_one_to_one(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a NAT 1:1 Mapping.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-1-to-1-mappings"""
        method = "DELETE"
        url = "/api/v1/firewall/nat/one_to_one"
        return self.call(url=url, method=method, payload=args)


    def update_firewall_nat_one_to_one(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update a NAT 1:1 Mapping.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-1-to-1-mappings"""
        method = "PUT"
        url = "/api/v1/firewall/nat/one_to_one"
        return self.call(url=url, method=method, payload=args)


    def get_firewall_nat_one_to_one(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read 1:1 NAT mappings.

        https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-1-to-1-mappings
        """
        url = "/api/v1/firewall/nat/one_to_one"
        return self.call(url, payload=kwargs)


    def update_nat_outbound_settings(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """mode: str, apply: Optional[bool]
        Update outbound NAT mode settings.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-outbound-nat-settings"""
        method = "PUT"
        url = "/api/v1/firewall/nat/outbound"
        return self.call(url, method=method, payload=args)


    def create_outbound_nat_mapping(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Create new outbound NAT mappings.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-outbound-nat-mappings"""
        method = "POST"
        url = "/api/v1/firewall/nat/outbound/mapping"
        return self.call(url, method=method, payload=args)


    def delete_outbound_nat_mapping(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """name: str
        apply: Optional[bool]
        Delete outbound NAT mappings.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-outbound-nat-mappings"""
        method = "DELETE"
        url = "/api/v1/firewall/nat/outbound/mapping"
        return self.call(url, method=method, payload=args)


    def get_nat_outbound_mapping(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read existing outbound NAT mode mappings.

        https://github.com/jaredhendrickson13/pfsense-api#3-read-outbound-nat-mappings
        """
        url = "/api/v1/firewall/nat/outbound/mapping"
        return self.call(url, payload=kwargs)


    def update_outbound_nat_mapping(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update existing outbound NAT mappings.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-outbound-nat-mappings"""
        method = "PUT"
        url = "/api/v1/firewall/nat/outbound/mapping"
        return self.call(url=url, method=method, payload=args)


    def create_nat_port_forward(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a new NAT port forward rule."""
        url = "/api/v1/firewall/nat/port_forward"
        method = "POST"
        return self.call(url=url, method=method, payload=args)


    def delete_nat_port_forward(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a NAT port forward rule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-port-forwards"""
        # name: str
        # apply: Optional[bool]
        url = "/api/v1/firewall/nat/port_forward"
        method = "DELETE"
        return self.call(url=url, method=method, payload=args)


    def get_firewall_nat_port_forward(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read NAT port forward rules.

        https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-port-forwards"""
        url = "/api/v1/firewall/nat/port_forward"
        return self.call(url, payload=kwargs)


    def update_nat_port_forward(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update a NAT port forward rule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-port-forwards"""
        method = "PUT"
        url = "/api/v1/firewall/nat/port_forward"
        return self.call(url=url, method=method, payload=args)


    # pylint: disable=line-too-long
    def delete_all_firewall_rules(self) -> requests.Response:
        """Deletes all existing firewall rules. This is useful for scripts that need to setup the firewall rules from scratch.

        Note: this endpoint will not reload the firewall filter automatically, you must make another API call to the /api/v1/firewall/apply endpoint to do so. Ensure firewall rules are created before reloading the filter to prevent lockout!.

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-delete-all-firewall-rules"""
        url = "/api/v1/firewall/rule/flush"
        method = "DELETE"
        return self.call(url=url, method=method)


    def create_firewall_schedule(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a firewall schedule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule"""
        url = "/api/v1/firewall/schedule"
        method = "POST"
        return self.call(url=url, method=method, payload=args)


    def delete_firewall_schedule(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a firewall schedule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule"""
        method = "DELETE"
        url = "/api/v1/firewall/schedule"
        return self.call(url=url, method=method, payload=args)


    def get_firewall_schedule(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read all existing firewall schedules."""
        url = "/api/v1/firewall/schedule"
        return self.call(url, payload=kwargs)


    def update_firewall_schedule(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update a firewall schedule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-schedule"""
        method = "PUT"
        url = "/api/v1/firewall/schedule"
        return self.call(url=url, method=method, payload=args)


    def create_schedule_time_range(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a time range to an existing firewall schedule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule-time-range"""
        method = "POST"
        url = "/api/v1/firewall/schedule/time_range"
        return self.call(url=url, method=method, payload=args)


    def delete_schedule_time_range(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a time range from an existing firewall schedule.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule-time-range"""
        method = "DELETE"
        url = "/api/v1/firewall/schedule/time_range"
        return self.call(url=url, method=method, payload=args)


    def get_firewall_states(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read the current firewall states.

        https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-states
        """
        url = "/api/v1/firewall/states"
        return self.call(url, payload=kwargs)


    def get_firewall_states_size(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read the maximum firewall state size, the current firewall state size, and the default firewall state size.

        https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-state-size
        """
        url = "/api/v1/firewall/states/size"
        return self.call(url, payload=kwargs)


    def update_firewall_state_size(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Modify the maximum number of firewall state table entries allowed by the system
        Note: use caution when making this call, setting the maximum state table size to a value lower than the current number of firewall state entries WILL choke the system
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-firewall-state-size"""

        # TODO: Add a check for current states > state size and require the user to pass force=True if they want to bypass the state check
        method = "PUT"
        url = "/api/v1/firewall/states/size"
        return self.call(url=url, method=method, payload=args)


    def create_traffic_shaper(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a traffic shaper policy to an interface.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper"""
        method = "POST"
        url = "/api/v1/firewall/traffic_shaper"
        return self.call(url=url, method=method, payload=args)


    def delete_traffic_shaper(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a traffic shaper policy from an interface.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper"""
        method = "DELETE"
        url = "/api/v1/firewall/traffic_shaper"
        return self.call(url=url, method=method, payload=args)


    def get_traffic_shaper(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read all configured traffic shapers.

        https://github.com/jaredhendrickson13/pfsense-api#3-read-traffic-shapers
        """
        url = "/api/v1/firewall/traffic_shaper"
        return self.call(url, payload=kwargs)


    def update_traffic_shaper(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update a traffic shaper policy for an interface.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-traffic-shaper"""
        url = "/api/v1/firewall/traffic_shaper"
        method = "PUT"
        return self.call(url=url, method=method, payload=args)


    def create_traffic_shaper_limiter(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a traffic shaper limiter.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter"""
        url = "/api/v1/firewall/traffic_shaper/limiter"
        method = "POST"
        return self.call(url=url, method=method, payload=args)


    def delete_traffic_shaper_limiter(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a traffic shaper limiter.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter"""
        method = "POST"
        url = "/api/v1/firewall/traffic_shaper/limiter"
        return self.call(url=url, method=method, payload=args)


    def get_traffic_shaper_limiter(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Get the traffic shaper limiters

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-limiters"""
        url = "/api/v1/firewall/traffic_shaper/limiter"
        return self.call(url, payload=kwargs)


    def create_limiter_bandwidth(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Create a limiter bandwidth setting.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-bandwidth"""
        method = "POST"
        url = "/api/v1/firewall/traffic_shaper/limiter/bandwidth"
        return self.call(url=url, method=method, payload=args)


    def delete_limiter_bandwidth(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a limiter bandwidth setting.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-bandwidth"""
        method = "DELETE"
        url = "/api/v1/firewall/traffic_shaper/limiter/bandwidth"
        return self.call(url=url, method=method, payload=args)


    def create_limiter_queue(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a child queue to an existing traffic shaper limiter
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-queue"""
        method = "POST"
        url = "/api/v1/firewall/traffic_shaper/limiter/queue"
        return self.call(url=url, method=method, payload=args)


    def delete_limiter_queue(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a child queue from an existing traffic shaper limiter
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-queue"""
        method = "DELETE"
        url = "/api/v1/firewall/traffic_shaper/limiter/queue"
        return self.call(url, method=method, payload=args)


    def create_firewall_rule(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Create firewall rules

        https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules"""
        url = "/api/v1/firewall/rule"
        method = "POST"
        return self.call(url=url, method=method, payload=args)


    @pydantic.validate_arguments
    def delete_firewall_rule(
        self, name: str, apply: Optional[bool]
    ) -> requests.Response:
        """Delete firewall rules

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-rules
        """
        url = "/api/v1/firewall/rule"
        method = "DELETE"

        payload: Dict[str, Union[str, bool]] = {"name": name}
        if apply:
            payload["apply"] = apply
        return self.call(url=url, method=method, payload=payload)


    def update_firewall_rule(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update firewall rules

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-rules
        """
        url = "/api/v1/firewall/rule"
        method = "PUT"
        return self.call(url=url, method=method, payload=args)


    def get_firewall_rule(
        self, **kwargs: Optional[Any]
    ) -> requests.Response:
        """Read firewall rules

        https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules
        """
        url = "/api/v1/firewall/rule"
        return self.call(url=url, payload=kwargs)


    def create_traffic_shaper_queue(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a queue to an traffic shaper interface.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper-queue"""
        method = "POST"
        url = "https://{{$hostname}}/api/v1/firewall/traffic_shaper/queue"
        return self.call(url=url, method=method, payload=args)


    def delete_traffic_shaper_queue(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a queue from an traffic shaper interface.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper-queue"""
        method = "DELETE"
        url = "https://{{$hostname}}/api/v1/firewall/traffic_shaper/queue"
        return self.call(url=url, method=method, payload=args)


    def create_virtual_ip(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Add a new virtual IP.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-virtual-ips"""
        method = "POST"
        url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
        return self.call(url=url, method=method, payload=args)


    def delete_virtual_ip(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Delete a virtual IP.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-virtual-ips"""
        method = "DELETE"
        url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
        return self.call(url=url, method=method, payload=args)


    def get_virtual_ip(
        self, **kwargs: Dict[str, Any]
    ) -> requests.Response:
        """Read virtual IP assignments.

        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-virtual-ips"""
        return self.call("/api/v1/firewall/virtual_ip", payload=kwargs)


    def update_virtual_ip(
        self, **args: Dict[str, Any]
    ) -> requests.Response:
        """Update a virtual IP.
        https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-virtual-ips"""
        method = "PUT"
        url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
        return self.call(url=url, method=method, payload=args)

apply_firewall_changes()

Apply pending firewall changes. This will reload all filter items. This endpoint returns no data.

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-apply-firewall

Source code in pfsense_api_client/firewall.py
200
201
202
203
204
205
206
207
208
def apply_firewall_changes(self) -> requests.Response:
    """Apply pending firewall changes. This will reload all filter items. This endpoint returns no data.

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-apply-firewall
    """

    url = "/api/v1/firewall/apply"
    method = "POST"
    return self.call(url, method)

create_firewall_alias(name, alias_type, descr, address, detail, apply=True)

Add a new host, network or port firewall alias. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-aliases

Source code in pfsense_api_client/firewall.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@pydantic.validate_arguments()
def create_firewall_alias(
    self,
    name: str,
    alias_type: str,
    descr: str,
    address: Union[str, List[str]],
    detail: Union[str, List[str]],
    apply: bool = True,
) -> requests.Response:
    """Add a new host, network or port firewall alias.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-aliases
    """
    url = "/api/v1/firewall/alias"
    method = "POST"
    payload = {}

    class FirewallAlias(pydantic.BaseModel):
        """validating the firewall alias"""

        name: str
        type: AliasTypes
        descr: str
        address: Union[str, List[str]]
        detail: Union[str, List[str]]
        apply: bool

    payload = FirewallAlias(
        name=name,
        type=alias_type,
        descr=descr,
        address=address,
        detail=detail,
        apply=apply,
    ).dict()

    return self.call(
        url=url,
        method=method,
        payload=payload,
    )

create_firewall_alias_entry(**args)

Add new entries to an existing firewall alias. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-alias-entries

Source code in pfsense_api_client/firewall.py
178
179
180
181
182
183
184
185
186
187
def create_firewall_alias_entry(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add new entries to an existing firewall alias.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-firewall-alias-entries
    """

    method = "POST"
    url = "/api/v1/firewall/alias/entry"
    return self.call(url=url, method=method, payload=args)

create_firewall_nat_one_to_one(**args)

Add a new NAT 1:1 Mapping. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-nat-1-to-1-mappings

Source code in pfsense_api_client/firewall.py
211
212
213
214
215
216
217
218
def create_firewall_nat_one_to_one(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a new NAT 1:1 Mapping.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-nat-1-to-1-mappings"""
    method = "POST"
    url = "/api/v1/firewall/nat/one_to_one"
    return self.call(url=url, method=method, payload=args)

create_firewall_rule(**args)

Create firewall rules

https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules

Source code in pfsense_api_client/firewall.py
563
564
565
566
567
568
569
570
571
def create_firewall_rule(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Create firewall rules

    https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules"""
    url = "/api/v1/firewall/rule"
    method = "POST"
    return self.call(url=url, method=method, payload=args)

create_firewall_schedule(**args)

Add a firewall schedule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule

Source code in pfsense_api_client/firewall.py
359
360
361
362
363
364
365
366
def create_firewall_schedule(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a firewall schedule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule"""
    url = "/api/v1/firewall/schedule"
    method = "POST"
    return self.call(url=url, method=method, payload=args)

create_limiter_bandwidth(**args)

Create a limiter bandwidth setting. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-bandwidth

Source code in pfsense_api_client/firewall.py
523
524
525
526
527
528
529
530
def create_limiter_bandwidth(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Create a limiter bandwidth setting.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-bandwidth"""
    method = "POST"
    url = "/api/v1/firewall/traffic_shaper/limiter/bandwidth"
    return self.call(url=url, method=method, payload=args)

create_limiter_queue(**args)

Add a child queue to an existing traffic shaper limiter https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-queue

Source code in pfsense_api_client/firewall.py
543
544
545
546
547
548
549
550
def create_limiter_queue(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a child queue to an existing traffic shaper limiter
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter-queue"""
    method = "POST"
    url = "/api/v1/firewall/traffic_shaper/limiter/queue"
    return self.call(url=url, method=method, payload=args)

create_nat_port_forward(**args)

Add a new NAT port forward rule.

Source code in pfsense_api_client/firewall.py
306
307
308
309
310
311
312
def create_nat_port_forward(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a new NAT port forward rule."""
    url = "/api/v1/firewall/nat/port_forward"
    method = "POST"
    return self.call(url=url, method=method, payload=args)

create_outbound_nat_mapping(**args)

Create new outbound NAT mappings. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-outbound-nat-mappings

Source code in pfsense_api_client/firewall.py
263
264
265
266
267
268
269
270
def create_outbound_nat_mapping(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Create new outbound NAT mappings.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-outbound-nat-mappings"""
    method = "POST"
    url = "/api/v1/firewall/nat/outbound/mapping"
    return self.call(url, method=method, payload=args)

create_schedule_time_range(**args)

Add a time range to an existing firewall schedule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule-time-range

Source code in pfsense_api_client/firewall.py
397
398
399
400
401
402
403
404
def create_schedule_time_range(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a time range to an existing firewall schedule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-schedule-time-range"""
    method = "POST"
    url = "/api/v1/firewall/schedule/time_range"
    return self.call(url=url, method=method, payload=args)

create_traffic_shaper(**args)

Add a traffic shaper policy to an interface. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper

Source code in pfsense_api_client/firewall.py
452
453
454
455
456
457
458
459
def create_traffic_shaper(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a traffic shaper policy to an interface.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper"""
    method = "POST"
    url = "/api/v1/firewall/traffic_shaper"
    return self.call(url=url, method=method, payload=args)

create_traffic_shaper_limiter(**args)

Add a traffic shaper limiter. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter

Source code in pfsense_api_client/firewall.py
493
494
495
496
497
498
499
500
def create_traffic_shaper_limiter(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a traffic shaper limiter.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-limiter"""
    url = "/api/v1/firewall/traffic_shaper/limiter"
    method = "POST"
    return self.call(url=url, method=method, payload=args)

create_traffic_shaper_queue(**args)

Add a queue to an traffic shaper interface. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper-queue

Source code in pfsense_api_client/firewall.py
614
615
616
617
618
619
620
621
def create_traffic_shaper_queue(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a queue to an traffic shaper interface.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-traffic-shaper-queue"""
    method = "POST"
    url = "https://{{$hostname}}/api/v1/firewall/traffic_shaper/queue"
    return self.call(url=url, method=method, payload=args)

create_virtual_ip(**args)

Add a new virtual IP. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-virtual-ips

Source code in pfsense_api_client/firewall.py
634
635
636
637
638
639
640
641
def create_virtual_ip(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a new virtual IP.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-create-virtual-ips"""
    method = "POST"
    url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
    return self.call(url=url, method=method, payload=args)

delete_all_firewall_rules()

Deletes all existing firewall rules. This is useful for scripts that need to setup the firewall rules from scratch.

Note: this endpoint will not reload the firewall filter automatically, you must make another API call to the /api/v1/firewall/apply endpoint to do so. Ensure firewall rules are created before reloading the filter to prevent lockout!.

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-delete-all-firewall-rules

Source code in pfsense_api_client/firewall.py
348
349
350
351
352
353
354
355
356
def delete_all_firewall_rules(self) -> requests.Response:
    """Deletes all existing firewall rules. This is useful for scripts that need to setup the firewall rules from scratch.

    Note: this endpoint will not reload the firewall filter automatically, you must make another API call to the /api/v1/firewall/apply endpoint to do so. Ensure firewall rules are created before reloading the filter to prevent lockout!.

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#1-delete-all-firewall-rules"""
    url = "/api/v1/firewall/rule/flush"
    method = "DELETE"
    return self.call(url=url, method=method)

delete_firewall_alias(name, apply=True)

Delete an existing alias and (optionally) reload filter. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-aliases

field: id in the API is 'name' because 'id' is reserved in python.
Source code in pfsense_api_client/firewall.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
@pydantic.validate_arguments()
def delete_firewall_alias(
    self,
    name: str,
    apply: bool = True,
) -> requests.Response:
    """Delete an existing alias and (optionally) reload filter.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-aliases

        field: id in the API is 'name' because 'id' is reserved in python.
    """
    url = "/api/v1/firewall/alias"
    method = "DELETE"
    payload = {"id": name, "apply": apply}
    return self.call(url=url, method=method, payload=payload)

delete_firewall_alias_entry(**args)

Delete existing entries from an existing firewall alias. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-alias-entries

Source code in pfsense_api_client/firewall.py
190
191
192
193
194
195
196
197
def delete_firewall_alias_entry(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete existing entries from an existing firewall alias.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-alias-entries"""
    method = "DELETE"
    url = "/api/v1/firewall/alias/entry"
    return self.call(url=url, method=method, payload=args)

delete_firewall_nat_one_to_one(**args)

Delete a NAT 1:1 Mapping. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-1-to-1-mappings

Source code in pfsense_api_client/firewall.py
221
222
223
224
225
226
227
228
def delete_firewall_nat_one_to_one(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a NAT 1:1 Mapping.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-1-to-1-mappings"""
    method = "DELETE"
    url = "/api/v1/firewall/nat/one_to_one"
    return self.call(url=url, method=method, payload=args)

delete_firewall_rule(name, apply)

Delete firewall rules

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-rules

Source code in pfsense_api_client/firewall.py
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
@pydantic.validate_arguments
def delete_firewall_rule(
    self, name: str, apply: Optional[bool]
) -> requests.Response:
    """Delete firewall rules

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-firewall-rules
    """
    url = "/api/v1/firewall/rule"
    method = "DELETE"

    payload: Dict[str, Union[str, bool]] = {"name": name}
    if apply:
        payload["apply"] = apply
    return self.call(url=url, method=method, payload=payload)

delete_firewall_schedule(**args)

Delete a firewall schedule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule

Source code in pfsense_api_client/firewall.py
369
370
371
372
373
374
375
376
def delete_firewall_schedule(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a firewall schedule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule"""
    method = "DELETE"
    url = "/api/v1/firewall/schedule"
    return self.call(url=url, method=method, payload=args)

delete_limiter_bandwidth(**args)

Delete a limiter bandwidth setting. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-bandwidth

Source code in pfsense_api_client/firewall.py
533
534
535
536
537
538
539
540
def delete_limiter_bandwidth(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a limiter bandwidth setting.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-bandwidth"""
    method = "DELETE"
    url = "/api/v1/firewall/traffic_shaper/limiter/bandwidth"
    return self.call(url=url, method=method, payload=args)

delete_limiter_queue(**args)

Delete a child queue from an existing traffic shaper limiter https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-queue

Source code in pfsense_api_client/firewall.py
553
554
555
556
557
558
559
560
def delete_limiter_queue(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a child queue from an existing traffic shaper limiter
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter-queue"""
    method = "DELETE"
    url = "/api/v1/firewall/traffic_shaper/limiter/queue"
    return self.call(url, method=method, payload=args)

delete_nat_port_forward(**args)

Delete a NAT port forward rule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-port-forwards

Source code in pfsense_api_client/firewall.py
315
316
317
318
319
320
321
322
323
324
def delete_nat_port_forward(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a NAT port forward rule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-nat-port-forwards"""
    # name: str
    # apply: Optional[bool]
    url = "/api/v1/firewall/nat/port_forward"
    method = "DELETE"
    return self.call(url=url, method=method, payload=args)

delete_outbound_nat_mapping(**args)

name: str apply: Optional[bool] Delete outbound NAT mappings. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-outbound-nat-mappings

Source code in pfsense_api_client/firewall.py
273
274
275
276
277
278
279
280
281
282
def delete_outbound_nat_mapping(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """name: str
    apply: Optional[bool]
    Delete outbound NAT mappings.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-outbound-nat-mappings"""
    method = "DELETE"
    url = "/api/v1/firewall/nat/outbound/mapping"
    return self.call(url, method=method, payload=args)

delete_schedule_time_range(**args)

Delete a time range from an existing firewall schedule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule-time-range

Source code in pfsense_api_client/firewall.py
407
408
409
410
411
412
413
414
def delete_schedule_time_range(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a time range from an existing firewall schedule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-schedule-time-range"""
    method = "DELETE"
    url = "/api/v1/firewall/schedule/time_range"
    return self.call(url=url, method=method, payload=args)

delete_traffic_shaper(**args)

Delete a traffic shaper policy from an interface. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper

Source code in pfsense_api_client/firewall.py
462
463
464
465
466
467
468
469
def delete_traffic_shaper(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a traffic shaper policy from an interface.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper"""
    method = "DELETE"
    url = "/api/v1/firewall/traffic_shaper"
    return self.call(url=url, method=method, payload=args)

delete_traffic_shaper_limiter(**args)

Add a traffic shaper limiter. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter

Source code in pfsense_api_client/firewall.py
503
504
505
506
507
508
509
510
def delete_traffic_shaper_limiter(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Add a traffic shaper limiter.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-limiter"""
    method = "POST"
    url = "/api/v1/firewall/traffic_shaper/limiter"
    return self.call(url=url, method=method, payload=args)

delete_traffic_shaper_queue(**args)

Delete a queue from an traffic shaper interface. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper-queue

Source code in pfsense_api_client/firewall.py
624
625
626
627
628
629
630
631
def delete_traffic_shaper_queue(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a queue from an traffic shaper interface.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-traffic-shaper-queue"""
    method = "DELETE"
    url = "https://{{$hostname}}/api/v1/firewall/traffic_shaper/queue"
    return self.call(url=url, method=method, payload=args)

delete_virtual_ip(**args)

Delete a virtual IP. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-virtual-ips

Source code in pfsense_api_client/firewall.py
644
645
646
647
648
649
650
651
def delete_virtual_ip(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Delete a virtual IP.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-delete-virtual-ips"""
    method = "DELETE"
    url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
    return self.call(url=url, method=method, payload=args)

get_firewall_alias(**kwargs)

get a list of firewall aliases https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-aliases

Source code in pfsense_api_client/firewall.py
90
91
92
93
94
95
96
97
def get_firewall_alias(
    self, **kwargs: Any
) -> requests.Response:
    """get a list of firewall aliases
    https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-aliases
    """
    url = "/api/v1/firewall/alias"
    return self.call(url=url, payload=dict(kwargs))

get_firewall_nat_one_to_one(**kwargs)

Read 1:1 NAT mappings.

https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-1-to-1-mappings

Source code in pfsense_api_client/firewall.py
241
242
243
244
245
246
247
248
249
def get_firewall_nat_one_to_one(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read 1:1 NAT mappings.

    https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-1-to-1-mappings
    """
    url = "/api/v1/firewall/nat/one_to_one"
    return self.call(url, payload=kwargs)

get_firewall_nat_port_forward(**kwargs)

Read NAT port forward rules.

https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-port-forwards

Source code in pfsense_api_client/firewall.py
327
328
329
330
331
332
333
334
def get_firewall_nat_port_forward(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read NAT port forward rules.

    https://github.com/jaredhendrickson13/pfsense-api#3-read-nat-port-forwards"""
    url = "/api/v1/firewall/nat/port_forward"
    return self.call(url, payload=kwargs)

get_firewall_rule(**kwargs)

Read firewall rules

https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules

Source code in pfsense_api_client/firewall.py
603
604
605
606
607
608
609
610
611
def get_firewall_rule(
    self, **kwargs: Optional[Any]
) -> requests.Response:
    """Read firewall rules

    https://github.com/jaredhendrickson13/pfsense-api#3-read-firewall-rules
    """
    url = "/api/v1/firewall/rule"
    return self.call(url=url, payload=kwargs)

get_firewall_schedule(**kwargs)

Read all existing firewall schedules.

Source code in pfsense_api_client/firewall.py
379
380
381
382
383
384
def get_firewall_schedule(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read all existing firewall schedules."""
    url = "/api/v1/firewall/schedule"
    return self.call(url, payload=kwargs)

get_firewall_states(**kwargs)

Read the current firewall states.

https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-states

Source code in pfsense_api_client/firewall.py
417
418
419
420
421
422
423
424
425
def get_firewall_states(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read the current firewall states.

    https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-states
    """
    url = "/api/v1/firewall/states"
    return self.call(url, payload=kwargs)

get_firewall_states_size(**kwargs)

Read the maximum firewall state size, the current firewall state size, and the default firewall state size.

https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-state-size

Source code in pfsense_api_client/firewall.py
428
429
430
431
432
433
434
435
436
def get_firewall_states_size(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read the maximum firewall state size, the current firewall state size, and the default firewall state size.

    https://github.com/jaredhendrickson13/pfsense-api#1-read-firewall-state-size
    """
    url = "/api/v1/firewall/states/size"
    return self.call(url, payload=kwargs)

get_nat_outbound_mapping(**kwargs)

Read existing outbound NAT mode mappings.

https://github.com/jaredhendrickson13/pfsense-api#3-read-outbound-nat-mappings

Source code in pfsense_api_client/firewall.py
285
286
287
288
289
290
291
292
293
def get_nat_outbound_mapping(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read existing outbound NAT mode mappings.

    https://github.com/jaredhendrickson13/pfsense-api#3-read-outbound-nat-mappings
    """
    url = "/api/v1/firewall/nat/outbound/mapping"
    return self.call(url, payload=kwargs)

get_traffic_shaper(**kwargs)

Read all configured traffic shapers.

https://github.com/jaredhendrickson13/pfsense-api#3-read-traffic-shapers

Source code in pfsense_api_client/firewall.py
472
473
474
475
476
477
478
479
480
def get_traffic_shaper(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read all configured traffic shapers.

    https://github.com/jaredhendrickson13/pfsense-api#3-read-traffic-shapers
    """
    url = "/api/v1/firewall/traffic_shaper"
    return self.call(url, payload=kwargs)

get_traffic_shaper_limiter(**kwargs)

Get the traffic shaper limiters

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-limiters

Source code in pfsense_api_client/firewall.py
513
514
515
516
517
518
519
520
def get_traffic_shaper_limiter(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Get the traffic shaper limiters

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-limiters"""
    url = "/api/v1/firewall/traffic_shaper/limiter"
    return self.call(url, payload=kwargs)

get_virtual_ip(**kwargs)

Read virtual IP assignments.

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-virtual-ips

Source code in pfsense_api_client/firewall.py
654
655
656
657
658
659
660
def get_virtual_ip(
    self, **kwargs: Dict[str, Any]
) -> requests.Response:
    """Read virtual IP assignments.

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#3-read-virtual-ips"""
    return self.call("/api/v1/firewall/virtual_ip", payload=kwargs)

update_firewall_alias(*args)

Modify an existing firewall alias.

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-aliases

Source code in pfsense_api_client/firewall.py
162
163
164
165
166
167
168
169
170
171
172
173
174
175
@pydantic.validate_arguments
def update_firewall_alias(
    self, *args: FirewallAliasUpdate
) -> requests.Response:
    """Modify an existing firewall alias.

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-aliases
    """
    method = "PUT"
    url = "/api/v1/firewall/alias"

    payload = FirewallAliasUpdate(*args).dict()

    return self.call(url=url, method=method, payload=payload)

update_firewall_nat_one_to_one(**args)

Update a NAT 1:1 Mapping. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-1-to-1-mappings

Source code in pfsense_api_client/firewall.py
231
232
233
234
235
236
237
238
def update_firewall_nat_one_to_one(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update a NAT 1:1 Mapping.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-1-to-1-mappings"""
    method = "PUT"
    url = "/api/v1/firewall/nat/one_to_one"
    return self.call(url=url, method=method, payload=args)

update_firewall_rule(**args)

Update firewall rules

https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-rules

Source code in pfsense_api_client/firewall.py
591
592
593
594
595
596
597
598
599
600
def update_firewall_rule(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update firewall rules

    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-firewall-rules
    """
    url = "/api/v1/firewall/rule"
    method = "PUT"
    return self.call(url=url, method=method, payload=args)

update_firewall_schedule(**args)

Update a firewall schedule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-schedule

Source code in pfsense_api_client/firewall.py
387
388
389
390
391
392
393
394
def update_firewall_schedule(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update a firewall schedule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-schedule"""
    method = "PUT"
    url = "/api/v1/firewall/schedule"
    return self.call(url=url, method=method, payload=args)

update_firewall_state_size(**args)

Modify the maximum number of firewall state table entries allowed by the system Note: use caution when making this call, setting the maximum state table size to a value lower than the current number of firewall state entries WILL choke the system https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-firewall-state-size

Source code in pfsense_api_client/firewall.py
439
440
441
442
443
444
445
446
447
448
449
def update_firewall_state_size(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Modify the maximum number of firewall state table entries allowed by the system
    Note: use caution when making this call, setting the maximum state table size to a value lower than the current number of firewall state entries WILL choke the system
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-firewall-state-size"""

    # TODO: Add a check for current states > state size and require the user to pass force=True if they want to bypass the state check
    method = "PUT"
    url = "/api/v1/firewall/states/size"
    return self.call(url=url, method=method, payload=args)

update_nat_outbound_settings(**args)

mode: str, apply: Optional[bool] Update outbound NAT mode settings. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-outbound-nat-settings

Source code in pfsense_api_client/firewall.py
252
253
254
255
256
257
258
259
260
def update_nat_outbound_settings(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """mode: str, apply: Optional[bool]
    Update outbound NAT mode settings.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#2-update-outbound-nat-settings"""
    method = "PUT"
    url = "/api/v1/firewall/nat/outbound"
    return self.call(url, method=method, payload=args)

update_nat_port_forward(**args)

Update a NAT port forward rule. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-port-forwards

Source code in pfsense_api_client/firewall.py
337
338
339
340
341
342
343
344
def update_nat_port_forward(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update a NAT port forward rule.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-nat-port-forwards"""
    method = "PUT"
    url = "/api/v1/firewall/nat/port_forward"
    return self.call(url=url, method=method, payload=args)

update_outbound_nat_mapping(**args)

Update existing outbound NAT mappings. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-outbound-nat-mappings

Source code in pfsense_api_client/firewall.py
296
297
298
299
300
301
302
303
def update_outbound_nat_mapping(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update existing outbound NAT mappings.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-outbound-nat-mappings"""
    method = "PUT"
    url = "/api/v1/firewall/nat/outbound/mapping"
    return self.call(url=url, method=method, payload=args)

update_traffic_shaper(**args)

Update a traffic shaper policy for an interface. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-traffic-shaper

Source code in pfsense_api_client/firewall.py
483
484
485
486
487
488
489
490
def update_traffic_shaper(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update a traffic shaper policy for an interface.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-traffic-shaper"""
    url = "/api/v1/firewall/traffic_shaper"
    method = "PUT"
    return self.call(url=url, method=method, payload=args)

update_virtual_ip(**args)

Update a virtual IP. https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-virtual-ips

Source code in pfsense_api_client/firewall.py
663
664
665
666
667
668
669
670
def update_virtual_ip(
    self, **args: Dict[str, Any]
) -> requests.Response:
    """Update a virtual IP.
    https://github.com/jaredhendrickson13/pfsense-api/blob/master/README.md#4-update-virtual-ips"""
    method = "PUT"
    url = "https://{{$hostname}}/api/v1/firewall/virtual_ip"
    return self.call(url=url, method=method, payload=args)