Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_carrierendpointbwl_entries.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_entries
15 short_description: Carrier end point black/white list.
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 carrier-endpoint-bwl:
29 description: Deprecated, please use "carrier_endpoint_bwl"
30 type: str
31 carrier_endpoint_bwl:
32 description: The parameter (carrier-endpoint-bwl) in requested url.
33 type: str
34 firewall_carrierendpointbwl_entries:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 action:
40 type: list
41 elements: str
42 description: Action to take on this end point
43 choices: ['block', 'exempt', 'exempt-mass-mms']
44 carrier_endpoint:
45 aliases: ['carrier-endpoint']
46 type: str
47 description: End point to act on.
48 required: true
49 log_action:
50 aliases: ['log-action']
51 type: list
52 elements: str
53 description: Action to take on this end point
54 choices: ['archive', 'intercept']
55 pattern_type:
56 aliases: ['pattern-type']
57 type: str
58 description: Wildcard pattern or regular expression.
59 choices: ['wildcard', 'regexp', 'simple']
60 status:
61 type: str
62 description: Enable/disable specified action
63 choices: ['disable', 'enable']
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: Carrier end point black/white list.
77 fortinet.fortimanager.fmgr_firewall_carrierendpointbwl_entries:
78 bypass_validation: false
79 adom: FortiCarrier # This is FOC-only object, need a FortiCarrier adom
80 carrier_endpoint_bwl: "1" # id
81 state: present
82 firewall_carrierendpointbwl_entries:
83 action:
84 - block
85 - exempt
86 - exempt-mass-mms
87 carrier_endpoint: "string"
88 log_action:
89 - archive
90 - intercept
91 pattern_type: wildcard # <value in [wildcard, regexp, simple]>
92 status: enable
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 table
104 fortinet.fortimanager.fmgr_fact:
105 facts:
106 selector: "firewall_carrierendpointbwl_entries"
107 params:
108 adom: "FortiCarrier" # This is FOC-only object, need a FortiCarrier adom
109 carrier_endpoint_bwl: "1" # id
110 entries: "your_value"
111 '''
112
113 RETURN = '''
114 meta:
115 description: The result of the request.
116 type: dict
117 returned: always
118 contains:
119 request_url:
120 description: The full url requested.
121 returned: always
122 type: str
123 sample: /sys/login/user
124 response_code:
125 description: The status of api request.
126 returned: always
127 type: int
128 sample: 0
129 response_data:
130 description: The api response.
131 type: list
132 returned: always
133 response_message:
134 description: The descriptive message of the api response.
135 type: str
136 returned: always
137 sample: OK.
138 system_information:
139 description: The information of the target system.
140 type: dict
141 returned: always
142 rc:
143 description: The status the request.
144 type: int
145 returned: always
146 sample: 0
147 version_check_warning:
148 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
149 type: list
150 returned: complex
151 '''
152 from ansible.module_utils.basic import AnsibleModule
153 from ansible.module_utils.connection import Connection
154 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
155 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
156
157
158 def main():
159 urls_list = [
160 '/pm/config/adom/{adom}/obj/firewall/carrier-endpoint-bwl/{carrier-endpoint-bwl}/entries',
161 '/pm/config/global/obj/firewall/carrier-endpoint-bwl/{carrier-endpoint-bwl}/entries'
162 ]
163 module_arg_spec = {
164 'adom': {'required': True, 'type': 'str'},
165 'carrier-endpoint-bwl': {'type': 'str', 'api_name': 'carrier_endpoint_bwl'},
166 'carrier_endpoint_bwl': {'type': 'str'},
167 'revision_note': {'type': 'str'},
168 'firewall_carrierendpointbwl_entries': {
169 'type': 'dict', 'v_range': [['6.0.0', '7.6.2']],
170 'options': {
171 'action': {'v_range': [['6.0.0', '7.6.2']], 'type': 'list', 'choices': ['block', 'exempt', 'exempt-mass-mms'], 'elements': 'str'},
172 'carrier-endpoint': {'v_range': [['6.0.0', '7.6.2']], 'required': True, 'type': 'str'},
173 'log-action': {'v_range': [['6.0.0', '7.6.2']], 'type': 'list', 'choices': ['archive', 'intercept'], 'elements': 'str'},
174 'pattern-type': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['wildcard', 'regexp', 'simple'], 'type': 'str'},
175 'status': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['disable', 'enable'], '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, 'firewall_carrierendpointbwl_entries'),
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 'carrier-endpoint', 'data', module, connection)
190 fmgr.process_crud()
191 module.exit_json(meta=module.params)
192
193
194 if __name__ == '__main__':
195 main()