firemon-api 0.3.1__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. {firemon-api-0.3.1/firemon_api.egg-info → firemon-api-0.3.4}/PKG-INFO +18 -12
  2. {firemon-api-0.3.1 → firemon-api-0.3.4}/README.md +8 -0
  3. {firemon-api-0.3.1 → firemon-api-0.3.4}/README.rst +15 -11
  4. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/index.rst +21 -1
  5. firemon-api-0.3.4/docs/policyplanner/tickets.rst +143 -0
  6. firemon-api-0.3.4/docs/policyplanner/workflows.rst +60 -0
  7. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/user/quickstart.rst +26 -0
  8. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/__init__.py +4 -2
  9. firemon-api-0.3.4/firemon_api/apps/orchestration/__init__.py +15 -0
  10. firemon-api-0.3.4/firemon_api/apps/orchestration/changes.py +181 -0
  11. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/packets.py +3 -34
  12. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/tasks.py +2 -11
  13. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/workflows.py +1 -1
  14. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/__init__.py +3 -0
  15. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/access_path.py +3 -21
  16. firemon-api-0.3.4/firemon_api/apps/securitymanager/devicegroups.py +261 -0
  17. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/devicepacks.py +13 -36
  18. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/devices.py +80 -36
  19. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/maps.py +5 -20
  20. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/revisions.py +4 -28
  21. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/routes.py +2 -9
  22. firemon-api-0.3.4/firemon_api/apps/securitymanager/rulerec.py +33 -0
  23. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/siql.py +2 -11
  24. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/users.py +2 -11
  25. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/zones.py +3 -9
  26. firemon-api-0.3.4/firemon_api/apps/structure/__init__.py +12 -0
  27. firemon-api-0.3.4/firemon_api/apps/structure/apa.py +10 -0
  28. firemon-api-0.3.4/firemon_api/apps/structure/policyplan.py +26 -0
  29. firemon-api-0.3.4/firemon_api/apps/structure/rulerec.py +43 -0
  30. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/api.py +1 -1
  31. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/endpoint.py +36 -29
  32. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/query.py +3 -2
  33. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/response.py +55 -34
  34. {firemon-api-0.3.1 → firemon-api-0.3.4/firemon_api.egg-info}/PKG-INFO +18 -12
  35. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api.egg-info/SOURCES.txt +10 -0
  36. {firemon-api-0.3.1 → firemon-api-0.3.4}/.gitignore +0 -0
  37. {firemon-api-0.3.1 → firemon-api-0.3.4}/.pre-commit-config.yaml +0 -0
  38. {firemon-api-0.3.1 → firemon-api-0.3.4}/Makefile +0 -0
  39. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/Makefile +0 -0
  40. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/_static/logo_firemon.png +0 -0
  41. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/_templates/sidebarintro.html +0 -0
  42. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/_templates/sidebarlogo.html +0 -0
  43. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/conf.py +0 -0
  44. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/make.bat +0 -0
  45. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/securitymanager/devicepacks.rst +0 -0
  46. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/securitymanager/devices.rst +0 -0
  47. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/securitymanager/siql.rst +0 -0
  48. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/securitymanager/users.rst +0 -0
  49. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/user/advanced.rst +0 -0
  50. {firemon-api-0.3.1 → firemon-api-0.3.4}/docs/user/install.rst +0 -0
  51. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/__init__.py +0 -0
  52. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/__init__.py +0 -0
  53. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/certauth.py +0 -0
  54. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/cleanup.py +0 -0
  55. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/config.py +0 -0
  56. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/database.py +0 -0
  57. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/diagpkg.py +0 -0
  58. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/controlpanel/errors.py +0 -0
  59. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyoptimizer/__init__.py +0 -0
  60. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/__init__.py +0 -0
  61. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/policyplan.py +0 -0
  62. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/policyplanner/siql.py +0 -0
  63. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/centralsyslogconfigs.py +0 -0
  64. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/centralsyslogs.py +0 -0
  65. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/collectionconfigs.py +0 -0
  66. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/collectors.py +0 -0
  67. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/deviceclusters.py +0 -0
  68. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/elasticsearch.py +0 -0
  69. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/license.py +0 -0
  70. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/apps/securitymanager/logging.py +0 -0
  71. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/__init__.py +0 -0
  72. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/app.py +0 -0
  73. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api/core/utils.py +0 -0
  74. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api.egg-info/dependency_links.txt +0 -0
  75. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api.egg-info/not-zip-safe +0 -0
  76. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api.egg-info/requires.txt +0 -0
  77. {firemon-api-0.3.1 → firemon-api-0.3.4}/firemon_api.egg-info/top_level.txt +0 -0
  78. {firemon-api-0.3.1 → firemon-api-0.3.4}/pyproject.toml +0 -0
  79. {firemon-api-0.3.1 → firemon-api-0.3.4}/requirements.txt +0 -0
  80. {firemon-api-0.3.1 → firemon-api-0.3.4}/setup.cfg +0 -0
  81. {firemon-api-0.3.1 → firemon-api-0.3.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: firemon-api
3
- Version: 0.3.1
3
+ Version: 0.3.4
4
4
  Summary: Python Wrapper for Firemon APIs
5
5
  Author: Luke Johannsen
6
6
  Author-email: luke.johannsen@firemon.com
@@ -19,6 +19,8 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Requires-Python: >=3.8
21
21
  Description-Content-Type: text/x-rst
22
+ Requires-Dist: requests
23
+ Requires-Dist: tenacity
22
24
 
23
25
  FireMon-API
24
26
  ===========
@@ -27,21 +29,24 @@ This project is for wrapper for the Firemon APIs (Security Manager, etc).
27
29
 
28
30
  The User Guide available on `Read the Docs <https://firemon-api.readthedocs.io/>`
29
31
 
30
- Current Design
31
- --------------
32
+ Current Philosophy
33
+ ------------------
32
34
 
33
- Everything is basically being coded by hand to attempt to fit a schema that makes sense to me.
34
- Endpoints are made and return objects which may have their own functions. For example search
35
- and manipulation of devices and their data. This is attempt to make the API a bit more user
36
- friendly without requiring more interaction by the user.
35
+ The ``firemon-api`` is an attempt to make a Pythonic wrapper to the FireMon SIP APIs (Security Manager, etc...).
37
36
 
38
- I have attempted to create a dynamic interface for all API calls if there is something needed
39
- that does not currently fit within the re-imagining of the API schema for user friendliness.
40
- Each application should automatically create these. Unfortunately many of the ``operationId``
41
- for the API are not helpful in what they actually do:
37
+ The intent is to hopefully speed up development of projects. There is no intent to do a 1-to-1 reference of all
38
+ the potential API calls. If that is desired you may try to use the dynamically built functions created using
39
+ the ``get_api()``. Or read the ``/api-doc`` of your FireMon product and make use of the ``request()`` function for
40
+ the individually created application objects.
42
41
 
43
- ex: (``get_1``, ``get_2``, ``get_3``, ...)
42
+ **Request Example**::
44
43
 
44
+ >>> fm.sm.request(key="device", use_domain=True).get()
45
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
46
+
47
+ There is currently no intention to follow any version of the FireMon products and so there may
48
+ be instances where a function worked in one version but no longer in another though this generally is not a
49
+ problem.
45
50
 
46
51
  Installation of FireMon API
47
52
  ---------------------------
@@ -54,6 +59,7 @@ Install ``firemon-api`` into a Python ``venv``.
54
59
  ~$ source ~/virtualenvs/fmapi/bin/activate
55
60
  (fmapi) ~$ pip install firemon-api
56
61
  Collecting firemon-api
62
+ ...
57
63
 
58
64
 
59
65
  Usage
@@ -12,6 +12,14 @@ I have attempted to create a dynamic interface for all API calls if there is som
12
12
 
13
13
  ex: (`get_1`, `get_2`, `get_3`, ...)
14
14
 
15
+ Or use the `/api-doc` from your FireMon server to extrapolate the need keys and methods to make and use the `request()`
16
+ function for the specific FireMon application.
17
+
18
+ ```
19
+ >>> fm.sm.request(key="device", use_domain=True).get()
20
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
21
+ ```
22
+
15
23
  # Usage
16
24
 
17
25
  Import module. Disable unverfied https certificate warnings. Switch https verification off.
@@ -5,21 +5,24 @@ This project is for wrapper for the Firemon APIs (Security Manager, etc).
5
5
 
6
6
  The User Guide available on `Read the Docs <https://firemon-api.readthedocs.io/>`
7
7
 
8
- Current Design
9
- --------------
8
+ Current Philosophy
9
+ ------------------
10
10
 
11
- Everything is basically being coded by hand to attempt to fit a schema that makes sense to me.
12
- Endpoints are made and return objects which may have their own functions. For example search
13
- and manipulation of devices and their data. This is attempt to make the API a bit more user
14
- friendly without requiring more interaction by the user.
11
+ The ``firemon-api`` is an attempt to make a Pythonic wrapper to the FireMon SIP APIs (Security Manager, etc...).
15
12
 
16
- I have attempted to create a dynamic interface for all API calls if there is something needed
17
- that does not currently fit within the re-imagining of the API schema for user friendliness.
18
- Each application should automatically create these. Unfortunately many of the ``operationId``
19
- for the API are not helpful in what they actually do:
13
+ The intent is to hopefully speed up development of projects. There is no intent to do a 1-to-1 reference of all
14
+ the potential API calls. If that is desired you may try to use the dynamically built functions created using
15
+ the ``get_api()``. Or read the ``/api-doc`` of your FireMon product and make use of the ``request()`` function for
16
+ the individually created application objects.
20
17
 
21
- ex: (``get_1``, ``get_2``, ``get_3``, ...)
18
+ **Request Example**::
22
19
 
20
+ >>> fm.sm.request(key="device", use_domain=True).get()
21
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
22
+
23
+ There is currently no intention to follow any version of the FireMon products and so there may
24
+ be instances where a function worked in one version but no longer in another though this generally is not a
25
+ problem.
23
26
 
24
27
  Installation of FireMon API
25
28
  ---------------------------
@@ -32,6 +35,7 @@ Install ``firemon-api`` into a Python ``venv``.
32
35
  ~$ source ~/virtualenvs/fmapi/bin/activate
33
36
  (fmapi) ~$ pip install firemon-api
34
37
  Collecting firemon-api
38
+ ...
35
39
 
36
40
 
37
41
  Usage
@@ -10,7 +10,15 @@ The ``firemon-api`` is an attempt to make a Pythonic wrapper to the FireMon SIP
10
10
 
11
11
  The intent is to hopefully speed up development of projects. There is no intent to do a 1-to-1 reference of all
12
12
  the potential API calls. If that is desired you may try to use the dynamically built functions created using
13
- the ``get_api()``. There is also no intention to follow any version of the FireMon products and so there may
13
+ the ``get_api()``. Or read the ``/api-doc`` of your FireMon product and make use of the ``request()`` function for
14
+ the individually created application objects.
15
+
16
+ **Request Example**::
17
+
18
+ >>> fm.sm.request(key="device", use_domain=True).get()
19
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
20
+
21
+ There is currently no intention to follow any version of the FireMon products and so there may
14
22
  be instances where a function worked in one version but no longer in another though this generally is not a
15
23
  problem.
16
24
 
@@ -32,6 +40,8 @@ problem.
32
40
  CSM-2
33
41
  vSRX-3
34
42
 
43
+ >>> fm.sm.request(key="device", use_domain=True).get()
44
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
35
45
 
36
46
  User Guide
37
47
  ----------
@@ -54,3 +64,13 @@ Security Manager
54
64
  securitymanager/devices
55
65
  securitymanager/users
56
66
  securitymanager/siql
67
+
68
+
69
+ Policy Planner
70
+ --------------
71
+
72
+ .. toctree::
73
+ :maxdepth: 2
74
+
75
+ policyplanner/workflows
76
+ policyplanner/tickets
@@ -0,0 +1,143 @@
1
+ Tickets or Packets
2
+ ==================
3
+
4
+ Once a user has a workflow object they may access and create tickets/packets.
5
+
6
+ To access and view all the tickets from a workflow.
7
+
8
+ ::
9
+
10
+ >>> wf = fm.pp.workflows.default()
11
+ >>> wf.tickets.all()
12
+ [<Packet(1)>]
13
+ >>> ticket = wf.tickets.get(1)
14
+ >>> ticket
15
+ <Packet(1)>
16
+
17
+ Automation In Action
18
+ --------------------
19
+
20
+ If a user had their workflow setup to Autodesign their request and their
21
+ environment is capable of making correct Rule Recommendations because FireMon
22
+ has knowledge of routing then the following example flow will automate changes
23
+ to the users security devices that are licensed for automation.
24
+
25
+ To create a new ticket the user needs to make a dictionary of values and submit the data.
26
+
27
+ ::
28
+
29
+ >>> import datetime
30
+ >>> ticket_defaults = {
31
+ ... "variables": {
32
+ ... "requesterName": "Ghost In the Machine",
33
+ ... "requesterEmail": "example@firemon.com",
34
+ ... "summary": "auto created ticket",
35
+ ... "businessNeed": "For Reasons",
36
+ ... "applicationOwner": "FireMon Tests",
37
+ ... "applicationName": "Firemon Test App",
38
+ ... "priority": "LOW",
39
+ ... "_btnAction": "complete",
40
+ ... }
41
+ ... }
42
+
43
+ >>> now = datetime.datetime.now()
44
+ >>> due = now + datetime.timedelta(days=10)
45
+ >>> ticket_defaults["variables"][
46
+ ... "dueDate"
47
+ ... ] = f"{due.strftime('%Y-%m-%d')}T00:00:00.000Z"
48
+ >>> ticket = wf.tickets.create(ticket_defaults)
49
+
50
+ Every ticket or packet will have a number of "packet tasks". Most often we are concerned
51
+ with working on "open" tasks. To know which tasks are listed by the server as "open" we
52
+ need to `refresh()` the ticket data and access the open packet task. After acquiring an
53
+ open packet task we will want to assign it to ourselves. Since this process of assigning
54
+ a task to ourselves occurs frequently it is handy to just make a quick variable to that
55
+ data.
56
+
57
+ ::
58
+
59
+ >>> user = fm.sm.users.get(fm.username)
60
+ >>> ticket.refresh()
61
+ >>> task = ticket.pt.get_open()
62
+ >>> task.assign(user.id)
63
+
64
+ Throughout the user will probably want to validate that they are in the proper phase by
65
+ accessing the open packet tasks' workFlowTask information.
66
+
67
+ ::
68
+
69
+ >>> task.workflowTask.key
70
+ "_b_reviewTask"
71
+
72
+ In the "Design" phase the user will want to add requirements. Create requirements as a
73
+ dictionary and pass into the packet task.
74
+
75
+ ::
76
+
77
+ >>> requirements = {
78
+ ... "apps": [],
79
+ ... "destinations": ["10.3.3.0/27"],
80
+ ... "services": ["tcp/9050"],
81
+ ... "sources": ["10.2.2.50"],
82
+ ... "users": [],
83
+ ... "requirementType": "RULE",
84
+ ... "childKey": "add_access",
85
+ ... "variables": {
86
+ ... "expiration": None,
87
+ ... "review": None,
88
+ ... },
89
+ ... "action": "ACCEPT",
90
+ ... }
91
+ >>> task.add_requirement(requirements)
92
+
93
+ In the "Review" stage the user will want to get the open task and approve all changes
94
+ and then approve the packet task itself.
95
+
96
+ ::
97
+
98
+ >>> ticket.refresh()
99
+ >>> task = ticket.pt.get_open()
100
+ >>> task.assign(user.id)
101
+ >>> for r in task.requirements.all():
102
+ ... r.set_review_decision()
103
+ >>> task.complete(action="approve")
104
+
105
+ The user will then want to execute all the automation requirements. A list of of all
106
+ change id will be made and then executed.
107
+
108
+ ::
109
+
110
+ >>> ticket.refresh()
111
+ >>> task = ticket.pt.get_open()
112
+ >>> task.assign(user.id)
113
+ >>> changes = []
114
+ >>> for change in task.changes.all():
115
+ ... changes.append(change.id)
116
+ >>> task.exec_automation(changes)
117
+
118
+ The user may also want to check the status of all their automation requests.
119
+
120
+ ::
121
+
122
+ >>> ticket.refresh()
123
+ >>> task = ticket.pt.get_open()
124
+ >>> task.assign(user.id)
125
+ >>> if not task:
126
+ ... print("Automation already completed. Using last task.")
127
+ ... task = ticket.pt.all()[-1]
128
+ >>> status_in_progress = ("RUNNING", "PENDING", "QUEUED")
129
+ >>> status_failed = ("UNIMPLEMENTED", "FAIL")
130
+ >>> status_passed = ("IMPLEMENTED", "STAGED", "SUCCESS")
131
+ >>> total_in_progress = 0
132
+ >>> total_failed = 0
133
+ >>> total_passed = 0
134
+ >>> for change in task.changes.all():
135
+ ... if change.implementationStatus in status_in_progress:
136
+ ... total_in_progress += 1
137
+ ... elif change.implementationStatus in status_failed:
138
+ ... total_failed += 1
139
+ ... elif change.implementationStatus in status_passed:
140
+ ... total_passed += 1
141
+ >>> print(f"Passed : {total_passed}")
142
+ >>> print(f"In Progress: {total_in_progress}")
143
+ >>> print(f"Failed : {total_failed}")
@@ -0,0 +1,60 @@
1
+ Workflows
2
+ =========
3
+
4
+ Workflows ``endpoint`` provides access to configured workflows and returns each workflow
5
+ as a parsed object.
6
+
7
+ Endpoint Defaults
8
+ -----------------
9
+
10
+ **All**
11
+
12
+ Return a list of all the workflows currently configured on the SIP instance.
13
+
14
+ ::
15
+
16
+ >>> fm.pp.workflows.all()
17
+ [<Workflow(wf__476)>, <Workflow(wf__393)>, <snip...>]
18
+
19
+ **Get**
20
+
21
+ Get a single workflow by the workflow ID. You may also get the "default" workflow.
22
+
23
+ ::
24
+
25
+ >>> wf = fm.pp.workflows.get(3)
26
+ >>> wf
27
+ <Workflow(wf__913)>
28
+
29
+ >>> wf = fm.pp.workflows.default()
30
+ >>> wf
31
+ <Workflow(wf__476)>
32
+
33
+
34
+ Create a Workflow
35
+ -----------------
36
+
37
+ In most cases creating a device requires a few additional bits of information such
38
+ as the management IP of the device, username, password, and a data collector to
39
+ assign the device.
40
+
41
+ ::
42
+
43
+ >>> wf = fm.pp.workflows.create(name="Flow_Like_the_Water")
44
+ >>> wf
45
+ <Workflow(Flow_Like_the_Water)>
46
+
47
+
48
+ View and Access Tickets/Packets
49
+ -------------------------------
50
+
51
+ To access and view all the tickets from a workflow.
52
+
53
+ ::
54
+
55
+ >>> wf = fm.pp.workflows.default()
56
+ >>> wf.tickets.all()
57
+ [<Packet(1)>]
58
+ >>> ticket = wf.tickets.get(1)
59
+ >>> ticket
60
+ <Packet(1)>
@@ -18,6 +18,32 @@ along with a valid username and password.
18
18
  >>> fm
19
19
  <Firemon(host='saffron', version='9.12.0')>
20
20
 
21
+ FireMon has a number of applications such as Security Manager (sm) and Policy Planner (pp)
22
+ and each has its own API. Each of these applications, once authed, are available from the
23
+ api object as another attribute. Each app also has a simple entry to the api which the user
24
+ may use to build requests for calls that may not be covered in other modules or for which
25
+ a direct response is more desirable. The following shows examples of making requests that
26
+ make use of "building" up of the ``app_url`` or the ``domain_url`` to make building API calls
27
+ shorter. The ``/api-doc`` endpoint on your FireMon server should provide documentation for
28
+ queries.
29
+
30
+ ::
31
+
32
+ >>> fm.sm.app_url
33
+ 'https://tuna-9-13-1-aio/securitymanager/api'
34
+ >>> fm.sm.domain_url
35
+ 'https://tuna-9-13-1-aio/securitymanager/api/domain/1'
36
+
37
+ >>> fm.sm.request(key="collector").get()
38
+ [{'changeThreads': 5, 'commandProcessorMinThreads': 1, 'commandProcessorMaxThreads': 5, 'eventDispatcherThreads': 0, <snip...>]
39
+
40
+ >>> fm.sm.request(key="device", use_domain=True).get()
41
+ [{'id': 27, 'domainId': 1, 'name': 'PA-VM 11.0.1', 'managementIp': <snip...>]
42
+
43
+ >>> help(fm.sm.request)
44
+ Help on method request in module firemon_api.core.app:
45
+
46
+ request(use_domain: Optional[bool] = False, filters: Optional[dict] = None, key: Optional[str] = None, url: Optional[str] = None, headers: Optional[dict] = None, cookies: Optional[dict] = None, trailing_slash: bool = False) -> firemon_api.core.query.Request method of firemon_api.apps.SecurityManager instance
21
47
 
22
48
  Security Manager
23
49
  ----------------
@@ -18,6 +18,7 @@ from firemon_api.core.query import Request, RequestResponse
18
18
  log = logging.getLogger(__name__)
19
19
 
20
20
 
21
+ from .orchestration import *
21
22
  from .policyoptimizer import *
22
23
  from .policyplanner import *
23
24
  from .securitymanager import *
@@ -55,6 +56,7 @@ class SecurityManager(App):
55
56
  self.collectors = Collectors(self.api, self)
56
57
  self.collectorgroups = CollectorGroups(self.api, self)
57
58
  self.deviceclusters = DeviceClusters(self.api, self)
59
+ self.devicegroups = DeviceGroups(self.api, self)
58
60
  self.devices = Devices(self.api, self)
59
61
  self.dp = DevicePacks(self.api, self) # Todo: create the other /plugin
60
62
  self.es = ElasticSearch(self.api, self)
@@ -87,7 +89,7 @@ class Orchestration(App):
87
89
  super().__init__(api)
88
90
 
89
91
  # Endpoints
90
- # self.xx = EndPoint(self)
92
+ self.changes = Changes(self.api, self)
91
93
 
92
94
 
93
95
  class PolicyOptimizer(App):
@@ -107,7 +109,7 @@ class PolicyOptimizer(App):
107
109
  super().__init__(api)
108
110
 
109
111
  # Endpoints
110
- # self.xx = EndPoint(self)
112
+ # self.xx = EndPoint(self.api, self)
111
113
 
112
114
 
113
115
  class PolicyPlanner(App):
@@ -0,0 +1,15 @@
1
+ """
2
+ (c) 2023 Firemon
3
+
4
+ Unless required by applicable law or agreed to in writing, software
5
+ distributed under the License is distributed on an "AS IS" BASIS,
6
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
+ See the License for the specific language governing permissions and
8
+ limitations under the License.
9
+ """
10
+
11
+ from .changes import Changes
12
+
13
+ __all__ = [
14
+ "Changes",
15
+ ]
@@ -0,0 +1,181 @@
1
+ """
2
+ (c) 2023 Firemon
3
+
4
+ Unless required by applicable law or agreed to in writing, software
5
+ distributed under the License is distributed on an "AS IS" BASIS,
6
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
+ See the License for the specific language governing permissions and
8
+ limitations under the License.
9
+ """
10
+
11
+ # Standard packages
12
+ import logging
13
+ from typing import Literal, Optional, Union
14
+
15
+ # Local packages
16
+ from firemon_api.core.app import App
17
+ from firemon_api.core.api import FiremonAPI
18
+ from firemon_api.core.endpoint import Endpoint
19
+ from firemon_api.core.query import Request
20
+ from firemon_api.core.response import BaseRecord
21
+ from firemon_api.apps.structure import RuleRecRequirement, ChangeRequestRequirement
22
+
23
+ log = logging.getLogger(__name__)
24
+
25
+
26
+ class OrchRuleRecommendation(BaseRecord):
27
+ _ep_name = "rulerec"
28
+ _is_domain_url = True
29
+
30
+ def __str__(self):
31
+ return str({self.__class__.__name__})
32
+
33
+ def __repr__(self):
34
+ return f"<{self.__class__.__name__}()>"
35
+
36
+
37
+ class ChangeRequest(BaseRecord):
38
+ _ep_name = "change/request"
39
+ _is_domain_url = True
40
+
41
+
42
+ class Changes(Endpoint):
43
+ ep_name = "change/request"
44
+ _is_domain_url = True
45
+
46
+ def __init__(self, api: FiremonAPI, app: App, record=ChangeRequest):
47
+ super().__init__(api, app, record=record)
48
+
49
+ def filter(
50
+ self,
51
+ *args,
52
+ status: Literal["PENDING", "QUEUED", "COMPLETE", "ERROR"] = None,
53
+ **kwargs,
54
+ ) -> list[ChangeRequest]:
55
+ if args:
56
+ _ = args
57
+ if kwargs:
58
+ _ = kwargs
59
+
60
+ if not status:
61
+ raise ValueError(
62
+ "filter must be passed `status`. Perhaps use all() instead."
63
+ )
64
+
65
+ filters = {"status": status}
66
+
67
+ req = Request(
68
+ base=self.url,
69
+ filters=filters,
70
+ key=self._ep["filter"],
71
+ session=self.api.session,
72
+ )
73
+
74
+ ret = [self._response_loader(i) for i in req.get()]
75
+ return ret
76
+
77
+ def device_rule_rec(
78
+ self,
79
+ device_id: int,
80
+ requirement: RuleRecRequirement,
81
+ license_category: Optional[
82
+ Literal[
83
+ "LOG_SERVERS",
84
+ "ROUTERS",
85
+ "OPERATING_SYSTEMS",
86
+ "FIREWALLS",
87
+ "FIREWALL_MANAGER_MODULES",
88
+ "EDGE_DEVICES",
89
+ "GENERIC_DEVICES",
90
+ "TRAFFIC_MANAGER_MODULES",
91
+ "UNKNOWN",
92
+ "SALES_ONLY_SMLO_HA",
93
+ "SALES_ONLY_SMSO_HA",
94
+ "SALES_ONLY_SMM_HA",
95
+ "POLICY_PLANNER",
96
+ "RISK",
97
+ "POLICY_OPTIMIZER",
98
+ "INSIGHT",
99
+ "GLOBAL_POLICY_CONTROLLER",
100
+ "AUTOMATION",
101
+ "LICENSE_NOT_REQUIRED",
102
+ ]
103
+ ] = None,
104
+ strategy: Literal["NAME_PATTERN", "HITCOUNT", "REFERENCES", "NONE"] = None,
105
+ force_tiebreak: Optional[bool] = None,
106
+ pattern: Optional[str] = None,
107
+ # Leaving these commented out. They seem redundant and don't make sense.
108
+ # device_ids: list[int] = [],
109
+ # device_group_id: int = None,
110
+ ) -> OrchRuleRecommendation:
111
+ key = f"change/device/{device_id}/rulerec"
112
+ filters = {}
113
+ if license_category:
114
+ filters["licenseCategory"] = license_category
115
+ if strategy:
116
+ filters["strategy"] = strategy
117
+ if force_tiebreak:
118
+ filters["forceTiebreak"] = force_tiebreak
119
+ if pattern:
120
+ filters["pattern"] = pattern
121
+ req = Request(
122
+ base=self.domain_url,
123
+ key=key,
124
+ filters=filters,
125
+ session=self.session,
126
+ )
127
+ return OrchRuleRecommendation(req.put(json=requirement), self)
128
+
129
+ def rule_rec(
130
+ self,
131
+ requirement: ChangeRequestRequirement,
132
+ license_category: Optional[
133
+ Literal[
134
+ "LOG_SERVERS",
135
+ "ROUTERS",
136
+ "OPERATING_SYSTEMS",
137
+ "FIREWALLS",
138
+ "FIREWALL_MANAGER_MODULES",
139
+ "EDGE_DEVICES",
140
+ "GENERIC_DEVICES",
141
+ "TRAFFIC_MANAGER_MODULES",
142
+ "UNKNOWN",
143
+ "SALES_ONLY_SMLO_HA",
144
+ "SALES_ONLY_SMSO_HA",
145
+ "SALES_ONLY_SMM_HA",
146
+ "POLICY_PLANNER",
147
+ "RISK",
148
+ "POLICY_OPTIMIZER",
149
+ "INSIGHT",
150
+ "GLOBAL_POLICY_CONTROLLER",
151
+ "AUTOMATION",
152
+ "LICENSE_NOT_REQUIRED",
153
+ ]
154
+ ] = None,
155
+ strategy: Literal["NAME_PATTERN", "HITCOUNT", "REFERENCES", "NONE"] = None,
156
+ force_tiebreak: Optional[bool] = None,
157
+ pattern: Optional[str] = None,
158
+ device_ids: Union[int, list[int]] = [],
159
+ device_group_id: int = None,
160
+ ) -> OrchRuleRecommendation:
161
+ key = f"change/rulerec"
162
+ filters = {}
163
+ if license_category:
164
+ filters["licenseCategory"] = license_category
165
+ if strategy:
166
+ filters["strategy"] = strategy
167
+ if force_tiebreak:
168
+ filters["forceTiebreak"] = force_tiebreak
169
+ if pattern:
170
+ filters["pattern"] = pattern
171
+ if device_ids:
172
+ filters["deviceId"] = device_ids
173
+ if device_group_id:
174
+ filters["deviceGroupId"] = device_group_id
175
+ req = Request(
176
+ base=self.domain_url,
177
+ key=key,
178
+ filters=filters,
179
+ session=self.session,
180
+ )
181
+ return OrchRuleRecommendation(req.post(json=requirement), self)