Debian Codegraph @

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