Debian Codegraph @

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