Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_syslog_policy_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 ANSIBLE_METADATA = {'metadata_version': '1.1',
10 'status': ['preview'],
11 'supported_by': 'community'}
12
13 DOCUMENTATION = r'''
14 ---
15 module: intersight_syslog_policy_info
16 short_description: Gather information about Syslog Policies in Cisco Intersight
17 description:
18 - Gathers information about existing Syslog Policies in L(Cisco Intersight,https://intersight.com).
19 - You can filter policies by O(organization) and O(name).
20 - If no filters are provided, the module returns all available Syslog Policies.
21 extends_documentation_fragment: intersight
22 options:
23 organization:
24 description:
25 - The name of the organization to which the Syslog Policy belongs.
26 type: str
27 name:
28 description:
29 - The name of the specific Syslog Policy to retrieve.
30 type: str
31 author:
32 - Ron Gershburg (@rgershbu)
33 '''
34
35 EXAMPLES = r'''
36 - name: Fetch a specific Syslog Policy by name
37 cisco.intersight.intersight_syslog_policy_info:
38 api_private_key: "{{ api_private_key }}"
39 api_key_id: "{{ api_key_id }}"
40 name: "Syslog-Policy-PROD"
41
42 - name: Fetch all Syslog Policies
43 cisco.intersight.intersight_syslog_policy_info:
44 api_private_key: "{{ api_private_key }}"
45 api_key_id: "{{ api_key_id }}"
46 '''
47
48 RETURN = r'''
49 api_response:
50 description: The API response output returned by the specified resource.
51 returned: always
52 type: dict
53 sample:
54 "api_response": [
55 {
56 "Name": "mac_pool_1",
57 "ObjectType": "macpool.Pool",
58 "Tags": [
59 {
60 "Key": "Site",
61 "Value": "tag1"
62 },
63 {
64 "Key": "Site2",
65 "Value": "tag2"
66 }
67 ]
68 },
69 {
70 "Name": "mac_pool_2",
71 "ObjectType": "macpool.Pool",
72 "Tags": [
73 {
74 "Key": "Site1",
75 "Value": "tag1"
76 },
77 {
78 "Key": "Site2",
79 "Value": "tag2"
80 }
81 ]
82 }
83 ]
84 '''
85
86
87 from ansible.module_utils.basic import AnsibleModule
88 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
89
90
91 def main():
92 argument_spec = intersight_argument_spec.copy()
93 argument_spec.update(
94 organization=dict(type='str'),
95 name=dict(type='str')
96 )
97 module = AnsibleModule(
98 argument_spec,
99 supports_check_mode=True,
100 )
101
102 intersight = IntersightModule(module)
103 intersight.result['api_response'] = {}
104 intersight.result['trace_id'] = ''
105
106 # Resource path used to fetch info
107 resource_path = '/syslog/Policies'
108
109 query_params = intersight.set_query_params()
110
111 intersight.get_resource(
112 resource_path=resource_path,
113 query_params=query_params,
114 return_list=True
115 )
116
117 module.exit_json(**intersight.result)
118
119
120 if __name__ == '__main__':
121 main()