Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_bonjourprofile.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_bonjourprofile
15 short_description: Configure Bonjour profiles.
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 bonjourprofile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 name:
37 type: str
38 description: Bonjour profile name.
39 required: true
40 policy_list:
41 aliases: ['policy-list']
42 type: list
43 elements: dict
44 description: Policy list.
45 suboptions:
46 description:
47 type: str
48 description: Description.
49 from_vlan:
50 aliases: ['from-vlan']
51 type: str
52 description: VLAN ID from which the Bonjour service is advertised
53 policy_id:
54 aliases: ['policy-id']
55 type: int
56 description: Policy ID.
57 services:
58 type: list
59 elements: str
60 description: Bonjour services for the VLAN connecting to the Bonjour network.
61 choices: ['airplay', 'afp', 'bit-torrent', 'ftp', 'ichat', 'itunes',
62 'printers', 'samba', 'scanners', 'ssh', 'chromecast', 'all',
63 'miracast']
64 to_vlan:
65 aliases: ['to-vlan']
66 type: str
67 description: VLAN ID to which the Bonjour service is made available
68 micro_location:
69 aliases: ['micro-location']
70 type: str
71 description: Enable/disable Micro location for Bonjour profile
72 choices: ['disable', 'enable']
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 Bonjour profiles.
82 fortinet.fortimanager.fmgr_bonjourprofile:
83 # workspace_locking_adom: <global or your adom name>
84 adom: <your own value>
85 state: present # <value in [present, absent]>
86 bonjourprofile:
87 name: "your value" # Required variable, string
88 # comment: <string>
89 # policy_list:
90 # - description: <string>
91 # from_vlan: <string>
92 # policy_id: <integer>
93 # services: ["airplay", "afp", "bit-torrent", "ftp", "ichat", "itunes", "printers",
94 # "samba", "scanners", "ssh", "chromecast", "all", "miracast"]
95 # to_vlan: <string>
96 # micro_location: <value in [disable, enable]>
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/wireless-controller/bonjour-profile',
147 '/pm/config/global/obj/wireless-controller/bonjour-profile'
148 ]
149 module_arg_spec = {
150 'adom': {'required': True, 'type': 'str'},
151 'revision_note': {'type': 'str'},
152 'bonjourprofile': {
153 'type': 'dict', 'v_range': [['6.0.0', '']],
154 'options': {
155 'comment': {'type': 'str'},
156 'name': {'required': True, 'type': 'str'},
157 'policy-list': {
158 'type': 'list',
159 'options': {
160 'description': {'type': 'str'},
161 'from-vlan': {'type': 'str'},
162 'policy-id': {'type': 'int'},
163 'services': {
164 'type': 'list',
165 'choices': [
166 'airplay', 'afp', 'bit-torrent', 'ftp', 'ichat', 'itunes', 'printers', 'samba', 'scanners', 'ssh', 'chromecast', 'all',
167 'miracast'
168 ],
169 'elements': 'str'
170 },
171 'to-vlan': {'type': 'str'}
172 },
173 'elements': 'dict'
174 },
175 'micro-location': {'v_range': [['7.6.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
176 }
177 }
178 }
179
180 module_option_spec = get_module_arg_spec('full crud')
181 module_arg_spec.update(module_option_spec)
182 check_galaxy_version(module_arg_spec)
183 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'bonjourprofile'),
184 supports_check_mode=True)
185 if not module._socket_path:
186 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
187 connection = Connection(module._socket_path)
188 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
189 'name', 'data', module, connection)
190 fmgr.process_crud()
191 module.exit_json(meta=module.params)
192
193
194 if __name__ == '__main__':
195 main()