Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_customcommand.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_switchcontroller_customcommand
15 short_description: Configure the FortiGate switch controller to send custom commands to managed FortiSwitch devices.
16 version_added: "2.1.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 switchcontroller_customcommand:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 command:
34 type: str
35 description: String of commands to send to FortiSwitch devices
36 command_name:
37 aliases: ['command-name']
38 type: str
39 description: Command name called by the FortiGate switch controller in the execute command.
40 description:
41 type: str
42 description: Description.
43 '''
44
45 EXAMPLES = '''
46 - name: Example playbook (generated based on argument schema)
47 hosts: fortimanagers
48 connection: httpapi
49 gather_facts: false
50 tasks:
51 - name: Configure the FortiGate switch controller to send custom commands to managed FortiSwitch devices.
52 fortinet.fortimanager.fmgr_switchcontroller_customcommand:
53 # workspace_locking_adom: <global or your adom name>
54 adom: <your own value>
55 state: present # <value in [present, absent]>
56 switchcontroller_customcommand:
57 # command: <string>
58 # command_name: <string>
59 # description: <string>
60 '''
61
62 RETURN = '''
63 meta:
64 description: The result of the request.
65 type: dict
66 returned: always
67 contains:
68 request_url:
69 description: The full url requested.
70 returned: always
71 type: str
72 sample: /sys/login/user
73 response_code:
74 description: The status of api request.
75 returned: always
76 type: int
77 sample: 0
78 response_data:
79 description: The api response.
80 type: list
81 returned: always
82 response_message:
83 description: The descriptive message of the api response.
84 type: str
85 returned: always
86 sample: OK.
87 system_information:
88 description: The information of the target system.
89 type: dict
90 returned: always
91 rc:
92 description: The status the request.
93 type: int
94 returned: always
95 sample: 0
96 version_check_warning:
97 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
98 type: list
99 returned: complex
100 '''
101 from ansible.module_utils.basic import AnsibleModule
102 from ansible.module_utils.connection import Connection
103 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
104 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
105
106
107 def main():
108 urls_list = [
109 '/pm/config/adom/{adom}/obj/switch-controller/custom-command',
110 '/pm/config/global/obj/switch-controller/custom-command'
111 ]
112 module_arg_spec = {
113 'adom': {'required': True, 'type': 'str'},
114 'revision_note': {'type': 'str'},
115 'switchcontroller_customcommand': {
116 'type': 'dict', 'v_range': [['7.0.0', '']],
117 'options': {
118 'command': {'v_range': [['7.0.0', '']], 'type': 'str'},
119 'command-name': {'v_range': [['7.0.0', '']], 'type': 'str'},
120 'description': {'v_range': [['7.0.0', '']], 'type': 'str'}
121 }
122 }
123 }
124
125 module_option_spec = get_module_arg_spec('full crud')
126 module_arg_spec.update(module_option_spec)
127 check_galaxy_version(module_arg_spec)
128 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_customcommand'),
129 supports_check_mode=True)
130 if not module._socket_path:
131 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
132 connection = Connection(module._socket_path)
133 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
134 None, 'data', module, connection)
135 fmgr.process_crud()
136 module.exit_json(meta=module.params)
137
138
139 if __name__ == '__main__':
140 main()