Debian Codegraph @

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