From e9892637b82e0b109d6bb23a4095d9608bc482d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mu=C3=B1oz?= Date: Fri, 20 Sep 2024 14:25:41 -0600 Subject: [PATCH] 2.18.2: changes: minor_changes: - Include networks_appliance_traffic_shaping_custom_performance_classes_info plugin. --- README.md | 2 +- changelogs/changelog.yaml | 6 +- galaxy.yml | 2 +- playbooks/test.yml | 10 ++ ...shaping_custom_performance_classes_info.py | 112 ++++++++++++++++ ...shaping_custom_performance_classes_info.py | 120 ++++++++++++++++++ 6 files changed, 249 insertions(+), 3 deletions(-) create mode 100644 plugins/action/networks_appliance_traffic_shaping_custom_performance_classes_info.py create mode 100644 plugins/modules/networks_appliance_traffic_shaping_custom_performance_classes_info.py diff --git a/README.md b/README.md index ef5fd1179..52e21a9f3 100644 --- a/README.md +++ b/README.md @@ -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*: diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 31f7c73bd..b200ec300 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -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. \ No newline at end of file + - 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. \ No newline at end of file diff --git a/galaxy.yml b/galaxy.yml index a5bef40cc..be1f714e1 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: cisco name: meraki -version: 2.18.1 +version: 2.18.2 readme: README.md authors: - Francisco Muñoz diff --git a/playbooks/test.yml b/playbooks/test.yml index f2b0a4dcb..c9b1a1a19 100644 --- a/playbooks/test.yml +++ b/playbooks/test.yml @@ -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 }}" \ No newline at end of file diff --git a/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes_info.py b/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes_info.py new file mode 100644 index 000000000..2be944307 --- /dev/null +++ b/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes_info.py @@ -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 diff --git a/plugins/modules/networks_appliance_traffic_shaping_custom_performance_classes_info.py b/plugins/modules/networks_appliance_traffic_shaping_custom_performance_classes_info.py new file mode 100644 index 000000000..26c8c22af --- /dev/null +++ b/plugins/modules/networks_appliance_traffic_shaping_custom_performance_classes_info.py @@ -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" + } +"""