Debian Codegraph @

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