Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_application_group.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_application_group
15 short_description: Configure firewall application groups.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 application_group:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 application:
34 type: raw
35 description: (list) Application ID list.
36 category:
37 type: raw
38 description: (list) Application category ID list.
39 comment:
40 type: str
41 description: Comment
42 name:
43 type: str
44 description: Application group name.
45 required: true
46 type:
47 type: str
48 description: Application group type.
49 choices: ['application', 'category', 'filter']
50 behavior:
51 type: raw
52 description: (list or str) Application behavior filter.
53 popularity:
54 type: list
55 elements: str
56 description: Application popularity filter
57 choices: ['1', '2', '3', '4', '5']
58 protocols:
59 type: raw
60 description: (list or str) Application protocol filter.
61 risk:
62 type: raw
63 description: (list) Risk, or impact, of allowing traffic from this application to occur
64 technology:
65 type: raw
66 description: (list or str) Application technology filter.
67 vendor:
68 type: raw
69 description: (list or str) Application vendor filter.
70 '''
71
72 EXAMPLES = '''
73 - name: Example playbook
74 hosts: fortimanagers
75 gather_facts: false
76 connection: httpapi
77 vars:
78 ansible_httpapi_use_ssl: true
79 ansible_httpapi_validate_certs: false
80 ansible_httpapi_port: 443
81 tasks:
82 - name: Configure firewall application groups.
83 fortinet.fortimanager.fmgr_application_group:
84 adom: ansible
85 state: present
86 application_group:
87 comment: "ansible-test-comment"
88 name: "ansible-test"
89 type: application # <value in [application, category]>
90
91 - name: Gathering fortimanager facts
92 hosts: fortimanagers
93 gather_facts: false
94 connection: httpapi
95 vars:
96 ansible_httpapi_use_ssl: true
97 ansible_httpapi_validate_certs: false
98 ansible_httpapi_port: 443
99 tasks:
100 - name: Retrieve all the application groups
101 fortinet.fortimanager.fmgr_fact:
102 facts:
103 selector: "application_group"
104 params:
105 adom: "ansible"
106 group: "your_value"
107 '''
108
109 RETURN = '''
110 meta:
111 description: The result of the request.
112 type: dict
113 returned: always
114 contains:
115 request_url:
116 description: The full url requested.
117 returned: always
118 type: str
119 sample: /sys/login/user
120 response_code:
121 description: The status of api request.
122 returned: always
123 type: int
124 sample: 0
125 response_data:
126 description: The api response.
127 type: list
128 returned: always
129 response_message:
130 description: The descriptive message of the api response.
131 type: str
132 returned: always
133 sample: OK.
134 system_information:
135 description: The information of the target system.
136 type: dict
137 returned: always
138 rc:
139 description: The status the request.
140 type: int
141 returned: always
142 sample: 0
143 version_check_warning:
144 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
145 type: list
146 returned: complex
147 '''
148 from ansible.module_utils.basic import AnsibleModule
149 from ansible.module_utils.connection import Connection
150 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
151 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
152
153
154 def main():
155 urls_list = [
156 '/pm/config/adom/{adom}/obj/application/group',
157 '/pm/config/global/obj/application/group'
158 ]
159 module_arg_spec = {
160 'adom': {'required': True, 'type': 'str'},
161 'revision_note': {'type': 'str'},
162 'application_group': {
163 'type': 'dict', 'v_range': [['6.0.0', '']],
164 'options': {
165 'application': {'type': 'raw'},
166 'category': {'type': 'raw'},
167 'comment': {'type': 'str'},
168 'name': {'required': True, 'type': 'str'},
169 'type': {'choices': ['application', 'category', 'filter'], 'type': 'str'},
170 'behavior': {'v_range': [['7.0.0', '']], 'type': 'raw'},
171 'popularity': {'v_range': [['7.0.0', '']], 'type': 'list', 'choices': ['1', '2', '3', '4', '5'], 'elements': 'str'},
172 'protocols': {'v_range': [['7.0.0', '']], 'type': 'raw'},
173 'risk': {'v_range': [['7.0.0', '']], 'type': 'raw'},
174 'technology': {'v_range': [['7.0.0', '']], 'type': 'raw'},
175 'vendor': {'v_range': [['7.0.0', '']], 'type': 'raw'}
176 }
177 }
178 }
179
180 module_option_spec = get_module_arg_spec('full crud')
181 module_arg_spec.update(module_option_spec)
182 check_galaxy_version(module_arg_spec)
183 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'application_group'),
184 supports_check_mode=True)
185 if not module._socket_path:
186 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
187 connection = Connection(module._socket_path)
188 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
189 'name', 'data', module, connection)
190 fmgr.process_crud()
191 module.exit_json(meta=module.params)
192
193
194 if __name__ == '__main__':
195 main()