Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetserviceaddition.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_internetserviceaddition
15 short_description: Configure Internet Services Addition.
16 version_added: "2.1.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_internetserviceaddition:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 entry:
37 type: list
38 elements: dict
39 description: Entry.
40 suboptions:
41 id:
42 type: int
43 description: Entry ID
44 port_range:
45 aliases: ['port-range']
46 type: list
47 elements: dict
48 description: Port range.
49 suboptions:
50 end_port:
51 aliases: ['end-port']
52 type: int
53 description: Integer value for ending TCP/UDP/SCTP destination port in range
54 id:
55 type: int
56 description: Custom entry port range ID.
57 start_port:
58 aliases: ['start-port']
59 type: int
60 description: Integer value for starting TCP/UDP/SCTP destination port in range
61 protocol:
62 type: int
63 description: Integer value for the protocol type as defined by IANA
64 addr_mode:
65 aliases: ['addr-mode']
66 type: str
67 description: Address mode
68 choices: ['ipv4', 'ipv6']
69 id:
70 type: str
71 description: Internet Service ID in the Internet Service database.
72 required: true
73 '''
74
75 EXAMPLES = '''
76 - name: Example playbook (generated based on argument schema)
77 hosts: fortimanagers
78 connection: httpapi
79 gather_facts: false
80 tasks:
81 - name: Configure Internet Services Addition.
82 fortinet.fortimanager.fmgr_firewall_internetserviceaddition:
83 # workspace_locking_adom: <global or your adom name>
84 adom: <your own value>
85 state: present # <value in [present, absent]>
86 firewall_internetserviceaddition:
87 id: "your value" # Required variable, string
88 # comment: <string>
89 # entry:
90 # - id: <integer>
91 # port_range:
92 # - end_port: <integer>
93 # id: <integer>
94 # start_port: <integer>
95 # protocol: <integer>
96 # addr_mode: <value in [ipv4, ipv6]>
97 '''
98
99 RETURN = '''
100 meta:
101 description: The result of the request.
102 type: dict
103 returned: always
104 contains:
105 request_url:
106 description: The full url requested.
107 returned: always
108 type: str
109 sample: /sys/login/user
110 response_code:
111 description: The status of api request.
112 returned: always
113 type: int
114 sample: 0
115 response_data:
116 description: The api response.
117 type: list
118 returned: always
119 response_message:
120 description: The descriptive message of the api response.
121 type: str
122 returned: always
123 sample: OK.
124 system_information:
125 description: The information of the target system.
126 type: dict
127 returned: always
128 rc:
129 description: The status the request.
130 type: int
131 returned: always
132 sample: 0
133 version_check_warning:
134 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
135 type: list
136 returned: complex
137 '''
138 from ansible.module_utils.basic import AnsibleModule
139 from ansible.module_utils.connection import Connection
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
142
143
144 def main():
145 urls_list = [
146 '/pm/config/adom/{adom}/obj/firewall/internet-service-addition',
147 '/pm/config/global/obj/firewall/internet-service-addition'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'revision_note': {'type': 'str'},
152 'firewall_internetserviceaddition': {
153 'type': 'dict', 'v_range': [['6.2.2', '']],
154 'options': {
155 'comment': {'v_range': [['6.2.2', '']], 'type': 'str'},
156 'entry': {
157 'v_range': [['6.2.2', '']],
158 'type': 'list',
159 'options': {
160 'id': {'v_range': [['6.2.2', '']], 'type': 'int'},
161 'port-range': {
162 'v_range': [['6.2.2', '']],
163 'type': 'list',
164 'options': {
165 'end-port': {'v_range': [['6.2.2', '']], 'type': 'int'},
166 'id': {'v_range': [['6.2.2', '']], 'type': 'int'},
167 'start-port': {'v_range': [['6.2.2', '']], 'type': 'int'}
168 },
169 'elements': 'dict'
170 },
171 'protocol': {'v_range': [['6.2.2', '']], 'type': 'int'},
172 'addr-mode': {'v_range': [['7.2.1', '']], 'choices': ['ipv4', 'ipv6'], 'type': 'str'}
173 },
174 'elements': 'dict'
175 },
176 'id': {'v_range': [['6.2.2', '']], 'required': True, 'type': 'str'}
177 }
178 }
179 }
180
181 module_option_spec = get_module_arg_spec('full crud')
182 module_arg_spec.update(module_option_spec)
183 check_galaxy_version(module_arg_spec)
184 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetserviceaddition'),
185 supports_check_mode=True)
186 if not module._socket_path:
187 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
188 connection = Connection(module._socket_path)
189 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
190 'id', 'data', module, connection)
191 fmgr.process_crud()
192 module.exit_json(meta=module.params)
193
194
195 if __name__ == '__main__':
196 main()