Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_interface_facts.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Ansible module to manage CheckPoint Firewall (c) 2019
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 from __future__ import (absolute_import, division, print_function)
21
22 __metaclass__ = type
23
24 ANSIBLE_METADATA = {'metadata_version': '1.1',
25 'status': ['preview'],
26 'supported_by': 'community'}
27
28 DOCUMENTATION = """
29 ---
30 module: cp_mgmt_interface_facts
31 short_description: Get interface objects facts on Checkpoint over Web Services API
32 description:
33 - Get interface objects facts on Checkpoint devices.
34 - All operations are performed over Web Services API.
35 - This module handles both operations, get a specific object and get several objects,
36 For getting a specific object use the parameter 'name'.
37 - Available from R82 management version.
38 version_added: "6.2.0"
39 author: "Eden Brillant (@chkp-edenbr)"
40 options:
41 name:
42 description:
43 - Network interface name.
44 type: str
45 gateway_uid:
46 description:
47 - Gateway or cluster object uid that the interfaces belongs to.
48 type: str
49 details_level:
50 description:
51 - The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed
52 representation of the object.
53 type: str
54 choices: ['uid', 'standard', 'full']
55 domains_to_process:
56 description:
57 - Indicates which domains to process the commands on. It cannot be used with the details-level full, must be run from the System Domain only and
58 with ignore-warnings true. Valid values are, CURRENT_DOMAIN, ALL_DOMAINS_ON_THIS_SERVER.
59 type: list
60 elements: str
61 filter:
62 description:
63 - Filter interfaces by name or IP address.
64 type: str
65 limit:
66 description:
67 - The maximal number of returned results.
68 This parameter is relevant only for getting few objects.
69 type: int
70 offset:
71 description:
72 - Number of the results to initially skip.
73 This parameter is relevant only for getting few objects.
74 type: int
75 order:
76 description:
77 - Sorts the results by search criteria. Automatically sorts the results by Name, in the ascending order.
78 This parameter is relevant only for getting few objects.
79 type: list
80 elements: dict
81 suboptions:
82 ASC:
83 description:
84 - Sorts results by the given field in ascending order.
85 type: str
86 choices: ['name']
87 DESC:
88 description:
89 - Sorts results by the given field in descending order.
90 type: str
91 choices: ['name']
92 show_membership:
93 description:
94 - Indicates whether to calculate and show "groups" field for every object in reply.
95 type: bool
96 extends_documentation_fragment: check_point.mgmt.checkpoint_facts
97 """
98
99 EXAMPLES = """
100 - name: show-interface
101 cp_mgmt_interface_facts:
102 name: eth0
103 gateway_uid: ff918e85-98c4-4b17-bcac-417aab863d87
104
105 - name: show-interfaces
106 cp_mgmt_interface_facts:
107 details_level: full
108 gateway_uid: ff918e85-98c4-4b17-bcac-417aab863d87
109 limit: 50
110 offset: 0
111 """
112
113 RETURN = """
114 ansible_facts:
115 description: The checkpoint object facts.
116 returned: always.
117 type: dict
118 """
119
120 from ansible.module_utils.basic import AnsibleModule
121 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_facts, api_call_facts
122
123
124 def main():
125 argument_spec = dict(
126 name=dict(type='str'),
127 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
128 domains_to_process=dict(type='list', elements='str'),
129 gateway_uid=dict(type='str'),
130 filter=dict(type='str'),
131 limit=dict(type='int'),
132 offset=dict(type='int'),
133 order=dict(type='list', elements='dict', options=dict(
134 ASC=dict(type='str', choices=['name']),
135 DESC=dict(type='str', choices=['name'])
136 )),
137 show_membership=dict(type='bool')
138 )
139 argument_spec.update(checkpoint_argument_spec_for_facts)
140
141 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
142
143 api_call_object = "interface"
144 api_call_object_plural_version = "interfaces"
145
146 result = api_call_facts(module, api_call_object, api_call_object_plural_version)
147 module.exit_json(ansible_facts=result)
148
149
150 if __name__ == '__main__':
151 main()