| 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: devices_info |
| 9 |
short_description: Information module for devices |
| 10 |
description: |
| 11 |
- Information module for Devices Info. |
| 12 |
- Get all devices. |
| 13 |
- Get devices by id. |
| 14 |
- List the devices in an organization that have been assigned to a network. |
| 15 |
- Return a single device. |
| 16 |
version_added: '1.0.0' |
| 17 |
extends_documentation_fragment: |
| 18 |
- cisco.meraki.module_info |
| 19 |
- cisco.meraki.module_info_pagination |
| 20 |
author: Francisco Munoz (@fmunoz) |
| 21 |
options: |
| 22 |
headers: |
| 23 |
description: Additional headers. |
| 24 |
type: dict |
| 25 |
serial: |
| 26 |
description: |
| 27 |
- Information module for Devices Info. |
| 28 |
- Serial path parameter. |
| 29 |
type: str |
| 30 |
organizationId: |
| 31 |
description: |
| 32 |
- Information module for Devices Info. |
| 33 |
- OrganizationId path parameter. Organization ID. |
| 34 |
type: str |
| 35 |
perPage: |
| 36 |
description: |
| 37 |
- Information module for Devices Info. |
| 38 |
- PerPage query parameter. The number of entries per page returned. Acceptable |
| 39 |
range is 3 - 5000. Default is 1000. |
| 40 |
type: int |
| 41 |
startingAfter: |
| 42 |
description: |
| 43 |
- Information module for Devices Info. |
| 44 |
- > |
| 45 |
StartingAfter query parameter. A token used by the server to indicate the |
| 46 |
start of the page. Often this is a timestamp or an ID but it is not limited |
| 47 |
to those. This parameter should not be defined by client applications. The |
| 48 |
link for the first, last, prev, or next page in the HTTP Link header should |
| 49 |
define it. |
| 50 |
type: str |
| 51 |
endingBefore: |
| 52 |
description: |
| 53 |
- Information module for Devices Info. |
| 54 |
- > |
| 55 |
EndingBefore query parameter. A token used by the server to indicate the end |
| 56 |
of the page. Often this is a timestamp or an ID but it is not limited to those. |
| 57 |
This parameter should not be defined by client applications. The link for |
| 58 |
the first, last, prev, or next page in the HTTP Link header should define |
| 59 |
it. |
| 60 |
type: str |
| 61 |
configurationUpdatedAfter: |
| 62 |
description: |
| 63 |
- Information module for Devices Info. |
| 64 |
- > |
| 65 |
ConfigurationUpdatedAfter query parameter. Filter results by whether or not |
| 66 |
the device's configuration has been updated after the given timestamp. |
| 67 |
type: str |
| 68 |
networkIds: |
| 69 |
description: |
| 70 |
- Information module for Devices Info. |
| 71 |
- NetworkIds query parameter. Optional parameter to filter devices by network. |
| 72 |
elements: str |
| 73 |
type: list |
| 74 |
productTypes: |
| 75 |
description: |
| 76 |
- Information module for Devices Info. |
| 77 |
- > |
| 78 |
ProductTypes query parameter. Optional parameter to filter devices by product |
| 79 |
type. Valid types are wireless, appliance, switch, systemsManager, camera, |
| 80 |
cellularGateway, sensor, wirelessController, campusGateway, and secureConnect. |
| 81 |
elements: str |
| 82 |
type: list |
| 83 |
tags: |
| 84 |
description: |
| 85 |
- Information module for Devices Info. |
| 86 |
- Tags query parameter. Optional parameter to filter devices by tags. |
| 87 |
elements: str |
| 88 |
type: list |
| 89 |
tagsFilterType: |
| 90 |
description: |
| 91 |
- Information module for Devices Info. |
| 92 |
- > |
| 93 |
TagsFilterType query parameter. Optional parameter of value 'withAnyTags' |
| 94 |
or 'withAllTags' to indicate whether to return networks which contain ANY |
| 95 |
or ALL of the included tags. If no type is included, 'withAnyTags' will be |
| 96 |
selected. |
| 97 |
type: str |
| 98 |
name: |
| 99 |
description: |
| 100 |
- Information module for Devices Info. |
| 101 |
- > |
| 102 |
Name query parameter. Optional parameter to filter devices by name. All returned |
| 103 |
devices will have a name that contains the search term or is an exact match. |
| 104 |
type: str |
| 105 |
mac: |
| 106 |
description: |
| 107 |
- Information module for Devices Info. |
| 108 |
- > |
| 109 |
Mac query parameter. Optional parameter to filter devices by MAC address. |
| 110 |
All returned devices will have a MAC address that contains the search term |
| 111 |
or is an exact match. |
| 112 |
type: str |
| 113 |
model: |
| 114 |
description: |
| 115 |
- Information module for Devices Info. |
| 116 |
- > |
| 117 |
Model query parameter. Optional parameter to filter devices by model. All |
| 118 |
returned devices will have a model that contains the search term or is an |
| 119 |
exact match. |
| 120 |
type: str |
| 121 |
macs: |
| 122 |
description: |
| 123 |
- Information module for Devices Info. |
| 124 |
- > |
| 125 |
Macs query parameter. Optional parameter to filter devices by one or more |
| 126 |
MAC addresses. All returned devices will have a MAC address that is an exact |
| 127 |
match. |
| 128 |
elements: str |
| 129 |
type: list |
| 130 |
serials: |
| 131 |
description: |
| 132 |
- Information module for Devices Info. |
| 133 |
- > |
| 134 |
Serials query parameter. Optional parameter to filter devices by one or more |
| 135 |
serial numbers. All returned devices will have a serial number that is an |
| 136 |
exact match. |
| 137 |
elements: str |
| 138 |
type: list |
| 139 |
sensorMetrics: |
| 140 |
description: |
| 141 |
- Information module for Devices Info. |
| 142 |
- > |
| 143 |
SensorMetrics query parameter. Optional parameter to filter devices by the |
| 144 |
metrics that they provide. Only applies to sensor devices. |
| 145 |
elements: str |
| 146 |
type: list |
| 147 |
sensorAlertProfileIds: |
| 148 |
description: |
| 149 |
- Information module for Devices Info. |
| 150 |
- > |
| 151 |
SensorAlertProfileIds query parameter. Optional parameter to filter devices |
| 152 |
by the alert profiles that are bound to them. Only applies to sensor devices. |
| 153 |
elements: str |
| 154 |
type: list |
| 155 |
models: |
| 156 |
description: |
| 157 |
- Information module for Devices Info. |
| 158 |
- > |
| 159 |
Models query parameter. Optional parameter to filter devices by one or more |
| 160 |
models. All returned devices will have a model that is an exact match. |
| 161 |
elements: str |
| 162 |
type: list |
| 163 |
requirements: |
| 164 |
- meraki >= 2.4.9 |
| 165 |
- python >= 3.5 |
| 166 |
seealso: |
| 167 |
- name: Cisco Meraki documentation for devices getDevice |
| 168 |
description: Complete reference of the getDevice API. |
| 169 |
link: https://developer.cisco.com/meraki/api-v1/#!get-device |
| 170 |
- name: Cisco Meraki documentation for devices getOrganizationDevices |
| 171 |
description: Complete reference of the getOrganizationDevices API. |
| 172 |
link: https://developer.cisco.com/meraki/api-v1/#!get-organization-devices |
| 173 |
notes: |
| 174 |
- SDK Method used are |
| 175 |
devices.Devices.get_device, |
| 176 |
devices.Devices.get_organization_devices, |
| 177 |
- Paths used are |
| 178 |
get /devices/{serial}, |
| 179 |
get /organizations/{organizationId}/devices, |
| 180 |
""" |
| 181 |
|
| 182 |
EXAMPLES = r""" |
| 183 |
- name: Get all devices |
| 184 |
cisco.meraki.devices_info: |
| 185 |
meraki_api_key: "{{ meraki_api_key }}" |
| 186 |
meraki_base_url: "{{ meraki_base_url }}" |
| 187 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 188 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 189 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 190 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 191 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 192 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 193 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 194 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 195 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 196 |
meraki_output_log: "{{ meraki_output_log }}" |
| 197 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 198 |
meraki_log_path: "{{ meraki_log_path }}" |
| 199 |
meraki_print_console: "{{ meraki_print_console }}" |
| 200 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 201 |
meraki_simulate: "{{ meraki_simulate }}" |
| 202 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 203 |
meraki_caller: "{{ meraki_caller }}" |
| 204 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 205 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 206 |
perPage: 0 |
| 207 |
startingAfter: string |
| 208 |
endingBefore: string |
| 209 |
configurationUpdatedAfter: string |
| 210 |
networkIds: [] |
| 211 |
productTypes: [] |
| 212 |
tags: [] |
| 213 |
tagsFilterType: string |
| 214 |
name: string |
| 215 |
mac: string |
| 216 |
serial: string |
| 217 |
model: string |
| 218 |
macs: [] |
| 219 |
serials: [] |
| 220 |
sensorMetrics: [] |
| 221 |
sensorAlertProfileIds: [] |
| 222 |
models: [] |
| 223 |
organizationId: string |
| 224 |
total_pages: -1 |
| 225 |
direction: next |
| 226 |
register: result |
| 227 |
- name: Get devices by id |
| 228 |
cisco.meraki.devices_info: |
| 229 |
meraki_api_key: "{{ meraki_api_key }}" |
| 230 |
meraki_base_url: "{{ meraki_base_url }}" |
| 231 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 232 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 233 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 234 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 235 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 236 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 237 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 238 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 239 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 240 |
meraki_output_log: "{{ meraki_output_log }}" |
| 241 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 242 |
meraki_log_path: "{{ meraki_log_path }}" |
| 243 |
meraki_print_console: "{{ meraki_print_console }}" |
| 244 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 245 |
meraki_simulate: "{{ meraki_simulate }}" |
| 246 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 247 |
meraki_caller: "{{ meraki_caller }}" |
| 248 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 249 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 250 |
serial: string |
| 251 |
register: result |
| 252 |
""" |
| 253 |
RETURN = r""" |
| 254 |
meraki_response: |
| 255 |
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK |
| 256 |
returned: always |
| 257 |
type: dict |
| 258 |
sample: > |
| 259 |
{ |
| 260 |
"name": "string", |
| 261 |
"lat": 0, |
| 262 |
"lng": 0, |
| 263 |
"address": "string", |
| 264 |
"notes": "string", |
| 265 |
"tags": [ |
| 266 |
"string" |
| 267 |
], |
| 268 |
"networkId": "string", |
| 269 |
"serial": "string", |
| 270 |
"model": "string", |
| 271 |
"mac": "string", |
| 272 |
"lanIp": "string", |
| 273 |
"firmware": "string", |
| 274 |
"floorPlanId": "string", |
| 275 |
"details": [ |
| 276 |
{ |
| 277 |
"name": "string", |
| 278 |
"value": "string" |
| 279 |
} |
| 280 |
], |
| 281 |
"beaconIdParams": { |
| 282 |
"uuid": "string", |
| 283 |
"major": 0, |
| 284 |
"minor": 0 |
| 285 |
} |
| 286 |
} |
| 287 |
""" |