Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_service_group.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_service_group
15 short_description: Configure service groups.
16 version_added: "1.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_service_group:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 color:
34 type: int
35 description: Color of icon on the GUI.
36 comment:
37 type: raw
38 description: (dict or str) Comment.
39 member:
40 type: raw
41 description: (list or str) Service objects contained within the group.
42 name:
43 type: str
44 description: Address group name.
45 required: true
46 proxy:
47 type: str
48 description: Enable/disable web proxy service group.
49 choices: ['disable', 'enable']
50 explicit_proxy:
51 aliases: ['explicit-proxy']
52 type: str
53 description: Enable/disable explicit web proxy service group.
54 choices: ['disable', 'enable']
55 global_object:
56 aliases: ['global-object']
57 type: int
58 description: Global Object.
59 fabric_object:
60 aliases: ['fabric-object']
61 type: str
62 description: Security Fabric global object setting.
63 choices: ['disable', 'enable']
64 uuid:
65 type: str
66 description: Universally Unique Identifier
67 '''
68
69 EXAMPLES = '''
70 - name: Example playbook
71 hosts: fortimanagers
72 gather_facts: false
73 connection: httpapi
74 vars:
75 ansible_httpapi_use_ssl: true
76 ansible_httpapi_validate_certs: false
77 ansible_httpapi_port: 443
78 tasks:
79 - name: Configure service groups.
80 fortinet.fortimanager.fmgr_firewall_service_group:
81 bypass_validation: false
82 adom: ansible
83 state: present
84 firewall_service_group:
85 color: 1
86 comment: "ansible-comment"
87 name: "ansible-test-group"
88 proxy: disable
89
90 - name: Gathering fortimanager facts
91 hosts: fortimanagers
92 gather_facts: false
93 connection: httpapi
94 vars:
95 ansible_httpapi_use_ssl: true
96 ansible_httpapi_validate_certs: false
97 ansible_httpapi_port: 443
98 tasks:
99 - name: Retrieve all the service groups
100 fortinet.fortimanager.fmgr_fact:
101 facts:
102 selector: "firewall_service_group"
103 params:
104 adom: "ansible"
105 group: "your_value"
106 '''
107
108 RETURN = '''
109 meta:
110 description: The result of the request.
111 type: dict
112 returned: always
113 contains:
114 request_url:
115 description: The full url requested.
116 returned: always
117 type: str
118 sample: /sys/login/user
119 response_code:
120 description: The status of api request.
121 returned: always
122 type: int
123 sample: 0
124 response_data:
125 description: The api response.
126 type: list
127 returned: always
128 response_message:
129 description: The descriptive message of the api response.
130 type: str
131 returned: always
132 sample: OK.
133 system_information:
134 description: The information of the target system.
135 type: dict
136 returned: always
137 rc:
138 description: The status the request.
139 type: int
140 returned: always
141 sample: 0
142 version_check_warning:
143 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
144 type: list
145 returned: complex
146 '''
147 from ansible.module_utils.basic import AnsibleModule
148 from ansible.module_utils.connection import Connection
149 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
150 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
151
152
153 def main():
154 urls_list = [
155 '/pm/config/adom/{adom}/obj/firewall/service/group',
156 '/pm/config/global/obj/firewall/service/group'
157 ]
158 module_arg_spec = {
159 'adom': {'required': True, 'type': 'str'},
160 'revision_note': {'type': 'str'},
161 'firewall_service_group': {
162 'type': 'dict', 'v_range': [['6.0.0', '']],
163 'options': {
164 'color': {'type': 'int'},
165 'comment': {'type': 'raw'},
166 'member': {'type': 'raw'},
167 'name': {'required': True, 'type': 'str'},
168 'proxy': {'choices': ['disable', 'enable'], 'type': 'str'},
169 'explicit-proxy': {'v_range': [['6.2.0', '6.2.13']], 'choices': ['disable', 'enable'], 'type': 'str'},
170 'global-object': {'v_range': [['6.4.0', '']], 'type': 'int'},
171 'fabric-object': {'v_range': [['6.4.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
172 'uuid': {'v_range': [['7.4.2', '']], 'type': 'str'}
173 }
174 }
175 }
176
177 module_option_spec = get_module_arg_spec('full crud')
178 module_arg_spec.update(module_option_spec)
179 check_galaxy_version(module_arg_spec)
180 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_service_group'),
181 supports_check_mode=True)
182 if not module._socket_path:
183 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
184 connection = Connection(module._socket_path)
185 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
186 'name', 'data', module, connection)
187 fmgr.process_crud()
188 module.exit_json(meta=module.params)
189
190
191 if __name__ == '__main__':
192 main()