Debian Codegraph @

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