Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dvmdb_script_scriptschedule.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_dvmdb_script_scriptschedule
15 short_description: Script schedule table.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 adom:
22 description: The parameter (adom) in requested url.
23 type: str
24 required: true
25 script:
26 description: The parameter (script) in requested url.
27 type: str
28 required: true
29 dvmdb_script_scriptschedule:
30 description: The top level parameters set.
31 required: false
32 type: dict
33 suboptions:
34 datetime:
35 type: str
36 description:
37 - Indicates the date and time of the schedule.
38 - onetime
39 - daily
40 - weekly
41 - monthly
42 day_of_week:
43 type: str
44 description: Day of week.
45 choices: ['unknown', 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']
46 device:
47 type: int
48 description: Name or id of an existing device in the database.
49 name:
50 type: str
51 description: Name.
52 required: true
53 run_on_db:
54 type: str
55 description: Indicates if the scheduled script should be executed on device database.
56 choices: ['disable', 'enable']
57 type:
58 type: str
59 description: Type.
60 choices: ['auto', 'onetime', 'daily', 'weekly', 'monthly']
61 '''
62
63 EXAMPLES = '''
64 - name: Example playbook (generated based on argument schema)
65 hosts: fortimanagers
66 connection: httpapi
67 gather_facts: false
68 tasks:
69 - name: Script schedule table.
70 fortinet.fortimanager.fmgr_dvmdb_script_scriptschedule:
71 # workspace_locking_adom: <global or your adom name>
72 adom: <your own value>
73 script: <your own value>
74 state: present # <value in [present, absent]>
75 dvmdb_script_scriptschedule:
76 name: "your value" # Required variable, string
77 # datetime: <string>
78 # day_of_week: <value in [unknown, sun, mon, ...]>
79 # device: <integer>
80 # run_on_db: <value in [disable, enable]>
81 # type: <value in [auto, onetime, daily, ...]>
82 '''
83
84 RETURN = '''
85 meta:
86 description: The result of the request.
87 type: dict
88 returned: always
89 contains:
90 request_url:
91 description: The full url requested.
92 returned: always
93 type: str
94 sample: /sys/login/user
95 response_code:
96 description: The status of api request.
97 returned: always
98 type: int
99 sample: 0
100 response_data:
101 description: The api response.
102 type: list
103 returned: always
104 response_message:
105 description: The descriptive message of the api response.
106 type: str
107 returned: always
108 sample: OK.
109 system_information:
110 description: The information of the target system.
111 type: dict
112 returned: always
113 rc:
114 description: The status the request.
115 type: int
116 returned: always
117 sample: 0
118 version_check_warning:
119 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
120 type: list
121 returned: complex
122 '''
123 from ansible.module_utils.basic import AnsibleModule
124 from ansible.module_utils.connection import Connection
125 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
126 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
127
128
129 def main():
130 urls_list = [
131 '/dvmdb/adom/{adom}/script/{script}/script_schedule',
132 '/dvmdb/global/script/{script}/script_schedule',
133 '/dvmdb/script/{script}/script_schedule'
134 ]
135 module_arg_spec = {
136 'adom': {'required': True, 'type': 'str'},
137 'script': {'required': True, 'type': 'str'},
138 'dvmdb_script_scriptschedule': {
139 'type': 'dict', 'v_range': [['6.0.0', '']],
140 'options': {
141 'datetime': {'type': 'str'},
142 'day_of_week': {'choices': ['unknown', 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'type': 'str'},
143 'device': {'type': 'int'},
144 'name': {'required': True, 'type': 'str'},
145 'run_on_db': {'choices': ['disable', 'enable'], 'type': 'str'},
146 'type': {'choices': ['auto', 'onetime', 'daily', 'weekly', 'monthly'], '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, 'dvmdb_script_scriptschedule'),
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()