| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_firewall_internetservice |
| 15 |
short_description: Show Internet Service application. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
firewall_internetservice: |
| 29 |
description: The top level parameters set. |
| 30 |
required: false |
| 31 |
type: dict |
| 32 |
suboptions: |
| 33 |
database: |
| 34 |
type: str |
| 35 |
description: Database. |
| 36 |
choices: ['isdb', 'irdb'] |
| 37 |
direction: |
| 38 |
type: str |
| 39 |
description: Direction. |
| 40 |
choices: ['src', 'dst', 'both'] |
| 41 |
entry: |
| 42 |
type: list |
| 43 |
elements: dict |
| 44 |
description: Entry. |
| 45 |
suboptions: |
| 46 |
id: |
| 47 |
type: int |
| 48 |
description: Entry ID. |
| 49 |
ip_number: |
| 50 |
aliases: ['ip-number'] |
| 51 |
type: int |
| 52 |
description: Total number of IP addresses. |
| 53 |
ip_range_number: |
| 54 |
aliases: ['ip-range-number'] |
| 55 |
type: int |
| 56 |
description: Total number of IP ranges. |
| 57 |
port: |
| 58 |
type: raw |
| 59 |
description: (list) Integer value for the TCP/IP port |
| 60 |
protocol: |
| 61 |
type: int |
| 62 |
description: Integer value for the protocol type as defined by IANA |
| 63 |
icon_id: |
| 64 |
aliases: ['icon-id'] |
| 65 |
type: int |
| 66 |
description: Icon id. |
| 67 |
id: |
| 68 |
type: int |
| 69 |
description: Id. |
| 70 |
name: |
| 71 |
type: str |
| 72 |
description: Name. |
| 73 |
offset: |
| 74 |
type: int |
| 75 |
description: Offset. |
| 76 |
reputation: |
| 77 |
type: int |
| 78 |
description: Reputation. |
| 79 |
sld_id: |
| 80 |
aliases: ['sld-id'] |
| 81 |
type: int |
| 82 |
description: Sld id. |
| 83 |
extra_ip_range_number: |
| 84 |
aliases: ['extra-ip-range-number'] |
| 85 |
type: int |
| 86 |
description: Extra ip range number. |
| 87 |
ip_number: |
| 88 |
aliases: ['ip-number'] |
| 89 |
type: int |
| 90 |
description: Ip number. |
| 91 |
ip_range_number: |
| 92 |
aliases: ['ip-range-number'] |
| 93 |
type: int |
| 94 |
description: Ip range number. |
| 95 |
jitter_threshold: |
| 96 |
aliases: ['jitter-threshold'] |
| 97 |
type: int |
| 98 |
description: Jitter threshold. |
| 99 |
latency_threshold: |
| 100 |
aliases: ['latency-threshold'] |
| 101 |
type: int |
| 102 |
description: Latency threshold. |
| 103 |
obsolete: |
| 104 |
type: int |
| 105 |
description: Obsolete. |
| 106 |
packetloss_threshold: |
| 107 |
aliases: ['packetloss-threshold'] |
| 108 |
type: int |
| 109 |
description: Packetloss threshold. |
| 110 |
singularity: |
| 111 |
type: int |
| 112 |
description: Singularity. |
| 113 |
city: |
| 114 |
type: raw |
| 115 |
description: (list) City sequence number list. |
| 116 |
country: |
| 117 |
type: raw |
| 118 |
description: (list) Country sequence number list. |
| 119 |
region: |
| 120 |
type: raw |
| 121 |
description: (list) Region sequence number list. |
| 122 |
city6: |
| 123 |
type: raw |
| 124 |
description: (list) IPv6 City sequence number list. |
| 125 |
country6: |
| 126 |
type: raw |
| 127 |
description: (list) IPv6 Country sequence number list. |
| 128 |
extra_ip6_range_number: |
| 129 |
aliases: ['extra-ip6-range-number'] |
| 130 |
type: int |
| 131 |
description: Extra ip6 range number. |
| 132 |
ip6_range_number: |
| 133 |
aliases: ['ip6-range-number'] |
| 134 |
type: int |
| 135 |
description: Ip6 range number. |
| 136 |
region6: |
| 137 |
type: raw |
| 138 |
description: (list) IPv6 Region sequence number list. |
| 139 |
''' |
| 140 |
|
| 141 |
EXAMPLES = ''' |
| 142 |
- name: Example playbook (generated based on argument schema) |
| 143 |
hosts: fortimanagers |
| 144 |
connection: httpapi |
| 145 |
gather_facts: false |
| 146 |
tasks: |
| 147 |
- name: Show Internet Service application. |
| 148 |
fortinet.fortimanager.fmgr_firewall_internetservice: |
| 149 |
# workspace_locking_adom: <global or your adom name> |
| 150 |
adom: <your own value> |
| 151 |
firewall_internetservice: |
| 152 |
# database: <value in [isdb, irdb]> |
| 153 |
# direction: <value in [src, dst, both]> |
| 154 |
# entry: |
| 155 |
# - id: <integer> |
| 156 |
# ip_number: <integer> |
| 157 |
# ip_range_number: <integer> |
| 158 |
# port: <list or integer> |
| 159 |
# protocol: <integer> |
| 160 |
# icon_id: <integer> |
| 161 |
# id: <integer> |
| 162 |
# name: <string> |
| 163 |
# offset: <integer> |
| 164 |
# reputation: <integer> |
| 165 |
# sld_id: <integer> |
| 166 |
# extra_ip_range_number: <integer> |
| 167 |
# ip_number: <integer> |
| 168 |
# ip_range_number: <integer> |
| 169 |
# jitter_threshold: <integer> |
| 170 |
# latency_threshold: <integer> |
| 171 |
# obsolete: <integer> |
| 172 |
# packetloss_threshold: <integer> |
| 173 |
# singularity: <integer> |
| 174 |
# city: <list or integer> |
| 175 |
# country: <list or integer> |
| 176 |
# region: <list or integer> |
| 177 |
# city6: <list or integer> |
| 178 |
# country6: <list or integer> |
| 179 |
# extra_ip6_range_number: <integer> |
| 180 |
# ip6_range_number: <integer> |
| 181 |
# region6: <list or integer> |
| 182 |
''' |
| 183 |
|
| 184 |
RETURN = ''' |
| 185 |
meta: |
| 186 |
description: The result of the request. |
| 187 |
type: dict |
| 188 |
returned: always |
| 189 |
contains: |
| 190 |
request_url: |
| 191 |
description: The full url requested. |
| 192 |
returned: always |
| 193 |
type: str |
| 194 |
sample: /sys/login/user |
| 195 |
response_code: |
| 196 |
description: The status of api request. |
| 197 |
returned: always |
| 198 |
type: int |
| 199 |
sample: 0 |
| 200 |
response_data: |
| 201 |
description: The api response. |
| 202 |
type: list |
| 203 |
returned: always |
| 204 |
response_message: |
| 205 |
description: The descriptive message of the api response. |
| 206 |
type: str |
| 207 |
returned: always |
| 208 |
sample: OK. |
| 209 |
system_information: |
| 210 |
description: The information of the target system. |
| 211 |
type: dict |
| 212 |
returned: always |
| 213 |
rc: |
| 214 |
description: The status the request. |
| 215 |
type: int |
| 216 |
returned: always |
| 217 |
sample: 0 |
| 218 |
version_check_warning: |
| 219 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 220 |
type: list |
| 221 |
returned: complex |
| 222 |
''' |
| 223 |
from ansible.module_utils.basic import AnsibleModule |
| 224 |
from ansible.module_utils.connection import Connection |
| 225 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 226 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 227 |
|
| 228 |
|
| 229 |
def main(): |
| 230 |
urls_list = [ |
| 231 |
'/pm/config/adom/{adom}/obj/firewall/internet-service', |
| 232 |
'/pm/config/global/obj/firewall/internet-service' |
| 233 |
] |
| 234 |
module_arg_spec = { |
| 235 |
'adom': {'required': True, 'type': 'str'}, |
| 236 |
'revision_note': {'type': 'str'}, |
| 237 |
'firewall_internetservice': { |
| 238 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 239 |
'options': { |
| 240 |
'database': {'choices': ['isdb', 'irdb'], 'type': 'str'}, |
| 241 |
'direction': {'choices': ['src', 'dst', 'both'], 'type': 'str'}, |
| 242 |
'entry': { |
| 243 |
'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], |
| 244 |
'type': 'list', |
| 245 |
'options': { |
| 246 |
'id': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'}, |
| 247 |
'ip-number': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'}, |
| 248 |
'ip-range-number': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'}, |
| 249 |
'port': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'raw'}, |
| 250 |
'protocol': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'} |
| 251 |
}, |
| 252 |
'elements': 'dict' |
| 253 |
}, |
| 254 |
'icon-id': {'type': 'int'}, |
| 255 |
'id': {'type': 'int'}, |
| 256 |
'name': {'type': 'str'}, |
| 257 |
'offset': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'int'}, |
| 258 |
'reputation': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'}, |
| 259 |
'sld-id': {'v_range': [['6.0.0', '7.6.2']], 'type': 'int'}, |
| 260 |
'extra-ip-range-number': {'v_range': [['6.2.0', '']], 'type': 'int'}, |
| 261 |
'ip-number': {'v_range': [['6.2.0', '']], 'type': 'int'}, |
| 262 |
'ip-range-number': {'v_range': [['6.2.0', '']], 'type': 'int'}, |
| 263 |
'jitter-threshold': {'v_range': [['6.2.0', '7.2.0']], 'type': 'int'}, |
| 264 |
'latency-threshold': {'v_range': [['6.2.0', '7.2.0']], 'type': 'int'}, |
| 265 |
'obsolete': {'v_range': [['6.2.0', '']], 'type': 'int'}, |
| 266 |
'packetloss-threshold': {'v_range': [['6.2.0', '7.2.0']], 'type': 'int'}, |
| 267 |
'singularity': {'v_range': [['6.2.0', '']], 'type': 'int'}, |
| 268 |
'city': {'v_range': [['6.4.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'}, |
| 269 |
'country': {'v_range': [['6.4.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'}, |
| 270 |
'region': {'v_range': [['6.4.0', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'}, |
| 271 |
'city6': {'v_range': [['7.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'}, |
| 272 |
'country6': {'v_range': [['7.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'}, |
| 273 |
'extra-ip6-range-number': {'v_range': [['7.2.1', '']], 'type': 'int'}, |
| 274 |
'ip6-range-number': {'v_range': [['7.2.1', '']], 'type': 'int'}, |
| 275 |
'region6': {'v_range': [['7.2.1', '7.2.5'], ['7.4.0', '7.4.2']], 'type': 'raw'} |
| 276 |
} |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
module_option_spec = get_module_arg_spec('partial crud') |
| 281 |
module_arg_spec.update(module_option_spec) |
| 282 |
check_galaxy_version(module_arg_spec) |
| 283 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_internetservice'), |
| 284 |
supports_check_mode=True) |
| 285 |
if not module._socket_path: |
| 286 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 287 |
connection = Connection(module._socket_path) |
| 288 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 289 |
None, 'data', module, connection) |
| 290 |
fmgr.process_partial_crud() |
| 291 |
module.exit_json(meta=module.params) |
| 292 |
|
| 293 |
|
| 294 |
if __name__ == '__main__': |
| 295 |
main() |