Debian Codegraph @

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