| 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_switch_port_schedules |
| 9 |
short_description: Resource module for networks _switch _portschedules |
| 10 |
description: |
| 11 |
- Manage operations create, update and delete of the resource networks _switch _portschedules. |
| 12 |
- Add a switch port schedule. |
| 13 |
- Delete a switch port schedule. |
| 14 |
- Update a switch port schedule. |
| 15 |
version_added: '1.0.0' |
| 16 |
extends_documentation_fragment: |
| 17 |
- cisco.meraki.module |
| 18 |
author: Francisco Munoz (@fmunoz) |
| 19 |
options: |
| 20 |
name: |
| 21 |
description: The name for your port schedule. Required. |
| 22 |
type: str |
| 23 |
networkId: |
| 24 |
description: NetworkId path parameter. Network ID. |
| 25 |
type: str |
| 26 |
portSchedule: |
| 27 |
description: The schedule for switch port scheduling. Schedules are applied to |
| 28 |
days of the week. When it's empty, default schedule with all days of a week |
| 29 |
are configured. Any unspecified day in the schedule is added as a default schedule |
| 30 |
configuration of the day. |
| 31 |
suboptions: |
| 32 |
friday: |
| 33 |
description: The schedule object for Friday. |
| 34 |
suboptions: |
| 35 |
active: |
| 36 |
description: Whether the schedule is active (true) or inactive (false) |
| 37 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 38 |
type: bool |
| 39 |
from: |
| 40 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 41 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 42 |
are allowed. |
| 43 |
type: str |
| 44 |
to: |
| 45 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 46 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 47 |
are allowed. |
| 48 |
type: str |
| 49 |
type: dict |
| 50 |
monday: |
| 51 |
description: The schedule object for Monday. |
| 52 |
suboptions: |
| 53 |
active: |
| 54 |
description: Whether the schedule is active (true) or inactive (false) |
| 55 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 56 |
type: bool |
| 57 |
from: |
| 58 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 59 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 60 |
are allowed. |
| 61 |
type: str |
| 62 |
to: |
| 63 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 64 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 65 |
are allowed. |
| 66 |
type: str |
| 67 |
type: dict |
| 68 |
saturday: |
| 69 |
description: The schedule object for Saturday. |
| 70 |
suboptions: |
| 71 |
active: |
| 72 |
description: Whether the schedule is active (true) or inactive (false) |
| 73 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 74 |
type: bool |
| 75 |
from: |
| 76 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 77 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 78 |
are allowed. |
| 79 |
type: str |
| 80 |
to: |
| 81 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 82 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 83 |
are allowed. |
| 84 |
type: str |
| 85 |
type: dict |
| 86 |
sunday: |
| 87 |
description: The schedule object for Sunday. |
| 88 |
suboptions: |
| 89 |
active: |
| 90 |
description: Whether the schedule is active (true) or inactive (false) |
| 91 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 92 |
type: bool |
| 93 |
from: |
| 94 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 95 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 96 |
are allowed. |
| 97 |
type: str |
| 98 |
to: |
| 99 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 100 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 101 |
are allowed. |
| 102 |
type: str |
| 103 |
type: dict |
| 104 |
thursday: |
| 105 |
description: The schedule object for Thursday. |
| 106 |
suboptions: |
| 107 |
active: |
| 108 |
description: Whether the schedule is active (true) or inactive (false) |
| 109 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 110 |
type: bool |
| 111 |
from: |
| 112 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 113 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 114 |
are allowed. |
| 115 |
type: str |
| 116 |
to: |
| 117 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 118 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 119 |
are allowed. |
| 120 |
type: str |
| 121 |
type: dict |
| 122 |
tuesday: |
| 123 |
description: The schedule object for Tuesday. |
| 124 |
suboptions: |
| 125 |
active: |
| 126 |
description: Whether the schedule is active (true) or inactive (false) |
| 127 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 128 |
type: bool |
| 129 |
from: |
| 130 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 131 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 132 |
are allowed. |
| 133 |
type: str |
| 134 |
to: |
| 135 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 136 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 137 |
are allowed. |
| 138 |
type: str |
| 139 |
type: dict |
| 140 |
wednesday: |
| 141 |
description: The schedule object for Wednesday. |
| 142 |
suboptions: |
| 143 |
active: |
| 144 |
description: Whether the schedule is active (true) or inactive (false) |
| 145 |
during the time specified between 'from' and 'to'. Defaults to true. |
| 146 |
type: bool |
| 147 |
from: |
| 148 |
description: The time, from '00 00' to '24 00'. Must be less than the |
| 149 |
time specified in 'to'. Defaults to '00 00'. Only 30 minute increments |
| 150 |
are allowed. |
| 151 |
type: str |
| 152 |
to: |
| 153 |
description: The time, from '00 00' to '24 00'. Must be greater than the |
| 154 |
time specified in 'from'. Defaults to '24 00'. Only 30 minute increments |
| 155 |
are allowed. |
| 156 |
type: str |
| 157 |
type: dict |
| 158 |
type: dict |
| 159 |
portScheduleId: |
| 160 |
description: PortScheduleId path parameter. Port schedule ID. |
| 161 |
type: str |
| 162 |
requirements: |
| 163 |
- meraki >= 2.4.9 |
| 164 |
- python >= 3.5 |
| 165 |
seealso: |
| 166 |
- name: Cisco Meraki documentation for switch createNetworkSwitchPortSchedule |
| 167 |
description: Complete reference of the createNetworkSwitchPortSchedule API. |
| 168 |
link: https://developer.cisco.com/meraki/api-v1/#!create-network-switch-port-schedule |
| 169 |
- name: Cisco Meraki documentation for switch deleteNetworkSwitchPortSchedule |
| 170 |
description: Complete reference of the deleteNetworkSwitchPortSchedule API. |
| 171 |
link: https://developer.cisco.com/meraki/api-v1/#!delete-network-switch-port-schedule |
| 172 |
- name: Cisco Meraki documentation for switch updateNetworkSwitchPortSchedule |
| 173 |
description: Complete reference of the updateNetworkSwitchPortSchedule API. |
| 174 |
link: https://developer.cisco.com/meraki/api-v1/#!update-network-switch-port-schedule |
| 175 |
notes: |
| 176 |
- SDK Method used are |
| 177 |
switch.Switch.create_network_switch_port_schedule, |
| 178 |
switch.Switch.delete_network_switch_port_schedule, |
| 179 |
switch.Switch.update_network_switch_port_schedule, |
| 180 |
- Paths used are |
| 181 |
post /networks/{networkId}/switch/portSchedules, |
| 182 |
delete /networks/{networkId}/switch/portSchedules/{portScheduleId}, |
| 183 |
put /networks/{networkId}/switch/portSchedules/{portScheduleId}, |
| 184 |
""" |
| 185 |
|
| 186 |
EXAMPLES = r""" |
| 187 |
- name: Create |
| 188 |
cisco.meraki.networks_switch_port_schedules: |
| 189 |
meraki_api_key: "{{ meraki_api_key }}" |
| 190 |
meraki_base_url: "{{ meraki_base_url }}" |
| 191 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 192 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 193 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 194 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 195 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 196 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 197 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 198 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 199 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 200 |
meraki_output_log: "{{ meraki_output_log }}" |
| 201 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 202 |
meraki_log_path: "{{ meraki_log_path }}" |
| 203 |
meraki_print_console: "{{ meraki_print_console }}" |
| 204 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 205 |
meraki_simulate: "{{ meraki_simulate }}" |
| 206 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 207 |
meraki_caller: "{{ meraki_caller }}" |
| 208 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 209 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 210 |
state: present |
| 211 |
name: Weekdays schedule |
| 212 |
networkId: string |
| 213 |
portSchedule: |
| 214 |
friday: |
| 215 |
active: true |
| 216 |
from: '9:00' |
| 217 |
to: '17:00' |
| 218 |
monday: |
| 219 |
active: true |
| 220 |
from: '9:00' |
| 221 |
to: '17:00' |
| 222 |
saturday: |
| 223 |
active: false |
| 224 |
from: 0:00 |
| 225 |
to: '24:00' |
| 226 |
sunday: |
| 227 |
active: false |
| 228 |
from: 0:00 |
| 229 |
to: '24:00' |
| 230 |
thursday: |
| 231 |
active: true |
| 232 |
from: '9:00' |
| 233 |
to: '17:00' |
| 234 |
tuesday: |
| 235 |
active: true |
| 236 |
from: '9:00' |
| 237 |
to: '17:00' |
| 238 |
wednesday: |
| 239 |
active: true |
| 240 |
from: '9:00' |
| 241 |
to: '17:00' |
| 242 |
- name: Delete by id |
| 243 |
cisco.meraki.networks_switch_port_schedules: |
| 244 |
meraki_api_key: "{{ meraki_api_key }}" |
| 245 |
meraki_base_url: "{{ meraki_base_url }}" |
| 246 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 247 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 248 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 249 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 250 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 251 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 252 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 253 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 254 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 255 |
meraki_output_log: "{{ meraki_output_log }}" |
| 256 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 257 |
meraki_log_path: "{{ meraki_log_path }}" |
| 258 |
meraki_print_console: "{{ meraki_print_console }}" |
| 259 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 260 |
meraki_simulate: "{{ meraki_simulate }}" |
| 261 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 262 |
meraki_caller: "{{ meraki_caller }}" |
| 263 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 264 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 265 |
state: absent |
| 266 |
networkId: string |
| 267 |
portScheduleId: string |
| 268 |
- name: Update by id |
| 269 |
cisco.meraki.networks_switch_port_schedules: |
| 270 |
meraki_api_key: "{{ meraki_api_key }}" |
| 271 |
meraki_base_url: "{{ meraki_base_url }}" |
| 272 |
meraki_single_request_timeout: "{{ meraki_single_request_timeout }}" |
| 273 |
meraki_certificate_path: "{{ meraki_certificate_path }}" |
| 274 |
meraki_requests_proxy: "{{ meraki_requests_proxy }}" |
| 275 |
meraki_wait_on_rate_limit: "{{ meraki_wait_on_rate_limit }}" |
| 276 |
meraki_nginx_429_retry_wait_time: "{{ meraki_nginx_429_retry_wait_time }}" |
| 277 |
meraki_action_batch_retry_wait_time: "{{ meraki_action_batch_retry_wait_time }}" |
| 278 |
meraki_retry_4xx_error: "{{ meraki_retry_4xx_error }}" |
| 279 |
meraki_retry_4xx_error_wait_time: "{{ meraki_retry_4xx_error_wait_time }}" |
| 280 |
meraki_maximum_retries: "{{ meraki_maximum_retries }}" |
| 281 |
meraki_output_log: "{{ meraki_output_log }}" |
| 282 |
meraki_log_file_prefix: "{{ meraki_log_file_prefix }}" |
| 283 |
meraki_log_path: "{{ meraki_log_path }}" |
| 284 |
meraki_print_console: "{{ meraki_print_console }}" |
| 285 |
meraki_suppress_logging: "{{ meraki_suppress_logging }}" |
| 286 |
meraki_simulate: "{{ meraki_simulate }}" |
| 287 |
meraki_be_geo_id: "{{ meraki_be_geo_id }}" |
| 288 |
meraki_caller: "{{ meraki_caller }}" |
| 289 |
meraki_use_iterator_for_get_pages: "{{ meraki_use_iterator_for_get_pages }}" |
| 290 |
meraki_inherit_logging_config: "{{ meraki_inherit_logging_config }}" |
| 291 |
state: present |
| 292 |
name: Weekdays schedule |
| 293 |
networkId: string |
| 294 |
portSchedule: |
| 295 |
friday: |
| 296 |
active: true |
| 297 |
from: '9:00' |
| 298 |
to: '17:00' |
| 299 |
monday: |
| 300 |
active: true |
| 301 |
from: '9:00' |
| 302 |
to: '17:00' |
| 303 |
saturday: |
| 304 |
active: false |
| 305 |
from: 0:00 |
| 306 |
to: '24:00' |
| 307 |
sunday: |
| 308 |
active: false |
| 309 |
from: 0:00 |
| 310 |
to: '24:00' |
| 311 |
thursday: |
| 312 |
active: true |
| 313 |
from: '9:00' |
| 314 |
to: '17:00' |
| 315 |
tuesday: |
| 316 |
active: true |
| 317 |
from: '9:00' |
| 318 |
to: '17:00' |
| 319 |
wednesday: |
| 320 |
active: true |
| 321 |
from: '9:00' |
| 322 |
to: '17:00' |
| 323 |
portScheduleId: string |
| 324 |
""" |
| 325 |
RETURN = r""" |
| 326 |
meraki_response: |
| 327 |
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK |
| 328 |
returned: always |
| 329 |
type: dict |
| 330 |
sample: > |
| 331 |
{ |
| 332 |
"id": "string", |
| 333 |
"networkId": "string", |
| 334 |
"name": "string", |
| 335 |
"portSchedule": { |
| 336 |
"monday": { |
| 337 |
"active": true, |
| 338 |
"from": "string", |
| 339 |
"to": "string" |
| 340 |
}, |
| 341 |
"tuesday": { |
| 342 |
"active": true, |
| 343 |
"from": "string", |
| 344 |
"to": "string" |
| 345 |
}, |
| 346 |
"wednesday": { |
| 347 |
"active": true, |
| 348 |
"from": "string", |
| 349 |
"to": "string" |
| 350 |
}, |
| 351 |
"thursday": { |
| 352 |
"active": true, |
| 353 |
"from": "string", |
| 354 |
"to": "string" |
| 355 |
}, |
| 356 |
"friday": { |
| 357 |
"active": true, |
| 358 |
"from": "string", |
| 359 |
"to": "string" |
| 360 |
}, |
| 361 |
"saturday": { |
| 362 |
"active": true, |
| 363 |
"from": "string", |
| 364 |
"to": "string" |
| 365 |
}, |
| 366 |
"sunday": { |
| 367 |
"active": true, |
| 368 |
"from": "string", |
| 369 |
"to": "string" |
| 370 |
} |
| 371 |
} |
| 372 |
} |
| 373 |
""" |