Debian Codegraph @

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