| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# Copyright (c) 2021, Cisco Systems |
| 5 |
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 |
|
| 7 |
DOCUMENTATION = r""" |
| 8 |
module: networks_clients_info |
| 9 |
short_description: Information module for networks _clients |
| 10 |
description: |
| 11 |
- Information module for Networks Clients Info. |
| 12 |
- Get all networks _clients. |
| 13 |
- Get networks _clients by id. |
| 14 |
- List the clients that have used this network in the timespan. The data is updated |
| 15 |
at most once every five minutes. |
| 16 |
- > |
| 17 |
Return the client associated with the given identifier. Clients can be identified |
| 18 |
by a client key or either the MAC or IP depending on whether the network uses |
| 19 |
Track-by-IP. |
| 20 |
version_added: '1.0.0' |
| 21 |
extends_documentation_fragment: |
| 22 |
- cisco.meraki.module_info |
| 23 |
- cisco.meraki.module_info_pagination |
| 24 |
author: Francisco Munoz (@fmunoz) |
| 25 |
options: |
| 26 |
headers: |
| 27 |
description: Additional headers. |
| 28 |
type: dict |
| 29 |
networkId: |
| 30 |
description: |
| 31 |
- Information module for Networks Clients Info. |
| 32 |
- NetworkId path parameter. Network ID. |
| 33 |
type: str |
| 34 |
t0: |
| 35 |
description: |
| 36 |
- Information module for Networks Clients Info. |
| 37 |
- T0 query parameter. The beginning of the timespan for the data. The maximum |
| 38 |
lookback period is 31 days from today. |
| 39 |
type: str |
| 40 |
timespan: |
| 41 |
description: |
| 42 |
- Information module for Networks Clients Info. |
| 43 |
- > |
| 44 |
Timespan query parameter. The timespan for which the information will be fetched. |
| 45 |
If specifying timespan, do not specify parameter t0. The value must be in |
| 46 |
seconds and be less than or equal to 31 days. The default is 1 day. |
| 47 |
type: float |
| 48 |
perPage: |
| 49 |
description: |
| 50 |
- Information module for Networks Clients Info. |
| 51 |
- PerPage query parameter. The number of entries per page returned. Acceptable |
| 52 |
range is 3 - 5000. Default is 10. |
| 53 |
type: int |
| 54 |
startingAfter: |
| 55 |
description: |
| 56 |
- Information module for Networks Clients Info. |
| 57 |
- > |
| 58 |
StartingAfter query parameter. A token used by the server to indicate the |
| 59 |
start of the page. Often this is a timestamp or an ID but it is not limited |
| 60 |
to those. This parameter should not be defined by client applications. The |
| 61 |
link for the first, last, prev, or next page in the HTTP Link header should |
| 62 |
define it. |
| 63 |
type: str |
| 64 |
endingBefore: |
| 65 |
description: |
| 66 |
- Information module for Networks Clients Info. |
| 67 |
- > |
| 68 |
EndingBefore query parameter. A token used by the server to indicate the end |
| 69 |
of the page. Often this is a timestamp or an ID but it is not limited to those. |
| 70 |
This parameter should not be defined by client applications. The link for |
| 71 |
the first, last, prev, or next page in the HTTP Link header should define |
| 72 |
it. |
| 73 |
type: str |
| 74 |
statuses: |
| 75 |
description: |
| 76 |
- Information module for Networks Clients Info. |
| 77 |
- Statuses query parameter. Filters clients based on status. Can be one of 'Online' |
| 78 |
or 'Offline'. |
| 79 |
elements: str |
| 80 |
type: list |
| 81 |
ip: |
| 82 |
description: |
| 83 |
- Information module for Networks Clients Info. |
| 84 |
- Ip query parameter. Filters clients based on a partial or full match for the |
| 85 |
ip address field. |
| 86 |
type: str |
| 87 |
ip6: |
| 88 |
description: |
| 89 |
- Information module for Networks Clients Info. |
| 90 |
- Ip6 query parameter. Filters clients based on a partial or full match for |
| 91 |
the ip6 address field. |
| 92 |
type: str |
| 93 |
ip6Local: |
| 94 |
description: |
| 95 |
- Information module for Networks Clients Info. |
| 96 |
- Ip6Local query parameter. Filters clients based on a partial or full match |
| 97 |
for the ip6Local address field. |
| 98 |
type: str |
| 99 |
mac: |
| 100 |
description: |
| 101 |
- Information module for Networks Clients Info. |
| 102 |
- Mac query parameter. Filters clients based on a partial or full match for |
| 103 |
the mac address field. |
| 104 |
type: str |
| 105 |
os: |
| 106 |
description: |
| 107 |
- Information module for Networks Clients Info. |
| 108 |
- Os query parameter. Filters clients based on a partial or full match for the |
| 109 |
os (operating system) field. |
| 110 |
type: str |
| 111 |
pskGroup: |
| 112 |
description: |
| 113 |
- Information module for Networks Clients Info. |
| 114 |
- PskGroup query parameter. Filters clients based on partial or full match for |
| 115 |
the iPSK name field. |
| 116 |
type: str |
| 117 |
description: |
| 118 |
description: |
| 119 |
- Information module for Networks Clients Info. |
| 120 |
- Description query parameter. Filters clients based on a partial or full match |
| 121 |
for the description field. |
| 122 |
type: str |
| 123 |
vlan: |
| 124 |
description: |
| 125 |
- Information module for Networks Clients Info. |
| 126 |
- Vlan query parameter. Filters clients based on the full match for the VLAN |
| 127 |
field. |
| 128 |
type: str |
| 129 |
namedVlan: |
| 130 |
description: |
| 131 |
- Information module for Networks Clients Info. |
| 132 |
- NamedVlan query parameter. Filters clients based on the partial or full match |
| 133 |
for the named VLAN field. |
| 134 |
type: str |
| 135 |
recentDeviceConnections: |
| 136 |
description: |
| 137 |
- Information module for Networks Clients Info. |
| 138 |
- > |
| 139 |
RecentDeviceConnections query parameter. Filters clients based on recent connection |
| 140 |
type. Can be one of 'Wired' or 'Wireless'. |
| 141 |
elements: str |
| 142 |
type: list |
| 143 |
clientId: |
| 144 |
description: |
| 145 |
- Information module for Networks Clients Info. |
| 146 |
- ClientId path parameter. Client ID. |
| 147 |
type: str |
| 148 |
requirements: |
| 149 |
- meraki >= 2.4.9 |
| 150 |
- python >= 3.5 |
| 151 |
seealso: |
| 152 |
- name: Cisco Meraki documentation for networks getNetworkClient |
| 153 |
description: Complete reference of the getNetworkClient API. |
| 154 |
link: https://developer.cisco.com/meraki/api-v1/#!get-network-client |
| 155 |
- name: Cisco Meraki documentation for networks getNetworkClients |
| 156 |
description: Complete reference of the getNetworkClients API. |
| 157 |
link: https://developer.cisco.com/meraki/api-v1/#!get-network-clients |
| 158 |
notes: |
| 159 |
- SDK Method used are |
| 160 |
networks.Networks.get_network_client, |
| 161 |
networks.Networks.get_network_clients, |
| 162 |
- Paths used are |
| 163 |
get /networks/{networkId}/clients, |
| 164 |
get /networks/{networkId}/clients/{clientId}, |
| 165 |
""" |
| 166 |
|
| 167 |
EXAMPLES = r""" |
| 168 |
- name: Get all networks _clients |
| 169 |
cisco.meraki.networks_clients_info: |
| 170 |
meraki_api_key: "{{ meraki_api_key }}" |
| 171 |
meraki_base_url: "{{ meraki_base_url }}" |
| 172 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 173 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 174 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 175 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 176 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 177 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 178 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 179 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 180 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 181 |
meraki_output_log: "{{ meraki_output_log }}" |
| 182 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 183 |
meraki_log_path: "{{ meraki_log_path }}" |
| 184 |
meraki_print_console: "{{ meraki_print_console }}" |
| 185 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 186 |
meraki_simulate: "{{ meraki_simulate }}" |
| 187 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 188 |
meraki_caller: "{{ meraki_caller }}" |
| 189 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 190 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 191 |
t0: string |
| 192 |
timespan: 0 |
| 193 |
perPage: 0 |
| 194 |
startingAfter: string |
| 195 |
endingBefore: string |
| 196 |
statuses: [] |
| 197 |
ip: string |
| 198 |
ip6: string |
| 199 |
ip6Local: string |
| 200 |
mac: string |
| 201 |
os: string |
| 202 |
pskGroup: string |
| 203 |
description: string |
| 204 |
vlan: string |
| 205 |
namedVlan: string |
| 206 |
recentDeviceConnections: [] |
| 207 |
networkId: string |
| 208 |
total_pages: -1 |
| 209 |
direction: next |
| 210 |
register: result |
| 211 |
- name: Get networks _clients by id |
| 212 |
cisco.meraki.networks_clients_info: |
| 213 |
meraki_api_key: "{{ meraki_api_key }}" |
| 214 |
meraki_base_url: "{{ meraki_base_url }}" |
| 215 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 216 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 217 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 218 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 219 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 220 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 221 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 222 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 223 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 224 |
meraki_output_log: "{{ meraki_output_log }}" |
| 225 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 226 |
meraki_log_path: "{{ meraki_log_path }}" |
| 227 |
meraki_print_console: "{{ meraki_print_console }}" |
| 228 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 229 |
meraki_simulate: "{{ meraki_simulate }}" |
| 230 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 231 |
meraki_caller: "{{ meraki_caller }}" |
| 232 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 233 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 234 |
networkId: string |
| 235 |
clientId: string |
| 236 |
register: result |
| 237 |
""" |
| 238 |
RETURN = r""" |
| 239 |
meraki_response: |
| 240 |
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK |
| 241 |
returned: always |
| 242 |
type: dict |
| 243 |
sample: > |
| 244 |
{ |
| 245 |
"id": "string", |
| 246 |
"mac": "string", |
| 247 |
"ip": "string", |
| 248 |
"ip6": "string", |
| 249 |
"ip6Local": "string", |
| 250 |
"description": "string", |
| 251 |
"firstSeen": 0, |
| 252 |
"lastSeen": 0, |
| 253 |
"manufacturer": "string", |
| 254 |
"os": "string", |
| 255 |
"user": "string", |
| 256 |
"vlan": "string", |
| 257 |
"namedVlan": "string", |
| 258 |
"ssid": "string", |
| 259 |
"switchport": "string", |
| 260 |
"wirelessCapabilities": "string", |
| 261 |
"smInstalled": true, |
| 262 |
"recentDeviceMac": "string", |
| 263 |
"recentDeviceName": "string", |
| 264 |
"recentDeviceSerial": "string", |
| 265 |
"recentDeviceConnection": "string", |
| 266 |
"clientVpnConnections": [ |
| 267 |
{ |
| 268 |
"remoteIp": "string", |
| 269 |
"connectedAt": 0, |
| 270 |
"disconnectedAt": 0 |
| 271 |
} |
| 272 |
], |
| 273 |
"lldp": [ |
| 274 |
[ |
| 275 |
"string" |
| 276 |
] |
| 277 |
], |
| 278 |
"cdp": [ |
| 279 |
[ |
| 280 |
"string" |
| 281 |
] |
| 282 |
], |
| 283 |
"status": "string", |
| 284 |
"notes": "string", |
| 285 |
"deviceTypePrediction": "string" |
| 286 |
} |
| 287 |
""" |