Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_system_smsserver.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_smsserver
15 short_description: Configure SMS server for sending SMS messages to support user authentication.
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 system_smsserver:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 mail_server:
34 aliases: ['mail-server']
35 type: str
36 description: Email-to-SMS server domain name.
37 name:
38 type: str
39 description: Name of SMS server.
40 required: true
41 '''
42
43 EXAMPLES = '''
44 - name: Example playbook
45 hosts: fortimanagers
46 gather_facts: false
47 connection: httpapi
48 vars:
49 ansible_httpapi_use_ssl: true
50 ansible_httpapi_validate_certs: false
51 ansible_httpapi_port: 443
52 tasks:
53 - name: Configure SMS server for sending SMS messages to support user authentication.
54 fortinet.fortimanager.fmgr_system_smsserver:
55 bypass_validation: false
56 adom: ansible
57 state: present
58 system_smsserver:
59 mail_server: ansible-test
60 name: ansible-test-smsserver
61
62 - name: Gathering fortimanager facts
63 hosts: fortimanagers
64 gather_facts: false
65 connection: httpapi
66 vars:
67 ansible_httpapi_use_ssl: true
68 ansible_httpapi_validate_certs: false
69 ansible_httpapi_port: 443
70 tasks:
71 - name: Retrieve all the SMS servers
72 fortinet.fortimanager.fmgr_fact:
73 facts:
74 selector: "system_smsserver"
75 params:
76 adom: "ansible"
77 sms_server: "your_value"
78 '''
79
80 RETURN = '''
81 meta:
82 description: The result of the request.
83 type: dict
84 returned: always
85 contains:
86 request_url:
87 description: The full url requested.
88 returned: always
89 type: str
90 sample: /sys/login/user
91 response_code:
92 description: The status of api request.
93 returned: always
94 type: int
95 sample: 0
96 response_data:
97 description: The api response.
98 type: list
99 returned: always
100 response_message:
101 description: The descriptive message of the api response.
102 type: str
103 returned: always
104 sample: OK.
105 system_information:
106 description: The information of the target system.
107 type: dict
108 returned: always
109 rc:
110 description: The status the request.
111 type: int
112 returned: always
113 sample: 0
114 version_check_warning:
115 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
116 type: list
117 returned: complex
118 '''
119 from ansible.module_utils.basic import AnsibleModule
120 from ansible.module_utils.connection import Connection
121 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
122 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
123
124
125 def main():
126 urls_list = [
127 '/pm/config/adom/{adom}/obj/system/sms-server',
128 '/pm/config/global/obj/system/sms-server'
129 ]
130 module_arg_spec = {
131 'adom': {'required': True, 'type': 'str'},
132 'revision_note': {'type': 'str'},
133 'system_smsserver': {
134 'type': 'dict', 'v_range': [['6.0.0', '']],
135 'options': {'mail-server': {'type': 'str'}, 'name': {'required': True, 'type': 'str'}}
136 }
137 }
138
139 module_option_spec = get_module_arg_spec('full crud')
140 module_arg_spec.update(module_option_spec)
141 check_galaxy_version(module_arg_spec)
142 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'system_smsserver'),
143 supports_check_mode=True)
144 if not module._socket_path:
145 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
146 connection = Connection(module._socket_path)
147 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
148 'name', 'data', module, connection)
149 fmgr.process_crud()
150 module.exit_json(meta=module.params)
151
152
153 if __name__ == '__main__':
154 main()