Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_fmg_script_schedule.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_fmg_script_schedule
15 short_description: Fmg script schedule
16 version_added: "2.13.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 script:
29 description: The parameter (script) in requested url.
30 type: str
31 required: true
32 fmg_script_schedule:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 datetime:
38 type: str
39 description: Datetime.
40 day_of_week:
41 aliases: ['day-of-week']
42 type: int
43 description: Day of week.
44 device:
45 type: int
46 description: Device.
47 run_on_db:
48 aliases: ['run-on-db']
49 type: int
50 description: Run on db.
51 timestamp:
52 type: int
53 description: Timestamp.
54 type:
55 type: str
56 description: Type.
57 choices: ['auto', 'onetime', 'daily', 'weekly', 'monthly']
58 user:
59 type: str
60 description: User.
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: Fmg script schedule
70 fortinet.fortimanager.fmgr_fmg_script_schedule:
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 fmg_script_schedule:
76 # datetime: <string>
77 # day_of_week: <integer>
78 # device: <integer>
79 # run_on_db: <integer>
80 # timestamp: <integer>
81 # type: <value in [auto, onetime, daily, ...]>
82 # user: <string>
83 '''
84
85 RETURN = '''
86 meta:
87 description: The result of the request.
88 type: dict
89 returned: always
90 contains:
91 request_url:
92 description: The full url requested.
93 returned: always
94 type: str
95 sample: /sys/login/user
96 response_code:
97 description: The status of api request.
98 returned: always
99 type: int
100 sample: 0
101 response_data:
102 description: The api response.
103 type: list
104 returned: always
105 response_message:
106 description: The descriptive message of the api response.
107 type: str
108 returned: always
109 sample: OK.
110 system_information:
111 description: The information of the target system.
112 type: dict
113 returned: always
114 rc:
115 description: The status the request.
116 type: int
117 returned: always
118 sample: 0
119 version_check_warning:
120 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
121 type: list
122 returned: complex
123 '''
124 from ansible.module_utils.basic import AnsibleModule
125 from ansible.module_utils.connection import Connection
126 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
127 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
128
129
130 def main():
131 urls_list = [
132 '/pm/config/adom/{adom}/obj/fmg/script/{script}/schedule',
133 '/pm/config/global/obj/fmg/script/{script}/schedule'
134 ]
135 module_arg_spec = {
136 'adom': {'required': True, 'type': 'str'},
137 'script': {'required': True, 'type': 'str'},
138 'revision_note': {'type': 'str'},
139 'fmg_script_schedule': {
140 'type': 'dict', 'v_range': [['7.6.5', '']],
141 'options': {
142 'datetime': {'v_range': [['7.6.5', '']], 'type': 'str'},
143 'day-of-week': {'v_range': [['7.6.5', '']], 'type': 'int'},
144 'device': {'v_range': [['7.6.5', '']], 'type': 'int'},
145 'run-on-db': {'v_range': [['7.6.5', '']], 'type': 'int'},
146 'timestamp': {'v_range': [['7.6.5', '']], 'type': 'int'},
147 'type': {'v_range': [['7.6.5', '']], 'choices': ['auto', 'onetime', 'daily', 'weekly', 'monthly'], 'type': 'str'},
148 'user': {'v_range': [['7.6.5', '']], 'type': 'str'}
149 }
150 }
151 }
152
153 module_option_spec = get_module_arg_spec('full crud')
154 module_arg_spec.update(module_option_spec)
155 check_galaxy_version(module_arg_spec)
156 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'fmg_script_schedule'),
157 supports_check_mode=True)
158 if not module._socket_path:
159 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
160 connection = Connection(module._socket_path)
161 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
162 None, 'data', module, connection)
163 fmgr.process_crud()
164 module.exit_json(meta=module.params)
165
166
167 if __name__ == '__main__':
168 main()