Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_carrierendpointbwl.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_firewall_carrierendpointbwl
15 short_description: Carrier end point black/white list tables.
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 firewall_carrierendpointbwl:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Optional comments.
36 entries:
37 type: list
38 elements: dict
39 description: Entries.
40 suboptions:
41 action:
42 type: list
43 elements: str
44 description: Action to take on this end point
45 choices: ['block', 'exempt', 'exempt-mass-mms']
46 carrier_endpoint:
47 aliases: ['carrier-endpoint']
48 type: str
49 description: End point to act on.
50 log_action:
51 aliases: ['log-action']
52 type: list
53 elements: str
54 description: Action to take on this end point
55 choices: ['archive', 'intercept']
56 pattern_type:
57 aliases: ['pattern-type']
58 type: str
59 description: Wildcard pattern or regular expression.
60 choices: ['wildcard', 'regexp', 'simple']
61 status:
62 type: str
63 description: Enable/disable specified action
64 choices: ['disable', 'enable']
65 id:
66 type: int
67 description: ID.
68 required: true
69 name:
70 type: str
71 description: Name of table.
72 '''
73
74 EXAMPLES = '''
75 - name: Example playbook
76 hosts: fortimanagers
77 gather_facts: false
78 connection: httpapi
79 vars:
80 ansible_httpapi_use_ssl: true
81 ansible_httpapi_validate_certs: false
82 ansible_httpapi_port: 443
83 tasks:
84 - name: Carrier end point black/white list tables.
85 fortinet.fortimanager.fmgr_firewall_carrierendpointbwl:
86 bypass_validation: false
87 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
88 state: present
89 firewall_carrierendpointbwl:
90 comment: "ansible-test"
91 id: 1
92 name: "ansible-test"
93
94 - name: Gathering fortimanager facts
95 hosts: fortimanagers
96 gather_facts: false
97 connection: httpapi
98 vars:
99 ansible_httpapi_use_ssl: true
100 ansible_httpapi_validate_certs: false
101 ansible_httpapi_port: 443
102 tasks:
103 - name: Retrieve all the carrier endpoint black/white list tables
104 fortinet.fortimanager.fmgr_fact:
105 facts:
106 selector: "firewall_carrierendpointbwl"
107 params:
108 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
109 carrier_endpoint_bwl: "your_value"
110 '''
111
112 RETURN = '''
113 meta:
114 description: The result of the request.
115 type: dict
116 returned: always
117 contains:
118 request_url:
119 description: The full url requested.
120 returned: always
121 type: str
122 sample: /sys/login/user
123 response_code:
124 description: The status of api request.
125 returned: always
126 type: int
127 sample: 0
128 response_data:
129 description: The api response.
130 type: list
131 returned: always
132 response_message:
133 description: The descriptive message of the api response.
134 type: str
135 returned: always
136 sample: OK.
137 system_information:
138 description: The information of the target system.
139 type: dict
140 returned: always
141 rc:
142 description: The status the request.
143 type: int
144 returned: always
145 sample: 0
146 version_check_warning:
147 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
148 type: list
149 returned: complex
150 '''
151 from ansible.module_utils.basic import AnsibleModule
152 from ansible.module_utils.connection import Connection
153 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
154 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
155
156
157 def main():
158 urls_list = [
159 '/pm/config/adom/{adom}/obj/firewall/carrier-endpoint-bwl',
160 '/pm/config/global/obj/firewall/carrier-endpoint-bwl'
161 ]
162 module_arg_spec = {
163 'adom': {'required': True, 'type': 'str'},
164 'revision_note': {'type': 'str'},
165 'firewall_carrierendpointbwl': {
166 'type': 'dict', 'v_range': [['6.0.0', '7.6.2']],
167 'options': {
168 'comment': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
169 'entries': {
170 'v_range': [['6.0.0', '7.6.2']],
171 'type': 'list',
172 'options': {
173 'action': {'v_range': [['6.0.0', '7.6.2']], 'type': 'list', 'choices': ['block', 'exempt', 'exempt-mass-mms'], 'elements': 'str'},
174 'carrier-endpoint': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'},
175 'log-action': {'v_range': [['6.0.0', '7.6.2']], 'type': 'list', 'choices': ['archive', 'intercept'], 'elements': 'str'},
176 'pattern-type': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['wildcard', 'regexp', 'simple'], 'type': 'str'},
177 'status': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'}
178 },
179 'elements': 'dict'
180 },
181 'id': {'v_range': [['6.0.0', '7.6.2']], 'required': True, 'type': 'int'},
182 'name': {'v_range': [['6.0.0', '7.6.2']], 'type': 'str'}
183 }
184 }
185 }
186
187 module_option_spec = get_module_arg_spec('full crud')
188 module_arg_spec.update(module_option_spec)
189 check_galaxy_version(module_arg_spec)
190 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_carrierendpointbwl'),
191 supports_check_mode=True)
192 if not module._socket_path:
193 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
194 connection = Connection(module._socket_path)
195 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
196 'id', 'data', module, connection)
197 fmgr.process_crud()
198 module.exit_json(meta=module.params)
199
200
201 if __name__ == '__main__':
202 main()