Debian Codegraph @

ansible_collections/check_point/mgmt/plugins/modules/cp_mgmt_mobile_access_rule.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_mobile_access_rule
31 short_description: Manages mobile-access-rule objects on Checkpoint over Web Services API
32 description:
33 - Manages mobile-access-rule objects on Checkpoint devices including creating, updating and removing objects.
34 - All operations are performed over Web Services API.
35 - Available from R82 management version.
36 version_added: "6.0.0"
37 author: "Eden Brillant (@chkp-edenbr)"
38 options:
39 position:
40 description:
41 - Position in the rulebase.
42 type: str
43 name:
44 description:
45 - Object name.
46 type: str
47 required: True
48 user_groups:
49 description:
50 - User groups that will be associated with the apps - identified by the name or UID.
51 type: list
52 elements: str
53 applications:
54 description:
55 - Available apps that will be associated with the user groups - identified by the name or UID.
56 type: list
57 elements: str
58 enabled:
59 description:
60 - Enable/Disable the rule.
61 type: bool
62 install_on:
63 description:
64 - Which Gateways identified by the name or UID to install the policy on.
65 type: list
66 elements: str
67 tags:
68 description:
69 - Collection of tag identifiers.
70 type: list
71 elements: str
72 comments:
73 description:
74 - Comments string.
75 type: str
76 details_level:
77 description:
78 - 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
79 representation of the object.
80 type: str
81 choices: ['uid', 'standard', 'full']
82 ignore_warnings:
83 description:
84 - Apply changes ignoring warnings.
85 type: bool
86 ignore_errors:
87 description:
88 - Apply changes ignoring errors. You won't be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored.
89 type: bool
90 extends_documentation_fragment: check_point.mgmt.checkpoint_objects
91 """
92
93 EXAMPLES = """
94 - name: add-mobile-access-rule
95 cp_mgmt_mobile_access_rule:
96 applications: New Application
97 name: Rule 1
98 position: 1
99 state: present
100 user_groups:
101 - my_group
102
103 - name: set-mobile-access-rule
104 cp_mgmt_mobile_access_rule:
105 applications:
106 - New Application
107 - New Application 2
108 name: Rule 1
109 state: present
110 user_groups:
111 - my_group
112
113 - name: delete-mobile-access-rule
114 cp_mgmt_mobile_access_rule:
115 name: Rule 1
116 state: absent
117 """
118
119 RETURN = """
120 cp_mgmt_mobile_access_rule:
121 description: The checkpoint object created or updated.
122 returned: always, except when deleting the object.
123 type: dict
124 """
125
126 from ansible.module_utils.basic import AnsibleModule
127 from ansible_collections.check_point.mgmt.plugins.module_utils.checkpoint import checkpoint_argument_spec_for_objects, api_call, api_call_for_rule
128
129
130 def main():
131 argument_spec = dict(
132 position=dict(type='str'),
133 name=dict(type='str', required=True),
134 user_groups=dict(type='list', elements='str'),
135 applications=dict(type='list', elements='str'),
136 enabled=dict(type='bool'),
137 install_on=dict(type='list', elements='str'),
138 tags=dict(type='list', elements='str'),
139 comments=dict(type='str'),
140 details_level=dict(type='str', choices=['uid', 'standard', 'full']),
141 ignore_warnings=dict(type='bool'),
142 ignore_errors=dict(type='bool')
143 )
144 argument_spec.update(checkpoint_argument_spec_for_objects)
145
146 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
147 api_call_object = 'mobile-access-rule'
148
149 if module.params["position"] is None:
150 result = api_call(module, api_call_object)
151 else:
152 result = api_call_for_rule(module, api_call_object)
153
154 module.exit_json(**result)
155
156
157 if __name__ == '__main__':
158 main()