Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_application_custom.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_custom
15 short_description: Configure custom application signatures.
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_custom:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 behavior:
34 type: str
35 description: Custom application signature behavior.
36 category:
37 type: str
38 description: Custom application category ID
39 comment:
40 type: str
41 description: Comment.
42 id:
43 type: int
44 description: Id.
45 name:
46 type: str
47 description: Name.
48 protocol:
49 type: str
50 description: Custom application signature protocol.
51 signature:
52 type: str
53 description: The text that makes up the actual custom application signature.
54 tag:
55 type: str
56 description: Signature tag.
57 required: true
58 technology:
59 type: str
60 description: Custom application signature technology.
61 vendor:
62 type: str
63 description: Custom application signature vendor.
64 '''
65
66 EXAMPLES = '''
67 - name: Example playbook
68 hosts: fortimanagers
69 gather_facts: false
70 connection: httpapi
71 vars:
72 ansible_httpapi_use_ssl: true
73 ansible_httpapi_validate_certs: false
74 ansible_httpapi_port: 443
75 tasks:
76 - name: Configure custom application signatures.
77 fortinet.fortimanager.fmgr_application_custom:
78 adom: ansible
79 state: present
80 application_custom:
81 behavior: "ansible-test1"
82 category: "ansible-test1"
83 comment: "ansble-test"
84 id: 1000
85 name: "ansible-test1"
86 protocol: "ansble-test1"
87 signature: "ansble-test1"
88 tag: "ansble-test-tag"
89 technology: "ansble-test"
90 vendor: "ansble-test-vendor"
91
92 - name: Gathering fortimanager facts
93 hosts: fortimanagers
94 gather_facts: false
95 connection: httpapi
96 vars:
97 ansible_httpapi_use_ssl: true
98 ansible_httpapi_validate_certs: false
99 ansible_httpapi_port: 443
100 tasks:
101 - name: Retrieve all the custom application signatures
102 fortinet.fortimanager.fmgr_fact:
103 facts:
104 selector: "application_custom"
105 params:
106 adom: "ansible"
107 custom: "your_value"
108 '''
109
110 RETURN = '''
111 meta:
112 description: The result of the request.
113 type: dict
114 returned: always
115 contains:
116 request_url:
117 description: The full url requested.
118 returned: always
119 type: str
120 sample: /sys/login/user
121 response_code:
122 description: The status of api request.
123 returned: always
124 type: int
125 sample: 0
126 response_data:
127 description: The api response.
128 type: list
129 returned: always
130 response_message:
131 description: The descriptive message of the api response.
132 type: str
133 returned: always
134 sample: OK.
135 system_information:
136 description: The information of the target system.
137 type: dict
138 returned: always
139 rc:
140 description: The status the request.
141 type: int
142 returned: always
143 sample: 0
144 version_check_warning:
145 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
146 type: list
147 returned: complex
148 '''
149 from ansible.module_utils.basic import AnsibleModule
150 from ansible.module_utils.connection import Connection
151 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
152 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
153
154
155 def main():
156 urls_list = [
157 '/pm/config/adom/{adom}/obj/application/custom',
158 '/pm/config/global/obj/application/custom'
159 ]
160 module_arg_spec = {
161 'adom': {'required': True, 'type': 'str'},
162 'revision_note': {'type': 'str'},
163 'application_custom': {
164 'type': 'dict', 'v_range': [['6.0.0', '']],
165 'options': {
166 'behavior': {'type': 'str'},
167 'category': {'type': 'str'},
168 'comment': {'type': 'str'},
169 'id': {'type': 'int'},
170 'name': {'type': 'str'},
171 'protocol': {'type': 'str'},
172 'signature': {'type': 'str'},
173 'tag': {'required': True, 'type': 'str'},
174 'technology': {'type': 'str'},
175 'vendor': {'type': 'str'}
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_custom'),
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 'tag', 'data', module, connection)
190 fmgr.process_crud()
191 module.exit_json(meta=module.params)
192
193
194 if __name__ == '__main__':
195 main()