Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_internetservicegroup.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_internetservicegroup
15 short_description: Configure group of Internet Service.
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 firewall_internetservicegroup:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 member:
37 type: raw
38 description: (list or str) Internet Service group member.
39 name:
40 type: str
41 description: Internet Service group name.
42 required: true
43 direction:
44 type: str
45 description: How this service may be used
46 choices: ['both', 'source', 'destination']
47 '''
48
49 EXAMPLES = '''
50 - name: Example playbook
51 hosts: fortimanagers
52 gather_facts: false
53 connection: httpapi
54 vars:
55 ansible_httpapi_use_ssl: true
56 ansible_httpapi_validate_certs: false
57 ansible_httpapi_port: 443
58 tasks:
59 - name: Configure group of Internet Service.
60 fortinet.fortimanager.fmgr_firewall_internetservicegroup:
61 bypass_validation: false
62 adom: ansible
63 state: present
64 firewall_internetservicegroup:
65 comment: "ansible-comment1"
66 # member: 'ansible-test' # a valid internet service name
67 name: "ansible-test"
68
69 - name: Gathering fortimanager facts
70 hosts: fortimanagers
71 gather_facts: false
72 connection: httpapi
73 vars:
74 ansible_httpapi_use_ssl: true
75 ansible_httpapi_validate_certs: false
76 ansible_httpapi_port: 443
77 tasks:
78 - name: Retrieve all the groups of Internet Service
79 fortinet.fortimanager.fmgr_fact:
80 facts:
81 selector: "firewall_internetservicegroup"
82 params:
83 adom: "ansible"
84 internet_service_group: "your_value"
85 '''
86
87 RETURN = '''
88 meta:
89 description: The result of the request.
90 type: dict
91 returned: always
92 contains:
93 request_url:
94 description: The full url requested.
95 returned: always
96 type: str
97 sample: /sys/login/user
98 response_code:
99 description: The status of api request.
100 returned: always
101 type: int
102 sample: 0
103 response_data:
104 description: The api response.
105 type: list
106 returned: always
107 response_message:
108 description: The descriptive message of the api response.
109 type: str
110 returned: always
111 sample: OK.
112 system_information:
113 description: The information of the target system.
114 type: dict
115 returned: always
116 rc:
117 description: The status the request.
118 type: int
119 returned: always
120 sample: 0
121 version_check_warning:
122 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
123 type: list
124 returned: complex
125 '''
126 from ansible.module_utils.basic import AnsibleModule
127 from ansible.module_utils.connection import Connection
128 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
129 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
130
131
132 def main():
133 urls_list = [
134 '/pm/config/adom/{adom}/obj/firewall/internet-service-group',
135 '/pm/config/global/obj/firewall/internet-service-group'
136 ]
137 module_arg_spec = {
138 'adom': {'required': True, 'type': 'str'},
139 'revision_note': {'type': 'str'},
140 'firewall_internetservicegroup': {
141 'type': 'dict', 'v_range': [['6.0.0', '']],
142 'options': {
143 'comment': {'type': 'str'},
144 'member': {'type': 'raw'},
145 'name': {'required': True, 'type': 'str'},
146 'direction': {'v_range': [['6.2.0', '']], 'choices': ['both', 'source', 'destination'], 'type': 'str'}
147 }
148 }
149 }
150
151 module_option_spec = get_module_arg_spec('full crud')
152 module_arg_spec.update(module_option_spec)
153 check_galaxy_version(module_arg_spec)
154 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetservicegroup'),
155 supports_check_mode=True)
156 if not module._socket_path:
157 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
158 connection = Connection(module._socket_path)
159 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
160 'name', 'data', module, connection)
161 fmgr.process_crud()
162 module.exit_json(meta=module.params)
163
164
165 if __name__ == '__main__':
166 main()