Skip to content

Commit

Permalink
Merge pull request #63 from meraki/develop
Browse files Browse the repository at this point in the history
2.18.2:
  • Loading branch information
fmunozmiranda authored Sep 20, 2024
2 parents f28bda0 + e989263 commit c1f789c
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Other versions of this collection have support for previous Cisco Meraki version
| Cisco Meraki version | Ansible "cisco.meraki" version | Python "DashboardAPI" version |
|--------------------------|------------------------------|-------------------------------|
| 1.33.0 | 2.17.0 |1.33.0 |
| 1.44.1 | 2.18.1 |1.44.1 |
| 1.44.1 | 2.18.2 |1.44.1 |

*Notes*:

Expand Down
6 changes: 5 additions & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1070,4 +1070,8 @@ releases:
- The `id` parameter is now required for `networks_appliance_vlans` module.
- The `id` parameter is change type to an `integer` in `networks_appliance_vlans` module.
- Fixing problem of naming in `organizations_appliance_vpn_third_party_vpnpeers_info`.
- Removing `state` from allowed parameters for `networks_syslog_servers` module.
- Removing `state` from allowed parameters for `networks_syslog_servers` module.
2.18.2:
changes:
minor_changes:
- Include networks_appliance_traffic_shaping_custom_performance_classes_info plugin.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: meraki
version: 2.18.1
version: 2.18.2
readme: README.md
authors:
- Francisco Muñoz <[email protected]>
Expand Down
10 changes: 10 additions & 0 deletions playbooks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@
# organizationId: "828099381482762270"
# register: result

# - name: Show result
# ansible.builtin.debug:
# msg: "{{ result }}"


# - name: Get all networks _appliance _trafficshaping _customperformanceclasses
# cisco.meraki.networks_appliance_traffic_shaping_custom_performance_classes_info:
# networkId: L_828099381482771185
# register: result

# - name: Show result
# ansible.builtin.debug:
# msg: "{{ result }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2021, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.plugins.action import ActionBase
try:
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
AnsibleArgSpecValidator,
)
except ImportError:
ANSIBLE_UTILS_IS_INSTALLED = False
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import (
MERAKI,
meraki_argument_spec,
)

# Get common arguments specification
argument_spec = meraki_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
networkId=dict(type="str"),
customPerformanceClassId=dict(type="str"),
))

required_if = []
required_one_of = []
mutually_exclusive = []
required_together = []


