Debian Codegraph @

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