|
1 | 1 | """api/v2/cmdb/firewall/address |
2 | 2 |
|
3 | | -- Create address in the Fortigate |
| 3 | +- Create address in the Fortigate, in the default vdom root |
4 | 4 | - Get all addresses from the Fortigate vdom root |
5 | 5 | - Format output data to return only required key values |
6 | 6 | - Get address by name (unique identifier) |
|
12 | 12 | - Delete address from the Fortigate by name (unique identifier) |
13 | 13 | - Delete addresses from the Fortigate by filter |
14 | 14 | - Check for absence of address in the Fortigate |
15 | | -- Get all addresses from the vdom |
| 15 | +
|
| 16 | +VDOM |
| 17 | +- Create address in the Fortigate, in the custom vdom |
| 18 | +- Get all addresses from the custom vdom |
| 19 | +- Delete addresses from the custom vdom |
16 | 20 | """ |
17 | 21 |
|
18 | 22 | import logging |
|
29 | 33 | api = FortiGateAPI(host=HOST, username=USERNAME, password=PASSWORD, logging_error=True) |
30 | 34 | api.login() # login is optional |
31 | 35 |
|
32 | | -# Create address in the Fortigate |
| 36 | +# Create address in the Fortigate, in the default vdom root |
33 | 37 | data = { |
34 | 38 | "name": "ADDRESS", |
35 | 39 | "obj-type": "ip", |
|
98 | 102 |
|
99 | 103 | api.logout() |
100 | 104 |
|
101 | | -# Get all addresses from the vdom="VDOM9" |
| 105 | +# VDOM |
| 106 | +# Create address in the Fortigate, in the custom vdom |
102 | 107 | api = FortiGateAPI(host=HOST, username=USERNAME, password=PASSWORD, vdom="VDOM9") |
| 108 | +data = { |
| 109 | + "name": "ADDRESS", |
| 110 | + "obj-type": "ip", |
| 111 | + "subnet": "127.0.0.100 255.255.255.252", |
| 112 | + "type": "ipmask", |
| 113 | +} |
| 114 | +response = api.cmdb.firewall.address.create(data) |
| 115 | +print(f"address.create {response}") # address.create <Response [200]> |
| 116 | + |
| 117 | +# Get all addresses from the custom vdom |
| 118 | + |
103 | 119 | items = api.cmdb.firewall.address.get() |
104 | 120 | print(f"addresses count={len(items)}") # addresses count=10 |
105 | 121 |
|
| 122 | +# Delete addresses from the custom vdom |
| 123 | +response = api.cmdb.firewall.address.delete("ADDRESS") |
| 124 | +print(f"address.delete {response}") # address.delete <Response [200]> |
| 125 | + |
106 | 126 | api.logout() |
0 commit comments