Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetservicename.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_internetservicename
15 short_description: Define internet service names.
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_internetservicename:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 city_id:
34 aliases: ['city-id']
35 type: int
36 description: City ID.
37 country_id:
38 aliases: ['country-id']
39 type: int
40 description: Country or Area ID.
41 internet_service_id:
42 aliases: ['internet-service-id']
43 type: str
44 description: Internet Service ID.
45 name:
46 type: str
47 description: Internet Service name.
48 required: true
49 region_id:
50 aliases: ['region-id']
51 type: int
52 description: Region ID.
53 type:
54 type: str
55 description: Internet Service name type.
56 choices: ['default', 'location']
57 '''
58
59 EXAMPLES = '''
60 - name: Example playbook (generated based on argument schema)
61 hosts: fortimanagers
62 connection: httpapi
63 gather_facts: false
64 tasks:
65 - name: Define internet service names.
66 fortinet.fortimanager.fmgr_firewall_internetservicename:
67 # workspace_locking_adom: <global or your adom name>
68 adom: <your own value>
69 state: present # <value in [present, absent]>
70 firewall_internetservicename:
71 name: "your value" # Required variable, string
72 # city_id: <integer>
73 # country_id: <integer>
74 # internet_service_id: <string>
75 # region_id: <integer>
76 # type: <value in [default, location]>
77 '''
78
79 RETURN = '''
80 meta:
81 description: The result of the request.
82 type: dict
83 returned: always
84 contains:
85 request_url:
86 description: The full url requested.
87 returned: always
88 type: str
89 sample: /sys/login/user
90 response_code:
91 description: The status of api request.
92 returned: always
93 type: int
94 sample: 0
95 response_data:
96 description: The api response.
97 type: list
98 returned: always
99 response_message:
100 description: The descriptive message of the api response.
101 type: str
102 returned: always
103 sample: OK.
104 system_information:
105 description: The information of the target system.
106 type: dict
107 returned: always
108 rc:
109 description: The status the request.
110 type: int
111 returned: always
112 sample: 0
113 version_check_warning:
114 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
115 type: list
116 returned: complex
117 '''
118 from ansible.module_utils.basic import AnsibleModule
119 from ansible.module_utils.connection import Connection
120 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
121 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
122
123
124 def main():
125 urls_list = [
126 '/pm/config/adom/{adom}/obj/firewall/internet-service-name',
127 '/pm/config/global/obj/firewall/internet-service-name'
128 ]
129 module_arg_spec = {
130 'adom': {'required': True, 'type': 'str'},
131 'revision_note': {'type': 'str'},
132 'firewall_internetservicename': {
133 'type': 'dict', 'v_range': [['6.4.0', '']],
134 'options': {
135 'city-id': {'v_range': [['6.4.0', '']], 'type': 'int'},
136 'country-id': {'v_range': [['6.4.0', '']], 'type': 'int'},
137 'internet-service-id': {'v_range': [['6.4.0', '']], 'type': 'str'},
138 'name': {'v_range': [['6.4.0', '']], 'required': True, 'type': 'str'},
139 'region-id': {'v_range': [['6.4.0', '']], 'type': 'int'},
140 'type': {'v_range': [['6.4.0', '']], 'choices': ['default', 'location'], 'type': 'str'}
141 }
142 }
143 }
144
145 module_option_spec = get_module_arg_spec('full crud')
146 module_arg_spec.update(module_option_spec)
147 check_galaxy_version(module_arg_spec)
148 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetservicename'),
149 supports_check_mode=True)
150 if not module._socket_path:
151 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
152 connection = Connection(module._socket_path)
153 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
154 'name', 'data', module, connection)
155 fmgr.process_crud()
156 module.exit_json(meta=module.params)
157
158
159 if __name__ == '__main__':
160 main()