1#!/usr/local/bin/python3.8
2# -*- coding: utf-8 -*-
3# (c) 2021 Evgeni Golov
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18from __future__ import absolute_import, division, print_function
19__metaclass__ = type
20
21
22DOCUMENTATION = '''
23---
24module: subnet_info
25version_added: 2.1.0
26short_description: Fetch information about Subnets
27description:
28  - Fetch information about Subnets
29author:
30  - "Evgeni Golov (@evgeni)"
31extends_documentation_fragment:
32  - theforeman.foreman.foreman
33  - theforeman.foreman.foreman.infomodule
34'''
35
36EXAMPLES = '''
37- name: "Show a subnet"
38  theforeman.foreman.subnet_info:
39    username: "admin"
40    password: "changeme"
41    server_url: "https://foreman.example.com"
42    name: "subnet.example.com"
43
44- name: "Show all subnets with domain example.com"
45  theforeman.foreman.subnet_info:
46    username: "admin"
47    password: "changeme"
48    server_url: "https://foreman.example.com"
49    search: "domain = example.com"
50'''
51
52RETURN = '''
53subnet:
54  description: Details about the found subnet
55  returned: success and I(name) was passed
56  type: dict
57subnets:
58  description: List of all found subnets and their details
59  returned: success and I(search) was passed
60  type: list
61  elements: dict
62'''
63
64from ansible_collections.theforeman.foreman.plugins.module_utils.foreman_helper import (
65    ForemanInfoAnsibleModule,
66)
67
68
69class ForemanSubnetInfo(ForemanInfoAnsibleModule):
70    pass
71
72
73def main():
74    module = ForemanSubnetInfo()
75
76    with module.api_connection():
77        module.run()
78
79
80if __name__ == '__main__':
81    main()
82