class ActionModule(ActionBase):
def __init__(self, *args, **kwargs):
if not ANSIBLE_UTILS_IS_INSTALLED:
raise AnsibleActionFail(
"ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
super(ActionModule, self).__init__(*args, **kwargs)
self._supports_async = False
self._supports_check_mode = True
self._result = None

# Checks the supplied parameters against the argument spec for this module
def _check_argspec(self):
aav = AnsibleArgSpecValidator(
data=self._task.args,
schema=dict(argument_spec=argument_spec),
schema_format="argspec",
schema_conditionals=dict(
required_if=required_if,
required_one_of=required_one_of,
mutually_exclusive=mutually_exclusive,
required_together=required_together,
),
name=self._task.action,
)
valid, errors, self._task.args = aav.validate()
if not valid:
raise AnsibleActionFail(errors)

def get_object(self, params):
new_object = {}
if params.get("networkId") is not None:
new_object["networkId"] = params.get(
"networkId")
if params.get("customPerformanceClassId") is not None:
new_object["customPerformanceClassId"] = params.get(
"customPerformanceClassId")
return new_object

def get_all(self, params):
new_object = {}
if params.get("networkId") is not None:
new_object["networkId"] = params.get(
"networkId")

return new_object

def run(self, tmp=None, task_vars=None):
self._task.diff = False
self._result = super(ActionModule, self).run(tmp, task_vars)
self._result["changed"] = False
self._check_argspec()

self._result.update(dict(meraki_response={}))

meraki = MERAKI(params=self._task.args)

id = self._task.args.get("customPerformanceClassId")
if id:
response = meraki.exec_meraki(
family="appliance",
function='getNetworkApplianceTrafficShapingCustomPerformanceClass',
params=self.get_object(self._task.args),
)
self._result.update(dict(meraki_response=response))
self._result.update(meraki.exit_json())
return self._result
if not id:
response = meraki.exec_meraki(
family="appliance",
function='getNetworkApplianceTrafficShapingCustomPerformanceClasses',
params=self.get_all(self._task.args),
)
self._result.update(dict(meraki_response=response))
self._result.update(meraki.exit_json())
return self._result
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

# Copyright (c) 2021, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

DOCUMENTATION = r"""
---
module: networks_appliance_traffic_shaping_custom_performance_classes_info
short_description: Information module for networks _appliance _trafficshaping _customperformanceclasses
description:
- Get all networks _appliance _trafficshaping _customperformanceclasses.
- Get networks _appliance _trafficshaping _customperformanceclasses by id.
- List all custom performance classes for an MX network.
- Return a custom performance class for an MX network.
version_added: '1.0.0'
extends_documentation_fragment:
- cisco.meraki.module_info
author: Francisco Munoz (@fmunoz)
options:
headers:
description: Additional headers.
type: dict
networkId:
description:
- NetworkId path parameter. Network ID.
type: str
customPerformanceClassId:
description:
- CustomPerformanceClassId path parameter. Custom performance class ID.
type: str
requirements:
- meraki >= 2.4.9
- python >= 3.5
seealso:
- name: Cisco Meraki documentation for appliance getNetworkApplianceTrafficShapingCustomPerformanceClass
description: Complete reference of the getNetworkApplianceTrafficShapingCustomPerformanceClass API.
link: https://developer.cisco.com/meraki/api-v1/#!get-network-appliance-traffic-shaping-custom-performance-class
- name: Cisco Meraki documentation for appliance getNetworkApplianceTrafficShapingCustomPerformanceClasses
description: Complete reference of the getNetworkApplianceTrafficShapingCustomPerformanceClasses API.
link: https://developer.cisco.com/meraki/api-v1/#!get-network-appliance-traffic-shaping-custom-performance-classes
notes:
- SDK Method used are
appliance.Appliance.get_network_appliance_traffic_shaping_custom_performance_class,
appliance.Appliance.get_network_appliance_traffic_shaping_custom_performance_classes,
- Paths used are
get /networks/{networkId}/appliance/trafficShaping/customPerformanceClasses,
get /networks/{networkId}/appliance/trafficShaping/customPerformanceClasses/{customPerformanceClassId},
"""

EXAMPLES = r"""
- name: Get all networks _appliance _trafficshaping _customperformanceclasses
cisco.meraki.networks_appliance_traffic_shaping_custom_performance_classes_info:
meraki_api_key: "{{meraki_api_key}}"
meraki_base_url: "{{meraki_base_url}}"
meraki_single_request_timeout: "{{meraki_single_request_timeout}}"
meraki_certificate_path: "{{meraki_certificate_path}}"
meraki_requests_proxy: "{{meraki_requests_proxy}}"
meraki_wait_on_rate_limit: "{{meraki_wait_on_rate_limit}}"
meraki_nginx_429_retry_wait_time: "{{meraki_nginx_429_retry_wait_time}}"
meraki_action_batch_retry_wait_time: "{{meraki_action_batch_retry_wait_time}}"
meraki_retry_4xx_error: "{{meraki_retry_4xx_error}}"
meraki_retry_4xx_error_wait_time: "{{meraki_retry_4xx_error_wait_time}}"
meraki_maximum_retries: "{{meraki_maximum_retries}}"
meraki_output_log: "{{meraki_output_log}}"
meraki_log_file_prefix: "{{meraki_log_file_prefix}}"
meraki_log_path: "{{meraki_log_path}}"
meraki_print_console: "{{meraki_print_console}}"
meraki_suppress_logging: "{{meraki_suppress_logging}}"
meraki_simulate: "{{meraki_simulate}}"
meraki_be_geo_id: "{{meraki_be_geo_id}}"
meraki_caller: "{{meraki_caller}}"
meraki_use_iterator_for_get_pages: "{{meraki_use_iterator_for_get_pages}}"
meraki_inherit_logging_config: "{{meraki_inherit_logging_config}}"
networkId: string
register: result
- name: Get networks _appliance _trafficshaping _customperformanceclasses by id
cisco.meraki.networks_appliance_traffic_shaping_custom_performance_classes_info:
meraki_api_key: "{{meraki_api_key}}"
meraki_base_url: "{{meraki_base_url}}"
meraki_single_request_timeout: "{{meraki_single_request_timeout}}"
meraki_certificate_path: "{{meraki_certificate_path}}"
meraki_requests_proxy: "{{meraki_requests_proxy}}"
meraki_wait_on_rate_limit: "{{meraki_wait_on_rate_limit}}"
meraki_nginx_429_retry_wait_time: "{{meraki_nginx_429_retry_wait_time}}"
meraki_action_batch_retry_wait_time: "{{meraki_action_batch_retry_wait_time}}"
meraki_retry_4xx_error: "{{meraki_retry_4xx_error}}"
meraki_retry_4xx_error_wait_time: "{{meraki_retry_4xx_error_wait_time}}"
meraki_maximum_retries: "{{meraki_maximum_retries}}"
meraki_output_log: "{{meraki_output_log}}"
meraki_log_file_prefix: "{{meraki_log_file_prefix}}"
meraki_log_path: "{{meraki_log_path}}"
meraki_print_console: "{{meraki_print_console}}"
meraki_suppress_logging: "{{meraki_suppress_logging}}"
meraki_simulate: "{{meraki_simulate}}"
meraki_be_geo_id: "{{meraki_be_geo_id}}"
meraki_caller: "{{meraki_caller}}"
meraki_use_iterator_for_get_pages: "{{meraki_use_iterator_for_get_pages}}"
meraki_inherit_logging_config: "{{meraki_inherit_logging_config}}"
networkId: string
customPerformanceClassId: string
register: result
"""
RETURN = r"""
meraki_response:
description: A dictionary or list with the response returned by the Cisco Meraki Python SDK
returned: always
type: dict
sample: >
{
"customPerformanceClassId": "string",
"maxJitter": 0,
"maxLatency": 0,
"maxLossPercentage": 0,
"name": "string"
}
"""

0 comments on commit c1f789c

Please sign in to comment.