Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_virtualpatch_profile_exemption.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_virtualpatch_profile_exemption
15 short_description: Exempt devices or rules.
16 version_added: "2.3.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 profile:
29 description: The parameter (profile) in requested url.
30 type: str
31 required: true
32 virtualpatch_profile_exemption:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 device:
38 type: list
39 elements: str
40 description: Device MAC addresses.
41 id:
42 type: int
43 description: IDs.
44 required: true
45 rule:
46 type: list
47 elements: int
48 description: Patch signature rule IDs.
49 status:
50 type: str
51 description: Enable/disable exemption.
52 choices: ['disable', 'enable']
53 '''
54
55 EXAMPLES = '''
56 - name: Example playbook (generated based on argument schema)
57 hosts: fortimanagers
58 connection: httpapi
59 gather_facts: false
60 tasks:
61 - name: Exempt devices or rules.
62 fortinet.fortimanager.fmgr_virtualpatch_profile_exemption:
63 # workspace_locking_adom: <global or your adom name>
64 adom: <your own value>
65 profile: <your own value>
66 state: present # <value in [present, absent]>
67 virtualpatch_profile_exemption:
68 id: 0 # Required variable, integer
69 # device: <list or string>
70 # rule: <list or integer>
71 # status: <value in [disable, enable]>
72 '''
73
74 RETURN = '''
75 meta:
76 description: The result of the request.
77 type: dict
78 returned: always
79 contains:
80 request_url:
81 description: The full url requested.
82 returned: always
83 type: str
84 sample: /sys/login/user
85 response_code:
86 description: The status of api request.
87 returned: always
88 type: int
89 sample: 0
90 response_data:
91 description: The api response.
92 type: list
93 returned: always
94 response_message:
95 description: The descriptive message of the api response.
96 type: str
97 returned: always
98 sample: OK.
99 system_information:
100 description: The information of the target system.
101 type: dict
102 returned: always
103 rc:
104 description: The status the request.
105 type: int
106 returned: always
107 sample: 0
108 version_check_warning:
109 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
110 type: list
111 returned: complex
112 '''
113 from ansible.module_utils.basic import AnsibleModule
114 from ansible.module_utils.connection import Connection
115 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
116 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
117
118
119 def main():
120 urls_list = [
121 '/pm/config/adom/{adom}/obj/virtual-patch/profile/{profile}/exemption',
122 '/pm/config/global/obj/virtual-patch/profile/{profile}/exemption'
123 ]
124 module_arg_spec = {
125 'adom': {'required': True, 'type': 'str'},
126 'profile': {'required': True, 'type': 'str'},
127 'revision_note': {'type': 'str'},
128 'virtualpatch_profile_exemption': {
129 'type': 'dict', 'v_range': [['7.4.1', '']],
130 'options': {
131 'device': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'str'},
132 'id': {'v_range': [['7.4.1', '']], 'required': True, 'type': 'int'},
133 'rule': {'v_range': [['7.4.1', '']], 'type': 'list', 'elements': 'int'},
134 'status': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
135 }
136 }
137 }
138
139 module_option_spec = get_module_arg_spec('full crud')
140 module_arg_spec.update(module_option_spec)
141 check_galaxy_version(module_arg_spec)
142 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'virtualpatch_profile_exemption'),
143 supports_check_mode=True)
144 if not module._socket_path:
145 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
146 connection = Connection(module._socket_path)
147 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
148 'id', 'data', module, connection)
149 fmgr.process_crud()
150 module.exit_json(meta=module.params)
151
152
153 if __name__ == '__main__':
154 main()