Debian Codegraph @

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