Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_backup_allsettings.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_system_backup_allsettings
15 short_description: Scheduled backup settings.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.partial_crud
20 options:
21 system_backup_allsettings:
22 description: The top level parameters set.
23 required: false
24 type: dict
25 suboptions:
26 cert:
27 type: str
28 description: SSH certificate for authentication.
29 crptpasswd:
30 type: raw
31 description: (list) Optional password to protect backup content.
32 directory:
33 type: str
34 description: Directory in which file will be stored on backup server.
35 passwd:
36 type: raw
37 description: (list) Backup server login user password.
38 protocol:
39 type: str
40 description:
41 - Protocol used to backup.
42 - sftp - SFTP.
43 - ftp - FTP.
44 - scp - SCP.
45 choices: ['sftp', 'ftp', 'scp']
46 server:
47 type: str
48 description: Backup server name/IP.
49 status:
50 type: str
51 description:
52 - Enable/disable schedule backup.
53 - disable - Disable setting.
54 - enable - Enable setting.
55 choices: ['disable', 'enable']
56 time:
57 type: str
58 description: Time to backup.
59 user:
60 type: str
61 description: Backup server login user.
62 week_days:
63 type: list
64 elements: str
65 description:
66 - Week days to backup.
67 - monday - Monday.
68 - tuesday - Tuesday.
69 - wednesday - Wednesday.
70 - thursday - Thursday.
71 - friday - Friday.
72 - saturday - Saturday.
73 - sunday - Sunday.
74 choices: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
75 'sunday']
76 '''
77
78 EXAMPLES = '''
79 - name: Example playbook (generated based on argument schema)
80 hosts: fortimanagers
81 connection: httpapi
82 gather_facts: false
83 tasks:
84 - name: Scheduled backup settings.
85 fortinet.fortimanager.fmgr_system_backup_allsettings:
86 # workspace_locking_adom: <global or your adom name>
87 system_backup_allsettings:
88 # cert: <string>
89 # crptpasswd: <list or string>
90 # directory: <string>
91 # passwd: <list or string>
92 # protocol: <value in [sftp, ftp, scp]>
93 # server: <string>
94 # status: <value in [disable, enable]>
95 # time: <string>
96 # user: <string>
97 # week_days: ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday",
98 # "sunday"]
99 '''
100
101 RETURN = '''
102 meta:
103 description: The result of the request.
104 type: dict
105 returned: always
106 contains:
107 request_url:
108 description: The full url requested.
109 returned: always
110 type: str
111 sample: /sys/login/user
112 response_code:
113 description: The status of api request.
114 returned: always
115 type: int
116 sample: 0
117 response_data:
118 description: The api response.
119 type: list
120 returned: always
121 response_message:
122 description: The descriptive message of the api response.
123 type: str
124 returned: always
125 sample: OK.
126 system_information:
127 description: The information of the target system.
128 type: dict
129 returned: always
130 rc:
131 description: The status the request.
132 type: int
133 returned: always
134 sample: 0
135 version_check_warning:
136 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
137 type: list
138 returned: complex
139 '''
140 from ansible.module_utils.basic import AnsibleModule
141 from ansible.module_utils.connection import Connection
142 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
143 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
144
145
146 def main():
147 urls_list = [
148 '/cli/global/system/backup/all-settings'
149 ]
150 module_arg_spec = {
151 'system_backup_allsettings': {
152 'type': 'dict', 'v_range': [['6.0.0', '']],
153 'options': {
154 'cert': {'type': 'str'},
155 'crptpasswd': {'no_log': True, 'type': 'raw'},
156 'directory': {'type': 'str'},
157 'passwd': {'no_log': True, 'type': 'raw'},
158 'protocol': {'choices': ['sftp', 'ftp', 'scp'], 'type': 'str'},
159 'server': {'type': 'str'},
160 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
161 'time': {'type': 'str'},
162 'user': {'type': 'str'},
163 'week_days': {
164 'type': 'list',
165 'choices': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'],
166 'elements': 'str'
167 }
168 }
169 }
170 }
171
172 module_option_spec = get_module_arg_spec('partial crud')
173 module_arg_spec.update(module_option_spec)
174 check_galaxy_version(module_arg_spec)
175 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_backup_allsettings'),
176 supports_check_mode=True)
177 if not module._socket_path:
178 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
179 connection = Connection(module._socket_path)
180 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
181 None, 'data', module, connection)
182 fmgr.process_partial_crud()
183 module.exit_json(meta=module.params)
184
185
186 if __name__ == '__main__':
187 main()