Debian Codegraph @

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