Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_webproxy_profile_headers.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_webproxy_profile_headers
15 short_description: Configure HTTP forwarded requests headers.
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 profile:
29 description: The parameter (profile) in requested url.
30 type: str
31 required: true
32 webproxy_profile_headers:
33 description: The top level parameters set.
34 required: false
35 type: dict
36 suboptions:
37 action:
38 type: str
39 description: Action when HTTP the header forwarded.
40 choices: ['add-to-request', 'add-to-response', 'remove-from-request',
41 'remove-from-response', 'monitor-request', 'monitor-response']
42 content:
43 type: str
44 description: HTTP headers content.
45 id:
46 type: int
47 description: HTTP forwarded header id.
48 required: true
49 name:
50 type: str
51 description: HTTP forwarded header name.
52 add_option:
53 aliases: ['add-option']
54 type: str
55 description: Configure options to append content to existing HTTP header or add new HTTP header.
56 choices: ['append', 'new-on-not-found', 'new', 'replace', 'replace-when-match']
57 base64_encoding:
58 aliases: ['base64-encoding']
59 type: str
60 description: Enable/disable use of base64 encoding of HTTP content.
61 choices: ['disable', 'enable']
62 dstaddr:
63 type: raw
64 description: (list or str) Destination address and address group names.
65 dstaddr6:
66 type: raw
67 description: (list or str) Destination address and address group names
68 protocol:
69 type: list
70 elements: str
71 description: Configure protocol
72 choices: ['https', 'http']
73 '''
74
75 EXAMPLES = '''
76 - name: Example playbook (generated based on argument schema)
77 hosts: fortimanagers
78 connection: httpapi
79 gather_facts: false
80 tasks:
81 - name: Configure HTTP forwarded requests headers.
82 fortinet.fortimanager.fmgr_webproxy_profile_headers:
83 # workspace_locking_adom: <global or your adom name>
84 adom: <your own value>
85 profile: <your own value>
86 state: present # <value in [present, absent]>
87 webproxy_profile_headers:
88 id: 0 # Required variable, integer
89 # action: <value in [add-to-request, add-to-response, remove-from-request, ...]>
90 # content: <string>
91 # name: <string>
92 # add_option: <value in [append, new-on-not-found, new, ...]>
93 # base64_encoding: <value in [disable, enable]>
94 # dstaddr: <list or string>
95 # dstaddr6: <list or string>
96 # protocol: ["https", "http"]
97 '''
98
99 RETURN = '''
100 meta:
101 description: The result of the request.
102 type: dict
103 returned: always
104 contains:
105 request_url:
106 description: The full url requested.
107 returned: always
108 type: str
109 sample: /sys/login/user
110 response_code:
111 description: The status of api request.
112 returned: always
113 type: int
114 sample: 0
115 response_data:
116 description: The api response.
117 type: list
118 returned: always
119 response_message:
120 description: The descriptive message of the api response.
121 type: str
122 returned: always
123 sample: OK.
124 system_information:
125 description: The information of the target system.
126 type: dict
127 returned: always
128 rc:
129 description: The status the request.
130 type: int
131 returned: always
132 sample: 0
133 version_check_warning:
134 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
135 type: list
136 returned: complex
137 '''
138 from ansible.module_utils.basic import AnsibleModule
139 from ansible.module_utils.connection import Connection
140 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
141 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
142
143
144 def main():
145 urls_list = [
146 '/pm/config/adom/{adom}/obj/web-proxy/profile/{profile}/headers',
147 '/pm/config/global/obj/web-proxy/profile/{profile}/headers'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'profile': {'required': True, 'type': 'str'},
152 'revision_note': {'type': 'str'},
153 'webproxy_profile_headers': {
154 'type': 'dict', 'v_range': [['6.0.0', '']],
155 'options': {
156 'action': {
157 'choices': ['add-to-request', 'add-to-response', 'remove-from-request', 'remove-from-response', 'monitor-request', 'monitor-response'],
158 'type': 'str'
159 },
160 'content': {'type': 'str'},
161 'id': {'required': True, 'type': 'int'},
162 'name': {'type': 'str'},
163 'add-option': {
164 'v_range': [['6.2.0', '']],
165 'choices': ['append', 'new-on-not-found', 'new', 'replace', 'replace-when-match'],
166 'type': 'str'
167 },
168 'base64-encoding': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
169 'dstaddr': {'v_range': [['6.2.0', '']], 'type': 'raw'},
170 'dstaddr6': {'v_range': [['6.2.0', '']], 'type': 'raw'},
171 'protocol': {'v_range': [['6.2.0', '']], 'type': 'list', 'choices': ['https', 'http'], 'elements': 'str'}
172 }
173 }
174 }
175
176 module_option_spec = get_module_arg_spec('full crud')
177 module_arg_spec.update(module_option_spec)
178 check_galaxy_version(module_arg_spec)
179 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'webproxy_profile_headers'),
180 supports_check_mode=True)
181 if not module._socket_path:
182 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
183 connection = Connection(module._socket_path)
184 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
185 'id', 'data', module, connection)
186 fmgr.process_crud()
187 module.exit_json(meta=module.params)
188
189
190 if __name__ == '__main__':
191 main()