Debian Codegraph @

ansible_collections/cisco/intersight/plugins/modules/intersight_organization_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_organization_info
16 short_description: Gather information about Organizations in Cisco Intersight
17 description:
18 - Gather information about Organizations in L(Cisco Intersight,https://intersight.com).
19 - Information can be filtered by O(name).
20 - If no filters are passed, all Organizations will be returned.
21 - Organizations are account-level resources and are not scoped to another organization.
22 extends_documentation_fragment: intersight
23 options:
24 name:
25 description:
26 - The name of the Organization to gather information from.
27 type: str
28 author:
29 - Ron Gershburg (@rgershbu)
30 '''
31
32 EXAMPLES = r'''
33 - name: Fetch a specific Organization by name
34 cisco.intersight.intersight_organization_info:
35 api_private_key: "{{ api_private_key }}"
36 api_key_id: "{{ api_key_id }}"
37 name: "my-organization"
38
39 - name: Fetch all Organizations
40 cisco.intersight.intersight_organization_info:
41 api_private_key: "{{ api_private_key }}"
42 api_key_id: "{{ api_key_id }}"
43 '''
44
45 RETURN = r'''
46 api_response:
47 description: The API response output returned by the specified resource.
48 returned: always
49 type: dict
50 sample:
51 "api_response": [
52 {
53 "Name": "my-organization",
54 "ObjectType": "organization.Organization",
55 "Description": "My organization"
56 },
57 {
58 "Name": "another-org",
59 "ObjectType": "organization.Organization",
60 "Description": "Another organization"
61 }
62 ]
63 '''
64
65
66 from ansible.module_utils.basic import AnsibleModule
67 from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec
68
69
70 def main():
71 argument_spec = intersight_argument_spec.copy()
72 argument_spec.update(
73 name=dict(type='str'),
74 )
75
76 module = AnsibleModule(
77 argument_spec,
78 supports_check_mode=True,
79 )
80
81 intersight = IntersightModule(module)
82 intersight.result['api_response'] = {}
83 intersight.result['trace_id'] = ''
84
85 resource_path = '/organization/Organizations'
86
87 query_params = intersight.set_query_params()
88
89 intersight.get_resource(
90 resource_path=resource_path,
91 query_params=query_params,
92 return_list=True,
93 )
94
95 module.exit_json(**intersight.result)
96
97
98 if __name__ == '__main__':
99 main()