diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 04:06:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-26 04:06:02 +0000 |
commit | e3eb94c23206603103f3c4faec6c227f59a1544c (patch) | |
tree | f2639459807ba88f55fc9c54d745bd7075d7f15c /ansible_collections/cisco/meraki/plugins/action | |
parent | Releasing progress-linux version 9.4.0+dfsg-1~progress7.99u1. (diff) | |
download | ansible-e3eb94c23206603103f3c4faec6c227f59a1544c.tar.xz ansible-e3eb94c23206603103f3c4faec6c227f59a1544c.zip |
Merging upstream version 9.5.1+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/cisco/meraki/plugins/action')
169 files changed, 9172 insertions, 2132 deletions
diff --git a/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_entitlements_info.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_entitlements_info.py new file mode 100644 index 000000000..b5af8055e --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_entitlements_info.py @@ -0,0 +1,90 @@ +#!/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( + skus=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("skus") is not None: + new_object["skus"] = params.get( + "skus") + + 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) + + response = meraki.exec_meraki( + family="licensing", + function='getAdministeredLicensingSubscriptionEntitlements', + 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/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_bind.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_bind.py new file mode 100644 index 000000000..e3cc7eba1 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_bind.py @@ -0,0 +1,91 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + networkIds=dict(type="list"), + subscriptionId=dict(type="str"), + validate=dict(type="bool"), +)) + +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 = False + 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 = dict( + networkIds=params.get("networkIds"), + subscription_id=params.get("subscriptionId"), + validate=params.get("validate"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="licensing", + function='bindAdministeredLicensingSubscriptionSubscription', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim.py new file mode 100644 index 000000000..cf02a8ac6 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim.py @@ -0,0 +1,95 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + claimKey=dict(type="str"), + description=dict(type="str"), + name=dict(type="str"), + organizationId=dict(type="str"), + validate=dict(type="bool"), +)) + +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 = False + 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 = dict( + claimKey=params.get("claimKey"), + description=params.get("description"), + name=params.get("name"), + organizationId=params.get("organizationId"), + validate=params.get("validate"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="licensing", + function='claimAdministeredLicensingSubscriptionSubscriptions', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim_key_validate.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim_key_validate.py new file mode 100644 index 000000000..9113049d7 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_claim_key_validate.py @@ -0,0 +1,87 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + claimKey=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 = False + 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 = dict( + claimKey=params.get("claimKey"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="licensing", + function='validateAdministeredLicensingSubscriptionSubscriptionsClaimKey', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_compliance_statuses_info.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_compliance_statuses_info.py new file mode 100644 index 000000000..ec2d035ab --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_compliance_statuses_info.py @@ -0,0 +1,94 @@ +#!/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( + organizationIds=dict(type="list"), + subscriptionIds=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationIds") is not None: + new_object["organizationIds"] = params.get( + "organizationIds") + if params.get("subscriptionIds") is not None: + new_object["subscriptionIds"] = params.get( + "subscriptionIds") + + 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) + + response = meraki.exec_meraki( + family="licensing", + function='getAdministeredLicensingSubscriptionSubscriptionsComplianceStatuses', + 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/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_info.py b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_info.py new file mode 100644 index 000000000..8be76a060 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/administered_licensing_subscription_subscriptions_info.py @@ -0,0 +1,128 @@ +#!/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( + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + subscriptionIds=dict(type="list"), + organizationIds=dict(type="list"), + statuses=dict(type="list"), + productTypes=dict(type="list"), + startDate=dict(type="str"), + endDate=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_all(self, params): + new_object = {} + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("subscriptionIds") is not None: + new_object["subscriptionIds"] = params.get( + "subscriptionIds") + if params.get("organizationIds") is not None: + new_object["organizationIds"] = params.get( + "organizationIds") + if params.get("statuses") is not None: + new_object["statuses"] = params.get( + "statuses") + if params.get("productTypes") is not None: + new_object["productTypes"] = params.get( + "productTypes") + if params.get("startDate") is not None: + new_object["startDate"] = params.get( + "startDate") + if params.get("endDate") is not None: + new_object["endDate"] = params.get( + "endDate") + + 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) + + response = meraki.exec_meraki( + family="licensing", + function='getAdministeredLicensingSubscriptionSubscriptions', + 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/ansible_collections/cisco/meraki/plugins/action/devices.py b/ansible_collections/cisco/meraki/plugins/action/devices.py index df0edfd10..49d41b1a7 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices.py @@ -32,16 +32,15 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - name=dict(type="str"), - tags=dict(type="list"), + address=dict(type="str"), + floorPlanId=dict(type="str"), lat=dict(type="float"), lng=dict(type="float"), - address=dict(type="str"), - notes=dict(type="str"), moveMapMarker=dict(type="bool"), + name=dict(type="str"), + notes=dict(type="str"), switchProfileId=dict(type="str"), - floorPlanId=dict(type="str"), - mac=dict(type="str"), + tags=dict(type="list"), serial=dict(type="str"), organizationId=dict(type="str"), )) @@ -58,16 +57,15 @@ class Devices(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - tags=params.get("tags"), + address=params.get("address"), + floorPlanId=params.get("floorPlanId"), lat=params.get("lat"), lng=params.get("lng"), - address=params.get("address"), - notes=params.get("notes"), moveMapMarker=params.get("moveMapMarker"), + name=params.get("name"), + notes=params.get("notes"), switchProfileId=params.get("switchProfileId"), - floorPlanId=params.get("floorPlanId"), - mac=params.get("mac"), + tags=params.get("tags"), serial=params.get("serial"), organization_id=params.get("organizationId"), ) @@ -130,36 +128,32 @@ class Devices(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: - new_object_params['tags'] = self.new_object.get('tags') or \ - self.new_object.get('tags') + if self.new_object.get('address') is not None or self.new_object.get('address') is not None: + new_object_params['address'] = self.new_object.get('address') or \ + self.new_object.get('address') + if self.new_object.get('floorPlanId') is not None or self.new_object.get('floor_plan_id') is not None: + new_object_params['floorPlanId'] = self.new_object.get('floorPlanId') or \ + self.new_object.get('floor_plan_id') if self.new_object.get('lat') is not None or self.new_object.get('lat') is not None: new_object_params['lat'] = self.new_object.get('lat') or \ self.new_object.get('lat') if self.new_object.get('lng') is not None or self.new_object.get('lng') is not None: new_object_params['lng'] = self.new_object.get('lng') or \ self.new_object.get('lng') - if self.new_object.get('address') is not None or self.new_object.get('address') is not None: - new_object_params['address'] = self.new_object.get('address') or \ - self.new_object.get('address') + if self.new_object.get('moveMapMarker') is not None or self.new_object.get('move_map_marker') is not None: + new_object_params['moveMapMarker'] = self.new_object.get('moveMapMarker') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('notes') is not None or self.new_object.get('notes') is not None: new_object_params['notes'] = self.new_object.get('notes') or \ self.new_object.get('notes') - if self.new_object.get('moveMapMarker') is not None or self.new_object.get('move_map_marker') is not None: - new_object_params['moveMapMarker'] = self.new_object.get( - 'moveMapMarker') if self.new_object.get('switchProfileId') is not None or self.new_object.get('switch_profile_id') is not None: new_object_params['switchProfileId'] = self.new_object.get('switchProfileId') or \ self.new_object.get('switch_profile_id') - if self.new_object.get('floorPlanId') is not None or self.new_object.get('floor_plan_id') is not None: - new_object_params['floorPlanId'] = self.new_object.get('floorPlanId') or \ - self.new_object.get('floor_plan_id') - if self.new_object.get('mac') is not None or self.new_object.get('mac') is not None: - new_object_params['mac'] = self.new_object.get('mac') or \ - self.new_object.get('mac') + if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: + new_object_params['tags'] = self.new_object.get('tags') or \ + self.new_object.get('tags') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -238,16 +232,15 @@ class Devices(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("tags", "tags"), + ("address", "address"), + ("floorPlanId", "floorPlanId"), ("lat", "lat"), ("lng", "lng"), - ("address", "address"), - ("notes", "notes"), ("moveMapMarker", "moveMapMarker"), + ("name", "name"), + ("notes", "notes"), ("switchProfileId", "switchProfileId"), - ("floorPlanId", "floorPlanId"), - ("mac", "mac"), + ("tags", "tags"), ("serial", "serial"), ("organizationId", "organizationId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings.py b/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings.py new file mode 100644 index 000000000..783ba4821 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings.py @@ -0,0 +1,211 @@ +#!/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, + meraki_compare_equality, + get_dict_result, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present"]), + fiveGhzSettings=dict(type="dict"), + rfProfileId=dict(type="str"), + twoFourGhzSettings=dict(type="dict"), + serial=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["serial"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class DevicesApplianceRadioSettings(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + fiveGhzSettings=params.get("fiveGhzSettings"), + rfProfileId=params.get("rfProfileId"), + twoFourGhzSettings=params.get("twoFourGhzSettings"), + serial=params.get("serial"), + ) + + def get_all_params(self, name=None, id=None): + new_object_params = {} + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') + return new_object_params + + def update_all_params(self): + new_object_params = {} + if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: + new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ + self.new_object.get('five_ghz_settings') + if self.new_object.get('rfProfileId') is not None or self.new_object.get('rf_profile_id') is not None: + new_object_params['rfProfileId'] = self.new_object.get('rfProfileId') or \ + self.new_object.get('rf_profile_id') + if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: + new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ + self.new_object.get('two_four_ghz_settings') + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') or \ + self.new_object.get('serial') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name method, using get all + try: + items = self.meraki.exec_meraki( + family="appliance", + function="getDeviceApplianceRadioSettings", + params=self.get_all_params(name=name), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'name', name) + if result is None: + result = items + except Exception as e: + print("Error: ", e) + result = None + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("serial") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("fiveGhzSettings", "fiveGhzSettings"), + ("rfProfileId", "rfProfileId"), + ("twoFourGhzSettings", "twoFourGhzSettings"), + ("serial", "serial"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def update(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + result = self.meraki.exec_meraki( + family="appliance", + function="updateDeviceApplianceRadioSettings", + params=self.update_all_params(), + op_modifies=True, + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = DevicesApplianceRadioSettings(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + meraki.fail_json( + "Object does not exists, plugin only has update") + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings_info.py b/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings_info.py new file mode 100644 index 000000000..2ac8e4768 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_appliance_radio_settings_info.py @@ -0,0 +1,90 @@ +#!/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( + serial=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_all(self, params): + new_object = {} + if params.get("serial") is not None: + new_object["serial"] = params.get( + "serial") + + 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) + + response = meraki.exec_meraki( + family="appliance", + function='getDeviceApplianceRadioSettings', + 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/ansible_collections/cisco/meraki/plugins/action/devices_blink_leds.py b/ansible_collections/cisco/meraki/plugins/action/devices_blink_leds.py index d6e157172..010922bcd 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_blink_leds.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_blink_leds.py @@ -26,8 +26,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( duration=dict(type="int"), - period=dict(type="int"), duty=dict(type="int"), + period=dict(type="int"), serial=dict(type="str"), )) @@ -68,8 +68,8 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( duration=params.get("duration"), - period=params.get("period"), duty=params.get("duty"), + period=params.get("period"), serial=params.get("serial"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_camera_custom_analytics.py b/ansible_collections/cisco/meraki/plugins/action/devices_camera_custom_analytics.py index 92f3aa3ae..7493fe9b4 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_camera_custom_analytics.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_camera_custom_analytics.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enabled=dict(type="bool"), artifactId=dict(type="str"), + enabled=dict(type="bool"), parameters=dict(type="list"), serial=dict(type="str"), )) @@ -50,8 +50,8 @@ class DevicesCameraCustomAnalytics(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enabled=params.get("enabled"), artifactId=params.get("artifactId"), + enabled=params.get("enabled"), parameters=params.get("parameters"), serial=params.get("serial"), ) @@ -64,11 +64,11 @@ class DevicesCameraCustomAnalytics(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('artifactId') is not None or self.new_object.get('artifact_id') is not None: new_object_params['artifactId'] = self.new_object.get('artifactId') or \ self.new_object.get('artifact_id') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('parameters') is not None or self.new_object.get('parameters') is not None: new_object_params['parameters'] = self.new_object.get('parameters') or \ self.new_object.get('parameters') @@ -128,8 +128,8 @@ class DevicesCameraCustomAnalytics(object): requested_obj = self.new_object obj_params = [ - ("enabled", "enabled"), ("artifactId", "artifactId"), + ("enabled", "enabled"), ("parameters", "parameters"), ("serial", "serial"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_camera_generate_snapshot.py b/ansible_collections/cisco/meraki/plugins/action/devices_camera_generate_snapshot.py index 8b7e68487..25f923011 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_camera_generate_snapshot.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_camera_generate_snapshot.py @@ -25,8 +25,8 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - timestamp=dict(type="str"), fullframe=dict(type="bool"), + timestamp=dict(type="str"), serial=dict(type="str"), )) @@ -66,8 +66,8 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - timestamp=params.get("timestamp"), fullframe=params.get("fullframe"), + timestamp=params.get("timestamp"), serial=params.get("serial"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_camera_quality_and_retention.py b/ansible_collections/cisco/meraki/plugins/action/devices_camera_quality_and_retention.py index b7781783a..7b5056cf0 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_camera_quality_and_retention.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_camera_quality_and_retention.py @@ -32,13 +32,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - profileId=dict(type="str"), - motionBasedRetentionEnabled=dict(type="bool"), audioRecordingEnabled=dict(type="bool"), - restrictedBandwidthModeEnabled=dict(type="bool"), + motionBasedRetentionEnabled=dict(type="bool"), + motionDetectorVersion=dict(type="int"), + profileId=dict(type="str"), quality=dict(type="str"), resolution=dict(type="str"), - motionDetectorVersion=dict(type="int"), + restrictedBandwidthModeEnabled=dict(type="bool"), serial=dict(type="str"), )) @@ -54,13 +54,13 @@ class DevicesCameraQualityAndRetention(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - profileId=params.get("profileId"), - motionBasedRetentionEnabled=params.get("motionBasedRetentionEnabled"), audioRecordingEnabled=params.get("audioRecordingEnabled"), - restrictedBandwidthModeEnabled=params.get("restrictedBandwidthModeEnabled"), + motionBasedRetentionEnabled=params.get("motionBasedRetentionEnabled"), + motionDetectorVersion=params.get("motionDetectorVersion"), + profileId=params.get("profileId"), quality=params.get("quality"), resolution=params.get("resolution"), - motionDetectorVersion=params.get("motionDetectorVersion"), + restrictedBandwidthModeEnabled=params.get("restrictedBandwidthModeEnabled"), serial=params.get("serial"), ) @@ -72,24 +72,24 @@ class DevicesCameraQualityAndRetention(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('audioRecordingEnabled') is not None or self.new_object.get('audio_recording_enabled') is not None: + new_object_params['audioRecordingEnabled'] = self.new_object.get('audioRecordingEnabled') + if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: + new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') + if self.new_object.get('motionDetectorVersion') is not None or self.new_object.get('motion_detector_version') is not None: + new_object_params['motionDetectorVersion'] = self.new_object.get('motionDetectorVersion') or \ + self.new_object.get('motion_detector_version') if self.new_object.get('profileId') is not None or self.new_object.get('profile_id') is not None: new_object_params['profileId'] = self.new_object.get('profileId') or \ self.new_object.get('profile_id') - if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: - new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') - if self.new_object.get('audioRecordingEnabled') is not None or self.new_object.get('audio_recording_enabled') is not None: - new_object_params['audioRecordingEnabled'] = self.new_object.get('audioRecordingEnabled') - if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: - new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('quality') is not None or self.new_object.get('quality') is not None: new_object_params['quality'] = self.new_object.get('quality') or \ self.new_object.get('quality') if self.new_object.get('resolution') is not None or self.new_object.get('resolution') is not None: new_object_params['resolution'] = self.new_object.get('resolution') or \ self.new_object.get('resolution') - if self.new_object.get('motionDetectorVersion') is not None or self.new_object.get('motion_detector_version') is not None: - new_object_params['motionDetectorVersion'] = self.new_object.get('motionDetectorVersion') or \ - self.new_object.get('motion_detector_version') + if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: + new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -146,13 +146,13 @@ class DevicesCameraQualityAndRetention(object): requested_obj = self.new_object obj_params = [ - ("profileId", "profileId"), - ("motionBasedRetentionEnabled", "motionBasedRetentionEnabled"), ("audioRecordingEnabled", "audioRecordingEnabled"), - ("restrictedBandwidthModeEnabled", "restrictedBandwidthModeEnabled"), + ("motionBasedRetentionEnabled", "motionBasedRetentionEnabled"), + ("motionDetectorVersion", "motionDetectorVersion"), + ("profileId", "profileId"), ("quality", "quality"), ("resolution", "resolution"), - ("motionDetectorVersion", "motionDetectorVersion"), + ("restrictedBandwidthModeEnabled", "restrictedBandwidthModeEnabled"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_camera_sense.py b/ansible_collections/cisco/meraki/plugins/action/devices_camera_sense.py index 3cc8dca92..c95304f52 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_camera_sense.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_camera_sense.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - senseEnabled=dict(type="bool"), - mqttBrokerId=dict(type="str"), audioDetection=dict(type="dict"), detectionModelId=dict(type="str"), + mqttBrokerId=dict(type="str"), + senseEnabled=dict(type="bool"), serial=dict(type="str"), )) @@ -51,10 +51,10 @@ class DevicesCameraSense(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - senseEnabled=params.get("senseEnabled"), - mqttBrokerId=params.get("mqttBrokerId"), audioDetection=params.get("audioDetection"), detectionModelId=params.get("detectionModelId"), + mqttBrokerId=params.get("mqttBrokerId"), + senseEnabled=params.get("senseEnabled"), serial=params.get("serial"), ) @@ -66,17 +66,17 @@ class DevicesCameraSense(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('senseEnabled') is not None or self.new_object.get('sense_enabled') is not None: - new_object_params['senseEnabled'] = self.new_object.get('senseEnabled') - if self.new_object.get('mqttBrokerId') is not None or self.new_object.get('mqtt_broker_id') is not None: - new_object_params['mqttBrokerId'] = self.new_object.get('mqttBrokerId') or \ - self.new_object.get('mqtt_broker_id') if self.new_object.get('audioDetection') is not None or self.new_object.get('audio_detection') is not None: new_object_params['audioDetection'] = self.new_object.get('audioDetection') or \ self.new_object.get('audio_detection') if self.new_object.get('detectionModelId') is not None or self.new_object.get('detection_model_id') is not None: new_object_params['detectionModelId'] = self.new_object.get('detectionModelId') or \ self.new_object.get('detection_model_id') + if self.new_object.get('mqttBrokerId') is not None or self.new_object.get('mqtt_broker_id') is not None: + new_object_params['mqttBrokerId'] = self.new_object.get('mqttBrokerId') or \ + self.new_object.get('mqtt_broker_id') + if self.new_object.get('senseEnabled') is not None or self.new_object.get('sense_enabled') is not None: + new_object_params['senseEnabled'] = self.new_object.get('senseEnabled') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -133,10 +133,10 @@ class DevicesCameraSense(object): requested_obj = self.new_object obj_params = [ - ("senseEnabled", "senseEnabled"), - ("mqttBrokerId", "mqttBrokerId"), ("audioDetection", "audioDetection"), ("detectionModelId", "detectionModelId"), + ("mqttBrokerId", "mqttBrokerId"), + ("senseEnabled", "senseEnabled"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_camera_wireless_profiles.py b/ansible_collections/cisco/meraki/plugins/action/devices_camera_wireless_profiles.py index 8153293df..f891d8c5b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_camera_wireless_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_camera_wireless_profiles.py @@ -78,8 +78,8 @@ class DevicesCameraWirelessProfiles(object): params=self.get_all_params(name=name), ) if isinstance(items, dict): - if 'response' in items: - items = items.get('response') + if 'ids' in items: + items = items.get('ids') result = get_dict_result(items, 'name', name) if result is None: result = items diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_lan.py b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_lan.py index ddb0b4d97..048e8a28b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_lan.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_lan.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - reservedIpRanges=dict(type="list"), fixedIpAssignments=dict(type="list"), + reservedIpRanges=dict(type="list"), serial=dict(type="str"), )) @@ -49,8 +49,8 @@ class DevicesCellularGatewayLan(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - reservedIpRanges=params.get("reservedIpRanges"), fixedIpAssignments=params.get("fixedIpAssignments"), + reservedIpRanges=params.get("reservedIpRanges"), serial=params.get("serial"), ) @@ -62,12 +62,12 @@ class DevicesCellularGatewayLan(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: - new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ - self.new_object.get('reserved_ip_ranges') if self.new_object.get('fixedIpAssignments') is not None or self.new_object.get('fixed_ip_assignments') is not None: new_object_params['fixedIpAssignments'] = self.new_object.get('fixedIpAssignments') or \ self.new_object.get('fixed_ip_assignments') + if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: + new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ + self.new_object.get('reserved_ip_ranges') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -124,8 +124,8 @@ class DevicesCellularGatewayLan(object): requested_obj = self.new_object obj_params = [ - ("reservedIpRanges", "reservedIpRanges"), ("fixedIpAssignments", "fixedIpAssignments"), + ("reservedIpRanges", "reservedIpRanges"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_port_forwarding_rules.py b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_port_forwarding_rules.py index 59a6ddf66..cb8693d61 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_port_forwarding_rules.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_gateway_port_forwarding_rules.py @@ -78,8 +78,8 @@ class DevicesCellularGatewayPortForwardingRules(object): params=self.get_all_params(name=name), ) if isinstance(items, dict): - if 'response' in items: - items = items.get('response') + if 'rules' in items: + items = items.get('rules') result = get_dict_result(items, 'name', name) if result is None: result = items diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_sims.py b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_sims.py index 93e187918..d00c47622 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_cellular_sims.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_cellular_sims.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - sims=dict(type="list"), simFailover=dict(type="dict"), + sims=dict(type="list"), serial=dict(type="str"), )) @@ -49,8 +49,8 @@ class DevicesCellularSims(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - sims=params.get("sims"), simFailover=params.get("simFailover"), + sims=params.get("sims"), serial=params.get("serial"), ) @@ -62,12 +62,12 @@ class DevicesCellularSims(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('sims') is not None or self.new_object.get('sims') is not None: - new_object_params['sims'] = self.new_object.get('sims') or \ - self.new_object.get('sims') if self.new_object.get('simFailover') is not None or self.new_object.get('sim_failover') is not None: new_object_params['simFailover'] = self.new_object.get('simFailover') or \ self.new_object.get('sim_failover') + if self.new_object.get('sims') is not None or self.new_object.get('sims') is not None: + new_object_params['sims'] = self.new_object.get('sims') or \ + self.new_object.get('sims') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -83,8 +83,8 @@ class DevicesCellularSims(object): params=self.get_all_params(name=name), ) if isinstance(items, dict): - if 'response' in items: - items = items.get('response') + if 'sims' in items: + items = items.get('sims') result = get_dict_result(items, 'name', name) if result is None: result = items @@ -124,8 +124,8 @@ class DevicesCellularSims(object): requested_obj = self.new_object obj_params = [ - ("sims", "sims"), ("simFailover", "simFailover"), + ("sims", "sims"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table.py new file mode 100644 index 000000000..3c80f50c5 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table.py @@ -0,0 +1,174 @@ +#!/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, + meraki_compare_equality, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present"]), + callback=dict(type="dict"), + serial=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["serial"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class DevicesLiveToolsArpTable(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + callback=params.get("callback"), + serial=params.get("serial"), + ) + + def create_params(self): + new_object_params = {} + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') or \ + self.new_object.get('serial') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name and get all + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("serial") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("callback", "callback"), + ("serial", "serial"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="devices", + function="createDeviceLiveToolsArpTable", + params=self.create_params(), + op_modifies=True, + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = DevicesLiveToolsArpTable(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = prev_obj + meraki.object_present_and_different() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table_info.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table_info.py new file mode 100644 index 000000000..8e972db51 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_arp_table_info.py @@ -0,0 +1,79 @@ +#!/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( +)) + +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 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) + + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test.py new file mode 100644 index 000000000..ec58e54fc --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test.py @@ -0,0 +1,180 @@ +#!/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, + meraki_compare_equality, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present"]), + callback=dict(type="dict"), + ports=dict(type="list"), + serial=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["serial"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class DevicesLiveToolsCableTest(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + callback=params.get("callback"), + ports=params.get("ports"), + serial=params.get("serial"), + ) + + def create_params(self): + new_object_params = {} + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') + if self.new_object.get('ports') is not None or self.new_object.get('ports') is not None: + new_object_params['ports'] = self.new_object.get('ports') or \ + self.new_object.get('ports') + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') or \ + self.new_object.get('serial') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name and get all + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("serial") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("callback", "callback"), + ("ports", "ports"), + ("serial", "serial"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="devices", + function="createDeviceLiveToolsCableTest", + params=self.create_params(), + op_modifies=True, + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = DevicesLiveToolsCableTest(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = prev_obj + meraki.object_present_and_different() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test_info.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test_info.py new file mode 100644 index 000000000..8e972db51 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_cable_test_info.py @@ -0,0 +1,79 @@ +#!/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( +)) + +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 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) + + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping.py index ba5ef2d67..bd91ad77e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping.py @@ -31,8 +31,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - target=dict(type="str"), + callback=dict(type="dict"), count=dict(type="int"), + target=dict(type="str"), serial=dict(type="str"), id=dict(type="str"), )) @@ -49,8 +50,9 @@ class DevicesLiveToolsPing(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - target=params.get("target"), + callback=params.get("callback"), count=params.get("count"), + target=params.get("target"), serial=params.get("serial"), id=params.get("id"), ) @@ -65,12 +67,15 @@ class DevicesLiveToolsPing(object): def create_params(self): new_object_params = {} - if self.new_object.get('target') is not None or self.new_object.get('target') is not None: - new_object_params['target'] = self.new_object.get('target') or \ - self.new_object.get('target') + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') if self.new_object.get('count') is not None or self.new_object.get('count') is not None: new_object_params['count'] = self.new_object.get('count') or \ self.new_object.get('count') + if self.new_object.get('target') is not None or self.new_object.get('target') is not None: + new_object_params['target'] = self.new_object.get('target') or \ + self.new_object.get('target') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -126,8 +131,9 @@ class DevicesLiveToolsPing(object): requested_obj = self.new_object obj_params = [ - ("target", "target"), + ("callback", "callback"), ("count", "count"), + ("target", "target"), ("serial", "serial"), ("id", "id"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping_device.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping_device.py index cb00a6c6b..4738511fb 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping_device.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_ping_device.py @@ -31,6 +31,7 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + callback=dict(type="dict"), count=dict(type="int"), serial=dict(type="str"), id=dict(type="str"), @@ -48,6 +49,7 @@ class DevicesLiveToolsPingDevice(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + callback=params.get("callback"), count=params.get("count"), serial=params.get("serial"), id=params.get("id"), @@ -63,6 +65,9 @@ class DevicesLiveToolsPingDevice(object): def create_params(self): new_object_params = {} + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') if self.new_object.get('count') is not None or self.new_object.get('count') is not None: new_object_params['count'] = self.new_object.get('count') or \ self.new_object.get('count') @@ -121,6 +126,7 @@ class DevicesLiveToolsPingDevice(object): requested_obj = self.new_object obj_params = [ + ("callback", "callback"), ("count", "count"), ("serial", "serial"), ("id", "id"), diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test.py new file mode 100644 index 000000000..50edfcffd --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test.py @@ -0,0 +1,174 @@ +#!/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, + meraki_compare_equality, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present"]), + callback=dict(type="dict"), + serial=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["serial"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class DevicesLiveToolsThroughputTest(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + callback=params.get("callback"), + serial=params.get("serial"), + ) + + def create_params(self): + new_object_params = {} + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') or \ + self.new_object.get('serial') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name and get all + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("serial") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("callback", "callback"), + ("serial", "serial"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="devices", + function="createDeviceLiveToolsThroughputTest", + params=self.create_params(), + op_modifies=True, + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = DevicesLiveToolsThroughputTest(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = prev_obj + meraki.object_present_and_different() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test_info.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test_info.py new file mode 100644 index 000000000..8e972db51 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_throughput_test_info.py @@ -0,0 +1,79 @@ +#!/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( +)) + +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 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) + + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan.py new file mode 100644 index 000000000..4fc6873e4 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan.py @@ -0,0 +1,186 @@ +#!/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, + meraki_compare_equality, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present"]), + callback=dict(type="dict"), + mac=dict(type="str"), + vlanId=dict(type="int"), + serial=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["serial"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class DevicesLiveToolsWakeOnLan(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + callback=params.get("callback"), + mac=params.get("mac"), + vlanId=params.get("vlanId"), + serial=params.get("serial"), + ) + + def create_params(self): + new_object_params = {} + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') + if self.new_object.get('mac') is not None or self.new_object.get('mac') is not None: + new_object_params['mac'] = self.new_object.get('mac') or \ + self.new_object.get('mac') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') + if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: + new_object_params['serial'] = self.new_object.get('serial') or \ + self.new_object.get('serial') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name and get all + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("serial") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("callback", "callback"), + ("mac", "mac"), + ("vlanId", "vlanId"), + ("serial", "serial"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="devices", + function="createDeviceLiveToolsWakeOnLan", + params=self.create_params(), + op_modifies=True, + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = DevicesLiveToolsWakeOnLan(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = prev_obj + meraki.object_present_and_different() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan_info.py b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan_info.py new file mode 100644 index 000000000..8e972db51 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_live_tools_wake_on_lan_info.py @@ -0,0 +1,79 @@ +#!/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( +)) + +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 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) + + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_sensor_relationships.py b/ansible_collections/cisco/meraki/plugins/action/devices_sensor_relationships.py index 75c20b830..b55f44b6e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_sensor_relationships.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_sensor_relationships.py @@ -78,8 +78,8 @@ class DevicesSensorRelationships(object): params=self.get_all_params(name=name), ) if isinstance(items, dict): - if 'response' in items: - items = items.get('response') + if 'livestream' in items: + items = items.get('livestream') result = get_dict_result(items, 'name', name) if result is None: result = items diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_switch_ports.py b/ansible_collections/cisco/meraki/plugins/action/devices_switch_ports.py index 659e6a4f8..44a238eb2 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_switch_ports.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_switch_ports.py @@ -32,31 +32,31 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - name=dict(type="str"), - tags=dict(type="list"), - enabled=dict(type="bool"), - poeEnabled=dict(type="bool"), - type=dict(type="str"), - vlan=dict(type="int"), - voiceVlan=dict(type="int"), + accessPolicyNumber=dict(type="int"), + accessPolicyType=dict(type="str"), + adaptivePolicyGroupId=dict(type="str"), allowedVlans=dict(type="str"), + daiTrusted=dict(type="bool"), + enabled=dict(type="bool"), + flexibleStackingEnabled=dict(type="bool"), isolationEnabled=dict(type="bool"), - rstpEnabled=dict(type="bool"), - stpGuard=dict(type="str"), linkNegotiation=dict(type="str"), - portScheduleId=dict(type="str"), - udld=dict(type="str"), - accessPolicyType=dict(type="str"), - accessPolicyNumber=dict(type="int"), macAllowList=dict(type="list"), + name=dict(type="str"), + peerSgtCapable=dict(type="bool"), + poeEnabled=dict(type="bool"), + portScheduleId=dict(type="str"), + profile=dict(type="dict"), + rstpEnabled=dict(type="bool"), stickyMacAllowList=dict(type="list"), stickyMacAllowListLimit=dict(type="int"), stormControlEnabled=dict(type="bool"), - adaptivePolicyGroupId=dict(type="str"), - peerSgtCapable=dict(type="bool"), - flexibleStackingEnabled=dict(type="bool"), - daiTrusted=dict(type="bool"), - profile=dict(type="dict"), + stpGuard=dict(type="str"), + tags=dict(type="list"), + type=dict(type="str"), + udld=dict(type="str"), + vlan=dict(type="int"), + voiceVlan=dict(type="int"), serial=dict(type="str"), portId=dict(type="str"), )) @@ -73,31 +73,31 @@ class DevicesSwitchPorts(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - tags=params.get("tags"), - enabled=params.get("enabled"), - poeEnabled=params.get("poeEnabled"), - type=params.get("type"), - vlan=params.get("vlan"), - voiceVlan=params.get("voiceVlan"), + accessPolicyNumber=params.get("accessPolicyNumber"), + accessPolicyType=params.get("accessPolicyType"), + adaptivePolicyGroupId=params.get("adaptivePolicyGroupId"), allowedVlans=params.get("allowedVlans"), + daiTrusted=params.get("daiTrusted"), + enabled=params.get("enabled"), + flexibleStackingEnabled=params.get("flexibleStackingEnabled"), isolationEnabled=params.get("isolationEnabled"), - rstpEnabled=params.get("rstpEnabled"), - stpGuard=params.get("stpGuard"), linkNegotiation=params.get("linkNegotiation"), - portScheduleId=params.get("portScheduleId"), - udld=params.get("udld"), - accessPolicyType=params.get("accessPolicyType"), - accessPolicyNumber=params.get("accessPolicyNumber"), macAllowList=params.get("macAllowList"), + name=params.get("name"), + peerSgtCapable=params.get("peerSgtCapable"), + poeEnabled=params.get("poeEnabled"), + portScheduleId=params.get("portScheduleId"), + profile=params.get("profile"), + rstpEnabled=params.get("rstpEnabled"), stickyMacAllowList=params.get("stickyMacAllowList"), stickyMacAllowListLimit=params.get("stickyMacAllowListLimit"), stormControlEnabled=params.get("stormControlEnabled"), - adaptivePolicyGroupId=params.get("adaptivePolicyGroupId"), - peerSgtCapable=params.get("peerSgtCapable"), - flexibleStackingEnabled=params.get("flexibleStackingEnabled"), - daiTrusted=params.get("daiTrusted"), - profile=params.get("profile"), + stpGuard=params.get("stpGuard"), + tags=params.get("tags"), + type=params.get("type"), + udld=params.get("udld"), + vlan=params.get("vlan"), + voiceVlan=params.get("voiceVlan"), serial=params.get("serial"), port_id=params.get("portId"), ) @@ -119,55 +119,47 @@ class DevicesSwitchPorts(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: - new_object_params['tags'] = self.new_object.get('tags') or \ - self.new_object.get('tags') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('poeEnabled') is not None or self.new_object.get('poe_enabled') is not None: - new_object_params['poeEnabled'] = self.new_object.get('poeEnabled') - if self.new_object.get('type') is not None or self.new_object.get('type') is not None: - new_object_params['type'] = self.new_object.get('type') or \ - self.new_object.get('type') - if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: - new_object_params['vlan'] = self.new_object.get('vlan') or \ - self.new_object.get('vlan') - if self.new_object.get('voiceVlan') is not None or self.new_object.get('voice_vlan') is not None: - new_object_params['voiceVlan'] = self.new_object.get('voiceVlan') or \ - self.new_object.get('voice_vlan') + if self.new_object.get('accessPolicyNumber') is not None or self.new_object.get('access_policy_number') is not None: + new_object_params['accessPolicyNumber'] = self.new_object.get('accessPolicyNumber') or \ + self.new_object.get('access_policy_number') + if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: + new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ + self.new_object.get('access_policy_type') + if self.new_object.get('adaptivePolicyGroupId') is not None or self.new_object.get('adaptive_policy_group_id') is not None: + new_object_params['adaptivePolicyGroupId'] = self.new_object.get('adaptivePolicyGroupId') or \ + self.new_object.get('adaptive_policy_group_id') if self.new_object.get('allowedVlans') is not None or self.new_object.get('allowed_vlans') is not None: new_object_params['allowedVlans'] = self.new_object.get('allowedVlans') or \ self.new_object.get('allowed_vlans') + if self.new_object.get('daiTrusted') is not None or self.new_object.get('dai_trusted') is not None: + new_object_params['daiTrusted'] = self.new_object.get('daiTrusted') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('flexibleStackingEnabled') is not None or self.new_object.get('flexible_stacking_enabled') is not None: + new_object_params['flexibleStackingEnabled'] = self.new_object.get('flexibleStackingEnabled') if self.new_object.get('isolationEnabled') is not None or self.new_object.get('isolation_enabled') is not None: - new_object_params['isolationEnabled'] = self.new_object.get( - 'isolationEnabled') - if self.new_object.get('rstpEnabled') is not None or self.new_object.get('rstp_enabled') is not None: - new_object_params['rstpEnabled'] = self.new_object.get( - 'rstpEnabled') - if self.new_object.get('stpGuard') is not None or self.new_object.get('stp_guard') is not None: - new_object_params['stpGuard'] = self.new_object.get('stpGuard') or \ - self.new_object.get('stp_guard') + new_object_params['isolationEnabled'] = self.new_object.get('isolationEnabled') if self.new_object.get('linkNegotiation') is not None or self.new_object.get('link_negotiation') is not None: new_object_params['linkNegotiation'] = self.new_object.get('linkNegotiation') or \ self.new_object.get('link_negotiation') - if self.new_object.get('portScheduleId') is not None or self.new_object.get('port_schedule_id') is not None: - new_object_params['portScheduleId'] = self.new_object.get('portScheduleId') or \ - self.new_object.get('port_schedule_id') - if self.new_object.get('udld') is not None or self.new_object.get('udld') is not None: - new_object_params['udld'] = self.new_object.get('udld') or \ - self.new_object.get('udld') - if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: - new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ - self.new_object.get('access_policy_type') - if self.new_object.get('accessPolicyNumber') is not None or self.new_object.get('access_policy_number') is not None: - new_object_params['accessPolicyNumber'] = self.new_object.get('accessPolicyNumber') or \ - self.new_object.get('access_policy_number') if self.new_object.get('macAllowList') is not None or self.new_object.get('mac_allow_list') is not None: new_object_params['macAllowList'] = self.new_object.get('macAllowList') or \ self.new_object.get('mac_allow_list') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('peerSgtCapable') is not None or self.new_object.get('peer_sgt_capable') is not None: + new_object_params['peerSgtCapable'] = self.new_object.get('peerSgtCapable') + if self.new_object.get('poeEnabled') is not None or self.new_object.get('poe_enabled') is not None: + new_object_params['poeEnabled'] = self.new_object.get('poeEnabled') + if self.new_object.get('portScheduleId') is not None or self.new_object.get('port_schedule_id') is not None: + new_object_params['portScheduleId'] = self.new_object.get('portScheduleId') or \ + self.new_object.get('port_schedule_id') + if self.new_object.get('profile') is not None or self.new_object.get('profile') is not None: + new_object_params['profile'] = self.new_object.get('profile') or \ + self.new_object.get('profile') + if self.new_object.get('rstpEnabled') is not None or self.new_object.get('rstp_enabled') is not None: + new_object_params['rstpEnabled'] = self.new_object.get('rstpEnabled') if self.new_object.get('stickyMacAllowList') is not None or self.new_object.get('sticky_mac_allow_list') is not None: new_object_params['stickyMacAllowList'] = self.new_object.get('stickyMacAllowList') or \ self.new_object.get('sticky_mac_allow_list') @@ -175,22 +167,25 @@ class DevicesSwitchPorts(object): new_object_params['stickyMacAllowListLimit'] = self.new_object.get('stickyMacAllowListLimit') or \ self.new_object.get('sticky_mac_allow_list_limit') if self.new_object.get('stormControlEnabled') is not None or self.new_object.get('storm_control_enabled') is not None: - new_object_params['stormControlEnabled'] = self.new_object.get( - 'stormControlEnabled') - if self.new_object.get('adaptivePolicyGroupId') is not None or self.new_object.get('adaptive_policy_group_id') is not None: - new_object_params['adaptivePolicyGroupId'] = self.new_object.get('adaptivePolicyGroupId') or \ - self.new_object.get('adaptive_policy_group_id') - if self.new_object.get('peerSgtCapable') is not None or self.new_object.get('peer_sgt_capable') is not None: - new_object_params['peerSgtCapable'] = self.new_object.get( - 'peerSgtCapable') - if self.new_object.get('flexibleStackingEnabled') is not None or self.new_object.get('flexible_stacking_enabled') is not None: - new_object_params['flexibleStackingEnabled'] = self.new_object.get( - 'flexibleStackingEnabled') - if self.new_object.get('daiTrusted') is not None or self.new_object.get('dai_trusted') is not None: - new_object_params['daiTrusted'] = self.new_object.get('daiTrusted') - if self.new_object.get('profile') is not None or self.new_object.get('profile') is not None: - new_object_params['profile'] = self.new_object.get('profile') or \ - self.new_object.get('profile') + new_object_params['stormControlEnabled'] = self.new_object.get('stormControlEnabled') + if self.new_object.get('stpGuard') is not None or self.new_object.get('stp_guard') is not None: + new_object_params['stpGuard'] = self.new_object.get('stpGuard') or \ + self.new_object.get('stp_guard') + if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: + new_object_params['tags'] = self.new_object.get('tags') or \ + self.new_object.get('tags') + if self.new_object.get('type') is not None or self.new_object.get('type') is not None: + new_object_params['type'] = self.new_object.get('type') or \ + self.new_object.get('type') + if self.new_object.get('udld') is not None or self.new_object.get('udld') is not None: + new_object_params['udld'] = self.new_object.get('udld') or \ + self.new_object.get('udld') + if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: + new_object_params['vlan'] = self.new_object.get('vlan') or \ + self.new_object.get('vlan') + if self.new_object.get('voiceVlan') is not None or self.new_object.get('voice_vlan') is not None: + new_object_params['voiceVlan'] = self.new_object.get('voiceVlan') or \ + self.new_object.get('voice_vlan') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -269,31 +264,31 @@ class DevicesSwitchPorts(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("tags", "tags"), - ("enabled", "enabled"), - ("poeEnabled", "poeEnabled"), - ("type", "type"), - ("vlan", "vlan"), - ("voiceVlan", "voiceVlan"), + ("accessPolicyNumber", "accessPolicyNumber"), + ("accessPolicyType", "accessPolicyType"), + ("adaptivePolicyGroupId", "adaptivePolicyGroupId"), ("allowedVlans", "allowedVlans"), + ("daiTrusted", "daiTrusted"), + ("enabled", "enabled"), + ("flexibleStackingEnabled", "flexibleStackingEnabled"), ("isolationEnabled", "isolationEnabled"), - ("rstpEnabled", "rstpEnabled"), - ("stpGuard", "stpGuard"), ("linkNegotiation", "linkNegotiation"), - ("portScheduleId", "portScheduleId"), - ("udld", "udld"), - ("accessPolicyType", "accessPolicyType"), - ("accessPolicyNumber", "accessPolicyNumber"), ("macAllowList", "macAllowList"), + ("name", "name"), + ("peerSgtCapable", "peerSgtCapable"), + ("poeEnabled", "poeEnabled"), + ("portScheduleId", "portScheduleId"), + ("profile", "profile"), + ("rstpEnabled", "rstpEnabled"), ("stickyMacAllowList", "stickyMacAllowList"), ("stickyMacAllowListLimit", "stickyMacAllowListLimit"), ("stormControlEnabled", "stormControlEnabled"), - ("adaptivePolicyGroupId", "adaptivePolicyGroupId"), - ("peerSgtCapable", "peerSgtCapable"), - ("flexibleStackingEnabled", "flexibleStackingEnabled"), - ("daiTrusted", "daiTrusted"), - ("profile", "profile"), + ("stpGuard", "stpGuard"), + ("tags", "tags"), + ("type", "type"), + ("udld", "udld"), + ("vlan", "vlan"), + ("voiceVlan", "voiceVlan"), ("serial", "serial"), ("portId", "portId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces.py b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces.py index 774366850..c013c4bb5 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces.py @@ -32,15 +32,15 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - subnet=dict(type="str"), + defaultGateway=dict(type="str"), interfaceIp=dict(type="str"), + ipv6=dict(type="dict"), multicastRouting=dict(type="str"), - vlanId=dict(type="int"), - defaultGateway=dict(type="str"), + name=dict(type="str"), ospfSettings=dict(type="dict"), ospfV3=dict(type="dict"), - ipv6=dict(type="dict"), + subnet=dict(type="str"), + vlanId=dict(type="int"), serial=dict(type="str"), interfaceId=dict(type="str"), )) @@ -58,15 +58,15 @@ class DevicesSwitchRoutingInterfaces(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - subnet=params.get("subnet"), + defaultGateway=params.get("defaultGateway"), interfaceIp=params.get("interfaceIp"), + ipv6=params.get("ipv6"), multicastRouting=params.get("multicastRouting"), - vlanId=params.get("vlanId"), - defaultGateway=params.get("defaultGateway"), + name=params.get("name"), ospfSettings=params.get("ospfSettings"), ospfV3=params.get("ospfV3"), - ipv6=params.get("ipv6"), + subnet=params.get("subnet"), + vlanId=params.get("vlanId"), serial=params.get("serial"), interfaceId=params.get("interfaceId"), ) @@ -88,33 +88,33 @@ class DevicesSwitchRoutingInterfaces(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') + if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: + new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ + self.new_object.get('default_gateway') if self.new_object.get('interfaceIp') is not None or self.new_object.get('interface_ip') is not None: new_object_params['interfaceIp'] = self.new_object.get('interfaceIp') or \ self.new_object.get('interface_ip') + if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: + new_object_params['ipv6'] = self.new_object.get('ipv6') or \ + self.new_object.get('ipv6') if self.new_object.get('multicastRouting') is not None or self.new_object.get('multicast_routing') is not None: new_object_params['multicastRouting'] = self.new_object.get('multicastRouting') or \ self.new_object.get('multicast_routing') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') - if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: - new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ - self.new_object.get('default_gateway') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('ospfSettings') is not None or self.new_object.get('ospf_settings') is not None: new_object_params['ospfSettings'] = self.new_object.get('ospfSettings') or \ self.new_object.get('ospf_settings') if self.new_object.get('ospfV3') is not None or self.new_object.get('ospf_v3') is not None: new_object_params['ospfV3'] = self.new_object.get('ospfV3') or \ self.new_object.get('ospf_v3') - if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: - new_object_params['ipv6'] = self.new_object.get('ipv6') or \ - self.new_object.get('ipv6') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -132,33 +132,33 @@ class DevicesSwitchRoutingInterfaces(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') + if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: + new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ + self.new_object.get('default_gateway') if self.new_object.get('interfaceIp') is not None or self.new_object.get('interface_ip') is not None: new_object_params['interfaceIp'] = self.new_object.get('interfaceIp') or \ self.new_object.get('interface_ip') + if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: + new_object_params['ipv6'] = self.new_object.get('ipv6') or \ + self.new_object.get('ipv6') if self.new_object.get('multicastRouting') is not None or self.new_object.get('multicast_routing') is not None: new_object_params['multicastRouting'] = self.new_object.get('multicastRouting') or \ self.new_object.get('multicast_routing') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') - if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: - new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ - self.new_object.get('default_gateway') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('ospfSettings') is not None or self.new_object.get('ospf_settings') is not None: new_object_params['ospfSettings'] = self.new_object.get('ospfSettings') or \ self.new_object.get('ospf_settings') if self.new_object.get('ospfV3') is not None or self.new_object.get('ospf_v3') is not None: new_object_params['ospfV3'] = self.new_object.get('ospfV3') or \ self.new_object.get('ospf_v3') - if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: - new_object_params['ipv6'] = self.new_object.get('ipv6') or \ - self.new_object.get('ipv6') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -236,15 +236,15 @@ class DevicesSwitchRoutingInterfaces(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("subnet", "subnet"), + ("defaultGateway", "defaultGateway"), ("interfaceIp", "interfaceIp"), + ("ipv6", "ipv6"), ("multicastRouting", "multicastRouting"), - ("vlanId", "vlanId"), - ("defaultGateway", "defaultGateway"), + ("name", "name"), ("ospfSettings", "ospfSettings"), ("ospfV3", "ospfV3"), - ("ipv6", "ipv6"), + ("subnet", "subnet"), + ("vlanId", "vlanId"), ("serial", "serial"), ("interfaceId", "interfaceId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces_dhcp.py b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces_dhcp.py index 4fdb74e4e..39063de9f 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces_dhcp.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_interfaces_dhcp.py @@ -32,17 +32,17 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + bootFileName=dict(type="str"), + bootNextServer=dict(type="str"), + bootOptionsEnabled=dict(type="bool"), + dhcpLeaseTime=dict(type="str"), dhcpMode=dict(type="str"), + dhcpOptions=dict(type="list"), dhcpRelayServerIps=dict(type="list"), - dhcpLeaseTime=dict(type="str"), - dnsNameserversOption=dict(type="str"), dnsCustomNameservers=dict(type="list"), - bootOptionsEnabled=dict(type="bool"), - bootNextServer=dict(type="str"), - bootFileName=dict(type="str"), - dhcpOptions=dict(type="list"), - reservedIpRanges=dict(type="list"), + dnsNameserversOption=dict(type="str"), fixedIpAssignments=dict(type="list"), + reservedIpRanges=dict(type="list"), serial=dict(type="str"), interfaceId=dict(type="str"), )) @@ -59,17 +59,17 @@ class DevicesSwitchRoutingInterfacesDhcp(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + bootFileName=params.get("bootFileName"), + bootNextServer=params.get("bootNextServer"), + bootOptionsEnabled=params.get("bootOptionsEnabled"), + dhcpLeaseTime=params.get("dhcpLeaseTime"), dhcpMode=params.get("dhcpMode"), + dhcpOptions=params.get("dhcpOptions"), dhcpRelayServerIps=params.get("dhcpRelayServerIps"), - dhcpLeaseTime=params.get("dhcpLeaseTime"), - dnsNameserversOption=params.get("dnsNameserversOption"), dnsCustomNameservers=params.get("dnsCustomNameservers"), - bootOptionsEnabled=params.get("bootOptionsEnabled"), - bootNextServer=params.get("bootNextServer"), - bootFileName=params.get("bootFileName"), - dhcpOptions=params.get("dhcpOptions"), - reservedIpRanges=params.get("reservedIpRanges"), + dnsNameserversOption=params.get("dnsNameserversOption"), fixedIpAssignments=params.get("fixedIpAssignments"), + reservedIpRanges=params.get("reservedIpRanges"), serial=params.get("serial"), interface_id=params.get("interfaceId"), ) @@ -85,38 +85,38 @@ class DevicesSwitchRoutingInterfacesDhcp(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('bootFileName') is not None or self.new_object.get('boot_file_name') is not None: + new_object_params['bootFileName'] = self.new_object.get('bootFileName') or \ + self.new_object.get('boot_file_name') + if self.new_object.get('bootNextServer') is not None or self.new_object.get('boot_next_server') is not None: + new_object_params['bootNextServer'] = self.new_object.get('bootNextServer') or \ + self.new_object.get('boot_next_server') + if self.new_object.get('bootOptionsEnabled') is not None or self.new_object.get('boot_options_enabled') is not None: + new_object_params['bootOptionsEnabled'] = self.new_object.get('bootOptionsEnabled') + if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: + new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ + self.new_object.get('dhcp_lease_time') if self.new_object.get('dhcpMode') is not None or self.new_object.get('dhcp_mode') is not None: new_object_params['dhcpMode'] = self.new_object.get('dhcpMode') or \ self.new_object.get('dhcp_mode') + if self.new_object.get('dhcpOptions') is not None or self.new_object.get('dhcp_options') is not None: + new_object_params['dhcpOptions'] = self.new_object.get('dhcpOptions') or \ + self.new_object.get('dhcp_options') if self.new_object.get('dhcpRelayServerIps') is not None or self.new_object.get('dhcp_relay_server_ips') is not None: new_object_params['dhcpRelayServerIps'] = self.new_object.get('dhcpRelayServerIps') or \ self.new_object.get('dhcp_relay_server_ips') - if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: - new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ - self.new_object.get('dhcp_lease_time') - if self.new_object.get('dnsNameserversOption') is not None or self.new_object.get('dns_nameservers_option') is not None: - new_object_params['dnsNameserversOption'] = self.new_object.get('dnsNameserversOption') or \ - self.new_object.get('dns_nameservers_option') if self.new_object.get('dnsCustomNameservers') is not None or self.new_object.get('dns_custom_nameservers') is not None: new_object_params['dnsCustomNameservers'] = self.new_object.get('dnsCustomNameservers') or \ self.new_object.get('dns_custom_nameservers') - if self.new_object.get('bootOptionsEnabled') is not None or self.new_object.get('boot_options_enabled') is not None: - new_object_params['bootOptionsEnabled'] = self.new_object.get('bootOptionsEnabled') - if self.new_object.get('bootNextServer') is not None or self.new_object.get('boot_next_server') is not None: - new_object_params['bootNextServer'] = self.new_object.get('bootNextServer') or \ - self.new_object.get('boot_next_server') - if self.new_object.get('bootFileName') is not None or self.new_object.get('boot_file_name') is not None: - new_object_params['bootFileName'] = self.new_object.get('bootFileName') or \ - self.new_object.get('boot_file_name') - if self.new_object.get('dhcpOptions') is not None or self.new_object.get('dhcp_options') is not None: - new_object_params['dhcpOptions'] = self.new_object.get('dhcpOptions') or \ - self.new_object.get('dhcp_options') - if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: - new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ - self.new_object.get('reserved_ip_ranges') + if self.new_object.get('dnsNameserversOption') is not None or self.new_object.get('dns_nameservers_option') is not None: + new_object_params['dnsNameserversOption'] = self.new_object.get('dnsNameserversOption') or \ + self.new_object.get('dns_nameservers_option') if self.new_object.get('fixedIpAssignments') is not None or self.new_object.get('fixed_ip_assignments') is not None: new_object_params['fixedIpAssignments'] = self.new_object.get('fixedIpAssignments') or \ self.new_object.get('fixed_ip_assignments') + if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: + new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ + self.new_object.get('reserved_ip_ranges') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -176,17 +176,17 @@ class DevicesSwitchRoutingInterfacesDhcp(object): requested_obj = self.new_object obj_params = [ + ("bootFileName", "bootFileName"), + ("bootNextServer", "bootNextServer"), + ("bootOptionsEnabled", "bootOptionsEnabled"), + ("dhcpLeaseTime", "dhcpLeaseTime"), ("dhcpMode", "dhcpMode"), + ("dhcpOptions", "dhcpOptions"), ("dhcpRelayServerIps", "dhcpRelayServerIps"), - ("dhcpLeaseTime", "dhcpLeaseTime"), - ("dnsNameserversOption", "dnsNameserversOption"), ("dnsCustomNameservers", "dnsCustomNameservers"), - ("bootOptionsEnabled", "bootOptionsEnabled"), - ("bootNextServer", "bootNextServer"), - ("bootFileName", "bootFileName"), - ("dhcpOptions", "dhcpOptions"), - ("reservedIpRanges", "reservedIpRanges"), + ("dnsNameserversOption", "dnsNameserversOption"), ("fixedIpAssignments", "fixedIpAssignments"), + ("reservedIpRanges", "reservedIpRanges"), ("serial", "serial"), ("interfaceId", "interfaceId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_static_routes.py b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_static_routes.py index e24a6e721..f146b8447 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_static_routes.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_switch_routing_static_routes.py @@ -32,11 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + advertiseViaOspfEnabled=dict(type="bool"), name=dict(type="str"), - subnet=dict(type="str"), nextHopIp=dict(type="str"), - advertiseViaOspfEnabled=dict(type="bool"), preferOverOspfRoutesEnabled=dict(type="bool"), + subnet=dict(type="str"), serial=dict(type="str"), staticRouteId=dict(type="str"), )) @@ -54,11 +54,11 @@ class DevicesSwitchRoutingStaticRoutes(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + advertiseViaOspfEnabled=params.get("advertiseViaOspfEnabled"), name=params.get("name"), - subnet=params.get("subnet"), nextHopIp=params.get("nextHopIp"), - advertiseViaOspfEnabled=params.get("advertiseViaOspfEnabled"), preferOverOspfRoutesEnabled=params.get("preferOverOspfRoutesEnabled"), + subnet=params.get("subnet"), serial=params.get("serial"), staticRouteId=params.get("staticRouteId"), ) @@ -80,19 +80,19 @@ class DevicesSwitchRoutingStaticRoutes(object): def create_params(self): new_object_params = {} + if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: + new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('nextHopIp') is not None or self.new_object.get('next_hop_ip') is not None: new_object_params['nextHopIp'] = self.new_object.get('nextHopIp') or \ self.new_object.get('next_hop_ip') - if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: - new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('preferOverOspfRoutesEnabled') is not None or self.new_object.get('prefer_over_ospf_routes_enabled') is not None: new_object_params['preferOverOspfRoutesEnabled'] = self.new_object.get('preferOverOspfRoutesEnabled') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -110,19 +110,19 @@ class DevicesSwitchRoutingStaticRoutes(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: + new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('nextHopIp') is not None or self.new_object.get('next_hop_ip') is not None: new_object_params['nextHopIp'] = self.new_object.get('nextHopIp') or \ self.new_object.get('next_hop_ip') - if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: - new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('preferOverOspfRoutesEnabled') is not None or self.new_object.get('prefer_over_ospf_routes_enabled') is not None: new_object_params['preferOverOspfRoutesEnabled'] = self.new_object.get('preferOverOspfRoutesEnabled') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -200,11 +200,11 @@ class DevicesSwitchRoutingStaticRoutes(object): requested_obj = self.new_object obj_params = [ + ("advertiseViaOspfEnabled", "advertiseViaOspfEnabled"), ("name", "name"), - ("subnet", "subnet"), ("nextHopIp", "nextHopIp"), - ("advertiseViaOspfEnabled", "advertiseViaOspfEnabled"), ("preferOverOspfRoutesEnabled", "preferOverOspfRoutesEnabled"), + ("subnet", "subnet"), ("serial", "serial"), ("staticRouteId", "staticRouteId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_wireless_alternate_management_interface_ipv6.py b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_alternate_management_interface_ipv6.py new file mode 100644 index 000000000..41447bb98 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_alternate_management_interface_ipv6.py @@ -0,0 +1,89 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + addresses=dict(type="list"), + serial=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 = False + 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 = dict( + addresses=params.get("addresses"), + serial=params.get("serial"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="wireless", + function='updateDeviceWirelessAlternateManagementInterfaceIpv6', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_wireless_bluetooth_settings.py b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_bluetooth_settings.py index dd3712df6..f1f41d07c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_wireless_bluetooth_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_bluetooth_settings.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - uuid=dict(type="str"), major=dict(type="int"), minor=dict(type="int"), + uuid=dict(type="str"), serial=dict(type="str"), )) @@ -50,9 +50,9 @@ class DevicesWirelessBluetoothSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - uuid=params.get("uuid"), major=params.get("major"), minor=params.get("minor"), + uuid=params.get("uuid"), serial=params.get("serial"), ) @@ -64,15 +64,15 @@ class DevicesWirelessBluetoothSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('uuid') is not None or self.new_object.get('uuid') is not None: - new_object_params['uuid'] = self.new_object.get('uuid') or \ - self.new_object.get('uuid') if self.new_object.get('major') is not None or self.new_object.get('major') is not None: new_object_params['major'] = self.new_object.get('major') or \ self.new_object.get('major') if self.new_object.get('minor') is not None or self.new_object.get('minor') is not None: new_object_params['minor'] = self.new_object.get('minor') or \ self.new_object.get('minor') + if self.new_object.get('uuid') is not None or self.new_object.get('uuid') is not None: + new_object_params['uuid'] = self.new_object.get('uuid') or \ + self.new_object.get('uuid') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -129,9 +129,9 @@ class DevicesWirelessBluetoothSettings(object): requested_obj = self.new_object obj_params = [ - ("uuid", "uuid"), ("major", "major"), ("minor", "minor"), + ("uuid", "uuid"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/devices_wireless_radio_settings.py b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_radio_settings.py index 72dad3f48..2fc35da7b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/devices_wireless_radio_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/devices_wireless_radio_settings.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + fiveGhzSettings=dict(type="dict"), rfProfileId=dict(type="str"), twoFourGhzSettings=dict(type="dict"), - fiveGhzSettings=dict(type="dict"), serial=dict(type="str"), )) @@ -50,9 +50,9 @@ class DevicesWirelessRadioSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + fiveGhzSettings=params.get("fiveGhzSettings"), rfProfileId=params.get("rfProfileId"), twoFourGhzSettings=params.get("twoFourGhzSettings"), - fiveGhzSettings=params.get("fiveGhzSettings"), serial=params.get("serial"), ) @@ -64,15 +64,15 @@ class DevicesWirelessRadioSettings(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: + new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ + self.new_object.get('five_ghz_settings') if self.new_object.get('rfProfileId') is not None or self.new_object.get('rf_profile_id') is not None: new_object_params['rfProfileId'] = self.new_object.get('rfProfileId') or \ self.new_object.get('rf_profile_id') if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ self.new_object.get('two_four_ghz_settings') - if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: - new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ - self.new_object.get('five_ghz_settings') if self.new_object.get('serial') is not None or self.new_object.get('serial') is not None: new_object_params['serial'] = self.new_object.get('serial') or \ self.new_object.get('serial') @@ -129,9 +129,9 @@ class DevicesWirelessRadioSettings(object): requested_obj = self.new_object obj_params = [ + ("fiveGhzSettings", "fiveGhzSettings"), ("rfProfileId", "rfProfileId"), ("twoFourGhzSettings", "twoFourGhzSettings"), - ("fiveGhzSettings", "fiveGhzSettings"), ("serial", "serial"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks.py b/ansible_collections/cisco/meraki/plugins/action/networks.py index 378b0bc0d..17904b9f8 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks.py @@ -32,12 +32,12 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + copyFromNetworkId=dict(type="str"), name=dict(type="str"), + notes=dict(type="str"), productTypes=dict(type="list"), tags=dict(type="list"), timeZone=dict(type="str"), - copyFromNetworkId=dict(type="str"), - notes=dict(type="str"), organizationId=dict(type="str"), networkId=dict(type="str"), enrollmentString=dict(type="str"), @@ -56,12 +56,12 @@ class Networks(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + copyFromNetworkId=params.get("copyFromNetworkId"), name=params.get("name"), + notes=params.get("notes"), productTypes=params.get("productTypes"), tags=params.get("tags"), timeZone=params.get("timeZone"), - copyFromNetworkId=params.get("copyFromNetworkId"), - notes=params.get("notes"), organizationId=params.get("organizationId"), networkId=params.get("networkId"), enrollmentString=params.get("enrollmentString"), @@ -104,9 +104,15 @@ class Networks(object): def create_params(self): new_object_params = {} + if self.new_object.get('copyFromNetworkId') is not None or self.new_object.get('copy_from_network_id') is not None: + new_object_params['copyFromNetworkId'] = self.new_object.get('copyFromNetworkId') or \ + self.new_object.get('copy_from_network_id') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') + if self.new_object.get('notes') is not None or self.new_object.get('notes') is not None: + new_object_params['notes'] = self.new_object.get('notes') or \ + self.new_object.get('notes') if self.new_object.get('productTypes') is not None or self.new_object.get('product_types') is not None: new_object_params['productTypes'] = self.new_object.get('productTypes') or \ self.new_object.get('product_types') @@ -116,12 +122,6 @@ class Networks(object): if self.new_object.get('timeZone') is not None or self.new_object.get('time_zone') is not None: new_object_params['timeZone'] = self.new_object.get('timeZone') or \ self.new_object.get('time_zone') - if self.new_object.get('copyFromNetworkId') is not None or self.new_object.get('copy_from_network_id') is not None: - new_object_params['copyFromNetworkId'] = self.new_object.get('copyFromNetworkId') or \ - self.new_object.get('copy_from_network_id') - if self.new_object.get('notes') is not None or self.new_object.get('notes') is not None: - new_object_params['notes'] = self.new_object.get('notes') or \ - self.new_object.get('notes') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -136,24 +136,21 @@ class Networks(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('timeZone') is not None or self.new_object.get('time_zone') is not None: - new_object_params['timeZone'] = self.new_object.get('timeZone') or \ - self.new_object.get('time_zone') - if self.new_object.get('productTypes') is not None or self.new_object.get('product_types') is not None: - new_object_params['productTypes'] = self.new_object.get('productTypes') or \ - self.new_object.get('product_types') - if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: - new_object_params['tags'] = self.new_object.get('tags') or \ - self.new_object.get('tags') if self.new_object.get('enrollmentString') is not None or self.new_object.get('enrollment_string') is not None: new_object_params['enrollmentString'] = self.new_object.get('enrollmentString') or \ self.new_object.get('enrollment_string') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('notes') is not None or self.new_object.get('notes') is not None: new_object_params['notes'] = self.new_object.get('notes') or \ self.new_object.get('notes') + if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: + new_object_params['tags'] = self.new_object.get('tags') or \ + self.new_object.get('tags') + if self.new_object.get('timeZone') is not None or self.new_object.get('time_zone') is not None: + new_object_params['timeZone'] = self.new_object.get('timeZone') or \ + self.new_object.get('time_zone') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -228,12 +225,12 @@ class Networks(object): requested_obj = self.new_object obj_params = [ + ("copyFromNetworkId", "copyFromNetworkId"), ("name", "name"), + ("notes", "notes"), ("productTypes", "productTypes"), ("tags", "tags"), ("timeZone", "timeZone"), - ("copyFromNetworkId", "copyFromNetworkId"), - ("notes", "notes"), ("organizationId", "organizationId"), ("networkId", "networkId"), ("enrollmentString", "enrollmentString"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_alerts_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_alerts_settings.py index 9389b5db1..6d0da8e32 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_alerts_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_alerts_settings.py @@ -32,8 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - defaultDestinations=dict(type="dict"), alerts=dict(type="list"), + defaultDestinations=dict(type="dict"), + muting=dict(type="dict"), networkId=dict(type="str"), )) @@ -49,8 +50,9 @@ class NetworksAlertsSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - defaultDestinations=params.get("defaultDestinations"), alerts=params.get("alerts"), + defaultDestinations=params.get("defaultDestinations"), + muting=params.get("muting"), network_id=params.get("networkId"), ) @@ -63,12 +65,15 @@ class NetworksAlertsSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('defaultDestinations') is not None or self.new_object.get('default_destinations') is not None: - new_object_params['defaultDestinations'] = self.new_object.get('defaultDestinations') or \ - self.new_object.get('default_destinations') if self.new_object.get('alerts') is not None or self.new_object.get('alerts') is not None: new_object_params['alerts'] = self.new_object.get('alerts') or \ self.new_object.get('alerts') + if self.new_object.get('defaultDestinations') is not None or self.new_object.get('default_destinations') is not None: + new_object_params['defaultDestinations'] = self.new_object.get('defaultDestinations') or \ + self.new_object.get('default_destinations') + if self.new_object.get('muting') is not None or self.new_object.get('muting') is not None: + new_object_params['muting'] = self.new_object.get('muting') or \ + self.new_object.get('muting') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -125,8 +130,9 @@ class NetworksAlertsSettings(object): requested_obj = self.new_object obj_params = [ - ("defaultDestinations", "defaultDestinations"), ("alerts", "alerts"), + ("defaultDestinations", "defaultDestinations"), + ("muting", "muting"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_content_filtering.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_content_filtering.py index 5cad13ae6..3f1144ee3 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_content_filtering.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_content_filtering.py @@ -33,8 +33,8 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), allowedUrlPatterns=dict(type="list"), - blockedUrlPatterns=dict(type="list"), blockedUrlCategories=dict(type="list"), + blockedUrlPatterns=dict(type="list"), urlCategoryListSize=dict(type="str"), networkId=dict(type="str"), )) @@ -52,8 +52,8 @@ class NetworksApplianceContentFiltering(object): self.meraki = meraki self.new_object = dict( allowedUrlPatterns=params.get("allowedUrlPatterns"), - blockedUrlPatterns=params.get("blockedUrlPatterns"), blockedUrlCategories=params.get("blockedUrlCategories"), + blockedUrlPatterns=params.get("blockedUrlPatterns"), urlCategoryListSize=params.get("urlCategoryListSize"), network_id=params.get("networkId"), ) @@ -70,12 +70,12 @@ class NetworksApplianceContentFiltering(object): if self.new_object.get('allowedUrlPatterns') is not None or self.new_object.get('allowed_url_patterns') is not None: new_object_params['allowedUrlPatterns'] = self.new_object.get('allowedUrlPatterns') or \ self.new_object.get('allowed_url_patterns') - if self.new_object.get('blockedUrlPatterns') is not None or self.new_object.get('blocked_url_patterns') is not None: - new_object_params['blockedUrlPatterns'] = self.new_object.get('blockedUrlPatterns') or \ - self.new_object.get('blocked_url_patterns') if self.new_object.get('blockedUrlCategories') is not None or self.new_object.get('blocked_url_categories') is not None: new_object_params['blockedUrlCategories'] = self.new_object.get('blockedUrlCategories') or \ self.new_object.get('blocked_url_categories') + if self.new_object.get('blockedUrlPatterns') is not None or self.new_object.get('blocked_url_patterns') is not None: + new_object_params['blockedUrlPatterns'] = self.new_object.get('blockedUrlPatterns') or \ + self.new_object.get('blocked_url_patterns') if self.new_object.get('urlCategoryListSize') is not None or self.new_object.get('url_category_list_size') is not None: new_object_params['urlCategoryListSize'] = self.new_object.get('urlCategoryListSize') or \ self.new_object.get('url_category_list_size') @@ -136,8 +136,8 @@ class NetworksApplianceContentFiltering(object): obj_params = [ ("allowedUrlPatterns", "allowedUrlPatterns"), - ("blockedUrlPatterns", "blockedUrlPatterns"), ("blockedUrlCategories", "blockedUrlCategories"), + ("blockedUrlPatterns", "blockedUrlPatterns"), ("urlCategoryListSize", "urlCategoryListSize"), ("networkId", "networkId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ports.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ports.py index 1c57e3fb3..c6a4ddbfb 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ports.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ports.py @@ -32,12 +32,12 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enabled=dict(type="bool"), + accessPolicy=dict(type="str"), + allowedVlans=dict(type="str"), dropUntaggedTraffic=dict(type="bool"), + enabled=dict(type="bool"), type=dict(type="str"), vlan=dict(type="int"), - allowedVlans=dict(type="str"), - accessPolicy=dict(type="str"), networkId=dict(type="str"), portId=dict(type="str"), )) @@ -54,12 +54,12 @@ class NetworksAppliancePorts(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enabled=params.get("enabled"), + accessPolicy=params.get("accessPolicy"), + allowedVlans=params.get("allowedVlans"), dropUntaggedTraffic=params.get("dropUntaggedTraffic"), + enabled=params.get("enabled"), type=params.get("type"), vlan=params.get("vlan"), - allowedVlans=params.get("allowedVlans"), - accessPolicy=params.get("accessPolicy"), network_id=params.get("networkId"), port_id=params.get("portId"), ) @@ -83,22 +83,22 @@ class NetworksAppliancePorts(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('accessPolicy') is not None or self.new_object.get('access_policy') is not None: + new_object_params['accessPolicy'] = self.new_object.get('accessPolicy') or \ + self.new_object.get('access_policy') + if self.new_object.get('allowedVlans') is not None or self.new_object.get('allowed_vlans') is not None: + new_object_params['allowedVlans'] = self.new_object.get('allowedVlans') or \ + self.new_object.get('allowed_vlans') if self.new_object.get('dropUntaggedTraffic') is not None or self.new_object.get('drop_untagged_traffic') is not None: new_object_params['dropUntaggedTraffic'] = self.new_object.get('dropUntaggedTraffic') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('type') is not None or self.new_object.get('type') is not None: new_object_params['type'] = self.new_object.get('type') or \ self.new_object.get('type') if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: new_object_params['vlan'] = self.new_object.get('vlan') or \ self.new_object.get('vlan') - if self.new_object.get('allowedVlans') is not None or self.new_object.get('allowed_vlans') is not None: - new_object_params['allowedVlans'] = self.new_object.get('allowedVlans') or \ - self.new_object.get('allowed_vlans') - if self.new_object.get('accessPolicy') is not None or self.new_object.get('access_policy') is not None: - new_object_params['accessPolicy'] = self.new_object.get('accessPolicy') or \ - self.new_object.get('access_policy') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -176,12 +176,12 @@ class NetworksAppliancePorts(object): requested_obj = self.new_object obj_params = [ - ("enabled", "enabled"), + ("accessPolicy", "accessPolicy"), + ("allowedVlans", "allowedVlans"), ("dropUntaggedTraffic", "dropUntaggedTraffic"), + ("enabled", "enabled"), ("type", "type"), ("vlan", "vlan"), - ("allowedVlans", "allowedVlans"), - ("accessPolicy", "accessPolicy"), ("networkId", "networkId"), ("portId", "portId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_prefixes_delegated_statics.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_prefixes_delegated_statics.py index 0297ff01e..f0fdfec7c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_prefixes_delegated_statics.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_prefixes_delegated_statics.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - prefix=dict(type="str"), - origin=dict(type="dict"), description=dict(type="str"), + origin=dict(type="dict"), + prefix=dict(type="str"), networkId=dict(type="str"), staticDelegatedPrefixId=dict(type="str"), )) @@ -52,9 +52,9 @@ class NetworksAppliancePrefixesDelegatedStatics(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - prefix=params.get("prefix"), - origin=params.get("origin"), description=params.get("description"), + origin=params.get("origin"), + prefix=params.get("prefix"), networkId=params.get("networkId"), staticDelegatedPrefixId=params.get("staticDelegatedPrefixId"), ) @@ -78,15 +78,15 @@ class NetworksAppliancePrefixesDelegatedStatics(object): def create_params(self): new_object_params = {} - if self.new_object.get('prefix') is not None or self.new_object.get('prefix') is not None: - new_object_params['prefix'] = self.new_object.get('prefix') or \ - self.new_object.get('prefix') - if self.new_object.get('origin') is not None or self.new_object.get('origin') is not None: - new_object_params['origin'] = self.new_object.get('origin') or \ - self.new_object.get('origin') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('origin') is not None or self.new_object.get('origin') is not None: + new_object_params['origin'] = self.new_object.get('origin') or \ + self.new_object.get('origin') + if self.new_object.get('prefix') is not None or self.new_object.get('prefix') is not None: + new_object_params['prefix'] = self.new_object.get('prefix') or \ + self.new_object.get('prefix') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -104,15 +104,15 @@ class NetworksAppliancePrefixesDelegatedStatics(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('prefix') is not None or self.new_object.get('prefix') is not None: - new_object_params['prefix'] = self.new_object.get('prefix') or \ - self.new_object.get('prefix') - if self.new_object.get('origin') is not None or self.new_object.get('origin') is not None: - new_object_params['origin'] = self.new_object.get('origin') or \ - self.new_object.get('origin') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('origin') is not None or self.new_object.get('origin') is not None: + new_object_params['origin'] = self.new_object.get('origin') or \ + self.new_object.get('origin') + if self.new_object.get('prefix') is not None or self.new_object.get('prefix') is not None: + new_object_params['prefix'] = self.new_object.get('prefix') or \ + self.new_object.get('prefix') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -190,9 +190,9 @@ class NetworksAppliancePrefixesDelegatedStatics(object): requested_obj = self.new_object obj_params = [ - ("prefix", "prefix"), - ("origin", "origin"), ("description", "description"), + ("origin", "origin"), + ("prefix", "prefix"), ("networkId", "networkId"), ("staticDelegatedPrefixId", "staticDelegatedPrefixId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles.py new file mode 100644 index 000000000..88a31b2d1 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles.py @@ -0,0 +1,252 @@ +#!/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, + meraki_compare_equality, + get_dict_result, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present", "absent"]), + fiveGhzSettings=dict(type="dict"), + name=dict(type="str"), + perSsidSettings=dict(type="dict"), + twoFourGhzSettings=dict(type="dict"), + networkId=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["name", "networkId"], True), + ("state", "absent", ["name", "networkId"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class NetworksApplianceRfProfiles(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + fiveGhzSettings=params.get("fiveGhzSettings"), + name=params.get("name"), + perSsidSettings=params.get("perSsidSettings"), + twoFourGhzSettings=params.get("twoFourGhzSettings"), + networkId=params.get("networkId"), + ) + + def get_all_params(self, name=None, id=None): + new_object_params = {} + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + return new_object_params + + def create_params(self): + new_object_params = {} + if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: + new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ + self.new_object.get('five_ghz_settings') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('perSsidSettings') is not None or self.new_object.get('per_ssid_settings') is not None: + new_object_params['perSsidSettings'] = self.new_object.get('perSsidSettings') or \ + self.new_object.get('per_ssid_settings') + if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: + new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ + self.new_object.get('two_four_ghz_settings') + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name method or it is in another action + try: + items = self.meraki.exec_meraki( + family="appliance", + function="getNetworkApplianceRfProfiles", + params=self.get_all_params(name=name), + ) + if isinstance(items, dict): + if 'assigned' in items: + items = items.get('assigned') + result = get_dict_result(items, 'name', name) + if result is None: + result = items + except Exception as e: + print("Error: ", e) + result = None + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + try: + items = self.meraki.exec_meraki( + family="appliance", + function="getNetworkApplianceRfProfiles", + params=self.get_all_params(id=id), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'id', id) + except Exception as e: + print("Error: ", e) + result = None + return result + + def exists(self): + id_exists = False + name_exists = False + prev_obj = None + o_id = self.new_object.get("id") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_id(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("fiveGhzSettings", "fiveGhzSettings"), + ("name", "name"), + ("perSsidSettings", "perSsidSettings"), + ("twoFourGhzSettings", "twoFourGhzSettings"), + ("networkId", "networkId"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="appliance", + function="createNetworkApplianceRfProfile", + params=self.create_params(), + op_modifies=True, + ) + return result + + def update(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have update method. What do we do? + return result + + def delete(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have delete method. What do we do? + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = NetworksApplianceRfProfiles(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + elif state == "absent": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + response = obj.delete() + meraki.object_deleted() + else: + meraki.object_already_absent() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles_info.py new file mode 100644 index 000000000..863571233 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_rf_profiles_info.py @@ -0,0 +1,90 @@ +#!/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"), +)) + +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_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) + + response = meraki.exec_meraki( + family="appliance", + function='getNetworkApplianceRfProfiles', + 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/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_intrusion.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_intrusion.py index 3449abf9c..6da952d48 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_intrusion.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_intrusion.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - mode=dict(type="str"), idsRulesets=dict(type="str"), + mode=dict(type="str"), protectedNetworks=dict(type="dict"), networkId=dict(type="str"), )) @@ -50,8 +50,8 @@ class NetworksApplianceSecurityIntrusion(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - mode=params.get("mode"), idsRulesets=params.get("idsRulesets"), + mode=params.get("mode"), protectedNetworks=params.get("protectedNetworks"), network_id=params.get("networkId"), ) @@ -65,12 +65,12 @@ class NetworksApplianceSecurityIntrusion(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: - new_object_params['mode'] = self.new_object.get('mode') or \ - self.new_object.get('mode') if self.new_object.get('idsRulesets') is not None or self.new_object.get('ids_rulesets') is not None: new_object_params['idsRulesets'] = self.new_object.get('idsRulesets') or \ self.new_object.get('ids_rulesets') + if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: + new_object_params['mode'] = self.new_object.get('mode') or \ + self.new_object.get('mode') if self.new_object.get('protectedNetworks') is not None or self.new_object.get('protected_networks') is not None: new_object_params['protectedNetworks'] = self.new_object.get('protectedNetworks') or \ self.new_object.get('protected_networks') @@ -130,8 +130,8 @@ class NetworksApplianceSecurityIntrusion(object): requested_obj = self.new_object obj_params = [ - ("mode", "mode"), ("idsRulesets", "idsRulesets"), + ("mode", "mode"), ("protectedNetworks", "protectedNetworks"), ("networkId", "networkId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_malware.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_malware.py index 904889494..faef0ed12 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_malware.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_security_malware.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - mode=dict(type="str"), - allowedUrls=dict(type="list"), allowedFiles=dict(type="list"), + allowedUrls=dict(type="list"), + mode=dict(type="str"), networkId=dict(type="str"), )) @@ -50,9 +50,9 @@ class NetworksApplianceSecurityMalware(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - mode=params.get("mode"), - allowedUrls=params.get("allowedUrls"), allowedFiles=params.get("allowedFiles"), + allowedUrls=params.get("allowedUrls"), + mode=params.get("mode"), network_id=params.get("networkId"), ) @@ -65,15 +65,15 @@ class NetworksApplianceSecurityMalware(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: - new_object_params['mode'] = self.new_object.get('mode') or \ - self.new_object.get('mode') - if self.new_object.get('allowedUrls') is not None or self.new_object.get('allowed_urls') is not None: - new_object_params['allowedUrls'] = self.new_object.get('allowedUrls') or \ - self.new_object.get('allowed_urls') if self.new_object.get('allowedFiles') is not None or self.new_object.get('allowed_files') is not None: new_object_params['allowedFiles'] = self.new_object.get('allowedFiles') or \ self.new_object.get('allowed_files') + if self.new_object.get('allowedUrls') is not None or self.new_object.get('allowed_urls') is not None: + new_object_params['allowedUrls'] = self.new_object.get('allowedUrls') or \ + self.new_object.get('allowed_urls') + if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: + new_object_params['mode'] = self.new_object.get('mode') or \ + self.new_object.get('mode') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -130,9 +130,9 @@ class NetworksApplianceSecurityMalware(object): requested_obj = self.new_object obj_params = [ - ("mode", "mode"), - ("allowedUrls", "allowedUrls"), ("allowedFiles", "allowedFiles"), + ("allowedUrls", "allowedUrls"), + ("mode", "mode"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_single_lan.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_single_lan.py index fd8219403..4254f631f 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_single_lan.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_single_lan.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - subnet=dict(type="str"), applianceIp=dict(type="str"), ipv6=dict(type="dict"), mandatoryDhcp=dict(type="dict"), + subnet=dict(type="str"), networkId=dict(type="str"), )) @@ -51,10 +51,10 @@ class NetworksApplianceSingleLan(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - subnet=params.get("subnet"), applianceIp=params.get("applianceIp"), ipv6=params.get("ipv6"), mandatoryDhcp=params.get("mandatoryDhcp"), + subnet=params.get("subnet"), network_id=params.get("networkId"), ) @@ -67,9 +67,6 @@ class NetworksApplianceSingleLan(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('applianceIp') is not None or self.new_object.get('appliance_ip') is not None: new_object_params['applianceIp'] = self.new_object.get('applianceIp') or \ self.new_object.get('appliance_ip') @@ -79,6 +76,9 @@ class NetworksApplianceSingleLan(object): if self.new_object.get('mandatoryDhcp') is not None or self.new_object.get('mandatory_dhcp') is not None: new_object_params['mandatoryDhcp'] = self.new_object.get('mandatoryDhcp') or \ self.new_object.get('mandatory_dhcp') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -135,10 +135,10 @@ class NetworksApplianceSingleLan(object): requested_obj = self.new_object obj_params = [ - ("subnet", "subnet"), ("applianceIp", "applianceIp"), ("ipv6", "ipv6"), ("mandatoryDhcp", "mandatoryDhcp"), + ("subnet", "subnet"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ssids.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ssids.py index cfe172d5a..364855692 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ssids.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_ssids.py @@ -32,16 +32,17 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - name=dict(type="str"), - enabled=dict(type="bool"), - defaultVlanId=dict(type="int"), authMode=dict(type="str"), + defaultVlanId=dict(type="int"), + dhcpEnforcedDeauthentication=dict(type="dict"), + dot11w=dict(type="dict"), + enabled=dict(type="bool"), + encryptionMode=dict(type="str"), + name=dict(type="str"), psk=dict(type="str"), radiusServers=dict(type="list"), - encryptionMode=dict(type="str"), - wpaEncryptionMode=dict(type="str"), visible=dict(type="bool"), - dhcpEnforcedDeauthentication=dict(type="dict"), + wpaEncryptionMode=dict(type="str"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -58,16 +59,17 @@ class NetworksApplianceSsids(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - enabled=params.get("enabled"), - defaultVlanId=params.get("defaultVlanId"), authMode=params.get("authMode"), + defaultVlanId=params.get("defaultVlanId"), + dhcpEnforcedDeauthentication=params.get("dhcpEnforcedDeauthentication"), + dot11w=params.get("dot11w"), + enabled=params.get("enabled"), + encryptionMode=params.get("encryptionMode"), + name=params.get("name"), psk=params.get("psk"), radiusServers=params.get("radiusServers"), - encryptionMode=params.get("encryptionMode"), - wpaEncryptionMode=params.get("wpaEncryptionMode"), visible=params.get("visible"), - dhcpEnforcedDeauthentication=params.get("dhcpEnforcedDeauthentication"), + wpaEncryptionMode=params.get("wpaEncryptionMode"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -90,34 +92,37 @@ class NetworksApplianceSsids(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('defaultVlanId') is not None or self.new_object.get('default_vlan_id') is not None: - new_object_params['defaultVlanId'] = self.new_object.get('defaultVlanId') or \ - self.new_object.get('default_vlan_id') if self.new_object.get('authMode') is not None or self.new_object.get('auth_mode') is not None: new_object_params['authMode'] = self.new_object.get('authMode') or \ self.new_object.get('auth_mode') + if self.new_object.get('defaultVlanId') is not None or self.new_object.get('default_vlan_id') is not None: + new_object_params['defaultVlanId'] = self.new_object.get('defaultVlanId') or \ + self.new_object.get('default_vlan_id') + if self.new_object.get('dhcpEnforcedDeauthentication') is not None or self.new_object.get('dhcp_enforced_deauthentication') is not None: + new_object_params['dhcpEnforcedDeauthentication'] = self.new_object.get('dhcpEnforcedDeauthentication') or \ + self.new_object.get('dhcp_enforced_deauthentication') + if self.new_object.get('dot11w') is not None or self.new_object.get('dot11w') is not None: + new_object_params['dot11w'] = self.new_object.get('dot11w') or \ + self.new_object.get('dot11w') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('encryptionMode') is not None or self.new_object.get('encryption_mode') is not None: + new_object_params['encryptionMode'] = self.new_object.get('encryptionMode') or \ + self.new_object.get('encryption_mode') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('psk') is not None or self.new_object.get('psk') is not None: new_object_params['psk'] = self.new_object.get('psk') or \ self.new_object.get('psk') if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ self.new_object.get('radius_servers') - if self.new_object.get('encryptionMode') is not None or self.new_object.get('encryption_mode') is not None: - new_object_params['encryptionMode'] = self.new_object.get('encryptionMode') or \ - self.new_object.get('encryption_mode') + if self.new_object.get('visible') is not None or self.new_object.get('visible') is not None: + new_object_params['visible'] = self.new_object.get('visible') if self.new_object.get('wpaEncryptionMode') is not None or self.new_object.get('wpa_encryption_mode') is not None: new_object_params['wpaEncryptionMode'] = self.new_object.get('wpaEncryptionMode') or \ self.new_object.get('wpa_encryption_mode') - if self.new_object.get('visible') is not None or self.new_object.get('visible') is not None: - new_object_params['visible'] = self.new_object.get('visible') - if self.new_object.get('dhcpEnforcedDeauthentication') is not None or self.new_object.get('dhcp_enforced_deauthentication') is not None: - new_object_params['dhcpEnforcedDeauthentication'] = self.new_object.get('dhcpEnforcedDeauthentication') or \ - self.new_object.get('dhcp_enforced_deauthentication') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -195,16 +200,17 @@ class NetworksApplianceSsids(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("enabled", "enabled"), - ("defaultVlanId", "defaultVlanId"), ("authMode", "authMode"), + ("defaultVlanId", "defaultVlanId"), + ("dhcpEnforcedDeauthentication", "dhcpEnforcedDeauthentication"), + ("dot11w", "dot11w"), + ("enabled", "enabled"), + ("encryptionMode", "encryptionMode"), + ("name", "name"), ("psk", "psk"), ("radiusServers", "radiusServers"), - ("encryptionMode", "encryptionMode"), - ("wpaEncryptionMode", "wpaEncryptionMode"), ("visible", "visible"), - ("dhcpEnforcedDeauthentication", "dhcpEnforcedDeauthentication"), + ("wpaEncryptionMode", "wpaEncryptionMode"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes.py index 4331bc9b2..dd072c4c8 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_custom_performance_classes.py @@ -25,10 +25,10 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - name=dict(type="str"), - maxLatency=dict(type="int"), maxJitter=dict(type="int"), + maxLatency=dict(type="int"), maxLossPercentage=dict(type="int"), + name=dict(type="str"), networkId=dict(type="str"), )) @@ -68,10 +68,10 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - name=params.get("name"), - maxLatency=params.get("maxLatency"), maxJitter=params.get("maxJitter"), + maxLatency=params.get("maxLatency"), maxLossPercentage=params.get("maxLossPercentage"), + name=params.get("name"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_uplink_selection.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_uplink_selection.py index 79b737a1e..525ba5f77 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_uplink_selection.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_uplink_selection.py @@ -34,10 +34,10 @@ argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), activeActiveAutoVpnEnabled=dict(type="bool"), defaultUplink=dict(type="str"), - loadBalancingEnabled=dict(type="bool"), failoverAndFailback=dict(type="dict"), - wanTrafficUplinkPreferences=dict(type="list"), + loadBalancingEnabled=dict(type="bool"), vpnTrafficUplinkPreferences=dict(type="list"), + wanTrafficUplinkPreferences=dict(type="list"), networkId=dict(type="str"), )) @@ -55,10 +55,10 @@ class NetworksApplianceTrafficShapingUplinkSelection(object): self.new_object = dict( activeActiveAutoVpnEnabled=params.get("activeActiveAutoVpnEnabled"), defaultUplink=params.get("defaultUplink"), - loadBalancingEnabled=params.get("loadBalancingEnabled"), failoverAndFailback=params.get("failoverAndFailback"), - wanTrafficUplinkPreferences=params.get("wanTrafficUplinkPreferences"), + loadBalancingEnabled=params.get("loadBalancingEnabled"), vpnTrafficUplinkPreferences=params.get("vpnTrafficUplinkPreferences"), + wanTrafficUplinkPreferences=params.get("wanTrafficUplinkPreferences"), network_id=params.get("networkId"), ) @@ -76,17 +76,17 @@ class NetworksApplianceTrafficShapingUplinkSelection(object): if self.new_object.get('defaultUplink') is not None or self.new_object.get('default_uplink') is not None: new_object_params['defaultUplink'] = self.new_object.get('defaultUplink') or \ self.new_object.get('default_uplink') - if self.new_object.get('loadBalancingEnabled') is not None or self.new_object.get('load_balancing_enabled') is not None: - new_object_params['loadBalancingEnabled'] = self.new_object.get('loadBalancingEnabled') if self.new_object.get('failoverAndFailback') is not None or self.new_object.get('failover_and_failback') is not None: new_object_params['failoverAndFailback'] = self.new_object.get('failoverAndFailback') or \ self.new_object.get('failover_and_failback') - if self.new_object.get('wanTrafficUplinkPreferences') is not None or self.new_object.get('wan_traffic_uplink_preferences') is not None: - new_object_params['wanTrafficUplinkPreferences'] = self.new_object.get('wanTrafficUplinkPreferences') or \ - self.new_object.get('wan_traffic_uplink_preferences') + if self.new_object.get('loadBalancingEnabled') is not None or self.new_object.get('load_balancing_enabled') is not None: + new_object_params['loadBalancingEnabled'] = self.new_object.get('loadBalancingEnabled') if self.new_object.get('vpnTrafficUplinkPreferences') is not None or self.new_object.get('vpn_traffic_uplink_preferences') is not None: new_object_params['vpnTrafficUplinkPreferences'] = self.new_object.get('vpnTrafficUplinkPreferences') or \ self.new_object.get('vpn_traffic_uplink_preferences') + if self.new_object.get('wanTrafficUplinkPreferences') is not None or self.new_object.get('wan_traffic_uplink_preferences') is not None: + new_object_params['wanTrafficUplinkPreferences'] = self.new_object.get('wanTrafficUplinkPreferences') or \ + self.new_object.get('wan_traffic_uplink_preferences') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -145,10 +145,10 @@ class NetworksApplianceTrafficShapingUplinkSelection(object): obj_params = [ ("activeActiveAutoVpnEnabled", "activeActiveAutoVpnEnabled"), ("defaultUplink", "defaultUplink"), - ("loadBalancingEnabled", "loadBalancingEnabled"), ("failoverAndFailback", "failoverAndFailback"), - ("wanTrafficUplinkPreferences", "wanTrafficUplinkPreferences"), + ("loadBalancingEnabled", "loadBalancingEnabled"), ("vpnTrafficUplinkPreferences", "vpnTrafficUplinkPreferences"), + ("wanTrafficUplinkPreferences", "wanTrafficUplinkPreferences"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_vpn_exclusions.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_vpn_exclusions.py new file mode 100644 index 000000000..447231a08 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_traffic_shaping_vpn_exclusions.py @@ -0,0 +1,91 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + custom=dict(type="list"), + majorApplications=dict(type="list"), + networkId=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 = False + 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 = dict( + custom=params.get("custom"), + majorApplications=params.get("majorApplications"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="appliance", + function='updateNetworkApplianceTrafficShapingVpnExclusions', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vlans.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vlans.py index ba4835a9d..48ebdb4ca 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vlans.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vlans.py @@ -32,29 +32,29 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - id=dict(type="str"), - name=dict(type="str"), - subnet=dict(type="str"), applianceIp=dict(type="str"), - groupPolicyId=dict(type="str"), - templateVlanType=dict(type="str"), cidr=dict(type="str"), - mask=dict(type="int"), + groupPolicyId=dict(type="str"), + id=dict(type="str"), ipv6=dict(type="dict"), mandatoryDhcp=dict(type="dict"), + mask=dict(type="int"), + name=dict(type="str"), + subnet=dict(type="str"), + templateVlanType=dict(type="str"), networkId=dict(type="str"), vlanId=dict(type="str"), - vpnNatSubnet=dict(type="str"), + dhcpBootFilename=dict(type="str"), + dhcpBootNextServer=dict(type="str"), + dhcpBootOptionsEnabled=dict(type="bool"), dhcpHandling=dict(type="str"), - dhcpRelayServerIps=dict(type="list"), dhcpLeaseTime=dict(type="str"), - dhcpBootOptionsEnabled=dict(type="bool"), - dhcpBootNextServer=dict(type="str"), - dhcpBootFilename=dict(type="str"), + dhcpOptions=dict(type="list"), + dhcpRelayServerIps=dict(type="list"), + dnsNameservers=dict(type="str"), fixedIpAssignments=dict(type="dict"), reservedIpRanges=dict(type="list"), - dnsNameservers=dict(type="str"), - dhcpOptions=dict(type="list"), + vpnNatSubnet=dict(type="str"), )) required_if = [ @@ -70,29 +70,29 @@ class NetworksApplianceVlans(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - id=params.get("id"), - name=params.get("name"), - subnet=params.get("subnet"), applianceIp=params.get("applianceIp"), - groupPolicyId=params.get("groupPolicyId"), - templateVlanType=params.get("templateVlanType"), cidr=params.get("cidr"), - mask=params.get("mask"), + groupPolicyId=params.get("groupPolicyId"), + id=params.get("id"), ipv6=params.get("ipv6"), mandatoryDhcp=params.get("mandatoryDhcp"), + mask=params.get("mask"), + name=params.get("name"), + subnet=params.get("subnet"), + templateVlanType=params.get("templateVlanType"), networkId=params.get("networkId"), vlanId=params.get("vlanId"), - vpnNatSubnet=params.get("vpnNatSubnet"), + dhcpBootFilename=params.get("dhcpBootFilename"), + dhcpBootNextServer=params.get("dhcpBootNextServer"), + dhcpBootOptionsEnabled=params.get("dhcpBootOptionsEnabled"), dhcpHandling=params.get("dhcpHandling"), - dhcpRelayServerIps=params.get("dhcpRelayServerIps"), dhcpLeaseTime=params.get("dhcpLeaseTime"), - dhcpBootOptionsEnabled=params.get("dhcpBootOptionsEnabled"), - dhcpBootNextServer=params.get("dhcpBootNextServer"), - dhcpBootFilename=params.get("dhcpBootFilename"), + dhcpOptions=params.get("dhcpOptions"), + dhcpRelayServerIps=params.get("dhcpRelayServerIps"), + dnsNameservers=params.get("dnsNameservers"), fixedIpAssignments=params.get("fixedIpAssignments"), reservedIpRanges=params.get("reservedIpRanges"), - dnsNameservers=params.get("dnsNameservers"), - dhcpOptions=params.get("dhcpOptions"), + vpnNatSubnet=params.get("vpnNatSubnet"), ) def get_all_params(self, name=None, id=None): @@ -107,43 +107,43 @@ class NetworksApplianceVlans(object): if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None or self.new_object.get('id') is not None: + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') or self.new_object.get('id') + self.new_object.get('vlan_id') return new_object_params def create_params(self): new_object_params = {} - if self.new_object.get('id') is not None or self.new_object.get('id') is not None: - new_object_params['id'] = self.new_object.get('id') or \ - self.new_object.get('id') - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('applianceIp') is not None or self.new_object.get('appliance_ip') is not None: new_object_params['applianceIp'] = self.new_object.get('applianceIp') or \ self.new_object.get('appliance_ip') - if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: - new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ - self.new_object.get('group_policy_id') - if self.new_object.get('templateVlanType') is not None or self.new_object.get('template_vlan_type') is not None: - new_object_params['templateVlanType'] = self.new_object.get('templateVlanType') or \ - self.new_object.get('template_vlan_type') if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: new_object_params['cidr'] = self.new_object.get('cidr') or \ self.new_object.get('cidr') - if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: - new_object_params['mask'] = self.new_object.get('mask') or \ - self.new_object.get('mask') + if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: + new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ + self.new_object.get('group_policy_id') + if self.new_object.get('id') is not None or self.new_object.get('id') is not None: + new_object_params['id'] = self.new_object.get('id') or \ + self.new_object.get('id') if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: new_object_params['ipv6'] = self.new_object.get('ipv6') or \ self.new_object.get('ipv6') if self.new_object.get('mandatoryDhcp') is not None or self.new_object.get('mandatory_dhcp') is not None: new_object_params['mandatoryDhcp'] = self.new_object.get('mandatoryDhcp') or \ self.new_object.get('mandatory_dhcp') + if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: + new_object_params['mask'] = self.new_object.get('mask') or \ + self.new_object.get('mask') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('templateVlanType') is not None or self.new_object.get('template_vlan_type') is not None: + new_object_params['templateVlanType'] = self.new_object.get('templateVlanType') or \ + self.new_object.get('template_vlan_type') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -154,79 +154,78 @@ class NetworksApplianceVlans(object): if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None is not None or self.new_object.get('id') is not None: + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') or self.new_object.get('id') + self.new_object.get('vlan_id') return new_object_params def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('applianceIp') is not None or self.new_object.get('appliance_ip') is not None: new_object_params['applianceIp'] = self.new_object.get('applianceIp') or \ self.new_object.get('appliance_ip') - if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: - new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ - self.new_object.get('group_policy_id') - if self.new_object.get('vpnNatSubnet') is not None or self.new_object.get('vpn_nat_subnet') is not None: - new_object_params['vpnNatSubnet'] = self.new_object.get('vpnNatSubnet') or \ - self.new_object.get('vpn_nat_subnet') + if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: + new_object_params['cidr'] = self.new_object.get('cidr') or \ + self.new_object.get('cidr') + if self.new_object.get('dhcpBootFilename') is not None or self.new_object.get('dhcp_boot_filename') is not None: + new_object_params['dhcpBootFilename'] = self.new_object.get('dhcpBootFilename') or \ + self.new_object.get('dhcp_boot_filename') + if self.new_object.get('dhcpBootNextServer') is not None or self.new_object.get('dhcp_boot_next_server') is not None: + new_object_params['dhcpBootNextServer'] = self.new_object.get('dhcpBootNextServer') or \ + self.new_object.get('dhcp_boot_next_server') + if self.new_object.get('dhcpBootOptionsEnabled') is not None or self.new_object.get('dhcp_boot_options_enabled') is not None: + new_object_params['dhcpBootOptionsEnabled'] = self.new_object.get('dhcpBootOptionsEnabled') if self.new_object.get('dhcpHandling') is not None or self.new_object.get('dhcp_handling') is not None: new_object_params['dhcpHandling'] = self.new_object.get('dhcpHandling') or \ self.new_object.get('dhcp_handling') - if self.new_object.get('dhcpRelayServerIps') is not None or self.new_object.get('dhcp_relay_server_ips') is not None: - new_object_params['dhcpRelayServerIps'] = self.new_object.get('dhcpRelayServerIps') or \ - self.new_object.get('dhcp_relay_server_ips') if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ self.new_object.get('dhcp_lease_time') - if self.new_object.get('dhcpBootOptionsEnabled') is not None or self.new_object.get('dhcp_boot_options_enabled') is not None: - new_object_params['dhcpBootOptionsEnabled'] = self.new_object.get( - 'dhcpBootOptionsEnabled') - if self.new_object.get('dhcpBootNextServer') is not None or self.new_object.get('dhcp_boot_next_server') is not None: - new_object_params['dhcpBootNextServer'] = self.new_object.get('dhcpBootNextServer') or \ - self.new_object.get('dhcp_boot_next_server') - if self.new_object.get('dhcpBootFilename') is not None or self.new_object.get('dhcp_boot_filename') is not None: - new_object_params['dhcpBootFilename'] = self.new_object.get('dhcpBootFilename') or \ - self.new_object.get('dhcp_boot_filename') - if self.new_object.get('fixedIpAssignments') is not None or self.new_object.get('fixed_ip_assignments') is not None: - new_object_params['fixedIpAssignments'] = self.new_object.get('fixedIpAssignments') or \ - self.new_object.get('fixed_ip_assignments') - if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: - new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ - self.new_object.get('reserved_ip_ranges') - if self.new_object.get('dnsNameservers') is not None or self.new_object.get('dns_nameservers') is not None: - new_object_params['dnsNameservers'] = self.new_object.get('dnsNameservers') or \ - self.new_object.get('dns_nameservers') if self.new_object.get('dhcpOptions') is not None or self.new_object.get('dhcp_options') is not None: new_object_params['dhcpOptions'] = self.new_object.get('dhcpOptions') or \ self.new_object.get('dhcp_options') - if self.new_object.get('templateVlanType') is not None or self.new_object.get('template_vlan_type') is not None: - new_object_params['templateVlanType'] = self.new_object.get('templateVlanType') or \ - self.new_object.get('template_vlan_type') - if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: - new_object_params['cidr'] = self.new_object.get('cidr') or \ - self.new_object.get('cidr') - if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: - new_object_params['mask'] = self.new_object.get('mask') or \ - self.new_object.get('mask') + if self.new_object.get('dhcpRelayServerIps') is not None or self.new_object.get('dhcp_relay_server_ips') is not None: + new_object_params['dhcpRelayServerIps'] = self.new_object.get('dhcpRelayServerIps') or \ + self.new_object.get('dhcp_relay_server_ips') + if self.new_object.get('dnsNameservers') is not None or self.new_object.get('dns_nameservers') is not None: + new_object_params['dnsNameservers'] = self.new_object.get('dnsNameservers') or \ + self.new_object.get('dns_nameservers') + if self.new_object.get('fixedIpAssignments') is not None or self.new_object.get('fixed_ip_assignments') is not None: + new_object_params['fixedIpAssignments'] = self.new_object.get('fixedIpAssignments') or \ + self.new_object.get('fixed_ip_assignments') + if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: + new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ + self.new_object.get('group_policy_id') if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: new_object_params['ipv6'] = self.new_object.get('ipv6') or \ self.new_object.get('ipv6') if self.new_object.get('mandatoryDhcp') is not None or self.new_object.get('mandatory_dhcp') is not None: new_object_params['mandatoryDhcp'] = self.new_object.get('mandatoryDhcp') or \ self.new_object.get('mandatory_dhcp') + if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: + new_object_params['mask'] = self.new_object.get('mask') or \ + self.new_object.get('mask') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: + new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ + self.new_object.get('reserved_ip_ranges') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('templateVlanType') is not None or self.new_object.get('template_vlan_type') is not None: + new_object_params['templateVlanType'] = self.new_object.get('templateVlanType') or \ + self.new_object.get('template_vlan_type') + if self.new_object.get('vpnNatSubnet') is not None or self.new_object.get('vpn_nat_subnet') is not None: + new_object_params['vpnNatSubnet'] = self.new_object.get('vpnNatSubnet') or \ + self.new_object.get('vpn_nat_subnet') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None is not None or self.new_object.get('id') is not None: + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') or self.new_object.get('id') + self.new_object.get('vlan_id') return new_object_params def get_object_by_name(self, name): @@ -298,29 +297,29 @@ class NetworksApplianceVlans(object): requested_obj = self.new_object obj_params = [ - ("id", "id"), - ("name", "name"), - ("subnet", "subnet"), ("applianceIp", "applianceIp"), - ("groupPolicyId", "groupPolicyId"), - ("templateVlanType", "templateVlanType"), ("cidr", "cidr"), - ("mask", "mask"), + ("groupPolicyId", "groupPolicyId"), + ("id", "id"), ("ipv6", "ipv6"), ("mandatoryDhcp", "mandatoryDhcp"), + ("mask", "mask"), + ("name", "name"), + ("subnet", "subnet"), + ("templateVlanType", "templateVlanType"), ("networkId", "networkId"), ("vlanId", "vlanId"), - ("vpnNatSubnet", "vpnNatSubnet"), + ("dhcpBootFilename", "dhcpBootFilename"), + ("dhcpBootNextServer", "dhcpBootNextServer"), + ("dhcpBootOptionsEnabled", "dhcpBootOptionsEnabled"), ("dhcpHandling", "dhcpHandling"), - ("dhcpRelayServerIps", "dhcpRelayServerIps"), ("dhcpLeaseTime", "dhcpLeaseTime"), - ("dhcpBootOptionsEnabled", "dhcpBootOptionsEnabled"), - ("dhcpBootNextServer", "dhcpBootNextServer"), - ("dhcpBootFilename", "dhcpBootFilename"), + ("dhcpOptions", "dhcpOptions"), + ("dhcpRelayServerIps", "dhcpRelayServerIps"), + ("dnsNameservers", "dnsNameservers"), ("fixedIpAssignments", "fixedIpAssignments"), ("reservedIpRanges", "reservedIpRanges"), - ("dnsNameservers", "dnsNameservers"), - ("dhcpOptions", "dhcpOptions"), + ("vpnNatSubnet", "vpnNatSubnet"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params # If any does not have eq params, it requires update diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_bgp.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_bgp.py index e3eba8000..956e2bf59 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_bgp.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_bgp.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enabled=dict(type="bool"), asNumber=dict(type="int"), + enabled=dict(type="bool"), ibgpHoldTimer=dict(type="int"), neighbors=dict(type="list"), networkId=dict(type="str"), @@ -51,8 +51,8 @@ class NetworksApplianceVpnBgp(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enabled=params.get("enabled"), asNumber=params.get("asNumber"), + enabled=params.get("enabled"), ibgpHoldTimer=params.get("ibgpHoldTimer"), neighbors=params.get("neighbors"), network_id=params.get("networkId"), @@ -67,11 +67,11 @@ class NetworksApplianceVpnBgp(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('asNumber') is not None or self.new_object.get('as_number') is not None: new_object_params['asNumber'] = self.new_object.get('asNumber') or \ self.new_object.get('as_number') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('ibgpHoldTimer') is not None or self.new_object.get('ibgp_hold_timer') is not None: new_object_params['ibgpHoldTimer'] = self.new_object.get('ibgpHoldTimer') or \ self.new_object.get('ibgp_hold_timer') @@ -134,8 +134,8 @@ class NetworksApplianceVpnBgp(object): requested_obj = self.new_object obj_params = [ - ("enabled", "enabled"), ("asNumber", "asNumber"), + ("enabled", "enabled"), ("ibgpHoldTimer", "ibgpHoldTimer"), ("neighbors", "neighbors"), ("networkId", "networkId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_site_to_site_vpn.py b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_site_to_site_vpn.py index 1a73bb08d..e687d1ed4 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_site_to_site_vpn.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_appliance_vpn_site_to_site_vpn.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - mode=dict(type="str"), hubs=dict(type="list"), + mode=dict(type="str"), subnets=dict(type="list"), networkId=dict(type="str"), )) @@ -50,8 +50,8 @@ class NetworksApplianceVpnSiteToSiteVpn(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - mode=params.get("mode"), hubs=params.get("hubs"), + mode=params.get("mode"), subnets=params.get("subnets"), network_id=params.get("networkId"), ) @@ -65,12 +65,12 @@ class NetworksApplianceVpnSiteToSiteVpn(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: - new_object_params['mode'] = self.new_object.get('mode') or \ - self.new_object.get('mode') if self.new_object.get('hubs') is not None or self.new_object.get('hubs') is not None: new_object_params['hubs'] = self.new_object.get('hubs') or \ self.new_object.get('hubs') + if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: + new_object_params['mode'] = self.new_object.get('mode') or \ + self.new_object.get('mode') if self.new_object.get('subnets') is not None or self.new_object.get('subnets') is not None: new_object_params['subnets'] = self.new_object.get('subnets') or \ self.new_object.get('subnets') @@ -130,8 +130,8 @@ class NetworksApplianceVpnSiteToSiteVpn(object): requested_obj = self.new_object obj_params = [ - ("mode", "mode"), ("hubs", "hubs"), + ("mode", "mode"), ("subnets", "subnets"), ("networkId", "networkId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_bind.py b/ansible_collections/cisco/meraki/plugins/action/networks_bind.py index 2e65eefb3..e25f56335 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_bind.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_bind.py @@ -25,8 +25,8 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - configTemplateId=dict(type="str"), autoBind=dict(type="bool"), + configTemplateId=dict(type="str"), networkId=dict(type="str"), )) @@ -66,8 +66,8 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - configTemplateId=params.get("configTemplateId"), autoBind=params.get("autoBind"), + configTemplateId=params.get("configTemplateId"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_camera_quality_retention_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_camera_quality_retention_profiles.py index 29e1aae17..4b33683b8 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_camera_quality_retention_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_camera_quality_retention_profiles.py @@ -32,14 +32,14 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - motionBasedRetentionEnabled=dict(type="bool"), - restrictedBandwidthModeEnabled=dict(type="bool"), audioRecordingEnabled=dict(type="bool"), cloudArchiveEnabled=dict(type="bool"), + maxRetentionDays=dict(type="int"), + motionBasedRetentionEnabled=dict(type="bool"), motionDetectorVersion=dict(type="int"), + name=dict(type="str"), + restrictedBandwidthModeEnabled=dict(type="bool"), scheduleId=dict(type="str"), - maxRetentionDays=dict(type="int"), videoSettings=dict(type="dict"), networkId=dict(type="str"), qualityRetentionProfileId=dict(type="str"), @@ -58,14 +58,14 @@ class NetworksCameraQualityRetentionProfiles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - motionBasedRetentionEnabled=params.get("motionBasedRetentionEnabled"), - restrictedBandwidthModeEnabled=params.get("restrictedBandwidthModeEnabled"), audioRecordingEnabled=params.get("audioRecordingEnabled"), cloudArchiveEnabled=params.get("cloudArchiveEnabled"), + maxRetentionDays=params.get("maxRetentionDays"), + motionBasedRetentionEnabled=params.get("motionBasedRetentionEnabled"), motionDetectorVersion=params.get("motionDetectorVersion"), + name=params.get("name"), + restrictedBandwidthModeEnabled=params.get("restrictedBandwidthModeEnabled"), scheduleId=params.get("scheduleId"), - maxRetentionDays=params.get("maxRetentionDays"), videoSettings=params.get("videoSettings"), networkId=params.get("networkId"), qualityRetentionProfileId=params.get("qualityRetentionProfileId"), @@ -90,26 +90,26 @@ class NetworksCameraQualityRetentionProfiles(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: - new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') - if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: - new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('audioRecordingEnabled') is not None or self.new_object.get('audio_recording_enabled') is not None: new_object_params['audioRecordingEnabled'] = self.new_object.get('audioRecordingEnabled') if self.new_object.get('cloudArchiveEnabled') is not None or self.new_object.get('cloud_archive_enabled') is not None: new_object_params['cloudArchiveEnabled'] = self.new_object.get('cloudArchiveEnabled') + if self.new_object.get('maxRetentionDays') is not None or self.new_object.get('max_retention_days') is not None: + new_object_params['maxRetentionDays'] = self.new_object.get('maxRetentionDays') or \ + self.new_object.get('max_retention_days') + if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: + new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') if self.new_object.get('motionDetectorVersion') is not None or self.new_object.get('motion_detector_version') is not None: new_object_params['motionDetectorVersion'] = self.new_object.get('motionDetectorVersion') or \ self.new_object.get('motion_detector_version') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: + new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('scheduleId') is not None or self.new_object.get('schedule_id') is not None: new_object_params['scheduleId'] = self.new_object.get('scheduleId') or \ self.new_object.get('schedule_id') - if self.new_object.get('maxRetentionDays') is not None or self.new_object.get('max_retention_days') is not None: - new_object_params['maxRetentionDays'] = self.new_object.get('maxRetentionDays') or \ - self.new_object.get('max_retention_days') if self.new_object.get('videoSettings') is not None or self.new_object.get('video_settings') is not None: new_object_params['videoSettings'] = self.new_object.get('videoSettings') or \ self.new_object.get('video_settings') @@ -130,26 +130,26 @@ class NetworksCameraQualityRetentionProfiles(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: - new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') - if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: - new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('audioRecordingEnabled') is not None or self.new_object.get('audio_recording_enabled') is not None: new_object_params['audioRecordingEnabled'] = self.new_object.get('audioRecordingEnabled') if self.new_object.get('cloudArchiveEnabled') is not None or self.new_object.get('cloud_archive_enabled') is not None: new_object_params['cloudArchiveEnabled'] = self.new_object.get('cloudArchiveEnabled') + if self.new_object.get('maxRetentionDays') is not None or self.new_object.get('max_retention_days') is not None: + new_object_params['maxRetentionDays'] = self.new_object.get('maxRetentionDays') or \ + self.new_object.get('max_retention_days') + if self.new_object.get('motionBasedRetentionEnabled') is not None or self.new_object.get('motion_based_retention_enabled') is not None: + new_object_params['motionBasedRetentionEnabled'] = self.new_object.get('motionBasedRetentionEnabled') if self.new_object.get('motionDetectorVersion') is not None or self.new_object.get('motion_detector_version') is not None: new_object_params['motionDetectorVersion'] = self.new_object.get('motionDetectorVersion') or \ self.new_object.get('motion_detector_version') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('restrictedBandwidthModeEnabled') is not None or self.new_object.get('restricted_bandwidth_mode_enabled') is not None: + new_object_params['restrictedBandwidthModeEnabled'] = self.new_object.get('restrictedBandwidthModeEnabled') if self.new_object.get('scheduleId') is not None or self.new_object.get('schedule_id') is not None: new_object_params['scheduleId'] = self.new_object.get('scheduleId') or \ self.new_object.get('schedule_id') - if self.new_object.get('maxRetentionDays') is not None or self.new_object.get('max_retention_days') is not None: - new_object_params['maxRetentionDays'] = self.new_object.get('maxRetentionDays') or \ - self.new_object.get('max_retention_days') if self.new_object.get('videoSettings') is not None or self.new_object.get('video_settings') is not None: new_object_params['videoSettings'] = self.new_object.get('videoSettings') or \ self.new_object.get('video_settings') @@ -230,14 +230,14 @@ class NetworksCameraQualityRetentionProfiles(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("motionBasedRetentionEnabled", "motionBasedRetentionEnabled"), - ("restrictedBandwidthModeEnabled", "restrictedBandwidthModeEnabled"), ("audioRecordingEnabled", "audioRecordingEnabled"), ("cloudArchiveEnabled", "cloudArchiveEnabled"), + ("maxRetentionDays", "maxRetentionDays"), + ("motionBasedRetentionEnabled", "motionBasedRetentionEnabled"), ("motionDetectorVersion", "motionDetectorVersion"), + ("name", "name"), + ("restrictedBandwidthModeEnabled", "restrictedBandwidthModeEnabled"), ("scheduleId", "scheduleId"), - ("maxRetentionDays", "maxRetentionDays"), ("videoSettings", "videoSettings"), ("networkId", "networkId"), ("qualityRetentionProfileId", "qualityRetentionProfileId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_camera_wireless_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_camera_wireless_profiles.py index 4aedf37c2..4525ab771 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_camera_wireless_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_camera_wireless_profiles.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + identity=dict(type="dict"), name=dict(type="str"), ssid=dict(type="dict"), - identity=dict(type="dict"), networkId=dict(type="str"), wirelessProfileId=dict(type="str"), )) @@ -52,9 +52,9 @@ class NetworksCameraWirelessProfiles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + identity=params.get("identity"), name=params.get("name"), ssid=params.get("ssid"), - identity=params.get("identity"), networkId=params.get("networkId"), wirelessProfileId=params.get("wirelessProfileId"), ) @@ -78,15 +78,15 @@ class NetworksCameraWirelessProfiles(object): def create_params(self): new_object_params = {} + if self.new_object.get('identity') is not None or self.new_object.get('identity') is not None: + new_object_params['identity'] = self.new_object.get('identity') or \ + self.new_object.get('identity') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('ssid') is not None or self.new_object.get('ssid') is not None: new_object_params['ssid'] = self.new_object.get('ssid') or \ self.new_object.get('ssid') - if self.new_object.get('identity') is not None or self.new_object.get('identity') is not None: - new_object_params['identity'] = self.new_object.get('identity') or \ - self.new_object.get('identity') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -104,15 +104,15 @@ class NetworksCameraWirelessProfiles(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('identity') is not None or self.new_object.get('identity') is not None: + new_object_params['identity'] = self.new_object.get('identity') or \ + self.new_object.get('identity') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('ssid') is not None or self.new_object.get('ssid') is not None: new_object_params['ssid'] = self.new_object.get('ssid') or \ self.new_object.get('ssid') - if self.new_object.get('identity') is not None or self.new_object.get('identity') is not None: - new_object_params['identity'] = self.new_object.get('identity') or \ - self.new_object.get('identity') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -190,9 +190,9 @@ class NetworksCameraWirelessProfiles(object): requested_obj = self.new_object obj_params = [ + ("identity", "identity"), ("name", "name"), ("ssid", "ssid"), - ("identity", "identity"), ("networkId", "networkId"), ("wirelessProfileId", "wirelessProfileId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_dhcp.py b/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_dhcp.py index a02d4c4d4..823ff2348 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_dhcp.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_dhcp.py @@ -33,8 +33,8 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), dhcpLeaseTime=dict(type="str"), - dnsNameservers=dict(type="str"), dnsCustomNameservers=dict(type="list"), + dnsNameservers=dict(type="str"), networkId=dict(type="str"), )) @@ -51,8 +51,8 @@ class NetworksCellularGatewayDhcp(object): self.meraki = meraki self.new_object = dict( dhcpLeaseTime=params.get("dhcpLeaseTime"), - dnsNameservers=params.get("dnsNameservers"), dnsCustomNameservers=params.get("dnsCustomNameservers"), + dnsNameservers=params.get("dnsNameservers"), network_id=params.get("networkId"), ) @@ -68,12 +68,12 @@ class NetworksCellularGatewayDhcp(object): if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ self.new_object.get('dhcp_lease_time') - if self.new_object.get('dnsNameservers') is not None or self.new_object.get('dns_nameservers') is not None: - new_object_params['dnsNameservers'] = self.new_object.get('dnsNameservers') or \ - self.new_object.get('dns_nameservers') if self.new_object.get('dnsCustomNameservers') is not None or self.new_object.get('dns_custom_nameservers') is not None: new_object_params['dnsCustomNameservers'] = self.new_object.get('dnsCustomNameservers') or \ self.new_object.get('dns_custom_nameservers') + if self.new_object.get('dnsNameservers') is not None or self.new_object.get('dns_nameservers') is not None: + new_object_params['dnsNameservers'] = self.new_object.get('dnsNameservers') or \ + self.new_object.get('dns_nameservers') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -131,8 +131,8 @@ class NetworksCellularGatewayDhcp(object): obj_params = [ ("dhcpLeaseTime", "dhcpLeaseTime"), - ("dnsNameservers", "dnsNameservers"), ("dnsCustomNameservers", "dnsCustomNameservers"), + ("dnsNameservers", "dnsNameservers"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_subnet_pool.py b/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_subnet_pool.py index 4af5e75ad..328e935ae 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_subnet_pool.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_cellular_gateway_subnet_pool.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - mask=dict(type="int"), cidr=dict(type="str"), + mask=dict(type="int"), networkId=dict(type="str"), )) @@ -49,8 +49,8 @@ class NetworksCellularGatewaySubnetPool(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - mask=params.get("mask"), cidr=params.get("cidr"), + mask=params.get("mask"), network_id=params.get("networkId"), ) @@ -63,12 +63,12 @@ class NetworksCellularGatewaySubnetPool(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: - new_object_params['mask'] = self.new_object.get('mask') or \ - self.new_object.get('mask') if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: new_object_params['cidr'] = self.new_object.get('cidr') or \ self.new_object.get('cidr') + if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: + new_object_params['mask'] = self.new_object.get('mask') or \ + self.new_object.get('mask') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -125,8 +125,8 @@ class NetworksCellularGatewaySubnetPool(object): requested_obj = self.new_object obj_params = [ - ("mask", "mask"), ("cidr", "cidr"), + ("mask", "mask"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_clients_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_clients_info.py index 7f6eae8dc..cb865220d 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_clients_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_clients_info.py @@ -26,23 +26,7 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( networkId=dict(type="str"), - t0=dict(type="str"), - timespan=dict(type="float"), - perPage=dict(type="int"), - total_pages=dict(type="int"), - direction=dict(type="str"), - startingAfter=dict(type="str"), - endingBefore=dict(type="str"), - statuses=dict(type="list"), - ip=dict(type="str"), - ip6=dict(type="str"), - ip6Local=dict(type="str"), - mac=dict(type="str"), - os=dict(type="str"), - pskGroup=dict(type="str"), - description=dict(type="str"), - vlan=dict(type="str"), - recentDeviceConnections=dict(type="list"), + clientId=dict(type="str"), )) required_if = [] @@ -79,61 +63,14 @@ class ActionModule(ActionBase): if not valid: raise AnsibleActionFail(errors) - def get_all(self, params): + def get_object(self, params): new_object = {} if params.get("networkId") is not None: new_object["networkId"] = params.get( "networkId") - if params.get("t0") is not None: - new_object["t0"] = params.get( - "t0") - if params.get("timespan") is not None: - new_object["timespan"] = params.get( - "timespan") - if params.get("perPage") is not None: - new_object["perPage"] = params.get( - "perPage") - new_object['total_pages'] = params.get( - "total_pages") or 1 - new_object['direction'] = params.get( - "direction") or "next" - if params.get("startingAfter") is not None: - new_object["startingAfter"] = params.get( - "startingAfter") - if params.get("endingBefore") is not None: - new_object["endingBefore"] = params.get( - "endingBefore") - if params.get("statuses") is not None: - new_object["statuses"] = params.get( - "statuses") - if params.get("ip") is not None: - new_object["ip"] = params.get( - "ip") - if params.get("ip6") is not None: - new_object["ip6"] = params.get( - "ip6") - if params.get("ip6Local") is not None: - new_object["ip6Local"] = params.get( - "ip6Local") - if params.get("mac") is not None: - new_object["mac"] = params.get( - "mac") - if params.get("os") is not None: - new_object["os"] = params.get( - "os") - if params.get("pskGroup") is not None: - new_object["pskGroup"] = params.get( - "pskGroup") - if params.get("description") is not None: - new_object["description"] = params.get( - "description") - if params.get("vlan") is not None: - new_object["vlan"] = params.get( - "vlan") - if params.get("recentDeviceConnections") is not None: - new_object["recentDeviceConnections"] = params.get( - "recentDeviceConnections") - + if params.get("clientId") is not None: + new_object["clientId"] = params.get( + "clientId") return new_object def run(self, tmp=None, task_vars=None): @@ -146,11 +83,20 @@ class ActionModule(ActionBase): meraki = MERAKI(params=self._task.args) - response = meraki.exec_meraki( - family="networks", - function='getNetworkClients', - params=self.get_all(self._task.args), - ) - self._result.update(dict(meraki_response=response)) - self._result.update(meraki.exit_json()) - return self._result + id = self._task.args.get("clientId") + if id: + response = meraki.exec_meraki( + family="networks", + function='getNetworkClient', + 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: + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades.py b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades.py index d60217404..f3cc453f0 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - upgradeWindow=dict(type="dict"), - timezone=dict(type="str"), products=dict(type="dict"), + timezone=dict(type="str"), + upgradeWindow=dict(type="dict"), networkId=dict(type="str"), )) @@ -50,9 +50,9 @@ class NetworksFirmwareUpgrades(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - upgradeWindow=params.get("upgradeWindow"), - timezone=params.get("timezone"), products=params.get("products"), + timezone=params.get("timezone"), + upgradeWindow=params.get("upgradeWindow"), network_id=params.get("networkId"), ) @@ -65,15 +65,15 @@ class NetworksFirmwareUpgrades(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('upgradeWindow') is not None or self.new_object.get('upgrade_window') is not None: - new_object_params['upgradeWindow'] = self.new_object.get('upgradeWindow') or \ - self.new_object.get('upgrade_window') - if self.new_object.get('timezone') is not None or self.new_object.get('timezone') is not None: - new_object_params['timezone'] = self.new_object.get('timezone') or \ - self.new_object.get('timezone') if self.new_object.get('products') is not None or self.new_object.get('products') is not None: new_object_params['products'] = self.new_object.get('products') or \ self.new_object.get('products') + if self.new_object.get('timezone') is not None or self.new_object.get('timezone') is not None: + new_object_params['timezone'] = self.new_object.get('timezone') or \ + self.new_object.get('timezone') + if self.new_object.get('upgradeWindow') is not None or self.new_object.get('upgrade_window') is not None: + new_object_params['upgradeWindow'] = self.new_object.get('upgradeWindow') or \ + self.new_object.get('upgrade_window') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -130,9 +130,9 @@ class NetworksFirmwareUpgrades(object): requested_obj = self.new_object obj_params = [ - ("upgradeWindow", "upgradeWindow"), - ("timezone", "timezone"), ("products", "products"), + ("timezone", "timezone"), + ("upgradeWindow", "upgradeWindow"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_rollbacks.py b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_rollbacks.py index 02dd7a060..ac1f8efea 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_rollbacks.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_rollbacks.py @@ -26,8 +26,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( product=dict(type="str"), - time=dict(type="str"), reasons=dict(type="list"), + time=dict(type="str"), toVersion=dict(type="dict"), networkId=dict(type="str"), )) @@ -69,8 +69,8 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( product=params.get("product"), - time=params.get("time"), reasons=params.get("reasons"), + time=params.get("time"), toVersion=params.get("toVersion"), networkId=params.get("networkId"), ) diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_defer.py b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_defer.py index db07326b4..f4676d6e5 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_defer.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_defer.py @@ -64,7 +64,7 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - network_id=params.get("networkId"), + networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_rollbacks.py b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_rollbacks.py index 72ab2abcc..4a7b0d8aa 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_rollbacks.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_events_rollbacks.py @@ -25,8 +25,8 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - stages=dict(type="list"), reasons=dict(type="list"), + stages=dict(type="list"), networkId=dict(type="str"), )) diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_groups.py b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_groups.py index ea0902e37..61f7f1b4b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_groups.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_firmware_upgrades_staged_groups.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), + assignedDevices=dict(type="dict"), description=dict(type="str"), isDefault=dict(type="bool"), - assignedDevices=dict(type="dict"), + name=dict(type="str"), networkId=dict(type="str"), groupId=dict(type="str"), )) @@ -53,10 +53,10 @@ class NetworksFirmwareUpgradesStagedGroups(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), + assignedDevices=params.get("assignedDevices"), description=params.get("description"), isDefault=params.get("isDefault"), - assignedDevices=params.get("assignedDevices"), + name=params.get("name"), networkId=params.get("networkId"), groupId=params.get("groupId"), ) @@ -80,17 +80,17 @@ class NetworksFirmwareUpgradesStagedGroups(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') + if self.new_object.get('assignedDevices') is not None or self.new_object.get('assigned_devices') is not None: + new_object_params['assignedDevices'] = self.new_object.get('assignedDevices') or \ + self.new_object.get('assigned_devices') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') if self.new_object.get('isDefault') is not None or self.new_object.get('is_default') is not None: new_object_params['isDefault'] = self.new_object.get('isDefault') - if self.new_object.get('assignedDevices') is not None or self.new_object.get('assigned_devices') is not None: - new_object_params['assignedDevices'] = self.new_object.get('assignedDevices') or \ - self.new_object.get('assigned_devices') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -108,17 +108,17 @@ class NetworksFirmwareUpgradesStagedGroups(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') + if self.new_object.get('assignedDevices') is not None or self.new_object.get('assigned_devices') is not None: + new_object_params['assignedDevices'] = self.new_object.get('assignedDevices') or \ + self.new_object.get('assigned_devices') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') if self.new_object.get('isDefault') is not None or self.new_object.get('is_default') is not None: new_object_params['isDefault'] = self.new_object.get('isDefault') - if self.new_object.get('assignedDevices') is not None or self.new_object.get('assigned_devices') is not None: - new_object_params['assignedDevices'] = self.new_object.get('assignedDevices') or \ - self.new_object.get('assigned_devices') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -196,10 +196,10 @@ class NetworksFirmwareUpgradesStagedGroups(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), + ("assignedDevices", "assignedDevices"), ("description", "description"), ("isDefault", "isDefault"), - ("assignedDevices", "assignedDevices"), + ("name", "name"), ("networkId", "networkId"), ("groupId", "groupId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_floor_plans.py b/ansible_collections/cisco/meraki/plugins/action/networks_floor_plans.py index 0e1a40eec..561919d38 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_floor_plans.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_floor_plans.py @@ -32,13 +32,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - center=dict(type="dict"), bottomLeftCorner=dict(type="dict"), bottomRightCorner=dict(type="dict"), + center=dict(type="dict"), + imageContents=dict(type="str"), + name=dict(type="str"), topLeftCorner=dict(type="dict"), topRightCorner=dict(type="dict"), - imageContents=dict(type="str"), networkId=dict(type="str"), floorPlanId=dict(type="str"), )) @@ -56,13 +56,13 @@ class NetworksFloorPlans(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - center=params.get("center"), bottomLeftCorner=params.get("bottomLeftCorner"), bottomRightCorner=params.get("bottomRightCorner"), + center=params.get("center"), + imageContents=params.get("imageContents"), + name=params.get("name"), topLeftCorner=params.get("topLeftCorner"), topRightCorner=params.get("topRightCorner"), - imageContents=params.get("imageContents"), networkId=params.get("networkId"), floorPlanId=params.get("floorPlanId"), ) @@ -86,27 +86,27 @@ class NetworksFloorPlans(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('center') is not None or self.new_object.get('center') is not None: - new_object_params['center'] = self.new_object.get('center') or \ - self.new_object.get('center') if self.new_object.get('bottomLeftCorner') is not None or self.new_object.get('bottom_left_corner') is not None: new_object_params['bottomLeftCorner'] = self.new_object.get('bottomLeftCorner') or \ self.new_object.get('bottom_left_corner') if self.new_object.get('bottomRightCorner') is not None or self.new_object.get('bottom_right_corner') is not None: new_object_params['bottomRightCorner'] = self.new_object.get('bottomRightCorner') or \ self.new_object.get('bottom_right_corner') + if self.new_object.get('center') is not None or self.new_object.get('center') is not None: + new_object_params['center'] = self.new_object.get('center') or \ + self.new_object.get('center') + if self.new_object.get('imageContents') is not None or self.new_object.get('image_contents') is not None: + new_object_params['imageContents'] = self.new_object.get('imageContents') or \ + self.new_object.get('image_contents') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('topLeftCorner') is not None or self.new_object.get('top_left_corner') is not None: new_object_params['topLeftCorner'] = self.new_object.get('topLeftCorner') or \ self.new_object.get('top_left_corner') if self.new_object.get('topRightCorner') is not None or self.new_object.get('top_right_corner') is not None: new_object_params['topRightCorner'] = self.new_object.get('topRightCorner') or \ self.new_object.get('top_right_corner') - if self.new_object.get('imageContents') is not None or self.new_object.get('image_contents') is not None: - new_object_params['imageContents'] = self.new_object.get('imageContents') or \ - self.new_object.get('image_contents') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -124,27 +124,27 @@ class NetworksFloorPlans(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('center') is not None or self.new_object.get('center') is not None: - new_object_params['center'] = self.new_object.get('center') or \ - self.new_object.get('center') if self.new_object.get('bottomLeftCorner') is not None or self.new_object.get('bottom_left_corner') is not None: new_object_params['bottomLeftCorner'] = self.new_object.get('bottomLeftCorner') or \ self.new_object.get('bottom_left_corner') if self.new_object.get('bottomRightCorner') is not None or self.new_object.get('bottom_right_corner') is not None: new_object_params['bottomRightCorner'] = self.new_object.get('bottomRightCorner') or \ self.new_object.get('bottom_right_corner') + if self.new_object.get('center') is not None or self.new_object.get('center') is not None: + new_object_params['center'] = self.new_object.get('center') or \ + self.new_object.get('center') + if self.new_object.get('imageContents') is not None or self.new_object.get('image_contents') is not None: + new_object_params['imageContents'] = self.new_object.get('imageContents') or \ + self.new_object.get('image_contents') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('topLeftCorner') is not None or self.new_object.get('top_left_corner') is not None: new_object_params['topLeftCorner'] = self.new_object.get('topLeftCorner') or \ self.new_object.get('top_left_corner') if self.new_object.get('topRightCorner') is not None or self.new_object.get('top_right_corner') is not None: new_object_params['topRightCorner'] = self.new_object.get('topRightCorner') or \ self.new_object.get('top_right_corner') - if self.new_object.get('imageContents') is not None or self.new_object.get('image_contents') is not None: - new_object_params['imageContents'] = self.new_object.get('imageContents') or \ - self.new_object.get('image_contents') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -222,13 +222,13 @@ class NetworksFloorPlans(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("center", "center"), ("bottomLeftCorner", "bottomLeftCorner"), ("bottomRightCorner", "bottomRightCorner"), + ("center", "center"), + ("imageContents", "imageContents"), + ("name", "name"), ("topLeftCorner", "topLeftCorner"), ("topRightCorner", "topRightCorner"), - ("imageContents", "imageContents"), ("networkId", "networkId"), ("floorPlanId", "floorPlanId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_group_policies.py b/ansible_collections/cisco/meraki/plugins/action/networks_group_policies.py index c8f41fc81..749350851 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_group_policies.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_group_policies.py @@ -32,14 +32,14 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - scheduling=dict(type="dict"), bandwidth=dict(type="dict"), - firewallAndTrafficShaping=dict(type="dict"), + bonjourForwarding=dict(type="dict"), contentFiltering=dict(type="dict"), + firewallAndTrafficShaping=dict(type="dict"), + name=dict(type="str"), + scheduling=dict(type="dict"), splashAuthSettings=dict(type="str"), vlanTagging=dict(type="dict"), - bonjourForwarding=dict(type="dict"), networkId=dict(type="str"), groupPolicyId=dict(type="str"), )) @@ -57,14 +57,14 @@ class NetworksGroupPolicies(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - scheduling=params.get("scheduling"), bandwidth=params.get("bandwidth"), - firewallAndTrafficShaping=params.get("firewallAndTrafficShaping"), + bonjourForwarding=params.get("bonjourForwarding"), contentFiltering=params.get("contentFiltering"), + firewallAndTrafficShaping=params.get("firewallAndTrafficShaping"), + name=params.get("name"), + scheduling=params.get("scheduling"), splashAuthSettings=params.get("splashAuthSettings"), vlanTagging=params.get("vlanTagging"), - bonjourForwarding=params.get("bonjourForwarding"), networkId=params.get("networkId"), groupPolicyId=params.get("groupPolicyId"), ) @@ -88,30 +88,30 @@ class NetworksGroupPolicies(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('scheduling') is not None or self.new_object.get('scheduling') is not None: - new_object_params['scheduling'] = self.new_object.get('scheduling') or \ - self.new_object.get('scheduling') if self.new_object.get('bandwidth') is not None or self.new_object.get('bandwidth') is not None: new_object_params['bandwidth'] = self.new_object.get('bandwidth') or \ self.new_object.get('bandwidth') - if self.new_object.get('firewallAndTrafficShaping') is not None or self.new_object.get('firewall_and_traffic_shaping') is not None: - new_object_params['firewallAndTrafficShaping'] = self.new_object.get('firewallAndTrafficShaping') or \ - self.new_object.get('firewall_and_traffic_shaping') + if self.new_object.get('bonjourForwarding') is not None or self.new_object.get('bonjour_forwarding') is not None: + new_object_params['bonjourForwarding'] = self.new_object.get('bonjourForwarding') or \ + self.new_object.get('bonjour_forwarding') if self.new_object.get('contentFiltering') is not None or self.new_object.get('content_filtering') is not None: new_object_params['contentFiltering'] = self.new_object.get('contentFiltering') or \ self.new_object.get('content_filtering') + if self.new_object.get('firewallAndTrafficShaping') is not None or self.new_object.get('firewall_and_traffic_shaping') is not None: + new_object_params['firewallAndTrafficShaping'] = self.new_object.get('firewallAndTrafficShaping') or \ + self.new_object.get('firewall_and_traffic_shaping') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('scheduling') is not None or self.new_object.get('scheduling') is not None: + new_object_params['scheduling'] = self.new_object.get('scheduling') or \ + self.new_object.get('scheduling') if self.new_object.get('splashAuthSettings') is not None or self.new_object.get('splash_auth_settings') is not None: new_object_params['splashAuthSettings'] = self.new_object.get('splashAuthSettings') or \ self.new_object.get('splash_auth_settings') if self.new_object.get('vlanTagging') is not None or self.new_object.get('vlan_tagging') is not None: new_object_params['vlanTagging'] = self.new_object.get('vlanTagging') or \ self.new_object.get('vlan_tagging') - if self.new_object.get('bonjourForwarding') is not None or self.new_object.get('bonjour_forwarding') is not None: - new_object_params['bonjourForwarding'] = self.new_object.get('bonjourForwarding') or \ - self.new_object.get('bonjour_forwarding') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -129,30 +129,30 @@ class NetworksGroupPolicies(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('scheduling') is not None or self.new_object.get('scheduling') is not None: - new_object_params['scheduling'] = self.new_object.get('scheduling') or \ - self.new_object.get('scheduling') if self.new_object.get('bandwidth') is not None or self.new_object.get('bandwidth') is not None: new_object_params['bandwidth'] = self.new_object.get('bandwidth') or \ self.new_object.get('bandwidth') - if self.new_object.get('firewallAndTrafficShaping') is not None or self.new_object.get('firewall_and_traffic_shaping') is not None: - new_object_params['firewallAndTrafficShaping'] = self.new_object.get('firewallAndTrafficShaping') or \ - self.new_object.get('firewall_and_traffic_shaping') + if self.new_object.get('bonjourForwarding') is not None or self.new_object.get('bonjour_forwarding') is not None: + new_object_params['bonjourForwarding'] = self.new_object.get('bonjourForwarding') or \ + self.new_object.get('bonjour_forwarding') if self.new_object.get('contentFiltering') is not None or self.new_object.get('content_filtering') is not None: new_object_params['contentFiltering'] = self.new_object.get('contentFiltering') or \ self.new_object.get('content_filtering') + if self.new_object.get('firewallAndTrafficShaping') is not None or self.new_object.get('firewall_and_traffic_shaping') is not None: + new_object_params['firewallAndTrafficShaping'] = self.new_object.get('firewallAndTrafficShaping') or \ + self.new_object.get('firewall_and_traffic_shaping') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('scheduling') is not None or self.new_object.get('scheduling') is not None: + new_object_params['scheduling'] = self.new_object.get('scheduling') or \ + self.new_object.get('scheduling') if self.new_object.get('splashAuthSettings') is not None or self.new_object.get('splash_auth_settings') is not None: new_object_params['splashAuthSettings'] = self.new_object.get('splashAuthSettings') or \ self.new_object.get('splash_auth_settings') if self.new_object.get('vlanTagging') is not None or self.new_object.get('vlan_tagging') is not None: new_object_params['vlanTagging'] = self.new_object.get('vlanTagging') or \ self.new_object.get('vlan_tagging') - if self.new_object.get('bonjourForwarding') is not None or self.new_object.get('bonjour_forwarding') is not None: - new_object_params['bonjourForwarding'] = self.new_object.get('bonjourForwarding') or \ - self.new_object.get('bonjour_forwarding') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -230,14 +230,14 @@ class NetworksGroupPolicies(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("scheduling", "scheduling"), ("bandwidth", "bandwidth"), - ("firewallAndTrafficShaping", "firewallAndTrafficShaping"), + ("bonjourForwarding", "bonjourForwarding"), ("contentFiltering", "contentFiltering"), + ("firewallAndTrafficShaping", "firewallAndTrafficShaping"), + ("name", "name"), + ("scheduling", "scheduling"), ("splashAuthSettings", "splashAuthSettings"), ("vlanTagging", "vlanTagging"), - ("bonjourForwarding", "bonjourForwarding"), ("networkId", "networkId"), ("groupPolicyId", "groupPolicyId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_meraki_auth_users.py b/ansible_collections/cisco/meraki/plugins/action/networks_meraki_auth_users.py index 56787c4fd..436947b7c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_meraki_auth_users.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_meraki_auth_users.py @@ -32,15 +32,16 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - email=dict(type="str"), - name=dict(type="str"), - password=dict(type="str"), accountType=dict(type="str"), + authorizations=dict(type="list"), + email=dict(type="str"), emailPasswordToUser=dict(type="bool"), isAdmin=dict(type="bool"), - authorizations=dict(type="list"), + name=dict(type="str"), + password=dict(type="str"), networkId=dict(type="str"), merakiAuthUserId=dict(type="str"), + delete=dict(type="bool"), )) required_if = [ @@ -56,15 +57,16 @@ class NetworksMerakiAuthUsers(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - email=params.get("email"), - name=params.get("name"), - password=params.get("password"), accountType=params.get("accountType"), + authorizations=params.get("authorizations"), + email=params.get("email"), emailPasswordToUser=params.get("emailPasswordToUser"), isAdmin=params.get("isAdmin"), - authorizations=params.get("authorizations"), + name=params.get("name"), + password=params.get("password"), networkId=params.get("networkId"), merakiAuthUserId=params.get("merakiAuthUserId"), + delete=params.get("delete"), ) def get_all_params(self, name=None, id=None): @@ -86,25 +88,25 @@ class NetworksMerakiAuthUsers(object): def create_params(self): new_object_params = {} + if self.new_object.get('accountType') is not None or self.new_object.get('account_type') is not None: + new_object_params['accountType'] = self.new_object.get('accountType') or \ + self.new_object.get('account_type') + if self.new_object.get('authorizations') is not None or self.new_object.get('authorizations') is not None: + new_object_params['authorizations'] = self.new_object.get('authorizations') or \ + self.new_object.get('authorizations') if self.new_object.get('email') is not None or self.new_object.get('email') is not None: new_object_params['email'] = self.new_object.get('email') or \ self.new_object.get('email') + if self.new_object.get('emailPasswordToUser') is not None or self.new_object.get('email_password_to_user') is not None: + new_object_params['emailPasswordToUser'] = self.new_object.get('emailPasswordToUser') + if self.new_object.get('isAdmin') is not None or self.new_object.get('is_admin') is not None: + new_object_params['isAdmin'] = self.new_object.get('isAdmin') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('password') is not None or self.new_object.get('password') is not None: new_object_params['password'] = self.new_object.get('password') or \ self.new_object.get('password') - if self.new_object.get('accountType') is not None or self.new_object.get('account_type') is not None: - new_object_params['accountType'] = self.new_object.get('accountType') or \ - self.new_object.get('account_type') - if self.new_object.get('emailPasswordToUser') is not None or self.new_object.get('email_password_to_user') is not None: - new_object_params['emailPasswordToUser'] = self.new_object.get('emailPasswordToUser') - if self.new_object.get('isAdmin') is not None or self.new_object.get('is_admin') is not None: - new_object_params['isAdmin'] = self.new_object.get('isAdmin') - if self.new_object.get('authorizations') is not None or self.new_object.get('authorizations') is not None: - new_object_params['authorizations'] = self.new_object.get('authorizations') or \ - self.new_object.get('authorizations') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -112,6 +114,8 @@ class NetworksMerakiAuthUsers(object): def delete_by_id_params(self): new_object_params = {} + if self.new_object.get('delete') is not None or self.new_object.get('delete') is not None: + new_object_params['delete'] = self.new_object.get('delete') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -122,17 +126,17 @@ class NetworksMerakiAuthUsers(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('authorizations') is not None or self.new_object.get('authorizations') is not None: + new_object_params['authorizations'] = self.new_object.get('authorizations') or \ + self.new_object.get('authorizations') + if self.new_object.get('emailPasswordToUser') is not None or self.new_object.get('email_password_to_user') is not None: + new_object_params['emailPasswordToUser'] = self.new_object.get('emailPasswordToUser') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('password') is not None or self.new_object.get('password') is not None: new_object_params['password'] = self.new_object.get('password') or \ self.new_object.get('password') - if self.new_object.get('emailPasswordToUser') is not None or self.new_object.get('email_password_to_user') is not None: - new_object_params['emailPasswordToUser'] = self.new_object.get('emailPasswordToUser') - if self.new_object.get('authorizations') is not None or self.new_object.get('authorizations') is not None: - new_object_params['authorizations'] = self.new_object.get('authorizations') or \ - self.new_object.get('authorizations') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -210,14 +214,15 @@ class NetworksMerakiAuthUsers(object): requested_obj = self.new_object obj_params = [ - ("email", "email"), - ("name", "name"), ("accountType", "accountType"), + ("authorizations", "authorizations"), + ("email", "email"), ("emailPasswordToUser", "emailPasswordToUser"), ("isAdmin", "isAdmin"), - ("authorizations", "authorizations"), + ("name", "name"), ("networkId", "networkId"), ("merakiAuthUserId", "merakiAuthUserId"), + ("delete", "delete"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params # If any does not have eq params, it requires update diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_mqtt_brokers.py b/ansible_collections/cisco/meraki/plugins/action/networks_mqtt_brokers.py index 4313ec519..89e45246e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_mqtt_brokers.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_mqtt_brokers.py @@ -25,11 +25,11 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - name=dict(type="str"), + authentication=dict(type="dict"), host=dict(type="str"), + name=dict(type="str"), port=dict(type="int"), security=dict(type="dict"), - authentication=dict(type="dict"), networkId=dict(type="str"), )) @@ -69,11 +69,11 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - name=params.get("name"), + authentication=params.get("authentication"), host=params.get("host"), + name=params.get("name"), port=params.get("port"), security=params.get("security"), - authentication=params.get("authentication"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_netflow.py b/ansible_collections/cisco/meraki/plugins/action/networks_netflow.py index 0360b2792..730f5518b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_netflow.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_netflow.py @@ -32,11 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - reportingEnabled=dict(type="bool"), collectorIp=dict(type="str"), collectorPort=dict(type="int"), - etaEnabled=dict(type="bool"), etaDstPort=dict(type="int"), + etaEnabled=dict(type="bool"), + reportingEnabled=dict(type="bool"), networkId=dict(type="str"), )) @@ -52,11 +52,11 @@ class NetworksNetflow(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - reportingEnabled=params.get("reportingEnabled"), collectorIp=params.get("collectorIp"), collectorPort=params.get("collectorPort"), - etaEnabled=params.get("etaEnabled"), etaDstPort=params.get("etaDstPort"), + etaEnabled=params.get("etaEnabled"), + reportingEnabled=params.get("reportingEnabled"), network_id=params.get("networkId"), ) @@ -69,19 +69,19 @@ class NetworksNetflow(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('reportingEnabled') is not None or self.new_object.get('reporting_enabled') is not None: - new_object_params['reportingEnabled'] = self.new_object.get('reportingEnabled') if self.new_object.get('collectorIp') is not None or self.new_object.get('collector_ip') is not None: new_object_params['collectorIp'] = self.new_object.get('collectorIp') or \ self.new_object.get('collector_ip') if self.new_object.get('collectorPort') is not None or self.new_object.get('collector_port') is not None: new_object_params['collectorPort'] = self.new_object.get('collectorPort') or \ self.new_object.get('collector_port') - if self.new_object.get('etaEnabled') is not None or self.new_object.get('eta_enabled') is not None: - new_object_params['etaEnabled'] = self.new_object.get('etaEnabled') if self.new_object.get('etaDstPort') is not None or self.new_object.get('eta_dst_port') is not None: new_object_params['etaDstPort'] = self.new_object.get('etaDstPort') or \ self.new_object.get('eta_dst_port') + if self.new_object.get('etaEnabled') is not None or self.new_object.get('eta_enabled') is not None: + new_object_params['etaEnabled'] = self.new_object.get('etaEnabled') + if self.new_object.get('reportingEnabled') is not None or self.new_object.get('reporting_enabled') is not None: + new_object_params['reportingEnabled'] = self.new_object.get('reportingEnabled') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -138,11 +138,11 @@ class NetworksNetflow(object): requested_obj = self.new_object obj_params = [ - ("reportingEnabled", "reportingEnabled"), ("collectorIp", "collectorIp"), ("collectorPort", "collectorPort"), - ("etaEnabled", "etaEnabled"), ("etaDstPort", "etaDstPort"), + ("etaEnabled", "etaEnabled"), + ("reportingEnabled", "reportingEnabled"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sensor_alerts_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_sensor_alerts_profiles.py index 13be65175..bb150c8fd 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sensor_alerts_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sensor_alerts_profiles.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - schedule=dict(type="dict"), conditions=dict(type="list"), + name=dict(type="str"), recipients=dict(type="dict"), + schedule=dict(type="dict"), serials=dict(type="list"), networkId=dict(type="str"), id=dict(type="str"), @@ -54,10 +54,10 @@ class NetworksSensorAlertsProfiles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - schedule=params.get("schedule"), conditions=params.get("conditions"), + name=params.get("name"), recipients=params.get("recipients"), + schedule=params.get("schedule"), serials=params.get("serials"), networkId=params.get("networkId"), id=params.get("id"), @@ -81,18 +81,18 @@ class NetworksSensorAlertsProfiles(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('schedule') is not None or self.new_object.get('schedule') is not None: - new_object_params['schedule'] = self.new_object.get('schedule') or \ - self.new_object.get('schedule') if self.new_object.get('conditions') is not None or self.new_object.get('conditions') is not None: new_object_params['conditions'] = self.new_object.get('conditions') or \ self.new_object.get('conditions') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: new_object_params['recipients'] = self.new_object.get('recipients') or \ self.new_object.get('recipients') + if self.new_object.get('schedule') is not None or self.new_object.get('schedule') is not None: + new_object_params['schedule'] = self.new_object.get('schedule') or \ + self.new_object.get('schedule') if self.new_object.get('serials') is not None or self.new_object.get('serials') is not None: new_object_params['serials'] = self.new_object.get('serials') or \ self.new_object.get('serials') @@ -113,18 +113,18 @@ class NetworksSensorAlertsProfiles(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('schedule') is not None or self.new_object.get('schedule') is not None: - new_object_params['schedule'] = self.new_object.get('schedule') or \ - self.new_object.get('schedule') if self.new_object.get('conditions') is not None or self.new_object.get('conditions') is not None: new_object_params['conditions'] = self.new_object.get('conditions') or \ self.new_object.get('conditions') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: new_object_params['recipients'] = self.new_object.get('recipients') or \ self.new_object.get('recipients') + if self.new_object.get('schedule') is not None or self.new_object.get('schedule') is not None: + new_object_params['schedule'] = self.new_object.get('schedule') or \ + self.new_object.get('schedule') if self.new_object.get('serials') is not None or self.new_object.get('serials') is not None: new_object_params['serials'] = self.new_object.get('serials') or \ self.new_object.get('serials') @@ -201,10 +201,10 @@ class NetworksSensorAlertsProfiles(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("schedule", "schedule"), ("conditions", "conditions"), + ("name", "name"), ("recipients", "recipients"), + ("schedule", "schedule"), ("serials", "serials"), ("networkId", "networkId"), ("id", "id"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_settings.py index 3827be9c0..26277be99 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_settings.py @@ -32,9 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + localStatusPage=dict(type="dict"), localStatusPageEnabled=dict(type="bool"), + namedVlans=dict(type="dict"), remoteStatusPageEnabled=dict(type="bool"), - localStatusPage=dict(type="dict"), securePort=dict(type="dict"), networkId=dict(type="str"), )) @@ -51,9 +52,10 @@ class NetworksSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + localStatusPage=params.get("localStatusPage"), localStatusPageEnabled=params.get("localStatusPageEnabled"), + namedVlans=params.get("namedVlans"), remoteStatusPageEnabled=params.get("remoteStatusPageEnabled"), - localStatusPage=params.get("localStatusPage"), securePort=params.get("securePort"), network_id=params.get("networkId"), ) @@ -67,13 +69,16 @@ class NetworksSettings(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('localStatusPage') is not None or self.new_object.get('local_status_page') is not None: + new_object_params['localStatusPage'] = self.new_object.get('localStatusPage') or \ + self.new_object.get('local_status_page') if self.new_object.get('localStatusPageEnabled') is not None or self.new_object.get('local_status_page_enabled') is not None: new_object_params['localStatusPageEnabled'] = self.new_object.get('localStatusPageEnabled') + if self.new_object.get('namedVlans') is not None or self.new_object.get('named_vlans') is not None: + new_object_params['namedVlans'] = self.new_object.get('namedVlans') or \ + self.new_object.get('named_vlans') if self.new_object.get('remoteStatusPageEnabled') is not None or self.new_object.get('remote_status_page_enabled') is not None: new_object_params['remoteStatusPageEnabled'] = self.new_object.get('remoteStatusPageEnabled') - if self.new_object.get('localStatusPage') is not None or self.new_object.get('local_status_page') is not None: - new_object_params['localStatusPage'] = self.new_object.get('localStatusPage') or \ - self.new_object.get('local_status_page') if self.new_object.get('securePort') is not None or self.new_object.get('secure_port') is not None: new_object_params['securePort'] = self.new_object.get('securePort') or \ self.new_object.get('secure_port') @@ -133,9 +138,10 @@ class NetworksSettings(object): requested_obj = self.new_object obj_params = [ + ("localStatusPage", "localStatusPage"), ("localStatusPageEnabled", "localStatusPageEnabled"), + ("namedVlans", "namedVlans"), ("remoteStatusPageEnabled", "remoteStatusPageEnabled"), - ("localStatusPage", "localStatusPage"), ("securePort", "securePort"), ("networkId", "networkId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_checkin.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_checkin.py index 8695838b5..ba46b4121 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_checkin.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_checkin.py @@ -25,10 +25,10 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMacs=dict(type="list"), ids=dict(type="list"), - serials=dict(type="list"), scope=dict(type="list"), + serials=dict(type="list"), + wifiMacs=dict(type="list"), networkId=dict(type="str"), )) @@ -68,10 +68,10 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMacs=params.get("wifiMacs"), ids=params.get("ids"), - serials=params.get("serials"), scope=params.get("scope"), + serials=params.get("serials"), + wifiMacs=params.get("wifiMacs"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_fields.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_fields.py index 6d9bda4c7..7d7ada596 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_fields.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_fields.py @@ -25,10 +25,10 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMac=dict(type="str"), + deviceFields=dict(type="dict"), id=dict(type="str"), serial=dict(type="str"), - deviceFields=dict(type="dict"), + wifiMac=dict(type="str"), networkId=dict(type="str"), )) @@ -68,10 +68,10 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMac=params.get("wifiMac"), + deviceFields=params.get("deviceFields"), id=params.get("id"), serial=params.get("serial"), - deviceFields=params.get("deviceFields"), + wifiMac=params.get("wifiMac"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_info.py index c37f3cc07..e186502cd 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_info.py @@ -30,6 +30,8 @@ argument_spec.update(dict( wifiMacs=dict(type="list"), serials=dict(type="list"), ids=dict(type="list"), + uuids=dict(type="list"), + systemTypes=dict(type="list"), scope=dict(type="list"), perPage=dict(type="int"), total_pages=dict(type="int"), @@ -89,6 +91,12 @@ class ActionModule(ActionBase): if params.get("ids") is not None: new_object["ids"] = params.get( "ids") + if params.get("uuids") is not None: + new_object["uuids"] = params.get( + "uuids") + if params.get("systemTypes") is not None: + new_object["systemTypes"] = params.get( + "systemTypes") if params.get("scope") is not None: new_object["scope"] = params.get( "scope") diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_install_apps.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_install_apps.py new file mode 100644 index 000000000..5dfbe018f --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_install_apps.py @@ -0,0 +1,93 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + appIds=dict(type="list"), + force=dict(type="bool"), + networkId=dict(type="str"), + deviceId=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 = False + 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 = dict( + appIds=params.get("appIds"), + force=params.get("force"), + networkId=params.get("networkId"), + deviceId=params.get("deviceId"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="sm", + function='installNetworkSmDeviceApps', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_lock.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_lock.py index c846a4dde..8f851fe0a 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_lock.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_lock.py @@ -25,11 +25,11 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMacs=dict(type="list"), ids=dict(type="list"), - serials=dict(type="list"), - scope=dict(type="list"), pin=dict(type="int"), + scope=dict(type="list"), + serials=dict(type="list"), + wifiMacs=dict(type="list"), networkId=dict(type="str"), )) @@ -69,11 +69,11 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMacs=params.get("wifiMacs"), ids=params.get("ids"), - serials=params.get("serials"), - scope=params.get("scope"), pin=params.get("pin"), + scope=params.get("scope"), + serials=params.get("serials"), + wifiMacs=params.get("wifiMacs"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_modify_tags.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_modify_tags.py index ea771b977..27f47614e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_modify_tags.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_modify_tags.py @@ -25,12 +25,12 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMacs=dict(type="list"), ids=dict(type="list"), - serials=dict(type="list"), scope=dict(type="list"), + serials=dict(type="list"), tags=dict(type="list"), updateAction=dict(type="str"), + wifiMacs=dict(type="list"), networkId=dict(type="str"), )) @@ -70,12 +70,12 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMacs=params.get("wifiMacs"), ids=params.get("ids"), - serials=params.get("serials"), scope=params.get("scope"), + serials=params.get("serials"), tags=params.get("tags"), updateAction=params.get("updateAction"), + wifiMacs=params.get("wifiMacs"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_move.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_move.py index 5ed4b5d65..384f3abf0 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_move.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_move.py @@ -25,11 +25,11 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMacs=dict(type="list"), ids=dict(type="list"), - serials=dict(type="list"), - scope=dict(type="list"), newNetwork=dict(type="str"), + scope=dict(type="list"), + serials=dict(type="list"), + wifiMacs=dict(type="list"), networkId=dict(type="str"), )) @@ -69,11 +69,11 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMacs=params.get("wifiMacs"), ids=params.get("ids"), - serials=params.get("serials"), - scope=params.get("scope"), newNetwork=params.get("newNetwork"), + scope=params.get("scope"), + serials=params.get("serials"), + wifiMacs=params.get("wifiMacs"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_reboot.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_reboot.py new file mode 100644 index 000000000..16e825308 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_reboot.py @@ -0,0 +1,103 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + ids=dict(type="list"), + kextPaths=dict(type="list"), + notifyUser=dict(type="bool"), + rebuildKernelCache=dict(type="bool"), + requestRequiresNetworkTether=dict(type="bool"), + scope=dict(type="list"), + serials=dict(type="list"), + wifiMacs=dict(type="list"), + networkId=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 = False + 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 = dict( + ids=params.get("ids"), + kextPaths=params.get("kextPaths"), + notifyUser=params.get("notifyUser"), + rebuildKernelCache=params.get("rebuildKernelCache"), + requestRequiresNetworkTether=params.get("requestRequiresNetworkTether"), + scope=params.get("scope"), + serials=params.get("serials"), + wifiMacs=params.get("wifiMacs"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="sm", + function='rebootNetworkSmDevices', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_shutdown.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_shutdown.py new file mode 100644 index 000000000..fb184208c --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_shutdown.py @@ -0,0 +1,95 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + ids=dict(type="list"), + scope=dict(type="list"), + serials=dict(type="list"), + wifiMacs=dict(type="list"), + networkId=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 = False + 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 = dict( + ids=params.get("ids"), + scope=params.get("scope"), + serials=params.get("serials"), + wifiMacs=params.get("wifiMacs"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="sm", + function='shutdownNetworkSmDevices', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_uninstall_apps.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_uninstall_apps.py new file mode 100644 index 000000000..056734402 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_uninstall_apps.py @@ -0,0 +1,91 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + appIds=dict(type="list"), + networkId=dict(type="str"), + deviceId=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 = False + 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 = dict( + appIds=params.get("appIds"), + networkId=params.get("networkId"), + deviceId=params.get("deviceId"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="sm", + function='uninstallNetworkSmDeviceApps', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_wipe.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_wipe.py index 1b20cad81..ca334bd8c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_wipe.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_devices_wipe.py @@ -25,10 +25,10 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( - wifiMac=dict(type="str"), id=dict(type="str"), - serial=dict(type="str"), pin=dict(type="int"), + serial=dict(type="str"), + wifiMac=dict(type="str"), networkId=dict(type="str"), )) @@ -68,10 +68,10 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( - wifiMac=params.get("wifiMac"), id=params.get("id"), - serial=params.get("serial"), pin=params.get("pin"), + serial=params.get("serial"), + wifiMac=params.get("wifiMac"), networkId=params.get("networkId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_sm_profiles_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_sm_profiles_info.py index 44ab17a59..d834af8b9 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_sm_profiles_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_sm_profiles_info.py @@ -26,6 +26,7 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( networkId=dict(type="str"), + payloadTypes=dict(type="list"), )) required_if = [] @@ -67,6 +68,9 @@ class ActionModule(ActionBase): if params.get("networkId") is not None: new_object["networkId"] = params.get( "networkId") + if params.get("payloadTypes") is not None: + new_object["payloadTypes"] = params.get( + "payloadTypes") return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_access_policies.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_access_policies.py index a56a7f0dd..aef2813a9 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_access_policies.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_access_policies.py @@ -32,23 +32,23 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + accessPolicyType=dict(type="str"), + dot1x=dict(type="dict"), + guestPortBouncing=dict(type="bool"), + guestVlanId=dict(type="int"), + hostMode=dict(type="str"), + increaseAccessSpeed=dict(type="bool"), name=dict(type="str"), - radiusServers=dict(type="list"), radius=dict(type="dict"), - guestPortBouncing=dict(type="bool"), - radiusTestingEnabled=dict(type="bool"), - radiusCoaSupportEnabled=dict(type="bool"), radiusAccountingEnabled=dict(type="bool"), radiusAccountingServers=dict(type="list"), + radiusCoaSupportEnabled=dict(type="bool"), radiusGroupAttribute=dict(type="str"), - hostMode=dict(type="str"), - accessPolicyType=dict(type="str"), - increaseAccessSpeed=dict(type="bool"), - guestVlanId=dict(type="int"), - dot1x=dict(type="dict"), - voiceVlanClients=dict(type="bool"), + radiusServers=dict(type="list"), + radiusTestingEnabled=dict(type="bool"), urlRedirectWalledGardenEnabled=dict(type="bool"), urlRedirectWalledGardenRanges=dict(type="list"), + voiceVlanClients=dict(type="bool"), networkId=dict(type="str"), accessPolicyNumber=dict(type="str"), )) @@ -66,25 +66,23 @@ class NetworksSwitchAccessPolicies(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + accessPolicyType=params.get("accessPolicyType"), + dot1x=params.get("dot1x"), + guestPortBouncing=params.get("guestPortBouncing"), + guestVlanId=params.get("guestVlanId"), + hostMode=params.get("hostMode"), + increaseAccessSpeed=params.get("increaseAccessSpeed"), name=params.get("name"), - radiusServers=params.get("radiusServers"), radius=params.get("radius"), - guestPortBouncing=params.get("guestPortBouncing"), - radiusTestingEnabled=params.get("radiusTestingEnabled"), - radiusCoaSupportEnabled=params.get("radiusCoaSupportEnabled"), radiusAccountingEnabled=params.get("radiusAccountingEnabled"), radiusAccountingServers=params.get("radiusAccountingServers"), + radiusCoaSupportEnabled=params.get("radiusCoaSupportEnabled"), radiusGroupAttribute=params.get("radiusGroupAttribute"), - hostMode=params.get("hostMode"), - accessPolicyType=params.get("accessPolicyType"), - increaseAccessSpeed=params.get("increaseAccessSpeed"), - guestVlanId=params.get("guestVlanId"), - dot1x=params.get("dot1x"), + radiusServers=params.get("radiusServers"), + radiusTestingEnabled=params.get("radiusTestingEnabled"), + urlRedirectWalledGardenEnabled=params.get("urlRedirectWalledGardenEnabled"), + urlRedirectWalledGardenRanges=params.get("urlRedirectWalledGardenRanges"), voiceVlanClients=params.get("voiceVlanClients"), - urlRedirectWalledGardenEnabled=params.get( - "urlRedirectWalledGardenEnabled"), - urlRedirectWalledGardenRanges=params.get( - "urlRedirectWalledGardenRanges"), networkId=params.get("networkId"), accessPolicyNumber=params.get("accessPolicyNumber"), ) @@ -108,57 +106,50 @@ class NetworksSwitchAccessPolicies(object): def create_params(self): new_object_params = {} + if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: + new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ + self.new_object.get('access_policy_type') + if self.new_object.get('dot1x') is not None or self.new_object.get('dot1x') is not None: + new_object_params['dot1x'] = self.new_object.get('dot1x') or \ + self.new_object.get('dot1x') + if self.new_object.get('guestPortBouncing') is not None or self.new_object.get('guest_port_bouncing') is not None: + new_object_params['guestPortBouncing'] = self.new_object.get('guestPortBouncing') + if self.new_object.get('guestVlanId') is not None or self.new_object.get('guest_vlan_id') is not None: + new_object_params['guestVlanId'] = self.new_object.get('guestVlanId') or \ + self.new_object.get('guest_vlan_id') + if self.new_object.get('hostMode') is not None or self.new_object.get('host_mode') is not None: + new_object_params['hostMode'] = self.new_object.get('hostMode') or \ + self.new_object.get('host_mode') + if self.new_object.get('increaseAccessSpeed') is not None or self.new_object.get('increase_access_speed') is not None: + new_object_params['increaseAccessSpeed'] = self.new_object.get('increaseAccessSpeed') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: - new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ - self.new_object.get('radius_servers') if self.new_object.get('radius') is not None or self.new_object.get('radius') is not None: new_object_params['radius'] = self.new_object.get('radius') or \ self.new_object.get('radius') - if self.new_object.get('guestPortBouncing') is not None or self.new_object.get('guest_port_bouncing') is not None: - new_object_params['guestPortBouncing'] = self.new_object.get( - 'guestPortBouncing') - if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: - new_object_params['radiusTestingEnabled'] = self.new_object.get( - 'radiusTestingEnabled') - if self.new_object.get('radiusCoaSupportEnabled') is not None or self.new_object.get('radius_coa_support_enabled') is not None: - new_object_params['radiusCoaSupportEnabled'] = self.new_object.get( - 'radiusCoaSupportEnabled') if self.new_object.get('radiusAccountingEnabled') is not None or self.new_object.get('radius_accounting_enabled') is not None: - new_object_params['radiusAccountingEnabled'] = self.new_object.get( - 'radiusAccountingEnabled') + new_object_params['radiusAccountingEnabled'] = self.new_object.get('radiusAccountingEnabled') if self.new_object.get('radiusAccountingServers') is not None or self.new_object.get('radius_accounting_servers') is not None: new_object_params['radiusAccountingServers'] = self.new_object.get('radiusAccountingServers') or \ self.new_object.get('radius_accounting_servers') + if self.new_object.get('radiusCoaSupportEnabled') is not None or self.new_object.get('radius_coa_support_enabled') is not None: + new_object_params['radiusCoaSupportEnabled'] = self.new_object.get('radiusCoaSupportEnabled') if self.new_object.get('radiusGroupAttribute') is not None or self.new_object.get('radius_group_attribute') is not None: new_object_params['radiusGroupAttribute'] = self.new_object.get('radiusGroupAttribute') or \ self.new_object.get('radius_group_attribute') - if self.new_object.get('hostMode') is not None or self.new_object.get('host_mode') is not None: - new_object_params['hostMode'] = self.new_object.get('hostMode') or \ - self.new_object.get('host_mode') - if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: - new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ - self.new_object.get('access_policy_type') - if self.new_object.get('increaseAccessSpeed') is not None or self.new_object.get('increase_access_speed') is not None: - new_object_params['increaseAccessSpeed'] = self.new_object.get( - 'increaseAccessSpeed') - if self.new_object.get('guestVlanId') is not None or self.new_object.get('guest_vlan_id') is not None: - new_object_params['guestVlanId'] = self.new_object.get('guestVlanId') or \ - self.new_object.get('guest_vlan_id') - if self.new_object.get('dot1x') is not None or self.new_object.get('dot1x') is not None: - new_object_params['dot1x'] = self.new_object.get('dot1x') or \ - self.new_object.get('dot1x') - if self.new_object.get('voiceVlanClients') is not None or self.new_object.get('voice_vlan_clients') is not None: - new_object_params['voiceVlanClients'] = self.new_object.get( - 'voiceVlanClients') + if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: + new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ + self.new_object.get('radius_servers') + if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: + new_object_params['radiusTestingEnabled'] = self.new_object.get('radiusTestingEnabled') if self.new_object.get('urlRedirectWalledGardenEnabled') is not None or self.new_object.get('url_redirect_walled_garden_enabled') is not None: - new_object_params['urlRedirectWalledGardenEnabled'] = self.new_object.get( - 'urlRedirectWalledGardenEnabled') + new_object_params['urlRedirectWalledGardenEnabled'] = self.new_object.get('urlRedirectWalledGardenEnabled') if self.new_object.get('urlRedirectWalledGardenRanges') is not None or self.new_object.get('url_redirect_walled_garden_ranges') is not None: new_object_params['urlRedirectWalledGardenRanges'] = self.new_object.get('urlRedirectWalledGardenRanges') or \ self.new_object.get('url_redirect_walled_garden_ranges') + if self.new_object.get('voiceVlanClients') is not None or self.new_object.get('voice_vlan_clients') is not None: + new_object_params['voiceVlanClients'] = self.new_object.get('voiceVlanClients') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -176,57 +167,50 @@ class NetworksSwitchAccessPolicies(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: + new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ + self.new_object.get('access_policy_type') + if self.new_object.get('dot1x') is not None or self.new_object.get('dot1x') is not None: + new_object_params['dot1x'] = self.new_object.get('dot1x') or \ + self.new_object.get('dot1x') + if self.new_object.get('guestPortBouncing') is not None or self.new_object.get('guest_port_bouncing') is not None: + new_object_params['guestPortBouncing'] = self.new_object.get('guestPortBouncing') + if self.new_object.get('guestVlanId') is not None or self.new_object.get('guest_vlan_id') is not None: + new_object_params['guestVlanId'] = self.new_object.get('guestVlanId') or \ + self.new_object.get('guest_vlan_id') + if self.new_object.get('hostMode') is not None or self.new_object.get('host_mode') is not None: + new_object_params['hostMode'] = self.new_object.get('hostMode') or \ + self.new_object.get('host_mode') + if self.new_object.get('increaseAccessSpeed') is not None or self.new_object.get('increase_access_speed') is not None: + new_object_params['increaseAccessSpeed'] = self.new_object.get('increaseAccessSpeed') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: - new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ - self.new_object.get('radius_servers') if self.new_object.get('radius') is not None or self.new_object.get('radius') is not None: new_object_params['radius'] = self.new_object.get('radius') or \ self.new_object.get('radius') - if self.new_object.get('guestPortBouncing') is not None or self.new_object.get('guest_port_bouncing') is not None: - new_object_params['guestPortBouncing'] = self.new_object.get( - 'guestPortBouncing') - if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: - new_object_params['radiusTestingEnabled'] = self.new_object.get( - 'radiusTestingEnabled') - if self.new_object.get('radiusCoaSupportEnabled') is not None or self.new_object.get('radius_coa_support_enabled') is not None: - new_object_params['radiusCoaSupportEnabled'] = self.new_object.get( - 'radiusCoaSupportEnabled') if self.new_object.get('radiusAccountingEnabled') is not None or self.new_object.get('radius_accounting_enabled') is not None: - new_object_params['radiusAccountingEnabled'] = self.new_object.get( - 'radiusAccountingEnabled') + new_object_params['radiusAccountingEnabled'] = self.new_object.get('radiusAccountingEnabled') if self.new_object.get('radiusAccountingServers') is not None or self.new_object.get('radius_accounting_servers') is not None: new_object_params['radiusAccountingServers'] = self.new_object.get('radiusAccountingServers') or \ self.new_object.get('radius_accounting_servers') + if self.new_object.get('radiusCoaSupportEnabled') is not None or self.new_object.get('radius_coa_support_enabled') is not None: + new_object_params['radiusCoaSupportEnabled'] = self.new_object.get('radiusCoaSupportEnabled') if self.new_object.get('radiusGroupAttribute') is not None or self.new_object.get('radius_group_attribute') is not None: new_object_params['radiusGroupAttribute'] = self.new_object.get('radiusGroupAttribute') or \ self.new_object.get('radius_group_attribute') - if self.new_object.get('hostMode') is not None or self.new_object.get('host_mode') is not None: - new_object_params['hostMode'] = self.new_object.get('hostMode') or \ - self.new_object.get('host_mode') - if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: - new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ - self.new_object.get('access_policy_type') - if self.new_object.get('increaseAccessSpeed') is not None or self.new_object.get('increase_access_speed') is not None: - new_object_params['increaseAccessSpeed'] = self.new_object.get( - 'increaseAccessSpeed') - if self.new_object.get('guestVlanId') is not None or self.new_object.get('guest_vlan_id') is not None: - new_object_params['guestVlanId'] = self.new_object.get('guestVlanId') or \ - self.new_object.get('guest_vlan_id') - if self.new_object.get('dot1x') is not None or self.new_object.get('dot1x') is not None: - new_object_params['dot1x'] = self.new_object.get('dot1x') or \ - self.new_object.get('dot1x') - if self.new_object.get('voiceVlanClients') is not None or self.new_object.get('voice_vlan_clients') is not None: - new_object_params['voiceVlanClients'] = self.new_object.get( - 'voiceVlanClients') + if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: + new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ + self.new_object.get('radius_servers') + if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: + new_object_params['radiusTestingEnabled'] = self.new_object.get('radiusTestingEnabled') if self.new_object.get('urlRedirectWalledGardenEnabled') is not None or self.new_object.get('url_redirect_walled_garden_enabled') is not None: - new_object_params['urlRedirectWalledGardenEnabled'] = self.new_object.get( - 'urlRedirectWalledGardenEnabled') + new_object_params['urlRedirectWalledGardenEnabled'] = self.new_object.get('urlRedirectWalledGardenEnabled') if self.new_object.get('urlRedirectWalledGardenRanges') is not None or self.new_object.get('url_redirect_walled_garden_ranges') is not None: new_object_params['urlRedirectWalledGardenRanges'] = self.new_object.get('urlRedirectWalledGardenRanges') or \ self.new_object.get('url_redirect_walled_garden_ranges') + if self.new_object.get('voiceVlanClients') is not None or self.new_object.get('voice_vlan_clients') is not None: + new_object_params['voiceVlanClients'] = self.new_object.get('voiceVlanClients') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -304,23 +288,23 @@ class NetworksSwitchAccessPolicies(object): requested_obj = self.new_object obj_params = [ + ("accessPolicyType", "accessPolicyType"), + ("dot1x", "dot1x"), + ("guestPortBouncing", "guestPortBouncing"), + ("guestVlanId", "guestVlanId"), + ("hostMode", "hostMode"), + ("increaseAccessSpeed", "increaseAccessSpeed"), ("name", "name"), - ("radiusServers", "radiusServers"), ("radius", "radius"), - ("guestPortBouncing", "guestPortBouncing"), - ("radiusTestingEnabled", "radiusTestingEnabled"), - ("radiusCoaSupportEnabled", "radiusCoaSupportEnabled"), ("radiusAccountingEnabled", "radiusAccountingEnabled"), ("radiusAccountingServers", "radiusAccountingServers"), + ("radiusCoaSupportEnabled", "radiusCoaSupportEnabled"), ("radiusGroupAttribute", "radiusGroupAttribute"), - ("hostMode", "hostMode"), - ("accessPolicyType", "accessPolicyType"), - ("increaseAccessSpeed", "increaseAccessSpeed"), - ("guestVlanId", "guestVlanId"), - ("dot1x", "dot1x"), - ("voiceVlanClients", "voiceVlanClients"), + ("radiusServers", "radiusServers"), + ("radiusTestingEnabled", "radiusTestingEnabled"), ("urlRedirectWalledGardenEnabled", "urlRedirectWalledGardenEnabled"), ("urlRedirectWalledGardenRanges", "urlRedirectWalledGardenRanges"), + ("voiceVlanClients", "voiceVlanClients"), ("networkId", "networkId"), ("accessPolicyNumber", "accessPolicyNumber"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_alternate_management_interface.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_alternate_management_interface.py index 7fd38d4f3..02d8d2c0c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_alternate_management_interface.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_alternate_management_interface.py @@ -33,9 +33,9 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), enabled=dict(type="bool"), - vlanId=dict(type="int"), protocols=dict(type="list"), switches=dict(type="list"), + vlanId=dict(type="int"), networkId=dict(type="str"), )) @@ -52,9 +52,9 @@ class NetworksSwitchAlternateManagementInterface(object): self.meraki = meraki self.new_object = dict( enabled=params.get("enabled"), - vlanId=params.get("vlanId"), protocols=params.get("protocols"), switches=params.get("switches"), + vlanId=params.get("vlanId"), network_id=params.get("networkId"), ) @@ -69,15 +69,15 @@ class NetworksSwitchAlternateManagementInterface(object): new_object_params = {} if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') if self.new_object.get('protocols') is not None or self.new_object.get('protocols') is not None: new_object_params['protocols'] = self.new_object.get('protocols') or \ self.new_object.get('protocols') if self.new_object.get('switches') is not None or self.new_object.get('switches') is not None: new_object_params['switches'] = self.new_object.get('switches') or \ self.new_object.get('switches') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -135,9 +135,9 @@ class NetworksSwitchAlternateManagementInterface(object): obj_params = [ ("enabled", "enabled"), - ("vlanId", "vlanId"), ("protocols", "protocols"), ("switches", "switches"), + ("vlanId", "vlanId"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy.py index 70dae83da..4e3434058 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy.py @@ -33,10 +33,10 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), alerts=dict(type="dict"), - defaultPolicy=dict(type="str"), allowedServers=dict(type="list"), - blockedServers=dict(type="list"), arpInspection=dict(type="dict"), + blockedServers=dict(type="list"), + defaultPolicy=dict(type="str"), networkId=dict(type="str"), )) @@ -53,10 +53,10 @@ class NetworksSwitchDhcpServerPolicy(object): self.meraki = meraki self.new_object = dict( alerts=params.get("alerts"), - defaultPolicy=params.get("defaultPolicy"), allowedServers=params.get("allowedServers"), - blockedServers=params.get("blockedServers"), arpInspection=params.get("arpInspection"), + blockedServers=params.get("blockedServers"), + defaultPolicy=params.get("defaultPolicy"), network_id=params.get("networkId"), ) @@ -72,18 +72,18 @@ class NetworksSwitchDhcpServerPolicy(object): if self.new_object.get('alerts') is not None or self.new_object.get('alerts') is not None: new_object_params['alerts'] = self.new_object.get('alerts') or \ self.new_object.get('alerts') - if self.new_object.get('defaultPolicy') is not None or self.new_object.get('default_policy') is not None: - new_object_params['defaultPolicy'] = self.new_object.get('defaultPolicy') or \ - self.new_object.get('default_policy') if self.new_object.get('allowedServers') is not None or self.new_object.get('allowed_servers') is not None: new_object_params['allowedServers'] = self.new_object.get('allowedServers') or \ self.new_object.get('allowed_servers') - if self.new_object.get('blockedServers') is not None or self.new_object.get('blocked_servers') is not None: - new_object_params['blockedServers'] = self.new_object.get('blockedServers') or \ - self.new_object.get('blocked_servers') if self.new_object.get('arpInspection') is not None or self.new_object.get('arp_inspection') is not None: new_object_params['arpInspection'] = self.new_object.get('arpInspection') or \ self.new_object.get('arp_inspection') + if self.new_object.get('blockedServers') is not None or self.new_object.get('blocked_servers') is not None: + new_object_params['blockedServers'] = self.new_object.get('blockedServers') or \ + self.new_object.get('blocked_servers') + if self.new_object.get('defaultPolicy') is not None or self.new_object.get('default_policy') is not None: + new_object_params['defaultPolicy'] = self.new_object.get('defaultPolicy') or \ + self.new_object.get('default_policy') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -141,10 +141,10 @@ class NetworksSwitchDhcpServerPolicy(object): obj_params = [ ("alerts", "alerts"), - ("defaultPolicy", "defaultPolicy"), ("allowedServers", "allowedServers"), - ("blockedServers", "blockedServers"), ("arpInspection", "arpInspection"), + ("blockedServers", "blockedServers"), + ("defaultPolicy", "defaultPolicy"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy_arp_inspection_trusted_servers.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy_arp_inspection_trusted_servers.py index d0bd4b120..e6110049d 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy_arp_inspection_trusted_servers.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_dhcp_server_policy_arp_inspection_trusted_servers.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + ipv4=dict(type="dict"), mac=dict(type="str"), vlan=dict(type="int"), - ipv4=dict(type="dict"), networkId=dict(type="str"), trustedServerId=dict(type="str"), )) @@ -52,9 +52,9 @@ class NetworksSwitchDhcpServerPolicyArpInspectionTrustedServers(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + ipv4=params.get("ipv4"), mac=params.get("mac"), vlan=params.get("vlan"), - ipv4=params.get("ipv4"), networkId=params.get("networkId"), trustedServerId=params.get("trustedServerId"), ) @@ -78,15 +78,15 @@ class NetworksSwitchDhcpServerPolicyArpInspectionTrustedServers(object): def create_params(self): new_object_params = {} + if self.new_object.get('ipv4') is not None or self.new_object.get('ipv4') is not None: + new_object_params['ipv4'] = self.new_object.get('ipv4') or \ + self.new_object.get('ipv4') if self.new_object.get('mac') is not None or self.new_object.get('mac') is not None: new_object_params['mac'] = self.new_object.get('mac') or \ self.new_object.get('mac') if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: new_object_params['vlan'] = self.new_object.get('vlan') or \ self.new_object.get('vlan') - if self.new_object.get('ipv4') is not None or self.new_object.get('ipv4') is not None: - new_object_params['ipv4'] = self.new_object.get('ipv4') or \ - self.new_object.get('ipv4') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -104,15 +104,15 @@ class NetworksSwitchDhcpServerPolicyArpInspectionTrustedServers(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('ipv4') is not None or self.new_object.get('ipv4') is not None: + new_object_params['ipv4'] = self.new_object.get('ipv4') or \ + self.new_object.get('ipv4') if self.new_object.get('mac') is not None or self.new_object.get('mac') is not None: new_object_params['mac'] = self.new_object.get('mac') or \ self.new_object.get('mac') if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: new_object_params['vlan'] = self.new_object.get('vlan') or \ self.new_object.get('vlan') - if self.new_object.get('ipv4') is not None or self.new_object.get('ipv4') is not None: - new_object_params['ipv4'] = self.new_object.get('ipv4') or \ - self.new_object.get('ipv4') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -189,9 +189,9 @@ class NetworksSwitchDhcpServerPolicyArpInspectionTrustedServers(object): requested_obj = self.new_object obj_params = [ + ("ipv4", "ipv4"), ("mac", "mac"), ("vlan", "vlan"), - ("ipv4", "ipv4"), ("networkId", "networkId"), ("trustedServerId", "trustedServerId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_qos_rules_order.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_qos_rules_order.py index 33841d11c..430d78211 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_qos_rules_order.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_qos_rules_order.py @@ -32,13 +32,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - vlan=dict(type="int"), + dscp=dict(type="int"), + dstPort=dict(type="int"), + dstPortRange=dict(type="str"), protocol=dict(type="str"), srcPort=dict(type="int"), srcPortRange=dict(type="str"), - dstPort=dict(type="int"), - dstPortRange=dict(type="str"), - dscp=dict(type="int"), + vlan=dict(type="int"), networkId=dict(type="str"), qosRuleId=dict(type="str"), )) @@ -56,13 +56,13 @@ class NetworksSwitchQosRulesOrder(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - vlan=params.get("vlan"), + dscp=params.get("dscp"), + dstPort=params.get("dstPort"), + dstPortRange=params.get("dstPortRange"), protocol=params.get("protocol"), srcPort=params.get("srcPort"), srcPortRange=params.get("srcPortRange"), - dstPort=params.get("dstPort"), - dstPortRange=params.get("dstPortRange"), - dscp=params.get("dscp"), + vlan=params.get("vlan"), networkId=params.get("networkId"), qosRuleId=params.get("qosRuleId"), ) @@ -86,9 +86,15 @@ class NetworksSwitchQosRulesOrder(object): def create_params(self): new_object_params = {} - if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: - new_object_params['vlan'] = self.new_object.get('vlan') or \ - self.new_object.get('vlan') + if self.new_object.get('dscp') is not None or self.new_object.get('dscp') is not None: + new_object_params['dscp'] = self.new_object.get('dscp') or \ + self.new_object.get('dscp') + if self.new_object.get('dstPort') is not None or self.new_object.get('dst_port') is not None: + new_object_params['dstPort'] = self.new_object.get('dstPort') or \ + self.new_object.get('dst_port') + if self.new_object.get('dstPortRange') is not None or self.new_object.get('dst_port_range') is not None: + new_object_params['dstPortRange'] = self.new_object.get('dstPortRange') or \ + self.new_object.get('dst_port_range') if self.new_object.get('protocol') is not None or self.new_object.get('protocol') is not None: new_object_params['protocol'] = self.new_object.get('protocol') or \ self.new_object.get('protocol') @@ -98,15 +104,9 @@ class NetworksSwitchQosRulesOrder(object): if self.new_object.get('srcPortRange') is not None or self.new_object.get('src_port_range') is not None: new_object_params['srcPortRange'] = self.new_object.get('srcPortRange') or \ self.new_object.get('src_port_range') - if self.new_object.get('dstPort') is not None or self.new_object.get('dst_port') is not None: - new_object_params['dstPort'] = self.new_object.get('dstPort') or \ - self.new_object.get('dst_port') - if self.new_object.get('dstPortRange') is not None or self.new_object.get('dst_port_range') is not None: - new_object_params['dstPortRange'] = self.new_object.get('dstPortRange') or \ - self.new_object.get('dst_port_range') - if self.new_object.get('dscp') is not None or self.new_object.get('dscp') is not None: - new_object_params['dscp'] = self.new_object.get('dscp') or \ - self.new_object.get('dscp') + if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: + new_object_params['vlan'] = self.new_object.get('vlan') or \ + self.new_object.get('vlan') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -124,9 +124,15 @@ class NetworksSwitchQosRulesOrder(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: - new_object_params['vlan'] = self.new_object.get('vlan') or \ - self.new_object.get('vlan') + if self.new_object.get('dscp') is not None or self.new_object.get('dscp') is not None: + new_object_params['dscp'] = self.new_object.get('dscp') or \ + self.new_object.get('dscp') + if self.new_object.get('dstPort') is not None or self.new_object.get('dst_port') is not None: + new_object_params['dstPort'] = self.new_object.get('dstPort') or \ + self.new_object.get('dst_port') + if self.new_object.get('dstPortRange') is not None or self.new_object.get('dst_port_range') is not None: + new_object_params['dstPortRange'] = self.new_object.get('dstPortRange') or \ + self.new_object.get('dst_port_range') if self.new_object.get('protocol') is not None or self.new_object.get('protocol') is not None: new_object_params['protocol'] = self.new_object.get('protocol') or \ self.new_object.get('protocol') @@ -136,15 +142,9 @@ class NetworksSwitchQosRulesOrder(object): if self.new_object.get('srcPortRange') is not None or self.new_object.get('src_port_range') is not None: new_object_params['srcPortRange'] = self.new_object.get('srcPortRange') or \ self.new_object.get('src_port_range') - if self.new_object.get('dstPort') is not None or self.new_object.get('dst_port') is not None: - new_object_params['dstPort'] = self.new_object.get('dstPort') or \ - self.new_object.get('dst_port') - if self.new_object.get('dstPortRange') is not None or self.new_object.get('dst_port_range') is not None: - new_object_params['dstPortRange'] = self.new_object.get('dstPortRange') or \ - self.new_object.get('dst_port_range') - if self.new_object.get('dscp') is not None or self.new_object.get('dscp') is not None: - new_object_params['dscp'] = self.new_object.get('dscp') or \ - self.new_object.get('dscp') + if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: + new_object_params['vlan'] = self.new_object.get('vlan') or \ + self.new_object.get('vlan') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -222,13 +222,13 @@ class NetworksSwitchQosRulesOrder(object): requested_obj = self.new_object obj_params = [ - ("vlan", "vlan"), + ("dscp", "dscp"), + ("dstPort", "dstPort"), + ("dstPortRange", "dstPortRange"), ("protocol", "protocol"), ("srcPort", "srcPort"), ("srcPortRange", "srcPortRange"), - ("dstPort", "dstPort"), - ("dstPortRange", "dstPortRange"), - ("dscp", "dscp"), + ("vlan", "vlan"), ("networkId", "networkId"), ("qosRuleId", "qosRuleId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_routing_ospf.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_routing_ospf.py index ec0eed0ee..aa72b735c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_routing_ospf.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_routing_ospf.py @@ -32,13 +32,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + areas=dict(type="list"), + deadTimerInSeconds=dict(type="int"), enabled=dict(type="bool"), helloTimerInSeconds=dict(type="int"), - deadTimerInSeconds=dict(type="int"), - areas=dict(type="list"), - v3=dict(type="dict"), md5AuthenticationEnabled=dict(type="bool"), md5AuthenticationKey=dict(type="dict"), + v3=dict(type="dict"), networkId=dict(type="str"), )) @@ -54,13 +54,13 @@ class NetworksSwitchRoutingOspf(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + areas=params.get("areas"), + deadTimerInSeconds=params.get("deadTimerInSeconds"), enabled=params.get("enabled"), helloTimerInSeconds=params.get("helloTimerInSeconds"), - deadTimerInSeconds=params.get("deadTimerInSeconds"), - areas=params.get("areas"), - v3=params.get("v3"), md5AuthenticationEnabled=params.get("md5AuthenticationEnabled"), md5AuthenticationKey=params.get("md5AuthenticationKey"), + v3=params.get("v3"), network_id=params.get("networkId"), ) @@ -73,25 +73,25 @@ class NetworksSwitchRoutingOspf(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('areas') is not None or self.new_object.get('areas') is not None: + new_object_params['areas'] = self.new_object.get('areas') or \ + self.new_object.get('areas') + if self.new_object.get('deadTimerInSeconds') is not None or self.new_object.get('dead_timer_in_seconds') is not None: + new_object_params['deadTimerInSeconds'] = self.new_object.get('deadTimerInSeconds') or \ + self.new_object.get('dead_timer_in_seconds') if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('helloTimerInSeconds') is not None or self.new_object.get('hello_timer_in_seconds') is not None: new_object_params['helloTimerInSeconds'] = self.new_object.get('helloTimerInSeconds') or \ self.new_object.get('hello_timer_in_seconds') - if self.new_object.get('deadTimerInSeconds') is not None or self.new_object.get('dead_timer_in_seconds') is not None: - new_object_params['deadTimerInSeconds'] = self.new_object.get('deadTimerInSeconds') or \ - self.new_object.get('dead_timer_in_seconds') - if self.new_object.get('areas') is not None or self.new_object.get('areas') is not None: - new_object_params['areas'] = self.new_object.get('areas') or \ - self.new_object.get('areas') - if self.new_object.get('v3') is not None or self.new_object.get('v3') is not None: - new_object_params['v3'] = self.new_object.get('v3') or \ - self.new_object.get('v3') if self.new_object.get('md5AuthenticationEnabled') is not None or self.new_object.get('md5_authentication_enabled') is not None: new_object_params['md5AuthenticationEnabled'] = self.new_object.get('md5AuthenticationEnabled') if self.new_object.get('md5AuthenticationKey') is not None or self.new_object.get('md5_authentication_key') is not None: new_object_params['md5AuthenticationKey'] = self.new_object.get('md5AuthenticationKey') or \ self.new_object.get('md5_authentication_key') + if self.new_object.get('v3') is not None or self.new_object.get('v3') is not None: + new_object_params['v3'] = self.new_object.get('v3') or \ + self.new_object.get('v3') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -148,13 +148,13 @@ class NetworksSwitchRoutingOspf(object): requested_obj = self.new_object obj_params = [ + ("areas", "areas"), + ("deadTimerInSeconds", "deadTimerInSeconds"), ("enabled", "enabled"), ("helloTimerInSeconds", "helloTimerInSeconds"), - ("deadTimerInSeconds", "deadTimerInSeconds"), - ("areas", "areas"), - ("v3", "v3"), ("md5AuthenticationEnabled", "md5AuthenticationEnabled"), ("md5AuthenticationKey", "md5AuthenticationKey"), + ("v3", "v3"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_settings.py index 65ae85bab..66664b957 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_settings.py @@ -32,9 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - vlan=dict(type="int"), - useCombinedPower=dict(type="bool"), + macBlocklist=dict(type="dict"), powerExceptions=dict(type="list"), + uplinkClientSampling=dict(type="dict"), + useCombinedPower=dict(type="bool"), + vlan=dict(type="int"), networkId=dict(type="str"), )) @@ -50,9 +52,11 @@ class NetworksSwitchSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - vlan=params.get("vlan"), - useCombinedPower=params.get("useCombinedPower"), + macBlocklist=params.get("macBlocklist"), powerExceptions=params.get("powerExceptions"), + uplinkClientSampling=params.get("uplinkClientSampling"), + useCombinedPower=params.get("useCombinedPower"), + vlan=params.get("vlan"), network_id=params.get("networkId"), ) @@ -65,14 +69,20 @@ class NetworksSwitchSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: - new_object_params['vlan'] = self.new_object.get('vlan') or \ - self.new_object.get('vlan') - if self.new_object.get('useCombinedPower') is not None or self.new_object.get('use_combined_power') is not None: - new_object_params['useCombinedPower'] = self.new_object.get('useCombinedPower') + if self.new_object.get('macBlocklist') is not None or self.new_object.get('mac_blocklist') is not None: + new_object_params['macBlocklist'] = self.new_object.get('macBlocklist') or \ + self.new_object.get('mac_blocklist') if self.new_object.get('powerExceptions') is not None or self.new_object.get('power_exceptions') is not None: new_object_params['powerExceptions'] = self.new_object.get('powerExceptions') or \ self.new_object.get('power_exceptions') + if self.new_object.get('uplinkClientSampling') is not None or self.new_object.get('uplink_client_sampling') is not None: + new_object_params['uplinkClientSampling'] = self.new_object.get('uplinkClientSampling') or \ + self.new_object.get('uplink_client_sampling') + if self.new_object.get('useCombinedPower') is not None or self.new_object.get('use_combined_power') is not None: + new_object_params['useCombinedPower'] = self.new_object.get('useCombinedPower') + if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: + new_object_params['vlan'] = self.new_object.get('vlan') or \ + self.new_object.get('vlan') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -129,9 +139,11 @@ class NetworksSwitchSettings(object): requested_obj = self.new_object obj_params = [ - ("vlan", "vlan"), - ("useCombinedPower", "useCombinedPower"), + ("macBlocklist", "macBlocklist"), ("powerExceptions", "powerExceptions"), + ("uplinkClientSampling", "uplinkClientSampling"), + ("useCombinedPower", "useCombinedPower"), + ("vlan", "vlan"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces.py index 948b77458..e126bce26 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces.py @@ -32,14 +32,14 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - subnet=dict(type="str"), + defaultGateway=dict(type="str"), interfaceIp=dict(type="str"), + ipv6=dict(type="dict"), multicastRouting=dict(type="str"), - vlanId=dict(type="int"), - defaultGateway=dict(type="str"), + name=dict(type="str"), ospfSettings=dict(type="dict"), - ipv6=dict(type="dict"), + subnet=dict(type="str"), + vlanId=dict(type="int"), networkId=dict(type="str"), switchStackId=dict(type="str"), interfaceId=dict(type="str"), @@ -58,14 +58,14 @@ class NetworksSwitchStacksRoutingInterfaces(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - subnet=params.get("subnet"), + defaultGateway=params.get("defaultGateway"), interfaceIp=params.get("interfaceIp"), + ipv6=params.get("ipv6"), multicastRouting=params.get("multicastRouting"), - vlanId=params.get("vlanId"), - defaultGateway=params.get("defaultGateway"), + name=params.get("name"), ospfSettings=params.get("ospfSettings"), - ipv6=params.get("ipv6"), + subnet=params.get("subnet"), + vlanId=params.get("vlanId"), networkId=params.get("networkId"), switchStackId=params.get("switchStackId"), interfaceId=params.get("interfaceId"), @@ -96,30 +96,30 @@ class NetworksSwitchStacksRoutingInterfaces(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') + if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: + new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ + self.new_object.get('default_gateway') if self.new_object.get('interfaceIp') is not None or self.new_object.get('interface_ip') is not None: new_object_params['interfaceIp'] = self.new_object.get('interfaceIp') or \ self.new_object.get('interface_ip') + if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: + new_object_params['ipv6'] = self.new_object.get('ipv6') or \ + self.new_object.get('ipv6') if self.new_object.get('multicastRouting') is not None or self.new_object.get('multicast_routing') is not None: new_object_params['multicastRouting'] = self.new_object.get('multicastRouting') or \ self.new_object.get('multicast_routing') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') - if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: - new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ - self.new_object.get('default_gateway') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('ospfSettings') is not None or self.new_object.get('ospf_settings') is not None: new_object_params['ospfSettings'] = self.new_object.get('ospfSettings') or \ self.new_object.get('ospf_settings') - if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: - new_object_params['ipv6'] = self.new_object.get('ipv6') or \ - self.new_object.get('ipv6') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -143,30 +143,30 @@ class NetworksSwitchStacksRoutingInterfaces(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') + if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: + new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ + self.new_object.get('default_gateway') if self.new_object.get('interfaceIp') is not None or self.new_object.get('interface_ip') is not None: new_object_params['interfaceIp'] = self.new_object.get('interfaceIp') or \ self.new_object.get('interface_ip') + if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: + new_object_params['ipv6'] = self.new_object.get('ipv6') or \ + self.new_object.get('ipv6') if self.new_object.get('multicastRouting') is not None or self.new_object.get('multicast_routing') is not None: new_object_params['multicastRouting'] = self.new_object.get('multicastRouting') or \ self.new_object.get('multicast_routing') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') - if self.new_object.get('defaultGateway') is not None or self.new_object.get('default_gateway') is not None: - new_object_params['defaultGateway'] = self.new_object.get('defaultGateway') or \ - self.new_object.get('default_gateway') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('ospfSettings') is not None or self.new_object.get('ospf_settings') is not None: new_object_params['ospfSettings'] = self.new_object.get('ospfSettings') or \ self.new_object.get('ospf_settings') - if self.new_object.get('ipv6') is not None or self.new_object.get('ipv6') is not None: - new_object_params['ipv6'] = self.new_object.get('ipv6') or \ - self.new_object.get('ipv6') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -247,14 +247,14 @@ class NetworksSwitchStacksRoutingInterfaces(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("subnet", "subnet"), + ("defaultGateway", "defaultGateway"), ("interfaceIp", "interfaceIp"), + ("ipv6", "ipv6"), ("multicastRouting", "multicastRouting"), - ("vlanId", "vlanId"), - ("defaultGateway", "defaultGateway"), + ("name", "name"), ("ospfSettings", "ospfSettings"), - ("ipv6", "ipv6"), + ("subnet", "subnet"), + ("vlanId", "vlanId"), ("networkId", "networkId"), ("switchStackId", "switchStackId"), ("interfaceId", "interfaceId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces_dhcp.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces_dhcp.py index 0127666a5..e1addc98e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces_dhcp.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_interfaces_dhcp.py @@ -32,17 +32,17 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + bootFileName=dict(type="str"), + bootNextServer=dict(type="str"), + bootOptionsEnabled=dict(type="bool"), + dhcpLeaseTime=dict(type="str"), dhcpMode=dict(type="str"), + dhcpOptions=dict(type="list"), dhcpRelayServerIps=dict(type="list"), - dhcpLeaseTime=dict(type="str"), - dnsNameserversOption=dict(type="str"), dnsCustomNameservers=dict(type="list"), - bootOptionsEnabled=dict(type="bool"), - bootNextServer=dict(type="str"), - bootFileName=dict(type="str"), - dhcpOptions=dict(type="list"), - reservedIpRanges=dict(type="list"), + dnsNameserversOption=dict(type="str"), fixedIpAssignments=dict(type="list"), + reservedIpRanges=dict(type="list"), networkId=dict(type="str"), switchStackId=dict(type="str"), interfaceId=dict(type="str"), @@ -60,17 +60,17 @@ class NetworksSwitchStacksRoutingInterfacesDhcp(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + bootFileName=params.get("bootFileName"), + bootNextServer=params.get("bootNextServer"), + bootOptionsEnabled=params.get("bootOptionsEnabled"), + dhcpLeaseTime=params.get("dhcpLeaseTime"), dhcpMode=params.get("dhcpMode"), + dhcpOptions=params.get("dhcpOptions"), dhcpRelayServerIps=params.get("dhcpRelayServerIps"), - dhcpLeaseTime=params.get("dhcpLeaseTime"), - dnsNameserversOption=params.get("dnsNameserversOption"), dnsCustomNameservers=params.get("dnsCustomNameservers"), - bootOptionsEnabled=params.get("bootOptionsEnabled"), - bootNextServer=params.get("bootNextServer"), - bootFileName=params.get("bootFileName"), - dhcpOptions=params.get("dhcpOptions"), - reservedIpRanges=params.get("reservedIpRanges"), + dnsNameserversOption=params.get("dnsNameserversOption"), fixedIpAssignments=params.get("fixedIpAssignments"), + reservedIpRanges=params.get("reservedIpRanges"), network_id=params.get("networkId"), switch_stack_id=params.get("switchStackId"), interface_id=params.get("interfaceId"), @@ -91,38 +91,38 @@ class NetworksSwitchStacksRoutingInterfacesDhcp(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('bootFileName') is not None or self.new_object.get('boot_file_name') is not None: + new_object_params['bootFileName'] = self.new_object.get('bootFileName') or \ + self.new_object.get('boot_file_name') + if self.new_object.get('bootNextServer') is not None or self.new_object.get('boot_next_server') is not None: + new_object_params['bootNextServer'] = self.new_object.get('bootNextServer') or \ + self.new_object.get('boot_next_server') + if self.new_object.get('bootOptionsEnabled') is not None or self.new_object.get('boot_options_enabled') is not None: + new_object_params['bootOptionsEnabled'] = self.new_object.get('bootOptionsEnabled') + if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: + new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ + self.new_object.get('dhcp_lease_time') if self.new_object.get('dhcpMode') is not None or self.new_object.get('dhcp_mode') is not None: new_object_params['dhcpMode'] = self.new_object.get('dhcpMode') or \ self.new_object.get('dhcp_mode') + if self.new_object.get('dhcpOptions') is not None or self.new_object.get('dhcp_options') is not None: + new_object_params['dhcpOptions'] = self.new_object.get('dhcpOptions') or \ + self.new_object.get('dhcp_options') if self.new_object.get('dhcpRelayServerIps') is not None or self.new_object.get('dhcp_relay_server_ips') is not None: new_object_params['dhcpRelayServerIps'] = self.new_object.get('dhcpRelayServerIps') or \ self.new_object.get('dhcp_relay_server_ips') - if self.new_object.get('dhcpLeaseTime') is not None or self.new_object.get('dhcp_lease_time') is not None: - new_object_params['dhcpLeaseTime'] = self.new_object.get('dhcpLeaseTime') or \ - self.new_object.get('dhcp_lease_time') - if self.new_object.get('dnsNameserversOption') is not None or self.new_object.get('dns_nameservers_option') is not None: - new_object_params['dnsNameserversOption'] = self.new_object.get('dnsNameserversOption') or \ - self.new_object.get('dns_nameservers_option') if self.new_object.get('dnsCustomNameservers') is not None or self.new_object.get('dns_custom_nameservers') is not None: new_object_params['dnsCustomNameservers'] = self.new_object.get('dnsCustomNameservers') or \ self.new_object.get('dns_custom_nameservers') - if self.new_object.get('bootOptionsEnabled') is not None or self.new_object.get('boot_options_enabled') is not None: - new_object_params['bootOptionsEnabled'] = self.new_object.get('bootOptionsEnabled') - if self.new_object.get('bootNextServer') is not None or self.new_object.get('boot_next_server') is not None: - new_object_params['bootNextServer'] = self.new_object.get('bootNextServer') or \ - self.new_object.get('boot_next_server') - if self.new_object.get('bootFileName') is not None or self.new_object.get('boot_file_name') is not None: - new_object_params['bootFileName'] = self.new_object.get('bootFileName') or \ - self.new_object.get('boot_file_name') - if self.new_object.get('dhcpOptions') is not None or self.new_object.get('dhcp_options') is not None: - new_object_params['dhcpOptions'] = self.new_object.get('dhcpOptions') or \ - self.new_object.get('dhcp_options') - if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: - new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ - self.new_object.get('reserved_ip_ranges') + if self.new_object.get('dnsNameserversOption') is not None or self.new_object.get('dns_nameservers_option') is not None: + new_object_params['dnsNameserversOption'] = self.new_object.get('dnsNameserversOption') or \ + self.new_object.get('dns_nameservers_option') if self.new_object.get('fixedIpAssignments') is not None or self.new_object.get('fixed_ip_assignments') is not None: new_object_params['fixedIpAssignments'] = self.new_object.get('fixedIpAssignments') or \ self.new_object.get('fixed_ip_assignments') + if self.new_object.get('reservedIpRanges') is not None or self.new_object.get('reserved_ip_ranges') is not None: + new_object_params['reservedIpRanges'] = self.new_object.get('reservedIpRanges') or \ + self.new_object.get('reserved_ip_ranges') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -185,17 +185,17 @@ class NetworksSwitchStacksRoutingInterfacesDhcp(object): requested_obj = self.new_object obj_params = [ + ("bootFileName", "bootFileName"), + ("bootNextServer", "bootNextServer"), + ("bootOptionsEnabled", "bootOptionsEnabled"), + ("dhcpLeaseTime", "dhcpLeaseTime"), ("dhcpMode", "dhcpMode"), + ("dhcpOptions", "dhcpOptions"), ("dhcpRelayServerIps", "dhcpRelayServerIps"), - ("dhcpLeaseTime", "dhcpLeaseTime"), - ("dnsNameserversOption", "dnsNameserversOption"), ("dnsCustomNameservers", "dnsCustomNameservers"), - ("bootOptionsEnabled", "bootOptionsEnabled"), - ("bootNextServer", "bootNextServer"), - ("bootFileName", "bootFileName"), - ("dhcpOptions", "dhcpOptions"), - ("reservedIpRanges", "reservedIpRanges"), + ("dnsNameserversOption", "dnsNameserversOption"), ("fixedIpAssignments", "fixedIpAssignments"), + ("reservedIpRanges", "reservedIpRanges"), ("networkId", "networkId"), ("switchStackId", "switchStackId"), ("interfaceId", "interfaceId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_static_routes.py b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_static_routes.py index 1ac473570..88d04e931 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_static_routes.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_switch_stacks_routing_static_routes.py @@ -32,11 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + advertiseViaOspfEnabled=dict(type="bool"), name=dict(type="str"), - subnet=dict(type="str"), nextHopIp=dict(type="str"), - advertiseViaOspfEnabled=dict(type="bool"), preferOverOspfRoutesEnabled=dict(type="bool"), + subnet=dict(type="str"), networkId=dict(type="str"), switchStackId=dict(type="str"), staticRouteId=dict(type="str"), @@ -55,11 +55,11 @@ class NetworksSwitchStacksRoutingStaticRoutes(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + advertiseViaOspfEnabled=params.get("advertiseViaOspfEnabled"), name=params.get("name"), - subnet=params.get("subnet"), nextHopIp=params.get("nextHopIp"), - advertiseViaOspfEnabled=params.get("advertiseViaOspfEnabled"), preferOverOspfRoutesEnabled=params.get("preferOverOspfRoutesEnabled"), + subnet=params.get("subnet"), networkId=params.get("networkId"), switchStackId=params.get("switchStackId"), staticRouteId=params.get("staticRouteId"), @@ -90,19 +90,19 @@ class NetworksSwitchStacksRoutingStaticRoutes(object): def create_params(self): new_object_params = {} + if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: + new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('nextHopIp') is not None or self.new_object.get('next_hop_ip') is not None: new_object_params['nextHopIp'] = self.new_object.get('nextHopIp') or \ self.new_object.get('next_hop_ip') - if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: - new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('preferOverOspfRoutesEnabled') is not None or self.new_object.get('prefer_over_ospf_routes_enabled') is not None: new_object_params['preferOverOspfRoutesEnabled'] = self.new_object.get('preferOverOspfRoutesEnabled') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -126,19 +126,19 @@ class NetworksSwitchStacksRoutingStaticRoutes(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: + new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: - new_object_params['subnet'] = self.new_object.get('subnet') or \ - self.new_object.get('subnet') if self.new_object.get('nextHopIp') is not None or self.new_object.get('next_hop_ip') is not None: new_object_params['nextHopIp'] = self.new_object.get('nextHopIp') or \ self.new_object.get('next_hop_ip') - if self.new_object.get('advertiseViaOspfEnabled') is not None or self.new_object.get('advertise_via_ospf_enabled') is not None: - new_object_params['advertiseViaOspfEnabled'] = self.new_object.get('advertiseViaOspfEnabled') if self.new_object.get('preferOverOspfRoutesEnabled') is not None or self.new_object.get('prefer_over_ospf_routes_enabled') is not None: new_object_params['preferOverOspfRoutesEnabled'] = self.new_object.get('preferOverOspfRoutesEnabled') + if self.new_object.get('subnet') is not None or self.new_object.get('subnet') is not None: + new_object_params['subnet'] = self.new_object.get('subnet') or \ + self.new_object.get('subnet') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -219,11 +219,11 @@ class NetworksSwitchStacksRoutingStaticRoutes(object): requested_obj = self.new_object obj_params = [ + ("advertiseViaOspfEnabled", "advertiseViaOspfEnabled"), ("name", "name"), - ("subnet", "subnet"), ("nextHopIp", "nextHopIp"), - ("advertiseViaOspfEnabled", "advertiseViaOspfEnabled"), ("preferOverOspfRoutesEnabled", "preferOverOspfRoutesEnabled"), + ("subnet", "subnet"), ("networkId", "networkId"), ("switchStackId", "switchStackId"), ("staticRouteId", "staticRouteId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_traffic_analysis.py b/ansible_collections/cisco/meraki/plugins/action/networks_traffic_analysis.py index eb815e34c..3a0362321 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_traffic_analysis.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_traffic_analysis.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - mode=dict(type="str"), customPieChartItems=dict(type="list"), + mode=dict(type="str"), networkId=dict(type="str"), )) @@ -49,8 +49,8 @@ class NetworksTrafficAnalysis(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - mode=params.get("mode"), customPieChartItems=params.get("customPieChartItems"), + mode=params.get("mode"), network_id=params.get("networkId"), ) @@ -63,12 +63,12 @@ class NetworksTrafficAnalysis(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: - new_object_params['mode'] = self.new_object.get('mode') or \ - self.new_object.get('mode') if self.new_object.get('customPieChartItems') is not None or self.new_object.get('custom_pie_chart_items') is not None: new_object_params['customPieChartItems'] = self.new_object.get('customPieChartItems') or \ self.new_object.get('custom_pie_chart_items') + if self.new_object.get('mode') is not None or self.new_object.get('mode') is not None: + new_object_params['mode'] = self.new_object.get('mode') or \ + self.new_object.get('mode') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -125,8 +125,8 @@ class NetworksTrafficAnalysis(object): requested_obj = self.new_object obj_params = [ - ("mode", "mode"), ("customPieChartItems", "customPieChartItems"), + ("mode", "mode"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles.py new file mode 100644 index 000000000..c92346bea --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles.py @@ -0,0 +1,260 @@ +#!/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, + meraki_compare_equality, + get_dict_result, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present", "absent"]), + name=dict(type="str"), + vlanGroups=dict(type="list"), + vlanNames=dict(type="list"), + networkId=dict(type="str"), + iname=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["iname", "name", "networkId"], True), + ("state", "absent", ["iname", "name", "networkId"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class NetworksVlanProfiles(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + name=params.get("name"), + vlanGroups=params.get("vlanGroups"), + vlanNames=params.get("vlanNames"), + network_id=params.get("networkId"), + iname=params.get("iname"), + ) + + def delete_by_name_params(self): + new_object_params = {} + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + if self.new_object.get('iname') is not None or self.new_object.get('iname') is not None: + new_object_params['iname'] = self.new_object.get('iname') or \ + self.new_object.get('iname') + return new_object_params + + def update_by_name_params(self): + new_object_params = {} + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('vlanGroups') is not None or self.new_object.get('vlan_groups') is not None: + new_object_params['vlanGroups'] = self.new_object.get('vlanGroups') or \ + self.new_object.get('vlan_groups') + if self.new_object.get('vlanNames') is not None or self.new_object.get('vlan_names') is not None: + new_object_params['vlanNames'] = self.new_object.get('vlanNames') or \ + self.new_object.get('vlan_names') + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + if self.new_object.get('iname') is not None or self.new_object.get('iname') is not None: + new_object_params['iname'] = self.new_object.get('iname') or \ + self.new_object.get('iname') + return new_object_params + + def get_object_by_name(self, name): + result = None + try: + items = self.meraki.exec_meraki( + family="networks", + function="getNetworkVlanProfile", + params={"iname": name} + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'iname', name) + except Exception: + result = None + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("networkId") or self.new_object.get("network_id") + name = self.new_object.get("name") + name = name or self.new_object.get("iname") + if o_id: + prev_obj = self.get_object_by_name(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if id_exists: + _name = prev_obj.get("name") + _name = _name or prev_obj.get("iname") + if _name: + self.new_object.update(dict(iname=_name)) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("name", "name"), + ("vlanGroups", "vlanGroups"), + ("vlanNames", "vlanNames"), + ("networkId", "networkId"), + ("iname", "iname"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def update(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + name = name or self.new_object.get("iname") + result = None + if not name: + prev_obj_id = self.get_object_by_id(id) + name_ = None + if prev_obj_id: + name_ = prev_obj_id.get("name") + name_ = name_ or prev_obj_id.get("iname") + if name_: + self.new_object.update(dict(iname=name_)) + result = self.meraki.exec_meraki( + family="networks", + function="updateNetworkVlanProfile", + params=self.update_by_name_params(), + op_modifies=True, + ) + return result + + def delete(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + name = name or self.new_object.get("iname") + result = None + if not name: + prev_obj_id = self.get_object_by_id(id) + name_ = None + if prev_obj_id: + name_ = prev_obj_id.get("name") + name_ = name_ or prev_obj_id.get("iname") + if name_: + self.new_object.update(dict(iname=name_)) + result = self.meraki.exec_meraki( + family="networks", + function="deleteNetworkVlanProfile", + params=self.delete_by_name_params(), + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = NetworksVlanProfiles(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + meraki.fail_json( + "Object does not exists, plugin only has update") + elif state == "absent": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + response = obj.delete() + meraki.object_deleted() + else: + meraki.object_already_absent() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_by_device_info.py new file mode 100644 index 000000000..2e386c0ab --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_by_device_info.py @@ -0,0 +1,120 @@ +#!/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"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + serials=dict(type="list"), + productTypes=dict(type="list"), + stackIds=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("networkId") is not None: + new_object["networkId"] = params.get( + "networkId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("productTypes") is not None: + new_object["productTypes"] = params.get( + "productTypes") + if params.get("stackIds") is not None: + new_object["stackIds"] = params.get( + "stackIds") + + 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) + + response = meraki.exec_meraki( + family="networks", + function='getNetworkVlanProfilesAssignmentsByDevice', + 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/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_reassign.py b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_reassign.py new file mode 100644 index 000000000..96cb0a3a1 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_assignments_reassign.py @@ -0,0 +1,93 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + serials=dict(type="list"), + stackIds=dict(type="list"), + vlanProfile=dict(type="dict"), + networkId=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 = False + 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 = dict( + serials=params.get("serials"), + stackIds=params.get("stackIds"), + vlanProfile=params.get("vlanProfile"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="networks", + function='reassignNetworkVlanProfilesAssignments', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_info.py new file mode 100644 index 000000000..74fa01c03 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_vlan_profiles_info.py @@ -0,0 +1,92 @@ +#!/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"), + iname=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 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) + + name = self._task.args.get("iname") + if name: + response = meraki.exec_meraki( + family="networks", + function='getNetworkVlanProfile', + 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 name: + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_http_servers.py b/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_http_servers.py index ef9a6d29d..a893960f6 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_http_servers.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_http_servers.py @@ -33,9 +33,9 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), name=dict(type="str"), - url=dict(type="str"), - sharedSecret=dict(type="str"), payloadTemplate=dict(type="dict"), + sharedSecret=dict(type="str"), + url=dict(type="str"), networkId=dict(type="str"), httpServerId=dict(type="str"), )) @@ -54,9 +54,9 @@ class NetworksWebhooksHttpServers(object): self.meraki = meraki self.new_object = dict( name=params.get("name"), - url=params.get("url"), - sharedSecret=params.get("sharedSecret"), payloadTemplate=params.get("payloadTemplate"), + sharedSecret=params.get("sharedSecret"), + url=params.get("url"), networkId=params.get("networkId"), httpServerId=params.get("httpServerId"), ) @@ -83,15 +83,15 @@ class NetworksWebhooksHttpServers(object): if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('url') is not None or self.new_object.get('url') is not None: - new_object_params['url'] = self.new_object.get('url') or \ - self.new_object.get('url') - if self.new_object.get('sharedSecret') is not None or self.new_object.get('shared_secret') is not None: - new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') or \ - self.new_object.get('shared_secret') if self.new_object.get('payloadTemplate') is not None or self.new_object.get('payload_template') is not None: new_object_params['payloadTemplate'] = self.new_object.get('payloadTemplate') or \ self.new_object.get('payload_template') + if self.new_object.get('sharedSecret') is not None or self.new_object.get('shared_secret') is not None: + new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') or \ + self.new_object.get('shared_secret') + if self.new_object.get('url') is not None or self.new_object.get('url') is not None: + new_object_params['url'] = self.new_object.get('url') or \ + self.new_object.get('url') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -112,12 +112,12 @@ class NetworksWebhooksHttpServers(object): if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') - if self.new_object.get('sharedSecret') is not None or self.new_object.get('shared_secret') is not None: - new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') or \ - self.new_object.get('shared_secret') if self.new_object.get('payloadTemplate') is not None or self.new_object.get('payload_template') is not None: new_object_params['payloadTemplate'] = self.new_object.get('payloadTemplate') or \ self.new_object.get('payload_template') + if self.new_object.get('sharedSecret') is not None or self.new_object.get('shared_secret') is not None: + new_object_params['sharedSecret'] = self.new_object.get('sharedSecret') or \ + self.new_object.get('shared_secret') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -196,9 +196,9 @@ class NetworksWebhooksHttpServers(object): obj_params = [ ("name", "name"), - ("url", "url"), - ("sharedSecret", "sharedSecret"), ("payloadTemplate", "payloadTemplate"), + ("sharedSecret", "sharedSecret"), + ("url", "url"), ("networkId", "networkId"), ("httpServerId", "httpServerId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_payload_templates.py b/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_payload_templates.py index 335a112bc..9f1b32936 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_payload_templates.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_webhooks_payload_templates.py @@ -32,11 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), body=dict(type="str"), - headers=dict(type="list"), bodyFile=dict(type="str"), + headers=dict(type="list"), headersFile=dict(type="str"), + name=dict(type="str"), networkId=dict(type="str"), payloadTemplateId=dict(type="str"), )) @@ -54,11 +54,11 @@ class NetworksWebhooksPayloadTemplates(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), body=params.get("body"), - headers=params.get("headers"), bodyFile=params.get("bodyFile"), + headers=params.get("headers"), headersFile=params.get("headersFile"), + name=params.get("name"), networkId=params.get("networkId"), payloadTemplateId=params.get("payloadTemplateId"), ) @@ -82,21 +82,21 @@ class NetworksWebhooksPayloadTemplates(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('body') is not None or self.new_object.get('body') is not None: new_object_params['body'] = self.new_object.get('body') or \ self.new_object.get('body') - if self.new_object.get('headers') is not None or self.new_object.get('headers') is not None: - new_object_params['headers'] = self.new_object.get('headers') or \ - self.new_object.get('headers') if self.new_object.get('bodyFile') is not None or self.new_object.get('body_file') is not None: new_object_params['bodyFile'] = self.new_object.get('bodyFile') or \ self.new_object.get('body_file') + if self.new_object.get('headers') is not None or self.new_object.get('headers') is not None: + new_object_params['headers'] = self.new_object.get('headers') or \ + self.new_object.get('headers') if self.new_object.get('headersFile') is not None or self.new_object.get('headers_file') is not None: new_object_params['headersFile'] = self.new_object.get('headersFile') or \ self.new_object.get('headers_file') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -114,21 +114,21 @@ class NetworksWebhooksPayloadTemplates(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('body') is not None or self.new_object.get('body') is not None: new_object_params['body'] = self.new_object.get('body') or \ self.new_object.get('body') - if self.new_object.get('headers') is not None or self.new_object.get('headers') is not None: - new_object_params['headers'] = self.new_object.get('headers') or \ - self.new_object.get('headers') if self.new_object.get('bodyFile') is not None or self.new_object.get('body_file') is not None: new_object_params['bodyFile'] = self.new_object.get('bodyFile') or \ self.new_object.get('body_file') + if self.new_object.get('headers') is not None or self.new_object.get('headers') is not None: + new_object_params['headers'] = self.new_object.get('headers') or \ + self.new_object.get('headers') if self.new_object.get('headersFile') is not None or self.new_object.get('headers_file') is not None: new_object_params['headersFile'] = self.new_object.get('headersFile') or \ self.new_object.get('headers_file') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -206,11 +206,11 @@ class NetworksWebhooksPayloadTemplates(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("body", "body"), - ("headers", "headers"), ("bodyFile", "bodyFile"), + ("headers", "headers"), ("headersFile", "headersFile"), + ("name", "name"), ("networkId", "networkId"), ("payloadTemplateId", "payloadTemplateId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_alternate_management_interface.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_alternate_management_interface.py index 899d9f264..f21ab1696 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_alternate_management_interface.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_alternate_management_interface.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + accessPoints=dict(type="list"), enabled=dict(type="bool"), - vlanId=dict(type="int"), protocols=dict(type="list"), - accessPoints=dict(type="list"), + vlanId=dict(type="int"), networkId=dict(type="str"), )) @@ -51,10 +51,10 @@ class NetworksWirelessAlternateManagementInterface(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + accessPoints=params.get("accessPoints"), enabled=params.get("enabled"), - vlanId=params.get("vlanId"), protocols=params.get("protocols"), - accessPoints=params.get("accessPoints"), + vlanId=params.get("vlanId"), network_id=params.get("networkId"), ) @@ -67,17 +67,17 @@ class NetworksWirelessAlternateManagementInterface(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('accessPoints') is not None or self.new_object.get('access_points') is not None: + new_object_params['accessPoints'] = self.new_object.get('accessPoints') or \ + self.new_object.get('access_points') if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: - new_object_params['vlanId'] = self.new_object.get('vlanId') or \ - self.new_object.get('vlan_id') if self.new_object.get('protocols') is not None or self.new_object.get('protocols') is not None: new_object_params['protocols'] = self.new_object.get('protocols') or \ self.new_object.get('protocols') - if self.new_object.get('accessPoints') is not None or self.new_object.get('access_points') is not None: - new_object_params['accessPoints'] = self.new_object.get('accessPoints') or \ - self.new_object.get('access_points') + if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: + new_object_params['vlanId'] = self.new_object.get('vlanId') or \ + self.new_object.get('vlan_id') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -134,10 +134,10 @@ class NetworksWirelessAlternateManagementInterface(object): requested_obj = self.new_object obj_params = [ + ("accessPoints", "accessPoints"), ("enabled", "enabled"), - ("vlanId", "vlanId"), ("protocols", "protocols"), - ("accessPoints", "accessPoints"), + ("vlanId", "vlanId"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_bluetooth_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_bluetooth_settings.py index 59f9f6c75..ea730674c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_bluetooth_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_bluetooth_settings.py @@ -32,12 +32,12 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - scanningEnabled=dict(type="bool"), advertisingEnabled=dict(type="bool"), - uuid=dict(type="str"), - majorMinorAssignmentMode=dict(type="str"), major=dict(type="int"), + majorMinorAssignmentMode=dict(type="str"), minor=dict(type="int"), + scanningEnabled=dict(type="bool"), + uuid=dict(type="str"), networkId=dict(type="str"), )) @@ -53,12 +53,12 @@ class NetworksWirelessBluetoothSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - scanningEnabled=params.get("scanningEnabled"), advertisingEnabled=params.get("advertisingEnabled"), - uuid=params.get("uuid"), - majorMinorAssignmentMode=params.get("majorMinorAssignmentMode"), major=params.get("major"), + majorMinorAssignmentMode=params.get("majorMinorAssignmentMode"), minor=params.get("minor"), + scanningEnabled=params.get("scanningEnabled"), + uuid=params.get("uuid"), network_id=params.get("networkId"), ) @@ -71,22 +71,22 @@ class NetworksWirelessBluetoothSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('scanningEnabled') is not None or self.new_object.get('scanning_enabled') is not None: - new_object_params['scanningEnabled'] = self.new_object.get('scanningEnabled') if self.new_object.get('advertisingEnabled') is not None or self.new_object.get('advertising_enabled') is not None: new_object_params['advertisingEnabled'] = self.new_object.get('advertisingEnabled') - if self.new_object.get('uuid') is not None or self.new_object.get('uuid') is not None: - new_object_params['uuid'] = self.new_object.get('uuid') or \ - self.new_object.get('uuid') - if self.new_object.get('majorMinorAssignmentMode') is not None or self.new_object.get('major_minor_assignment_mode') is not None: - new_object_params['majorMinorAssignmentMode'] = self.new_object.get('majorMinorAssignmentMode') or \ - self.new_object.get('major_minor_assignment_mode') if self.new_object.get('major') is not None or self.new_object.get('major') is not None: new_object_params['major'] = self.new_object.get('major') or \ self.new_object.get('major') + if self.new_object.get('majorMinorAssignmentMode') is not None or self.new_object.get('major_minor_assignment_mode') is not None: + new_object_params['majorMinorAssignmentMode'] = self.new_object.get('majorMinorAssignmentMode') or \ + self.new_object.get('major_minor_assignment_mode') if self.new_object.get('minor') is not None or self.new_object.get('minor') is not None: new_object_params['minor'] = self.new_object.get('minor') or \ self.new_object.get('minor') + if self.new_object.get('scanningEnabled') is not None or self.new_object.get('scanning_enabled') is not None: + new_object_params['scanningEnabled'] = self.new_object.get('scanningEnabled') + if self.new_object.get('uuid') is not None or self.new_object.get('uuid') is not None: + new_object_params['uuid'] = self.new_object.get('uuid') or \ + self.new_object.get('uuid') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -143,12 +143,12 @@ class NetworksWirelessBluetoothSettings(object): requested_obj = self.new_object obj_params = [ - ("scanningEnabled", "scanningEnabled"), ("advertisingEnabled", "advertisingEnabled"), - ("uuid", "uuid"), - ("majorMinorAssignmentMode", "majorMinorAssignmentMode"), ("major", "major"), + ("majorMinorAssignmentMode", "majorMinorAssignmentMode"), ("minor", "minor"), + ("scanningEnabled", "scanningEnabled"), + ("uuid", "uuid"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles.py new file mode 100644 index 000000000..fc95256a5 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles.py @@ -0,0 +1,270 @@ +#!/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, + meraki_compare_equality, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present", "absent"]), + name=dict(type="str"), + ports=dict(type="list"), + usbPorts=dict(type="list"), + networkId=dict(type="str"), + profileId=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["name", "networkId", "profileId"], True), + ("state", "absent", ["name", "networkId", "profileId"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class NetworksWirelessEthernetPortsProfiles(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + name=params.get("name"), + ports=params.get("ports"), + usbPorts=params.get("usbPorts"), + network_id=params.get("networkId"), + profile_id=params.get("profileId"), + ) + + def get_params_by_id(self, name=None, id=None): + new_object_params = {} + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + if self.new_object.get('profileId') is not None or self.new_object.get('profile_id') is not None: + new_object_params['profileId'] = self.new_object.get('profileId') or \ + self.new_object.get('profile_id') + return new_object_params + + def delete_by_id_params(self): + new_object_params = {} + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + if self.new_object.get('profileId') is not None or self.new_object.get('profile_id') is not None: + new_object_params['profileId'] = self.new_object.get('profileId') or \ + self.new_object.get('profile_id') + return new_object_params + + def update_by_id_params(self): + new_object_params = {} + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('ports') is not None or self.new_object.get('ports') is not None: + new_object_params['ports'] = self.new_object.get('ports') or \ + self.new_object.get('ports') + if self.new_object.get('usbPorts') is not None or self.new_object.get('usb_ports') is not None: + new_object_params['usbPorts'] = self.new_object.get('usbPorts') or \ + self.new_object.get('usb_ports') + if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: + new_object_params['networkId'] = self.new_object.get('networkId') or \ + self.new_object.get('network_id') + if self.new_object.get('profileId') is not None or self.new_object.get('profile_id') is not None: + new_object_params['profileId'] = self.new_object.get('profileId') or \ + self.new_object.get('profile_id') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name and get all + return result + + def get_object_by_id(self, id): + result = None + try: + items = self.meraki.exec_meraki( + family="wireless", + function="getNetworkWirelessEthernetPortsProfile", + params=self.get_params_by_id() + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = items + except Exception as e: + print("Error: ", e) + result = None + return result + + def exists(self): + prev_obj = None + id_exists = False + name_exists = False + o_id = self.new_object.get("networkId") or self.new_object.get("network_id") + o_id = o_id or self.new_object.get( + "profile_id") or self.new_object.get("profileId") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_id(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + _id = _id or prev_obj.get("profileId") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + self.new_object.update(dict(profileId=_id)) + if _id: + prev_obj = self.get_object_by_id(_id) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("name", "name"), + ("ports", "ports"), + ("usbPorts", "usbPorts"), + ("networkId", "networkId"), + ("profileId", "profileId"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def update(self): + id = self.new_object.get("id") + id = id or self.new_object.get("profileId") + name = self.new_object.get("name") + result = None + if not id: + prev_obj_name = self.get_object_by_name(name) + id_ = None + if prev_obj_name: + id_ = prev_obj_name.get("id") + id_ = id_ or prev_obj_name.get("profileId") + if id_: + self.new_object.update(dict(profileid=id_)) + result = self.meraki.exec_meraki( + family="wireless", + function="updateNetworkWirelessEthernetPortsProfile", + params=self.update_by_id_params(), + op_modifies=True, + ) + return result + + def delete(self): + id = self.new_object.get("id") + id = id or self.new_object.get("profileId") + name = self.new_object.get("name") + result = None + if not id: + prev_obj_name = self.get_object_by_name(name) + id_ = None + if prev_obj_name: + id_ = prev_obj_name.get("id") + id_ = id_ or prev_obj_name.get("profileId") + if id_: + self.new_object.update(dict(profileid=id_)) + result = self.meraki.exec_meraki( + family="wireless", + function="deleteNetworkWirelessEthernetPortsProfile", + params=self.delete_by_id_params(), + ) + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = NetworksWirelessEthernetPortsProfiles(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + meraki.fail_json( + "Object does not exists, plugin only has update") + elif state == "absent": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + response = obj.delete() + meraki.object_deleted() + else: + meraki.object_already_absent() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_assign.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_assign.py new file mode 100644 index 000000000..8e594fcae --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_assign.py @@ -0,0 +1,91 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + profileId=dict(type="str"), + serials=dict(type="list"), + networkId=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 = False + 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 = dict( + profileId=params.get("profileId"), + serials=params.get("serials"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="wireless", + function='assignNetworkWirelessEthernetPortsProfiles', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_info.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_info.py new file mode 100644 index 000000000..1bf4c8dee --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_info.py @@ -0,0 +1,102 @@ +#!/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"), + profileId=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("profileId") is not None: + new_object["profileId"] = params.get( + "profileId") + 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("profileId") + if id: + response = meraki.exec_meraki( + family="wireless", + function='getNetworkWirelessEthernetPortsProfile', + 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: + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_set_default.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_set_default.py new file mode 100644 index 000000000..1cccd7aa1 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ethernet_ports_profiles_set_default.py @@ -0,0 +1,89 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + profileId=dict(type="str"), + networkId=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 = False + 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 = dict( + profileId=params.get("profileId"), + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="wireless", + function='setNetworkWirelessEthernetPortsProfilesDefault', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_rf_profiles.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_rf_profiles.py index ad3f0d8ec..c4d650c4d 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_rf_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_rf_profiles.py @@ -32,16 +32,17 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - clientBalancingEnabled=dict(type="bool"), - minBitrateType=dict(type="str"), - bandSelectionType=dict(type="str"), apBandSettings=dict(type="dict"), - twoFourGhzSettings=dict(type="dict"), + bandSelectionType=dict(type="str"), + clientBalancingEnabled=dict(type="bool"), fiveGhzSettings=dict(type="dict"), + flexRadios=dict(type="dict"), + minBitrateType=dict(type="str"), + name=dict(type="str"), + perSsidSettings=dict(type="dict"), sixGhzSettings=dict(type="dict"), transmission=dict(type="dict"), - perSsidSettings=dict(type="dict"), + twoFourGhzSettings=dict(type="dict"), networkId=dict(type="str"), rfProfileId=dict(type="str"), )) @@ -59,16 +60,17 @@ class NetworksWirelessRfProfiles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - clientBalancingEnabled=params.get("clientBalancingEnabled"), - minBitrateType=params.get("minBitrateType"), - bandSelectionType=params.get("bandSelectionType"), apBandSettings=params.get("apBandSettings"), - twoFourGhzSettings=params.get("twoFourGhzSettings"), + bandSelectionType=params.get("bandSelectionType"), + clientBalancingEnabled=params.get("clientBalancingEnabled"), fiveGhzSettings=params.get("fiveGhzSettings"), + flexRadios=params.get("flexRadios"), + minBitrateType=params.get("minBitrateType"), + name=params.get("name"), + perSsidSettings=params.get("perSsidSettings"), sixGhzSettings=params.get("sixGhzSettings"), transmission=params.get("transmission"), - perSsidSettings=params.get("perSsidSettings"), + twoFourGhzSettings=params.get("twoFourGhzSettings"), networkId=params.get("networkId"), rfProfileId=params.get("rfProfileId"), ) @@ -95,35 +97,38 @@ class NetworksWirelessRfProfiles(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('clientBalancingEnabled') is not None or self.new_object.get('client_balancing_enabled') is not None: - new_object_params['clientBalancingEnabled'] = self.new_object.get('clientBalancingEnabled') - if self.new_object.get('minBitrateType') is not None or self.new_object.get('min_bitrate_type') is not None: - new_object_params['minBitrateType'] = self.new_object.get('minBitrateType') or \ - self.new_object.get('min_bitrate_type') - if self.new_object.get('bandSelectionType') is not None or self.new_object.get('band_selection_type') is not None: - new_object_params['bandSelectionType'] = self.new_object.get('bandSelectionType') or \ - self.new_object.get('band_selection_type') if self.new_object.get('apBandSettings') is not None or self.new_object.get('ap_band_settings') is not None: new_object_params['apBandSettings'] = self.new_object.get('apBandSettings') or \ self.new_object.get('ap_band_settings') - if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: - new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ - self.new_object.get('two_four_ghz_settings') + if self.new_object.get('bandSelectionType') is not None or self.new_object.get('band_selection_type') is not None: + new_object_params['bandSelectionType'] = self.new_object.get('bandSelectionType') or \ + self.new_object.get('band_selection_type') + if self.new_object.get('clientBalancingEnabled') is not None or self.new_object.get('client_balancing_enabled') is not None: + new_object_params['clientBalancingEnabled'] = self.new_object.get('clientBalancingEnabled') if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ self.new_object.get('five_ghz_settings') + if self.new_object.get('flexRadios') is not None or self.new_object.get('flex_radios') is not None: + new_object_params['flexRadios'] = self.new_object.get('flexRadios') or \ + self.new_object.get('flex_radios') + if self.new_object.get('minBitrateType') is not None or self.new_object.get('min_bitrate_type') is not None: + new_object_params['minBitrateType'] = self.new_object.get('minBitrateType') or \ + self.new_object.get('min_bitrate_type') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('perSsidSettings') is not None or self.new_object.get('per_ssid_settings') is not None: + new_object_params['perSsidSettings'] = self.new_object.get('perSsidSettings') or \ + self.new_object.get('per_ssid_settings') if self.new_object.get('sixGhzSettings') is not None or self.new_object.get('six_ghz_settings') is not None: new_object_params['sixGhzSettings'] = self.new_object.get('sixGhzSettings') or \ self.new_object.get('six_ghz_settings') if self.new_object.get('transmission') is not None or self.new_object.get('transmission') is not None: new_object_params['transmission'] = self.new_object.get('transmission') or \ self.new_object.get('transmission') - if self.new_object.get('perSsidSettings') is not None or self.new_object.get('per_ssid_settings') is not None: - new_object_params['perSsidSettings'] = self.new_object.get('perSsidSettings') or \ - self.new_object.get('per_ssid_settings') + if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: + new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ + self.new_object.get('two_four_ghz_settings') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -141,35 +146,38 @@ class NetworksWirelessRfProfiles(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('clientBalancingEnabled') is not None or self.new_object.get('client_balancing_enabled') is not None: - new_object_params['clientBalancingEnabled'] = self.new_object.get('clientBalancingEnabled') - if self.new_object.get('minBitrateType') is not None or self.new_object.get('min_bitrate_type') is not None: - new_object_params['minBitrateType'] = self.new_object.get('minBitrateType') or \ - self.new_object.get('min_bitrate_type') - if self.new_object.get('bandSelectionType') is not None or self.new_object.get('band_selection_type') is not None: - new_object_params['bandSelectionType'] = self.new_object.get('bandSelectionType') or \ - self.new_object.get('band_selection_type') if self.new_object.get('apBandSettings') is not None or self.new_object.get('ap_band_settings') is not None: new_object_params['apBandSettings'] = self.new_object.get('apBandSettings') or \ self.new_object.get('ap_band_settings') - if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: - new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ - self.new_object.get('two_four_ghz_settings') + if self.new_object.get('bandSelectionType') is not None or self.new_object.get('band_selection_type') is not None: + new_object_params['bandSelectionType'] = self.new_object.get('bandSelectionType') or \ + self.new_object.get('band_selection_type') + if self.new_object.get('clientBalancingEnabled') is not None or self.new_object.get('client_balancing_enabled') is not None: + new_object_params['clientBalancingEnabled'] = self.new_object.get('clientBalancingEnabled') if self.new_object.get('fiveGhzSettings') is not None or self.new_object.get('five_ghz_settings') is not None: new_object_params['fiveGhzSettings'] = self.new_object.get('fiveGhzSettings') or \ self.new_object.get('five_ghz_settings') + if self.new_object.get('flexRadios') is not None or self.new_object.get('flex_radios') is not None: + new_object_params['flexRadios'] = self.new_object.get('flexRadios') or \ + self.new_object.get('flex_radios') + if self.new_object.get('minBitrateType') is not None or self.new_object.get('min_bitrate_type') is not None: + new_object_params['minBitrateType'] = self.new_object.get('minBitrateType') or \ + self.new_object.get('min_bitrate_type') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('perSsidSettings') is not None or self.new_object.get('per_ssid_settings') is not None: + new_object_params['perSsidSettings'] = self.new_object.get('perSsidSettings') or \ + self.new_object.get('per_ssid_settings') if self.new_object.get('sixGhzSettings') is not None or self.new_object.get('six_ghz_settings') is not None: new_object_params['sixGhzSettings'] = self.new_object.get('sixGhzSettings') or \ self.new_object.get('six_ghz_settings') if self.new_object.get('transmission') is not None or self.new_object.get('transmission') is not None: new_object_params['transmission'] = self.new_object.get('transmission') or \ self.new_object.get('transmission') - if self.new_object.get('perSsidSettings') is not None or self.new_object.get('per_ssid_settings') is not None: - new_object_params['perSsidSettings'] = self.new_object.get('perSsidSettings') or \ - self.new_object.get('per_ssid_settings') + if self.new_object.get('twoFourGhzSettings') is not None or self.new_object.get('two_four_ghz_settings') is not None: + new_object_params['twoFourGhzSettings'] = self.new_object.get('twoFourGhzSettings') or \ + self.new_object.get('two_four_ghz_settings') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -247,16 +255,17 @@ class NetworksWirelessRfProfiles(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("clientBalancingEnabled", "clientBalancingEnabled"), - ("minBitrateType", "minBitrateType"), - ("bandSelectionType", "bandSelectionType"), ("apBandSettings", "apBandSettings"), - ("twoFourGhzSettings", "twoFourGhzSettings"), + ("bandSelectionType", "bandSelectionType"), + ("clientBalancingEnabled", "clientBalancingEnabled"), ("fiveGhzSettings", "fiveGhzSettings"), + ("flexRadios", "flexRadios"), + ("minBitrateType", "minBitrateType"), + ("name", "name"), + ("perSsidSettings", "perSsidSettings"), ("sixGhzSettings", "sixGhzSettings"), ("transmission", "transmission"), - ("perSsidSettings", "perSsidSettings"), + ("twoFourGhzSettings", "twoFourGhzSettings"), ("networkId", "networkId"), ("rfProfileId", "rfProfileId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_settings.py index 2a7543475..4fecff005 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_settings.py @@ -32,11 +32,12 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - meshingEnabled=dict(type="bool"), ipv6BridgeEnabled=dict(type="bool"), + ledLightsOn=dict(type="bool"), locationAnalyticsEnabled=dict(type="bool"), + meshingEnabled=dict(type="bool"), + namedVlans=dict(type="dict"), upgradeStrategy=dict(type="str"), - ledLightsOn=dict(type="bool"), networkId=dict(type="str"), )) @@ -52,11 +53,12 @@ class NetworksWirelessSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - meshingEnabled=params.get("meshingEnabled"), ipv6BridgeEnabled=params.get("ipv6BridgeEnabled"), + ledLightsOn=params.get("ledLightsOn"), locationAnalyticsEnabled=params.get("locationAnalyticsEnabled"), + meshingEnabled=params.get("meshingEnabled"), + namedVlans=params.get("namedVlans"), upgradeStrategy=params.get("upgradeStrategy"), - ledLightsOn=params.get("ledLightsOn"), network_id=params.get("networkId"), ) @@ -69,17 +71,20 @@ class NetworksWirelessSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('meshingEnabled') is not None or self.new_object.get('meshing_enabled') is not None: - new_object_params['meshingEnabled'] = self.new_object.get('meshingEnabled') if self.new_object.get('ipv6BridgeEnabled') is not None or self.new_object.get('ipv6_bridge_enabled') is not None: new_object_params['ipv6BridgeEnabled'] = self.new_object.get('ipv6BridgeEnabled') + if self.new_object.get('ledLightsOn') is not None or self.new_object.get('led_lights_on') is not None: + new_object_params['ledLightsOn'] = self.new_object.get('ledLightsOn') if self.new_object.get('locationAnalyticsEnabled') is not None or self.new_object.get('location_analytics_enabled') is not None: new_object_params['locationAnalyticsEnabled'] = self.new_object.get('locationAnalyticsEnabled') + if self.new_object.get('meshingEnabled') is not None or self.new_object.get('meshing_enabled') is not None: + new_object_params['meshingEnabled'] = self.new_object.get('meshingEnabled') + if self.new_object.get('namedVlans') is not None or self.new_object.get('named_vlans') is not None: + new_object_params['namedVlans'] = self.new_object.get('namedVlans') or \ + self.new_object.get('named_vlans') if self.new_object.get('upgradeStrategy') is not None or self.new_object.get('upgrade_strategy') is not None: new_object_params['upgradeStrategy'] = self.new_object.get('upgradeStrategy') or \ self.new_object.get('upgrade_strategy') - if self.new_object.get('ledLightsOn') is not None or self.new_object.get('led_lights_on') is not None: - new_object_params['ledLightsOn'] = self.new_object.get('ledLightsOn') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -136,11 +141,12 @@ class NetworksWirelessSettings(object): requested_obj = self.new_object obj_params = [ - ("meshingEnabled", "meshingEnabled"), ("ipv6BridgeEnabled", "ipv6BridgeEnabled"), + ("ledLightsOn", "ledLightsOn"), ("locationAnalyticsEnabled", "locationAnalyticsEnabled"), + ("meshingEnabled", "meshingEnabled"), + ("namedVlans", "namedVlans"), ("upgradeStrategy", "upgradeStrategy"), - ("ledLightsOn", "ledLightsOn"), ("networkId", "networkId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids.py index eb8affa88..24272855d 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids.py @@ -32,64 +32,65 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - name=dict(type="str"), - enabled=dict(type="bool"), + activeDirectory=dict(type="dict"), + adultContentFilteringEnabled=dict(type="bool"), + apTagsAndVlanIds=dict(type="list"), authMode=dict(type="str"), - enterpriseAdminAccess=dict(type="str"), - encryptionMode=dict(type="str"), - psk=dict(type="str"), - wpaEncryptionMode=dict(type="str"), - dot11w=dict(type="dict"), + availabilityTags=dict(type="list"), + availableOnAllAps=dict(type="bool"), + bandSelection=dict(type="str"), + concentratorNetworkId=dict(type="str"), + defaultVlanId=dict(type="int"), + disassociateClientsOnVpnFailover=dict(type="bool"), + dnsRewrite=dict(type="dict"), dot11r=dict(type="dict"), - splashPage=dict(type="str"), - splashGuestSponsorDomains=dict(type="list"), - oauth=dict(type="dict"), - localRadius=dict(type="dict"), + dot11w=dict(type="dict"), + enabled=dict(type="bool"), + encryptionMode=dict(type="str"), + enterpriseAdminAccess=dict(type="str"), + gre=dict(type="dict"), + ipAssignmentMode=dict(type="str"), + lanIsolationEnabled=dict(type="bool"), ldap=dict(type="dict"), - activeDirectory=dict(type="dict"), - radiusServers=dict(type="list"), - radiusProxyEnabled=dict(type="bool"), - radiusTestingEnabled=dict(type="bool"), - radiusCalledStationId=dict(type="str"), + localRadius=dict(type="dict"), + mandatoryDhcpEnabled=dict(type="bool"), + minBitrate=dict(type="float"), + name=dict(type="str"), + namedVlans=dict(type="dict"), + oauth=dict(type="dict"), + perClientBandwidthLimitDown=dict(type="int"), + perClientBandwidthLimitUp=dict(type="int"), + perSsidBandwidthLimitDown=dict(type="int"), + perSsidBandwidthLimitUp=dict(type="int"), + psk=dict(type="str"), + radiusAccountingEnabled=dict(type="bool"), + radiusAccountingInterimInterval=dict(type="int"), + radiusAccountingServers=dict(type="list"), + radiusAttributeForGroupPolicies=dict(type="str"), radiusAuthenticationNasId=dict(type="str"), - radiusServerTimeout=dict(type="int"), - radiusServerAttemptsLimit=dict(type="int"), - radiusFallbackEnabled=dict(type="bool"), + radiusCalledStationId=dict(type="str"), radiusCoaEnabled=dict(type="bool"), radiusFailoverPolicy=dict(type="str"), + radiusFallbackEnabled=dict(type="bool"), + radiusGuestVlanEnabled=dict(type="bool"), + radiusGuestVlanId=dict(type="int"), radiusLoadBalancingPolicy=dict(type="str"), - radiusAccountingEnabled=dict(type="bool"), - radiusAccountingServers=dict(type="list"), - radiusAccountingInterimInterval=dict(type="int"), - radiusAttributeForGroupPolicies=dict(type="str"), - ipAssignmentMode=dict(type="str"), - useVlanTagging=dict(type="bool"), - concentratorNetworkId=dict(type="str"), + radiusOverride=dict(type="bool"), + radiusProxyEnabled=dict(type="bool"), + radiusServerAttemptsLimit=dict(type="int"), + radiusServerTimeout=dict(type="int"), + radiusServers=dict(type="list"), + radiusTestingEnabled=dict(type="bool"), secondaryConcentratorNetworkId=dict(type="str"), - disassociateClientsOnVpnFailover=dict(type="bool"), + speedBurst=dict(type="dict"), + splashGuestSponsorDomains=dict(type="list"), + splashPage=dict(type="str"), + useVlanTagging=dict(type="bool"), + visible=dict(type="bool"), vlanId=dict(type="int"), - defaultVlanId=dict(type="int"), - apTagsAndVlanIds=dict(type="list"), walledGardenEnabled=dict(type="bool"), walledGardenRanges=dict(type="list"), - gre=dict(type="dict"), - radiusOverride=dict(type="bool"), - radiusGuestVlanEnabled=dict(type="bool"), - radiusGuestVlanId=dict(type="int"), - minBitrate=dict(type="float"), - bandSelection=dict(type="str"), - perClientBandwidthLimitUp=dict(type="int"), - perClientBandwidthLimitDown=dict(type="int"), - perSsidBandwidthLimitUp=dict(type="int"), - perSsidBandwidthLimitDown=dict(type="int"), - lanIsolationEnabled=dict(type="bool"), - visible=dict(type="bool"), - availableOnAllAps=dict(type="bool"), - availabilityTags=dict(type="list"), - mandatoryDhcpEnabled=dict(type="bool"), - adultContentFilteringEnabled=dict(type="bool"), - dnsRewrite=dict(type="dict"), - speedBurst=dict(type="dict"), + wpaEncryptionMode=dict(type="str"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -106,64 +107,65 @@ class NetworksWirelessSsids(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - enabled=params.get("enabled"), + activeDirectory=params.get("activeDirectory"), + adultContentFilteringEnabled=params.get("adultContentFilteringEnabled"), + apTagsAndVlanIds=params.get("apTagsAndVlanIds"), authMode=params.get("authMode"), - enterpriseAdminAccess=params.get("enterpriseAdminAccess"), - encryptionMode=params.get("encryptionMode"), - psk=params.get("psk"), - wpaEncryptionMode=params.get("wpaEncryptionMode"), - dot11w=params.get("dot11w"), + availabilityTags=params.get("availabilityTags"), + availableOnAllAps=params.get("availableOnAllAps"), + bandSelection=params.get("bandSelection"), + concentratorNetworkId=params.get("concentratorNetworkId"), + defaultVlanId=params.get("defaultVlanId"), + disassociateClientsOnVpnFailover=params.get("disassociateClientsOnVpnFailover"), + dnsRewrite=params.get("dnsRewrite"), dot11r=params.get("dot11r"), - splashPage=params.get("splashPage"), - splashGuestSponsorDomains=params.get("splashGuestSponsorDomains"), - oauth=params.get("oauth"), - localRadius=params.get("localRadius"), + dot11w=params.get("dot11w"), + enabled=params.get("enabled"), + encryptionMode=params.get("encryptionMode"), + enterpriseAdminAccess=params.get("enterpriseAdminAccess"), + gre=params.get("gre"), + ipAssignmentMode=params.get("ipAssignmentMode"), + lanIsolationEnabled=params.get("lanIsolationEnabled"), ldap=params.get("ldap"), - activeDirectory=params.get("activeDirectory"), - radiusServers=params.get("radiusServers"), - radiusProxyEnabled=params.get("radiusProxyEnabled"), - radiusTestingEnabled=params.get("radiusTestingEnabled"), - radiusCalledStationId=params.get("radiusCalledStationId"), + localRadius=params.get("localRadius"), + mandatoryDhcpEnabled=params.get("mandatoryDhcpEnabled"), + minBitrate=params.get("minBitrate"), + name=params.get("name"), + namedVlans=params.get("namedVlans"), + oauth=params.get("oauth"), + perClientBandwidthLimitDown=params.get("perClientBandwidthLimitDown"), + perClientBandwidthLimitUp=params.get("perClientBandwidthLimitUp"), + perSsidBandwidthLimitDown=params.get("perSsidBandwidthLimitDown"), + perSsidBandwidthLimitUp=params.get("perSsidBandwidthLimitUp"), + psk=params.get("psk"), + radiusAccountingEnabled=params.get("radiusAccountingEnabled"), + radiusAccountingInterimInterval=params.get("radiusAccountingInterimInterval"), + radiusAccountingServers=params.get("radiusAccountingServers"), + radiusAttributeForGroupPolicies=params.get("radiusAttributeForGroupPolicies"), radiusAuthenticationNasId=params.get("radiusAuthenticationNasId"), - radiusServerTimeout=params.get("radiusServerTimeout"), - radiusServerAttemptsLimit=params.get("radiusServerAttemptsLimit"), - radiusFallbackEnabled=params.get("radiusFallbackEnabled"), + radiusCalledStationId=params.get("radiusCalledStationId"), radiusCoaEnabled=params.get("radiusCoaEnabled"), radiusFailoverPolicy=params.get("radiusFailoverPolicy"), + radiusFallbackEnabled=params.get("radiusFallbackEnabled"), + radiusGuestVlanEnabled=params.get("radiusGuestVlanEnabled"), + radiusGuestVlanId=params.get("radiusGuestVlanId"), radiusLoadBalancingPolicy=params.get("radiusLoadBalancingPolicy"), - radiusAccountingEnabled=params.get("radiusAccountingEnabled"), - radiusAccountingServers=params.get("radiusAccountingServers"), - radiusAccountingInterimInterval=params.get("radiusAccountingInterimInterval"), - radiusAttributeForGroupPolicies=params.get("radiusAttributeForGroupPolicies"), - ipAssignmentMode=params.get("ipAssignmentMode"), - useVlanTagging=params.get("useVlanTagging"), - concentratorNetworkId=params.get("concentratorNetworkId"), + radiusOverride=params.get("radiusOverride"), + radiusProxyEnabled=params.get("radiusProxyEnabled"), + radiusServerAttemptsLimit=params.get("radiusServerAttemptsLimit"), + radiusServerTimeout=params.get("radiusServerTimeout"), + radiusServers=params.get("radiusServers"), + radiusTestingEnabled=params.get("radiusTestingEnabled"), secondaryConcentratorNetworkId=params.get("secondaryConcentratorNetworkId"), - disassociateClientsOnVpnFailover=params.get("disassociateClientsOnVpnFailover"), + speedBurst=params.get("speedBurst"), + splashGuestSponsorDomains=params.get("splashGuestSponsorDomains"), + splashPage=params.get("splashPage"), + useVlanTagging=params.get("useVlanTagging"), + visible=params.get("visible"), vlanId=params.get("vlanId"), - defaultVlanId=params.get("defaultVlanId"), - apTagsAndVlanIds=params.get("apTagsAndVlanIds"), walledGardenEnabled=params.get("walledGardenEnabled"), walledGardenRanges=params.get("walledGardenRanges"), - gre=params.get("gre"), - radiusOverride=params.get("radiusOverride"), - radiusGuestVlanEnabled=params.get("radiusGuestVlanEnabled"), - radiusGuestVlanId=params.get("radiusGuestVlanId"), - minBitrate=params.get("minBitrate"), - bandSelection=params.get("bandSelection"), - perClientBandwidthLimitUp=params.get("perClientBandwidthLimitUp"), - perClientBandwidthLimitDown=params.get("perClientBandwidthLimitDown"), - perSsidBandwidthLimitUp=params.get("perSsidBandwidthLimitUp"), - perSsidBandwidthLimitDown=params.get("perSsidBandwidthLimitDown"), - lanIsolationEnabled=params.get("lanIsolationEnabled"), - visible=params.get("visible"), - availableOnAllAps=params.get("availableOnAllAps"), - availabilityTags=params.get("availabilityTags"), - mandatoryDhcpEnabled=params.get("mandatoryDhcpEnabled"), - adultContentFilteringEnabled=params.get("adultContentFilteringEnabled"), - dnsRewrite=params.get("dnsRewrite"), - speedBurst=params.get("speedBurst"), + wpaEncryptionMode=params.get("wpaEncryptionMode"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -186,164 +188,167 @@ class NetworksWirelessSsids(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('activeDirectory') is not None or self.new_object.get('active_directory') is not None: + new_object_params['activeDirectory'] = self.new_object.get('activeDirectory') or \ + self.new_object.get('active_directory') + if self.new_object.get('adultContentFilteringEnabled') is not None or self.new_object.get('adult_content_filtering_enabled') is not None: + new_object_params['adultContentFilteringEnabled'] = self.new_object.get('adultContentFilteringEnabled') + if self.new_object.get('apTagsAndVlanIds') is not None or self.new_object.get('ap_tags_and_vlan_ids') is not None: + new_object_params['apTagsAndVlanIds'] = self.new_object.get('apTagsAndVlanIds') or \ + self.new_object.get('ap_tags_and_vlan_ids') if self.new_object.get('authMode') is not None or self.new_object.get('auth_mode') is not None: new_object_params['authMode'] = self.new_object.get('authMode') or \ self.new_object.get('auth_mode') - if self.new_object.get('enterpriseAdminAccess') is not None or self.new_object.get('enterprise_admin_access') is not None: - new_object_params['enterpriseAdminAccess'] = self.new_object.get('enterpriseAdminAccess') or \ - self.new_object.get('enterprise_admin_access') - if self.new_object.get('encryptionMode') is not None or self.new_object.get('encryption_mode') is not None: - new_object_params['encryptionMode'] = self.new_object.get('encryptionMode') or \ - self.new_object.get('encryption_mode') - if self.new_object.get('psk') is not None or self.new_object.get('psk') is not None: - new_object_params['psk'] = self.new_object.get('psk') or \ - self.new_object.get('psk') - if self.new_object.get('wpaEncryptionMode') is not None or self.new_object.get('wpa_encryption_mode') is not None: - new_object_params['wpaEncryptionMode'] = self.new_object.get('wpaEncryptionMode') or \ - self.new_object.get('wpa_encryption_mode') - if self.new_object.get('dot11w') is not None or self.new_object.get('dot11w') is not None: - new_object_params['dot11w'] = self.new_object.get('dot11w') or \ - self.new_object.get('dot11w') + if self.new_object.get('availabilityTags') is not None or self.new_object.get('availability_tags') is not None: + new_object_params['availabilityTags'] = self.new_object.get('availabilityTags') or \ + self.new_object.get('availability_tags') + if self.new_object.get('availableOnAllAps') is not None or self.new_object.get('available_on_all_aps') is not None: + new_object_params['availableOnAllAps'] = self.new_object.get('availableOnAllAps') + if self.new_object.get('bandSelection') is not None or self.new_object.get('band_selection') is not None: + new_object_params['bandSelection'] = self.new_object.get('bandSelection') or \ + self.new_object.get('band_selection') + if self.new_object.get('concentratorNetworkId') is not None or self.new_object.get('concentrator_network_id') is not None: + new_object_params['concentratorNetworkId'] = self.new_object.get('concentratorNetworkId') or \ + self.new_object.get('concentrator_network_id') + if self.new_object.get('defaultVlanId') is not None or self.new_object.get('default_vlan_id') is not None: + new_object_params['defaultVlanId'] = self.new_object.get('defaultVlanId') or \ + self.new_object.get('default_vlan_id') + if self.new_object.get('disassociateClientsOnVpnFailover') is not None or self.new_object.get('disassociate_clients_on_vpn_failover') is not None: + new_object_params['disassociateClientsOnVpnFailover'] = self.new_object.get('disassociateClientsOnVpnFailover') + if self.new_object.get('dnsRewrite') is not None or self.new_object.get('dns_rewrite') is not None: + new_object_params['dnsRewrite'] = self.new_object.get('dnsRewrite') or \ + self.new_object.get('dns_rewrite') if self.new_object.get('dot11r') is not None or self.new_object.get('dot11r') is not None: new_object_params['dot11r'] = self.new_object.get('dot11r') or \ self.new_object.get('dot11r') - if self.new_object.get('splashPage') is not None or self.new_object.get('splash_page') is not None: - new_object_params['splashPage'] = self.new_object.get('splashPage') or \ - self.new_object.get('splash_page') - if self.new_object.get('splashGuestSponsorDomains') is not None or self.new_object.get('splash_guest_sponsor_domains') is not None: - new_object_params['splashGuestSponsorDomains'] = self.new_object.get('splashGuestSponsorDomains') or \ - self.new_object.get('splash_guest_sponsor_domains') - if self.new_object.get('oauth') is not None or self.new_object.get('oauth') is not None: - new_object_params['oauth'] = self.new_object.get('oauth') or \ - self.new_object.get('oauth') - if self.new_object.get('localRadius') is not None or self.new_object.get('local_radius') is not None: - new_object_params['localRadius'] = self.new_object.get('localRadius') or \ - self.new_object.get('local_radius') + if self.new_object.get('dot11w') is not None or self.new_object.get('dot11w') is not None: + new_object_params['dot11w'] = self.new_object.get('dot11w') or \ + self.new_object.get('dot11w') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('encryptionMode') is not None or self.new_object.get('encryption_mode') is not None: + new_object_params['encryptionMode'] = self.new_object.get('encryptionMode') or \ + self.new_object.get('encryption_mode') + if self.new_object.get('enterpriseAdminAccess') is not None or self.new_object.get('enterprise_admin_access') is not None: + new_object_params['enterpriseAdminAccess'] = self.new_object.get('enterpriseAdminAccess') or \ + self.new_object.get('enterprise_admin_access') + if self.new_object.get('gre') is not None or self.new_object.get('gre') is not None: + new_object_params['gre'] = self.new_object.get('gre') or \ + self.new_object.get('gre') + if self.new_object.get('ipAssignmentMode') is not None or self.new_object.get('ip_assignment_mode') is not None: + new_object_params['ipAssignmentMode'] = self.new_object.get('ipAssignmentMode') or \ + self.new_object.get('ip_assignment_mode') + if self.new_object.get('lanIsolationEnabled') is not None or self.new_object.get('lan_isolation_enabled') is not None: + new_object_params['lanIsolationEnabled'] = self.new_object.get('lanIsolationEnabled') if self.new_object.get('ldap') is not None or self.new_object.get('ldap') is not None: new_object_params['ldap'] = self.new_object.get('ldap') or \ self.new_object.get('ldap') - if self.new_object.get('activeDirectory') is not None or self.new_object.get('active_directory') is not None: - new_object_params['activeDirectory'] = self.new_object.get('activeDirectory') or \ - self.new_object.get('active_directory') - if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: - new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ - self.new_object.get('radius_servers') - if self.new_object.get('radiusProxyEnabled') is not None or self.new_object.get('radius_proxy_enabled') is not None: - new_object_params['radiusProxyEnabled'] = self.new_object.get('radiusProxyEnabled') - if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: - new_object_params['radiusTestingEnabled'] = self.new_object.get('radiusTestingEnabled') - if self.new_object.get('radiusCalledStationId') is not None or self.new_object.get('radius_called_station_id') is not None: - new_object_params['radiusCalledStationId'] = self.new_object.get('radiusCalledStationId') or \ - self.new_object.get('radius_called_station_id') + if self.new_object.get('localRadius') is not None or self.new_object.get('local_radius') is not None: + new_object_params['localRadius'] = self.new_object.get('localRadius') or \ + self.new_object.get('local_radius') + if self.new_object.get('mandatoryDhcpEnabled') is not None or self.new_object.get('mandatory_dhcp_enabled') is not None: + new_object_params['mandatoryDhcpEnabled'] = self.new_object.get('mandatoryDhcpEnabled') + if self.new_object.get('minBitrate') is not None or self.new_object.get('min_bitrate') is not None: + new_object_params['minBitrate'] = self.new_object.get('minBitrate') or \ + self.new_object.get('min_bitrate') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('namedVlans') is not None or self.new_object.get('named_vlans') is not None: + new_object_params['namedVlans'] = self.new_object.get('namedVlans') or \ + self.new_object.get('named_vlans') + if self.new_object.get('oauth') is not None or self.new_object.get('oauth') is not None: + new_object_params['oauth'] = self.new_object.get('oauth') or \ + self.new_object.get('oauth') + if self.new_object.get('perClientBandwidthLimitDown') is not None or self.new_object.get('per_client_bandwidth_limit_down') is not None: + new_object_params['perClientBandwidthLimitDown'] = self.new_object.get('perClientBandwidthLimitDown') or \ + self.new_object.get('per_client_bandwidth_limit_down') + if self.new_object.get('perClientBandwidthLimitUp') is not None or self.new_object.get('per_client_bandwidth_limit_up') is not None: + new_object_params['perClientBandwidthLimitUp'] = self.new_object.get('perClientBandwidthLimitUp') or \ + self.new_object.get('per_client_bandwidth_limit_up') + if self.new_object.get('perSsidBandwidthLimitDown') is not None or self.new_object.get('per_ssid_bandwidth_limit_down') is not None: + new_object_params['perSsidBandwidthLimitDown'] = self.new_object.get('perSsidBandwidthLimitDown') or \ + self.new_object.get('per_ssid_bandwidth_limit_down') + if self.new_object.get('perSsidBandwidthLimitUp') is not None or self.new_object.get('per_ssid_bandwidth_limit_up') is not None: + new_object_params['perSsidBandwidthLimitUp'] = self.new_object.get('perSsidBandwidthLimitUp') or \ + self.new_object.get('per_ssid_bandwidth_limit_up') + if self.new_object.get('psk') is not None or self.new_object.get('psk') is not None: + new_object_params['psk'] = self.new_object.get('psk') or \ + self.new_object.get('psk') + if self.new_object.get('radiusAccountingEnabled') is not None or self.new_object.get('radius_accounting_enabled') is not None: + new_object_params['radiusAccountingEnabled'] = self.new_object.get('radiusAccountingEnabled') + if self.new_object.get('radiusAccountingInterimInterval') is not None or self.new_object.get('radius_accounting_interim_interval') is not None: + new_object_params['radiusAccountingInterimInterval'] = self.new_object.get('radiusAccountingInterimInterval') or \ + self.new_object.get('radius_accounting_interim_interval') + if self.new_object.get('radiusAccountingServers') is not None or self.new_object.get('radius_accounting_servers') is not None: + new_object_params['radiusAccountingServers'] = self.new_object.get('radiusAccountingServers') or \ + self.new_object.get('radius_accounting_servers') + if self.new_object.get('radiusAttributeForGroupPolicies') is not None or self.new_object.get('radius_attribute_for_group_policies') is not None: + new_object_params['radiusAttributeForGroupPolicies'] = self.new_object.get('radiusAttributeForGroupPolicies') or \ + self.new_object.get('radius_attribute_for_group_policies') if self.new_object.get('radiusAuthenticationNasId') is not None or self.new_object.get('radius_authentication_nas_id') is not None: new_object_params['radiusAuthenticationNasId'] = self.new_object.get('radiusAuthenticationNasId') or \ self.new_object.get('radius_authentication_nas_id') - if self.new_object.get('radiusServerTimeout') is not None or self.new_object.get('radius_server_timeout') is not None: - new_object_params['radiusServerTimeout'] = self.new_object.get('radiusServerTimeout') or \ - self.new_object.get('radius_server_timeout') - if self.new_object.get('radiusServerAttemptsLimit') is not None or self.new_object.get('radius_server_attempts_limit') is not None: - new_object_params['radiusServerAttemptsLimit'] = self.new_object.get('radiusServerAttemptsLimit') or \ - self.new_object.get('radius_server_attempts_limit') - if self.new_object.get('radiusFallbackEnabled') is not None or self.new_object.get('radius_fallback_enabled') is not None: - new_object_params['radiusFallbackEnabled'] = self.new_object.get('radiusFallbackEnabled') + if self.new_object.get('radiusCalledStationId') is not None or self.new_object.get('radius_called_station_id') is not None: + new_object_params['radiusCalledStationId'] = self.new_object.get('radiusCalledStationId') or \ + self.new_object.get('radius_called_station_id') if self.new_object.get('radiusCoaEnabled') is not None or self.new_object.get('radius_coa_enabled') is not None: new_object_params['radiusCoaEnabled'] = self.new_object.get('radiusCoaEnabled') if self.new_object.get('radiusFailoverPolicy') is not None or self.new_object.get('radius_failover_policy') is not None: new_object_params['radiusFailoverPolicy'] = self.new_object.get('radiusFailoverPolicy') or \ self.new_object.get('radius_failover_policy') + if self.new_object.get('radiusFallbackEnabled') is not None or self.new_object.get('radius_fallback_enabled') is not None: + new_object_params['radiusFallbackEnabled'] = self.new_object.get('radiusFallbackEnabled') + if self.new_object.get('radiusGuestVlanEnabled') is not None or self.new_object.get('radius_guest_vlan_enabled') is not None: + new_object_params['radiusGuestVlanEnabled'] = self.new_object.get('radiusGuestVlanEnabled') + if self.new_object.get('radiusGuestVlanId') is not None or self.new_object.get('radius_guest_vlan_id') is not None: + new_object_params['radiusGuestVlanId'] = self.new_object.get('radiusGuestVlanId') or \ + self.new_object.get('radius_guest_vlan_id') if self.new_object.get('radiusLoadBalancingPolicy') is not None or self.new_object.get('radius_load_balancing_policy') is not None: new_object_params['radiusLoadBalancingPolicy'] = self.new_object.get('radiusLoadBalancingPolicy') or \ self.new_object.get('radius_load_balancing_policy') - if self.new_object.get('radiusAccountingEnabled') is not None or self.new_object.get('radius_accounting_enabled') is not None: - new_object_params['radiusAccountingEnabled'] = self.new_object.get('radiusAccountingEnabled') - if self.new_object.get('radiusAccountingServers') is not None or self.new_object.get('radius_accounting_servers') is not None: - new_object_params['radiusAccountingServers'] = self.new_object.get('radiusAccountingServers') or \ - self.new_object.get('radius_accounting_servers') - if self.new_object.get('radiusAccountingInterimInterval') is not None or self.new_object.get('radius_accounting_interim_interval') is not None: - new_object_params['radiusAccountingInterimInterval'] = self.new_object.get('radiusAccountingInterimInterval') or \ - self.new_object.get('radius_accounting_interim_interval') - if self.new_object.get('radiusAttributeForGroupPolicies') is not None or self.new_object.get('radius_attribute_for_group_policies') is not None: - new_object_params['radiusAttributeForGroupPolicies'] = self.new_object.get('radiusAttributeForGroupPolicies') or \ - self.new_object.get('radius_attribute_for_group_policies') - if self.new_object.get('ipAssignmentMode') is not None or self.new_object.get('ip_assignment_mode') is not None: - new_object_params['ipAssignmentMode'] = self.new_object.get('ipAssignmentMode') or \ - self.new_object.get('ip_assignment_mode') - if self.new_object.get('useVlanTagging') is not None or self.new_object.get('use_vlan_tagging') is not None: - new_object_params['useVlanTagging'] = self.new_object.get('useVlanTagging') - if self.new_object.get('concentratorNetworkId') is not None or self.new_object.get('concentrator_network_id') is not None: - new_object_params['concentratorNetworkId'] = self.new_object.get('concentratorNetworkId') or \ - self.new_object.get('concentrator_network_id') + if self.new_object.get('radiusOverride') is not None or self.new_object.get('radius_override') is not None: + new_object_params['radiusOverride'] = self.new_object.get('radiusOverride') + if self.new_object.get('radiusProxyEnabled') is not None or self.new_object.get('radius_proxy_enabled') is not None: + new_object_params['radiusProxyEnabled'] = self.new_object.get('radiusProxyEnabled') + if self.new_object.get('radiusServerAttemptsLimit') is not None or self.new_object.get('radius_server_attempts_limit') is not None: + new_object_params['radiusServerAttemptsLimit'] = self.new_object.get('radiusServerAttemptsLimit') or \ + self.new_object.get('radius_server_attempts_limit') + if self.new_object.get('radiusServerTimeout') is not None or self.new_object.get('radius_server_timeout') is not None: + new_object_params['radiusServerTimeout'] = self.new_object.get('radiusServerTimeout') or \ + self.new_object.get('radius_server_timeout') + if self.new_object.get('radiusServers') is not None or self.new_object.get('radius_servers') is not None: + new_object_params['radiusServers'] = self.new_object.get('radiusServers') or \ + self.new_object.get('radius_servers') + if self.new_object.get('radiusTestingEnabled') is not None or self.new_object.get('radius_testing_enabled') is not None: + new_object_params['radiusTestingEnabled'] = self.new_object.get('radiusTestingEnabled') if self.new_object.get('secondaryConcentratorNetworkId') is not None or self.new_object.get('secondary_concentrator_network_id') is not None: new_object_params['secondaryConcentratorNetworkId'] = self.new_object.get('secondaryConcentratorNetworkId') or \ self.new_object.get('secondary_concentrator_network_id') - if self.new_object.get('disassociateClientsOnVpnFailover') is not None or self.new_object.get('disassociate_clients_on_vpn_failover') is not None: - new_object_params['disassociateClientsOnVpnFailover'] = self.new_object.get('disassociateClientsOnVpnFailover') + if self.new_object.get('speedBurst') is not None or self.new_object.get('speed_burst') is not None: + new_object_params['speedBurst'] = self.new_object.get('speedBurst') or \ + self.new_object.get('speed_burst') + if self.new_object.get('splashGuestSponsorDomains') is not None or self.new_object.get('splash_guest_sponsor_domains') is not None: + new_object_params['splashGuestSponsorDomains'] = self.new_object.get('splashGuestSponsorDomains') or \ + self.new_object.get('splash_guest_sponsor_domains') + if self.new_object.get('splashPage') is not None or self.new_object.get('splash_page') is not None: + new_object_params['splashPage'] = self.new_object.get('splashPage') or \ + self.new_object.get('splash_page') + if self.new_object.get('useVlanTagging') is not None or self.new_object.get('use_vlan_tagging') is not None: + new_object_params['useVlanTagging'] = self.new_object.get('useVlanTagging') + if self.new_object.get('visible') is not None or self.new_object.get('visible') is not None: + new_object_params['visible'] = self.new_object.get('visible') if self.new_object.get('vlanId') is not None or self.new_object.get('vlan_id') is not None: new_object_params['vlanId'] = self.new_object.get('vlanId') or \ self.new_object.get('vlan_id') - if self.new_object.get('defaultVlanId') is not None or self.new_object.get('default_vlan_id') is not None: - new_object_params['defaultVlanId'] = self.new_object.get('defaultVlanId') or \ - self.new_object.get('default_vlan_id') - if self.new_object.get('apTagsAndVlanIds') is not None or self.new_object.get('ap_tags_and_vlan_ids') is not None: - new_object_params['apTagsAndVlanIds'] = self.new_object.get('apTagsAndVlanIds') or \ - self.new_object.get('ap_tags_and_vlan_ids') if self.new_object.get('walledGardenEnabled') is not None or self.new_object.get('walled_garden_enabled') is not None: new_object_params['walledGardenEnabled'] = self.new_object.get('walledGardenEnabled') if self.new_object.get('walledGardenRanges') is not None or self.new_object.get('walled_garden_ranges') is not None: new_object_params['walledGardenRanges'] = self.new_object.get('walledGardenRanges') or \ self.new_object.get('walled_garden_ranges') - if self.new_object.get('gre') is not None or self.new_object.get('gre') is not None: - new_object_params['gre'] = self.new_object.get('gre') or \ - self.new_object.get('gre') - if self.new_object.get('radiusOverride') is not None or self.new_object.get('radius_override') is not None: - new_object_params['radiusOverride'] = self.new_object.get('radiusOverride') - if self.new_object.get('radiusGuestVlanEnabled') is not None or self.new_object.get('radius_guest_vlan_enabled') is not None: - new_object_params['radiusGuestVlanEnabled'] = self.new_object.get('radiusGuestVlanEnabled') - if self.new_object.get('radiusGuestVlanId') is not None or self.new_object.get('radius_guest_vlan_id') is not None: - new_object_params['radiusGuestVlanId'] = self.new_object.get('radiusGuestVlanId') or \ - self.new_object.get('radius_guest_vlan_id') - if self.new_object.get('minBitrate') is not None or self.new_object.get('min_bitrate') is not None: - new_object_params['minBitrate'] = self.new_object.get('minBitrate') or \ - self.new_object.get('min_bitrate') - if self.new_object.get('bandSelection') is not None or self.new_object.get('band_selection') is not None: - new_object_params['bandSelection'] = self.new_object.get('bandSelection') or \ - self.new_object.get('band_selection') - if self.new_object.get('perClientBandwidthLimitUp') is not None or self.new_object.get('per_client_bandwidth_limit_up') is not None: - new_object_params['perClientBandwidthLimitUp'] = self.new_object.get('perClientBandwidthLimitUp') or \ - self.new_object.get('per_client_bandwidth_limit_up') - if self.new_object.get('perClientBandwidthLimitDown') is not None or self.new_object.get('per_client_bandwidth_limit_down') is not None: - new_object_params['perClientBandwidthLimitDown'] = self.new_object.get('perClientBandwidthLimitDown') or \ - self.new_object.get('per_client_bandwidth_limit_down') - if self.new_object.get('perSsidBandwidthLimitUp') is not None or self.new_object.get('per_ssid_bandwidth_limit_up') is not None: - new_object_params['perSsidBandwidthLimitUp'] = self.new_object.get('perSsidBandwidthLimitUp') or \ - self.new_object.get('per_ssid_bandwidth_limit_up') - if self.new_object.get('perSsidBandwidthLimitDown') is not None or self.new_object.get('per_ssid_bandwidth_limit_down') is not None: - new_object_params['perSsidBandwidthLimitDown'] = self.new_object.get('perSsidBandwidthLimitDown') or \ - self.new_object.get('per_ssid_bandwidth_limit_down') - if self.new_object.get('lanIsolationEnabled') is not None or self.new_object.get('lan_isolation_enabled') is not None: - new_object_params['lanIsolationEnabled'] = self.new_object.get('lanIsolationEnabled') - if self.new_object.get('visible') is not None or self.new_object.get('visible') is not None: - new_object_params['visible'] = self.new_object.get('visible') - if self.new_object.get('availableOnAllAps') is not None or self.new_object.get('available_on_all_aps') is not None: - new_object_params['availableOnAllAps'] = self.new_object.get('availableOnAllAps') - if self.new_object.get('availabilityTags') is not None or self.new_object.get('availability_tags') is not None: - new_object_params['availabilityTags'] = self.new_object.get('availabilityTags') or \ - self.new_object.get('availability_tags') - if self.new_object.get('mandatoryDhcpEnabled') is not None or self.new_object.get('mandatory_dhcp_enabled') is not None: - new_object_params['mandatoryDhcpEnabled'] = self.new_object.get('mandatoryDhcpEnabled') - if self.new_object.get('adultContentFilteringEnabled') is not None or self.new_object.get('adult_content_filtering_enabled') is not None: - new_object_params['adultContentFilteringEnabled'] = self.new_object.get('adultContentFilteringEnabled') - if self.new_object.get('dnsRewrite') is not None or self.new_object.get('dns_rewrite') is not None: - new_object_params['dnsRewrite'] = self.new_object.get('dnsRewrite') or \ - self.new_object.get('dns_rewrite') - if self.new_object.get('speedBurst') is not None or self.new_object.get('speed_burst') is not None: - new_object_params['speedBurst'] = self.new_object.get('speedBurst') or \ - self.new_object.get('speed_burst') + if self.new_object.get('wpaEncryptionMode') is not None or self.new_object.get('wpa_encryption_mode') is not None: + new_object_params['wpaEncryptionMode'] = self.new_object.get('wpaEncryptionMode') or \ + self.new_object.get('wpa_encryption_mode') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -421,64 +426,65 @@ class NetworksWirelessSsids(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("enabled", "enabled"), + ("activeDirectory", "activeDirectory"), + ("adultContentFilteringEnabled", "adultContentFilteringEnabled"), + ("apTagsAndVlanIds", "apTagsAndVlanIds"), ("authMode", "authMode"), - ("enterpriseAdminAccess", "enterpriseAdminAccess"), - ("encryptionMode", "encryptionMode"), - ("psk", "psk"), - ("wpaEncryptionMode", "wpaEncryptionMode"), - ("dot11w", "dot11w"), + ("availabilityTags", "availabilityTags"), + ("availableOnAllAps", "availableOnAllAps"), + ("bandSelection", "bandSelection"), + ("concentratorNetworkId", "concentratorNetworkId"), + ("defaultVlanId", "defaultVlanId"), + ("disassociateClientsOnVpnFailover", "disassociateClientsOnVpnFailover"), + ("dnsRewrite", "dnsRewrite"), ("dot11r", "dot11r"), - ("splashPage", "splashPage"), - ("splashGuestSponsorDomains", "splashGuestSponsorDomains"), - ("oauth", "oauth"), - ("localRadius", "localRadius"), + ("dot11w", "dot11w"), + ("enabled", "enabled"), + ("encryptionMode", "encryptionMode"), + ("enterpriseAdminAccess", "enterpriseAdminAccess"), + ("gre", "gre"), + ("ipAssignmentMode", "ipAssignmentMode"), + ("lanIsolationEnabled", "lanIsolationEnabled"), ("ldap", "ldap"), - ("activeDirectory", "activeDirectory"), - ("radiusServers", "radiusServers"), - ("radiusProxyEnabled", "radiusProxyEnabled"), - ("radiusTestingEnabled", "radiusTestingEnabled"), - ("radiusCalledStationId", "radiusCalledStationId"), + ("localRadius", "localRadius"), + ("mandatoryDhcpEnabled", "mandatoryDhcpEnabled"), + ("minBitrate", "minBitrate"), + ("name", "name"), + ("namedVlans", "namedVlans"), + ("oauth", "oauth"), + ("perClientBandwidthLimitDown", "perClientBandwidthLimitDown"), + ("perClientBandwidthLimitUp", "perClientBandwidthLimitUp"), + ("perSsidBandwidthLimitDown", "perSsidBandwidthLimitDown"), + ("perSsidBandwidthLimitUp", "perSsidBandwidthLimitUp"), + ("psk", "psk"), + ("radiusAccountingEnabled", "radiusAccountingEnabled"), + ("radiusAccountingInterimInterval", "radiusAccountingInterimInterval"), + ("radiusAccountingServers", "radiusAccountingServers"), + ("radiusAttributeForGroupPolicies", "radiusAttributeForGroupPolicies"), ("radiusAuthenticationNasId", "radiusAuthenticationNasId"), - ("radiusServerTimeout", "radiusServerTimeout"), - ("radiusServerAttemptsLimit", "radiusServerAttemptsLimit"), - ("radiusFallbackEnabled", "radiusFallbackEnabled"), + ("radiusCalledStationId", "radiusCalledStationId"), ("radiusCoaEnabled", "radiusCoaEnabled"), ("radiusFailoverPolicy", "radiusFailoverPolicy"), + ("radiusFallbackEnabled", "radiusFallbackEnabled"), + ("radiusGuestVlanEnabled", "radiusGuestVlanEnabled"), + ("radiusGuestVlanId", "radiusGuestVlanId"), ("radiusLoadBalancingPolicy", "radiusLoadBalancingPolicy"), - ("radiusAccountingEnabled", "radiusAccountingEnabled"), - ("radiusAccountingServers", "radiusAccountingServers"), - ("radiusAccountingInterimInterval", "radiusAccountingInterimInterval"), - ("radiusAttributeForGroupPolicies", "radiusAttributeForGroupPolicies"), - ("ipAssignmentMode", "ipAssignmentMode"), - ("useVlanTagging", "useVlanTagging"), - ("concentratorNetworkId", "concentratorNetworkId"), + ("radiusOverride", "radiusOverride"), + ("radiusProxyEnabled", "radiusProxyEnabled"), + ("radiusServerAttemptsLimit", "radiusServerAttemptsLimit"), + ("radiusServerTimeout", "radiusServerTimeout"), + ("radiusServers", "radiusServers"), + ("radiusTestingEnabled", "radiusTestingEnabled"), ("secondaryConcentratorNetworkId", "secondaryConcentratorNetworkId"), - ("disassociateClientsOnVpnFailover", "disassociateClientsOnVpnFailover"), + ("speedBurst", "speedBurst"), + ("splashGuestSponsorDomains", "splashGuestSponsorDomains"), + ("splashPage", "splashPage"), + ("useVlanTagging", "useVlanTagging"), + ("visible", "visible"), ("vlanId", "vlanId"), - ("defaultVlanId", "defaultVlanId"), - ("apTagsAndVlanIds", "apTagsAndVlanIds"), ("walledGardenEnabled", "walledGardenEnabled"), ("walledGardenRanges", "walledGardenRanges"), - ("gre", "gre"), - ("radiusOverride", "radiusOverride"), - ("radiusGuestVlanEnabled", "radiusGuestVlanEnabled"), - ("radiusGuestVlanId", "radiusGuestVlanId"), - ("minBitrate", "minBitrate"), - ("bandSelection", "bandSelection"), - ("perClientBandwidthLimitUp", "perClientBandwidthLimitUp"), - ("perClientBandwidthLimitDown", "perClientBandwidthLimitDown"), - ("perSsidBandwidthLimitUp", "perSsidBandwidthLimitUp"), - ("perSsidBandwidthLimitDown", "perSsidBandwidthLimitDown"), - ("lanIsolationEnabled", "lanIsolationEnabled"), - ("visible", "visible"), - ("availableOnAllAps", "availableOnAllAps"), - ("availabilityTags", "availabilityTags"), - ("mandatoryDhcpEnabled", "mandatoryDhcpEnabled"), - ("adultContentFilteringEnabled", "adultContentFilteringEnabled"), - ("dnsRewrite", "dnsRewrite"), - ("speedBurst", "speedBurst"), + ("wpaEncryptionMode", "wpaEncryptionMode"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_bonjour_forwarding.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_bonjour_forwarding.py index 43f69849a..85a078a39 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_bonjour_forwarding.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_bonjour_forwarding.py @@ -33,6 +33,7 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), enabled=dict(type="bool"), + exception=dict(type="dict"), rules=dict(type="list"), networkId=dict(type="str"), number=dict(type="str"), @@ -51,6 +52,7 @@ class NetworksWirelessSsidsBonjourForwarding(object): self.meraki = meraki self.new_object = dict( enabled=params.get("enabled"), + exception=params.get("exception"), rules=params.get("rules"), network_id=params.get("networkId"), number=params.get("number"), @@ -69,6 +71,9 @@ class NetworksWirelessSsidsBonjourForwarding(object): new_object_params = {} if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('exception') is not None or self.new_object.get('exception') is not None: + new_object_params['exception'] = self.new_object.get('exception') or \ + self.new_object.get('exception') if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: new_object_params['rules'] = self.new_object.get('rules') or \ self.new_object.get('rules') @@ -132,6 +137,7 @@ class NetworksWirelessSsidsBonjourForwarding(object): obj_params = [ ("enabled", "enabled"), + ("exception", "exception"), ("rules", "rules"), ("networkId", "networkId"), ("number", "number"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_device_type_group_policies.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_device_type_group_policies.py index 7cc30fd3e..b3890afbe 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_device_type_group_policies.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_device_type_group_policies.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enabled=dict(type="bool"), deviceTypePolicies=dict(type="list"), + enabled=dict(type="bool"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -50,8 +50,8 @@ class NetworksWirelessSsidsDeviceTypeGroupPolicies(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enabled=params.get("enabled"), deviceTypePolicies=params.get("deviceTypePolicies"), + enabled=params.get("enabled"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -67,11 +67,11 @@ class NetworksWirelessSsidsDeviceTypeGroupPolicies(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('deviceTypePolicies') is not None or self.new_object.get('device_type_policies') is not None: new_object_params['deviceTypePolicies'] = self.new_object.get('deviceTypePolicies') or \ self.new_object.get('device_type_policies') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -131,8 +131,8 @@ class NetworksWirelessSsidsDeviceTypeGroupPolicies(object): requested_obj = self.new_object obj_params = [ - ("enabled", "enabled"), ("deviceTypePolicies", "deviceTypePolicies"), + ("enabled", "enabled"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_eap_override.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_eap_override.py index d0e924aaa..2d0748958 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_eap_override.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_eap_override.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - timeout=dict(type="int"), + eapolKey=dict(type="dict"), identity=dict(type="dict"), maxRetries=dict(type="int"), - eapolKey=dict(type="dict"), + timeout=dict(type="int"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -52,10 +52,10 @@ class NetworksWirelessSsidsEapOverride(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - timeout=params.get("timeout"), + eapolKey=params.get("eapolKey"), identity=params.get("identity"), maxRetries=params.get("maxRetries"), - eapolKey=params.get("eapolKey"), + timeout=params.get("timeout"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -71,18 +71,18 @@ class NetworksWirelessSsidsEapOverride(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('timeout') is not None or self.new_object.get('timeout') is not None: - new_object_params['timeout'] = self.new_object.get('timeout') or \ - self.new_object.get('timeout') + if self.new_object.get('eapolKey') is not None or self.new_object.get('eapol_key') is not None: + new_object_params['eapolKey'] = self.new_object.get('eapolKey') or \ + self.new_object.get('eapol_key') if self.new_object.get('identity') is not None or self.new_object.get('identity') is not None: new_object_params['identity'] = self.new_object.get('identity') or \ self.new_object.get('identity') if self.new_object.get('maxRetries') is not None or self.new_object.get('max_retries') is not None: new_object_params['maxRetries'] = self.new_object.get('maxRetries') or \ self.new_object.get('max_retries') - if self.new_object.get('eapolKey') is not None or self.new_object.get('eapol_key') is not None: - new_object_params['eapolKey'] = self.new_object.get('eapolKey') or \ - self.new_object.get('eapol_key') + if self.new_object.get('timeout') is not None or self.new_object.get('timeout') is not None: + new_object_params['timeout'] = self.new_object.get('timeout') or \ + self.new_object.get('timeout') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -142,10 +142,10 @@ class NetworksWirelessSsidsEapOverride(object): requested_obj = self.new_object obj_params = [ - ("timeout", "timeout"), + ("eapolKey", "eapolKey"), ("identity", "identity"), ("maxRetries", "maxRetries"), - ("eapolKey", "eapolKey"), + ("timeout", "timeout"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_firewall_l3_firewall_rules.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_firewall_l3_firewall_rules.py index 178967038..909fc147c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_firewall_l3_firewall_rules.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_firewall_l3_firewall_rules.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - rules=dict(type="list"), allowLanAccess=dict(type="bool"), + rules=dict(type="list"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -50,8 +50,8 @@ class NetworksWirelessSsidsFirewallL3FirewallRules(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - rules=params.get("rules"), allowLanAccess=params.get("allowLanAccess"), + rules=params.get("rules"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -67,11 +67,11 @@ class NetworksWirelessSsidsFirewallL3FirewallRules(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('allowLanAccess') is not None or self.new_object.get('allow_lan_access') is not None: + new_object_params['allowLanAccess'] = self.new_object.get('allowLanAccess') if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: new_object_params['rules'] = self.new_object.get('rules') or \ self.new_object.get('rules') - if self.new_object.get('allowLanAccess') is not None or self.new_object.get('allow_lan_access') is not None: - new_object_params['allowLanAccess'] = self.new_object.get('allowLanAccess') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -131,8 +131,8 @@ class NetworksWirelessSsidsFirewallL3FirewallRules(object): requested_obj = self.new_object obj_params = [ - ("rules", "rules"), ("allowLanAccess", "allowLanAccess"), + ("rules", "rules"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_hotspot20.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_hotspot20.py index 553ea6544..8efc94199 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_hotspot20.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_hotspot20.py @@ -32,14 +32,14 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enabled=dict(type="bool"), - operator=dict(type="dict"), - venue=dict(type="dict"), - networkAccessType=dict(type="str"), domains=dict(type="list"), - roamConsortOis=dict(type="list"), + enabled=dict(type="bool"), mccMncs=dict(type="list"), naiRealms=dict(type="list"), + networkAccessType=dict(type="str"), + operator=dict(type="dict"), + roamConsortOis=dict(type="list"), + venue=dict(type="dict"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -56,14 +56,14 @@ class NetworksWirelessSsidsHotspot20(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enabled=params.get("enabled"), - operator=params.get("operator"), - venue=params.get("venue"), - networkAccessType=params.get("networkAccessType"), domains=params.get("domains"), - roamConsortOis=params.get("roamConsortOis"), + enabled=params.get("enabled"), mccMncs=params.get("mccMncs"), naiRealms=params.get("naiRealms"), + networkAccessType=params.get("networkAccessType"), + operator=params.get("operator"), + roamConsortOis=params.get("roamConsortOis"), + venue=params.get("venue"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -79,29 +79,29 @@ class NetworksWirelessSsidsHotspot20(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('operator') is not None or self.new_object.get('operator') is not None: - new_object_params['operator'] = self.new_object.get('operator') or \ - self.new_object.get('operator') - if self.new_object.get('venue') is not None or self.new_object.get('venue') is not None: - new_object_params['venue'] = self.new_object.get('venue') or \ - self.new_object.get('venue') - if self.new_object.get('networkAccessType') is not None or self.new_object.get('network_access_type') is not None: - new_object_params['networkAccessType'] = self.new_object.get('networkAccessType') or \ - self.new_object.get('network_access_type') if self.new_object.get('domains') is not None or self.new_object.get('domains') is not None: new_object_params['domains'] = self.new_object.get('domains') or \ self.new_object.get('domains') - if self.new_object.get('roamConsortOis') is not None or self.new_object.get('roam_consort_ois') is not None: - new_object_params['roamConsortOis'] = self.new_object.get('roamConsortOis') or \ - self.new_object.get('roam_consort_ois') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('mccMncs') is not None or self.new_object.get('mcc_mncs') is not None: new_object_params['mccMncs'] = self.new_object.get('mccMncs') or \ self.new_object.get('mcc_mncs') if self.new_object.get('naiRealms') is not None or self.new_object.get('nai_realms') is not None: new_object_params['naiRealms'] = self.new_object.get('naiRealms') or \ self.new_object.get('nai_realms') + if self.new_object.get('networkAccessType') is not None or self.new_object.get('network_access_type') is not None: + new_object_params['networkAccessType'] = self.new_object.get('networkAccessType') or \ + self.new_object.get('network_access_type') + if self.new_object.get('operator') is not None or self.new_object.get('operator') is not None: + new_object_params['operator'] = self.new_object.get('operator') or \ + self.new_object.get('operator') + if self.new_object.get('roamConsortOis') is not None or self.new_object.get('roam_consort_ois') is not None: + new_object_params['roamConsortOis'] = self.new_object.get('roamConsortOis') or \ + self.new_object.get('roam_consort_ois') + if self.new_object.get('venue') is not None or self.new_object.get('venue') is not None: + new_object_params['venue'] = self.new_object.get('venue') or \ + self.new_object.get('venue') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -161,14 +161,14 @@ class NetworksWirelessSsidsHotspot20(object): requested_obj = self.new_object obj_params = [ - ("enabled", "enabled"), - ("operator", "operator"), - ("venue", "venue"), - ("networkAccessType", "networkAccessType"), ("domains", "domains"), - ("roamConsortOis", "roamConsortOis"), + ("enabled", "enabled"), ("mccMncs", "mccMncs"), ("naiRealms", "naiRealms"), + ("networkAccessType", "networkAccessType"), + ("operator", "operator"), + ("roamConsortOis", "roamConsortOis"), + ("venue", "venue"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_identity_psks.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_identity_psks.py index 266306851..995997893 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_identity_psks.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_identity_psks.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + expiresAt=dict(type="str"), + groupPolicyId=dict(type="str"), name=dict(type="str"), passphrase=dict(type="str"), - groupPolicyId=dict(type="str"), - expiresAt=dict(type="str"), networkId=dict(type="str"), number=dict(type="str"), identityPskId=dict(type="str"), @@ -54,10 +54,10 @@ class NetworksWirelessSsidsIdentityPsks(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + expiresAt=params.get("expiresAt"), + groupPolicyId=params.get("groupPolicyId"), name=params.get("name"), passphrase=params.get("passphrase"), - groupPolicyId=params.get("groupPolicyId"), - expiresAt=params.get("expiresAt"), networkId=params.get("networkId"), number=params.get("number"), identityPskId=params.get("identityPskId"), @@ -86,18 +86,18 @@ class NetworksWirelessSsidsIdentityPsks(object): def create_params(self): new_object_params = {} + if self.new_object.get('expiresAt') is not None or self.new_object.get('expires_at') is not None: + new_object_params['expiresAt'] = self.new_object.get('expiresAt') or \ + self.new_object.get('expires_at') + if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: + new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ + self.new_object.get('group_policy_id') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('passphrase') is not None or self.new_object.get('passphrase') is not None: new_object_params['passphrase'] = self.new_object.get('passphrase') or \ self.new_object.get('passphrase') - if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: - new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ - self.new_object.get('group_policy_id') - if self.new_object.get('expiresAt') is not None or self.new_object.get('expires_at') is not None: - new_object_params['expiresAt'] = self.new_object.get('expiresAt') or \ - self.new_object.get('expires_at') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -121,18 +121,18 @@ class NetworksWirelessSsidsIdentityPsks(object): def update_by_id_params(self): new_object_params = {} + if self.new_object.get('expiresAt') is not None or self.new_object.get('expires_at') is not None: + new_object_params['expiresAt'] = self.new_object.get('expiresAt') or \ + self.new_object.get('expires_at') + if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: + new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ + self.new_object.get('group_policy_id') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') if self.new_object.get('passphrase') is not None or self.new_object.get('passphrase') is not None: new_object_params['passphrase'] = self.new_object.get('passphrase') or \ self.new_object.get('passphrase') - if self.new_object.get('groupPolicyId') is not None or self.new_object.get('group_policy_id') is not None: - new_object_params['groupPolicyId'] = self.new_object.get('groupPolicyId') or \ - self.new_object.get('group_policy_id') - if self.new_object.get('expiresAt') is not None or self.new_object.get('expires_at') is not None: - new_object_params['expiresAt'] = self.new_object.get('expiresAt') or \ - self.new_object.get('expires_at') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -213,10 +213,10 @@ class NetworksWirelessSsidsIdentityPsks(object): requested_obj = self.new_object obj_params = [ + ("expiresAt", "expiresAt"), + ("groupPolicyId", "groupPolicyId"), ("name", "name"), ("passphrase", "passphrase"), - ("groupPolicyId", "groupPolicyId"), - ("expiresAt", "expiresAt"), ("networkId", "networkId"), ("number", "number"), ("identityPskId", "identityPskId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_splash_settings.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_splash_settings.py index 71989ade2..b062af863 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_splash_settings.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_splash_settings.py @@ -32,21 +32,22 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - splashUrl=dict(type="str"), - useSplashUrl=dict(type="bool"), - splashTimeout=dict(type="int"), - redirectUrl=dict(type="str"), - useRedirectUrl=dict(type="bool"), - welcomeMessage=dict(type="str"), - splashLogo=dict(type="dict"), - splashImage=dict(type="dict"), - splashPrepaidFront=dict(type="dict"), + allowSimultaneousLogins=dict(type="bool"), + billing=dict(type="dict"), blockAllTrafficBeforeSignOn=dict(type="bool"), controllerDisconnectionBehavior=dict(type="str"), - allowSimultaneousLogins=dict(type="bool"), guestSponsorship=dict(type="dict"), - billing=dict(type="dict"), + redirectUrl=dict(type="str"), sentryEnrollment=dict(type="dict"), + splashImage=dict(type="dict"), + splashLogo=dict(type="dict"), + splashPrepaidFront=dict(type="dict"), + splashTimeout=dict(type="int"), + splashUrl=dict(type="str"), + themeId=dict(type="str"), + useRedirectUrl=dict(type="bool"), + useSplashUrl=dict(type="bool"), + welcomeMessage=dict(type="str"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -63,21 +64,22 @@ class NetworksWirelessSsidsSplashSettings(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - splashUrl=params.get("splashUrl"), - useSplashUrl=params.get("useSplashUrl"), - splashTimeout=params.get("splashTimeout"), - redirectUrl=params.get("redirectUrl"), - useRedirectUrl=params.get("useRedirectUrl"), - welcomeMessage=params.get("welcomeMessage"), - splashLogo=params.get("splashLogo"), - splashImage=params.get("splashImage"), - splashPrepaidFront=params.get("splashPrepaidFront"), + allowSimultaneousLogins=params.get("allowSimultaneousLogins"), + billing=params.get("billing"), blockAllTrafficBeforeSignOn=params.get("blockAllTrafficBeforeSignOn"), controllerDisconnectionBehavior=params.get("controllerDisconnectionBehavior"), - allowSimultaneousLogins=params.get("allowSimultaneousLogins"), guestSponsorship=params.get("guestSponsorship"), - billing=params.get("billing"), + redirectUrl=params.get("redirectUrl"), sentryEnrollment=params.get("sentryEnrollment"), + splashImage=params.get("splashImage"), + splashLogo=params.get("splashLogo"), + splashPrepaidFront=params.get("splashPrepaidFront"), + splashTimeout=params.get("splashTimeout"), + splashUrl=params.get("splashUrl"), + themeId=params.get("themeId"), + useRedirectUrl=params.get("useRedirectUrl"), + useSplashUrl=params.get("useSplashUrl"), + welcomeMessage=params.get("welcomeMessage"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -93,47 +95,50 @@ class NetworksWirelessSsidsSplashSettings(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('splashUrl') is not None or self.new_object.get('splash_url') is not None: - new_object_params['splashUrl'] = self.new_object.get('splashUrl') or \ - self.new_object.get('splash_url') - if self.new_object.get('useSplashUrl') is not None or self.new_object.get('use_splash_url') is not None: - new_object_params['useSplashUrl'] = self.new_object.get('useSplashUrl') - if self.new_object.get('splashTimeout') is not None or self.new_object.get('splash_timeout') is not None: - new_object_params['splashTimeout'] = self.new_object.get('splashTimeout') or \ - self.new_object.get('splash_timeout') - if self.new_object.get('redirectUrl') is not None or self.new_object.get('redirect_url') is not None: - new_object_params['redirectUrl'] = self.new_object.get('redirectUrl') or \ - self.new_object.get('redirect_url') - if self.new_object.get('useRedirectUrl') is not None or self.new_object.get('use_redirect_url') is not None: - new_object_params['useRedirectUrl'] = self.new_object.get('useRedirectUrl') - if self.new_object.get('welcomeMessage') is not None or self.new_object.get('welcome_message') is not None: - new_object_params['welcomeMessage'] = self.new_object.get('welcomeMessage') or \ - self.new_object.get('welcome_message') - if self.new_object.get('splashLogo') is not None or self.new_object.get('splash_logo') is not None: - new_object_params['splashLogo'] = self.new_object.get('splashLogo') or \ - self.new_object.get('splash_logo') - if self.new_object.get('splashImage') is not None or self.new_object.get('splash_image') is not None: - new_object_params['splashImage'] = self.new_object.get('splashImage') or \ - self.new_object.get('splash_image') - if self.new_object.get('splashPrepaidFront') is not None or self.new_object.get('splash_prepaid_front') is not None: - new_object_params['splashPrepaidFront'] = self.new_object.get('splashPrepaidFront') or \ - self.new_object.get('splash_prepaid_front') + if self.new_object.get('allowSimultaneousLogins') is not None or self.new_object.get('allow_simultaneous_logins') is not None: + new_object_params['allowSimultaneousLogins'] = self.new_object.get('allowSimultaneousLogins') + if self.new_object.get('billing') is not None or self.new_object.get('billing') is not None: + new_object_params['billing'] = self.new_object.get('billing') or \ + self.new_object.get('billing') if self.new_object.get('blockAllTrafficBeforeSignOn') is not None or self.new_object.get('block_all_traffic_before_sign_on') is not None: new_object_params['blockAllTrafficBeforeSignOn'] = self.new_object.get('blockAllTrafficBeforeSignOn') if self.new_object.get('controllerDisconnectionBehavior') is not None or self.new_object.get('controller_disconnection_behavior') is not None: new_object_params['controllerDisconnectionBehavior'] = self.new_object.get('controllerDisconnectionBehavior') or \ self.new_object.get('controller_disconnection_behavior') - if self.new_object.get('allowSimultaneousLogins') is not None or self.new_object.get('allow_simultaneous_logins') is not None: - new_object_params['allowSimultaneousLogins'] = self.new_object.get('allowSimultaneousLogins') if self.new_object.get('guestSponsorship') is not None or self.new_object.get('guest_sponsorship') is not None: new_object_params['guestSponsorship'] = self.new_object.get('guestSponsorship') or \ self.new_object.get('guest_sponsorship') - if self.new_object.get('billing') is not None or self.new_object.get('billing') is not None: - new_object_params['billing'] = self.new_object.get('billing') or \ - self.new_object.get('billing') + if self.new_object.get('redirectUrl') is not None or self.new_object.get('redirect_url') is not None: + new_object_params['redirectUrl'] = self.new_object.get('redirectUrl') or \ + self.new_object.get('redirect_url') if self.new_object.get('sentryEnrollment') is not None or self.new_object.get('sentry_enrollment') is not None: new_object_params['sentryEnrollment'] = self.new_object.get('sentryEnrollment') or \ self.new_object.get('sentry_enrollment') + if self.new_object.get('splashImage') is not None or self.new_object.get('splash_image') is not None: + new_object_params['splashImage'] = self.new_object.get('splashImage') or \ + self.new_object.get('splash_image') + if self.new_object.get('splashLogo') is not None or self.new_object.get('splash_logo') is not None: + new_object_params['splashLogo'] = self.new_object.get('splashLogo') or \ + self.new_object.get('splash_logo') + if self.new_object.get('splashPrepaidFront') is not None or self.new_object.get('splash_prepaid_front') is not None: + new_object_params['splashPrepaidFront'] = self.new_object.get('splashPrepaidFront') or \ + self.new_object.get('splash_prepaid_front') + if self.new_object.get('splashTimeout') is not None or self.new_object.get('splash_timeout') is not None: + new_object_params['splashTimeout'] = self.new_object.get('splashTimeout') or \ + self.new_object.get('splash_timeout') + if self.new_object.get('splashUrl') is not None or self.new_object.get('splash_url') is not None: + new_object_params['splashUrl'] = self.new_object.get('splashUrl') or \ + self.new_object.get('splash_url') + if self.new_object.get('themeId') is not None or self.new_object.get('theme_id') is not None: + new_object_params['themeId'] = self.new_object.get('themeId') or \ + self.new_object.get('theme_id') + if self.new_object.get('useRedirectUrl') is not None or self.new_object.get('use_redirect_url') is not None: + new_object_params['useRedirectUrl'] = self.new_object.get('useRedirectUrl') + if self.new_object.get('useSplashUrl') is not None or self.new_object.get('use_splash_url') is not None: + new_object_params['useSplashUrl'] = self.new_object.get('useSplashUrl') + if self.new_object.get('welcomeMessage') is not None or self.new_object.get('welcome_message') is not None: + new_object_params['welcomeMessage'] = self.new_object.get('welcomeMessage') or \ + self.new_object.get('welcome_message') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -193,21 +198,22 @@ class NetworksWirelessSsidsSplashSettings(object): requested_obj = self.new_object obj_params = [ - ("splashUrl", "splashUrl"), - ("useSplashUrl", "useSplashUrl"), - ("splashTimeout", "splashTimeout"), - ("redirectUrl", "redirectUrl"), - ("useRedirectUrl", "useRedirectUrl"), - ("welcomeMessage", "welcomeMessage"), - ("splashLogo", "splashLogo"), - ("splashImage", "splashImage"), - ("splashPrepaidFront", "splashPrepaidFront"), + ("allowSimultaneousLogins", "allowSimultaneousLogins"), + ("billing", "billing"), ("blockAllTrafficBeforeSignOn", "blockAllTrafficBeforeSignOn"), ("controllerDisconnectionBehavior", "controllerDisconnectionBehavior"), - ("allowSimultaneousLogins", "allowSimultaneousLogins"), ("guestSponsorship", "guestSponsorship"), - ("billing", "billing"), + ("redirectUrl", "redirectUrl"), ("sentryEnrollment", "sentryEnrollment"), + ("splashImage", "splashImage"), + ("splashLogo", "splashLogo"), + ("splashPrepaidFront", "splashPrepaidFront"), + ("splashTimeout", "splashTimeout"), + ("splashUrl", "splashUrl"), + ("themeId", "themeId"), + ("useRedirectUrl", "useRedirectUrl"), + ("useSplashUrl", "useSplashUrl"), + ("welcomeMessage", "welcomeMessage"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_traffic_shaping_rules.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_traffic_shaping_rules.py index de13a0d80..bddddcbea 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_traffic_shaping_rules.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_traffic_shaping_rules.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - trafficShapingEnabled=dict(type="bool"), defaultRulesEnabled=dict(type="bool"), rules=dict(type="list"), + trafficShapingEnabled=dict(type="bool"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -51,9 +51,9 @@ class NetworksWirelessSsidsTrafficShapingRules(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - trafficShapingEnabled=params.get("trafficShapingEnabled"), defaultRulesEnabled=params.get("defaultRulesEnabled"), rules=params.get("rules"), + trafficShapingEnabled=params.get("trafficShapingEnabled"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -69,13 +69,13 @@ class NetworksWirelessSsidsTrafficShapingRules(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('trafficShapingEnabled') is not None or self.new_object.get('traffic_shaping_enabled') is not None: - new_object_params['trafficShapingEnabled'] = self.new_object.get('trafficShapingEnabled') if self.new_object.get('defaultRulesEnabled') is not None or self.new_object.get('default_rules_enabled') is not None: new_object_params['defaultRulesEnabled'] = self.new_object.get('defaultRulesEnabled') if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: new_object_params['rules'] = self.new_object.get('rules') or \ self.new_object.get('rules') + if self.new_object.get('trafficShapingEnabled') is not None or self.new_object.get('traffic_shaping_enabled') is not None: + new_object_params['trafficShapingEnabled'] = self.new_object.get('trafficShapingEnabled') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -135,9 +135,9 @@ class NetworksWirelessSsidsTrafficShapingRules(object): requested_obj = self.new_object obj_params = [ - ("trafficShapingEnabled", "trafficShapingEnabled"), ("defaultRulesEnabled", "defaultRulesEnabled"), ("rules", "rules"), + ("trafficShapingEnabled", "trafficShapingEnabled"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_vpn.py b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_vpn.py index cc3836353..a66830f81 100644 --- a/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_vpn.py +++ b/ansible_collections/cisco/meraki/plugins/action/networks_wireless_ssids_vpn.py @@ -33,8 +33,8 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), concentrator=dict(type="dict"), - splitTunnel=dict(type="dict"), failover=dict(type="dict"), + splitTunnel=dict(type="dict"), networkId=dict(type="str"), number=dict(type="str"), )) @@ -52,8 +52,8 @@ class NetworksWirelessSsidsVpn(object): self.meraki = meraki self.new_object = dict( concentrator=params.get("concentrator"), - splitTunnel=params.get("splitTunnel"), failover=params.get("failover"), + splitTunnel=params.get("splitTunnel"), network_id=params.get("networkId"), number=params.get("number"), ) @@ -72,12 +72,12 @@ class NetworksWirelessSsidsVpn(object): if self.new_object.get('concentrator') is not None or self.new_object.get('concentrator') is not None: new_object_params['concentrator'] = self.new_object.get('concentrator') or \ self.new_object.get('concentrator') - if self.new_object.get('splitTunnel') is not None or self.new_object.get('split_tunnel') is not None: - new_object_params['splitTunnel'] = self.new_object.get('splitTunnel') or \ - self.new_object.get('split_tunnel') if self.new_object.get('failover') is not None or self.new_object.get('failover') is not None: new_object_params['failover'] = self.new_object.get('failover') or \ self.new_object.get('failover') + if self.new_object.get('splitTunnel') is not None or self.new_object.get('split_tunnel') is not None: + new_object_params['splitTunnel'] = self.new_object.get('splitTunnel') or \ + self.new_object.get('split_tunnel') if self.new_object.get('networkId') is not None or self.new_object.get('network_id') is not None: new_object_params['networkId'] = self.new_object.get('networkId') or \ self.new_object.get('network_id') @@ -138,8 +138,8 @@ class NetworksWirelessSsidsVpn(object): obj_params = [ ("concentrator", "concentrator"), - ("splitTunnel", "splitTunnel"), ("failover", "failover"), + ("splitTunnel", "splitTunnel"), ("networkId", "networkId"), ("number", "number"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations.py b/ansible_collections/cisco/meraki/plugins/action/organizations.py index 0cb1670ef..410ebc37d 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), management=dict(type="dict"), + name=dict(type="str"), organizationId=dict(type="str"), api=dict(type="dict"), )) @@ -51,14 +51,24 @@ class Organizations(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), management=params.get("management"), + name=params.get("name"), organizationId=params.get("organizationId"), api=params.get("api"), ) def get_all_params(self, name=None, id=None): new_object_params = {} + if self.new_object.get('perPage') is not None or self.new_object.get('per_page') is not None: + new_object_params['perPage'] = self.new_object.get('perPage') or \ + self.new_object.get('per_page') + new_object_params['total_pages'] = -1 + if self.new_object.get('startingAfter') is not None or self.new_object.get('starting_after') is not None: + new_object_params['startingAfter'] = self.new_object.get('startingAfter') or \ + self.new_object.get('starting_after') + if self.new_object.get('endingBefore') is not None or self.new_object.get('ending_before') is not None: + new_object_params['endingBefore'] = self.new_object.get('endingBefore') or \ + self.new_object.get('ending_before') return new_object_params def get_params_by_id(self, name=None, id=None): @@ -70,12 +80,12 @@ class Organizations(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('management') is not None or self.new_object.get('management') is not None: new_object_params['management'] = self.new_object.get('management') or \ self.new_object.get('management') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') return new_object_params def delete_by_id_params(self): @@ -87,15 +97,15 @@ class Organizations(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('management') is not None or self.new_object.get('management') is not None: - new_object_params['management'] = self.new_object.get('management') or \ - self.new_object.get('management') if self.new_object.get('api') is not None or self.new_object.get('api') is not None: new_object_params['api'] = self.new_object.get('api') or \ self.new_object.get('api') + if self.new_object.get('management') is not None or self.new_object.get('management') is not None: + new_object_params['management'] = self.new_object.get('management') or \ + self.new_object.get('management') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -170,8 +180,8 @@ class Organizations(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("management", "management"), + ("name", "name"), ("organizationId", "organizationId"), ("api", "api"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_action_batches.py b/ansible_collections/cisco/meraki/plugins/action/organizations_action_batches.py index 8780b3e82..92a82e869 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_action_batches.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_action_batches.py @@ -32,9 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + actions=dict(type="list"), + callback=dict(type="dict"), confirmed=dict(type="bool"), synchronous=dict(type="bool"), - actions=dict(type="list"), organizationId=dict(type="str"), actionBatchId=dict(type="str"), )) @@ -52,9 +53,10 @@ class OrganizationsActionBatches(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + actions=params.get("actions"), + callback=params.get("callback"), confirmed=params.get("confirmed"), synchronous=params.get("synchronous"), - actions=params.get("actions"), organizationId=params.get("organizationId"), actionBatchId=params.get("actionBatchId"), ) @@ -80,13 +82,16 @@ class OrganizationsActionBatches(object): def create_params(self): new_object_params = {} + if self.new_object.get('actions') is not None or self.new_object.get('actions') is not None: + new_object_params['actions'] = self.new_object.get('actions') or \ + self.new_object.get('actions') + if self.new_object.get('callback') is not None or self.new_object.get('callback') is not None: + new_object_params['callback'] = self.new_object.get('callback') or \ + self.new_object.get('callback') if self.new_object.get('confirmed') is not None or self.new_object.get('confirmed') is not None: new_object_params['confirmed'] = self.new_object.get('confirmed') if self.new_object.get('synchronous') is not None or self.new_object.get('synchronous') is not None: new_object_params['synchronous'] = self.new_object.get('synchronous') - if self.new_object.get('actions') is not None or self.new_object.get('actions') is not None: - new_object_params['actions'] = self.new_object.get('actions') or \ - self.new_object.get('actions') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -185,9 +190,10 @@ class OrganizationsActionBatches(object): requested_obj = self.new_object obj_params = [ + ("actions", "actions"), + ("callback", "callback"), ("confirmed", "confirmed"), ("synchronous", "synchronous"), - ("actions", "actions"), ("organizationId", "organizationId"), ("actionBatchId", "actionBatchId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_acls.py b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_acls.py index cc445e11f..b5249443c 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_acls.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_acls.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), description=dict(type="str"), - rules=dict(type="list"), ipVersion=dict(type="str"), + name=dict(type="str"), + rules=dict(type="list"), organizationId=dict(type="str"), aclId=dict(type="str"), )) @@ -53,10 +53,10 @@ class OrganizationsAdaptivePolicyAcls(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), description=params.get("description"), - rules=params.get("rules"), ipVersion=params.get("ipVersion"), + name=params.get("name"), + rules=params.get("rules"), organizationId=params.get("organizationId"), aclId=params.get("aclId"), ) @@ -80,18 +80,18 @@ class OrganizationsAdaptivePolicyAcls(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') - if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: - new_object_params['rules'] = self.new_object.get('rules') or \ - self.new_object.get('rules') if self.new_object.get('ipVersion') is not None or self.new_object.get('ip_version') is not None: new_object_params['ipVersion'] = self.new_object.get('ipVersion') or \ self.new_object.get('ip_version') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: + new_object_params['rules'] = self.new_object.get('rules') or \ + self.new_object.get('rules') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -109,18 +109,18 @@ class OrganizationsAdaptivePolicyAcls(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') - if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: - new_object_params['rules'] = self.new_object.get('rules') or \ - self.new_object.get('rules') if self.new_object.get('ipVersion') is not None or self.new_object.get('ip_version') is not None: new_object_params['ipVersion'] = self.new_object.get('ipVersion') or \ self.new_object.get('ip_version') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('rules') is not None or self.new_object.get('rules') is not None: + new_object_params['rules'] = self.new_object.get('rules') or \ + self.new_object.get('rules') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -198,10 +198,10 @@ class OrganizationsAdaptivePolicyAcls(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("description", "description"), - ("rules", "rules"), ("ipVersion", "ipVersion"), + ("name", "name"), + ("rules", "rules"), ("organizationId", "organizationId"), ("aclId", "aclId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_groups.py b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_groups.py index f170a7ad0..7a871b57b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_groups.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_groups.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - sgt=dict(type="int"), description=dict(type="str"), + name=dict(type="str"), policyObjects=dict(type="list"), + sgt=dict(type="int"), organizationId=dict(type="str"), id=dict(type="str"), )) @@ -53,10 +53,10 @@ class OrganizationsAdaptivePolicyGroups(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - sgt=params.get("sgt"), description=params.get("description"), + name=params.get("name"), policyObjects=params.get("policyObjects"), + sgt=params.get("sgt"), organizationId=params.get("organizationId"), id=params.get("id"), ) @@ -79,18 +79,18 @@ class OrganizationsAdaptivePolicyGroups(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('sgt') is not None or self.new_object.get('sgt') is not None: - new_object_params['sgt'] = self.new_object.get('sgt') or \ - self.new_object.get('sgt') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('policyObjects') is not None or self.new_object.get('policy_objects') is not None: new_object_params['policyObjects'] = self.new_object.get('policyObjects') or \ self.new_object.get('policy_objects') + if self.new_object.get('sgt') is not None or self.new_object.get('sgt') is not None: + new_object_params['sgt'] = self.new_object.get('sgt') or \ + self.new_object.get('sgt') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -108,18 +108,18 @@ class OrganizationsAdaptivePolicyGroups(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('sgt') is not None or self.new_object.get('sgt') is not None: - new_object_params['sgt'] = self.new_object.get('sgt') or \ - self.new_object.get('sgt') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('policyObjects') is not None or self.new_object.get('policy_objects') is not None: new_object_params['policyObjects'] = self.new_object.get('policyObjects') or \ self.new_object.get('policy_objects') + if self.new_object.get('sgt') is not None or self.new_object.get('sgt') is not None: + new_object_params['sgt'] = self.new_object.get('sgt') or \ + self.new_object.get('sgt') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -193,10 +193,10 @@ class OrganizationsAdaptivePolicyGroups(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("sgt", "sgt"), ("description", "description"), + ("name", "name"), ("policyObjects", "policyObjects"), + ("sgt", "sgt"), ("organizationId", "organizationId"), ("id", "id"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_policies.py b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_policies.py index 9717b4aef..856b7ac16 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_policies.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_adaptive_policy_policies.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - sourceGroup=dict(type="dict"), - destinationGroup=dict(type="dict"), acls=dict(type="list"), + destinationGroup=dict(type="dict"), lastEntryRule=dict(type="str"), + sourceGroup=dict(type="dict"), organizationId=dict(type="str"), id=dict(type="str"), )) @@ -53,10 +53,10 @@ class OrganizationsAdaptivePolicyPolicies(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - sourceGroup=params.get("sourceGroup"), - destinationGroup=params.get("destinationGroup"), acls=params.get("acls"), + destinationGroup=params.get("destinationGroup"), lastEntryRule=params.get("lastEntryRule"), + sourceGroup=params.get("sourceGroup"), organizationId=params.get("organizationId"), id=params.get("id"), ) @@ -79,18 +79,18 @@ class OrganizationsAdaptivePolicyPolicies(object): def create_params(self): new_object_params = {} - if self.new_object.get('sourceGroup') is not None or self.new_object.get('source_group') is not None: - new_object_params['sourceGroup'] = self.new_object.get('sourceGroup') or \ - self.new_object.get('source_group') - if self.new_object.get('destinationGroup') is not None or self.new_object.get('destination_group') is not None: - new_object_params['destinationGroup'] = self.new_object.get('destinationGroup') or \ - self.new_object.get('destination_group') if self.new_object.get('acls') is not None or self.new_object.get('acls') is not None: new_object_params['acls'] = self.new_object.get('acls') or \ self.new_object.get('acls') + if self.new_object.get('destinationGroup') is not None or self.new_object.get('destination_group') is not None: + new_object_params['destinationGroup'] = self.new_object.get('destinationGroup') or \ + self.new_object.get('destination_group') if self.new_object.get('lastEntryRule') is not None or self.new_object.get('last_entry_rule') is not None: new_object_params['lastEntryRule'] = self.new_object.get('lastEntryRule') or \ self.new_object.get('last_entry_rule') + if self.new_object.get('sourceGroup') is not None or self.new_object.get('source_group') is not None: + new_object_params['sourceGroup'] = self.new_object.get('sourceGroup') or \ + self.new_object.get('source_group') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -108,18 +108,18 @@ class OrganizationsAdaptivePolicyPolicies(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('sourceGroup') is not None or self.new_object.get('source_group') is not None: - new_object_params['sourceGroup'] = self.new_object.get('sourceGroup') or \ - self.new_object.get('source_group') - if self.new_object.get('destinationGroup') is not None or self.new_object.get('destination_group') is not None: - new_object_params['destinationGroup'] = self.new_object.get('destinationGroup') or \ - self.new_object.get('destination_group') if self.new_object.get('acls') is not None or self.new_object.get('acls') is not None: new_object_params['acls'] = self.new_object.get('acls') or \ self.new_object.get('acls') + if self.new_object.get('destinationGroup') is not None or self.new_object.get('destination_group') is not None: + new_object_params['destinationGroup'] = self.new_object.get('destinationGroup') or \ + self.new_object.get('destination_group') if self.new_object.get('lastEntryRule') is not None or self.new_object.get('last_entry_rule') is not None: new_object_params['lastEntryRule'] = self.new_object.get('lastEntryRule') or \ self.new_object.get('last_entry_rule') + if self.new_object.get('sourceGroup') is not None or self.new_object.get('source_group') is not None: + new_object_params['sourceGroup'] = self.new_object.get('sourceGroup') or \ + self.new_object.get('source_group') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -193,10 +193,10 @@ class OrganizationsAdaptivePolicyPolicies(object): requested_obj = self.new_object obj_params = [ - ("sourceGroup", "sourceGroup"), - ("destinationGroup", "destinationGroup"), ("acls", "acls"), + ("destinationGroup", "destinationGroup"), ("lastEntryRule", "lastEntryRule"), + ("sourceGroup", "sourceGroup"), ("organizationId", "organizationId"), ("id", "id"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_admins.py b/ansible_collections/cisco/meraki/plugins/action/organizations_admins.py index a9b2140ef..641befa29 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_admins.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_admins.py @@ -32,12 +32,12 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + authenticationMethod=dict(type="str"), email=dict(type="str"), name=dict(type="str"), + networks=dict(type="list"), orgAccess=dict(type="str"), tags=dict(type="list"), - networks=dict(type="list"), - authenticationMethod=dict(type="str"), organizationId=dict(type="str"), adminId=dict(type="str"), )) @@ -55,12 +55,12 @@ class OrganizationsAdmins(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + authenticationMethod=params.get("authenticationMethod"), email=params.get("email"), name=params.get("name"), + networks=params.get("networks"), orgAccess=params.get("orgAccess"), tags=params.get("tags"), - networks=params.get("networks"), - authenticationMethod=params.get("authenticationMethod"), organizationId=params.get("organizationId"), adminId=params.get("adminId"), ) @@ -74,24 +74,24 @@ class OrganizationsAdmins(object): def create_params(self): new_object_params = {} + if self.new_object.get('authenticationMethod') is not None or self.new_object.get('authentication_method') is not None: + new_object_params['authenticationMethod'] = self.new_object.get('authenticationMethod') or \ + self.new_object.get('authentication_method') if self.new_object.get('email') is not None or self.new_object.get('email') is not None: new_object_params['email'] = self.new_object.get('email') or \ self.new_object.get('email') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') + if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: + new_object_params['networks'] = self.new_object.get('networks') or \ + self.new_object.get('networks') if self.new_object.get('orgAccess') is not None or self.new_object.get('org_access') is not None: new_object_params['orgAccess'] = self.new_object.get('orgAccess') or \ self.new_object.get('org_access') if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: new_object_params['tags'] = self.new_object.get('tags') or \ self.new_object.get('tags') - if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: - new_object_params['networks'] = self.new_object.get('networks') or \ - self.new_object.get('networks') - if self.new_object.get('authenticationMethod') is not None or self.new_object.get('authentication_method') is not None: - new_object_params['authenticationMethod'] = self.new_object.get('authenticationMethod') or \ - self.new_object.get('authentication_method') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -112,15 +112,15 @@ class OrganizationsAdmins(object): if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') + if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: + new_object_params['networks'] = self.new_object.get('networks') or \ + self.new_object.get('networks') if self.new_object.get('orgAccess') is not None or self.new_object.get('org_access') is not None: new_object_params['orgAccess'] = self.new_object.get('orgAccess') or \ self.new_object.get('org_access') if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: new_object_params['tags'] = self.new_object.get('tags') or \ self.new_object.get('tags') - if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: - new_object_params['networks'] = self.new_object.get('networks') or \ - self.new_object.get('networks') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -195,12 +195,12 @@ class OrganizationsAdmins(object): requested_obj = self.new_object obj_params = [ + ("authenticationMethod", "authenticationMethod"), ("email", "email"), ("name", "name"), + ("networks", "networks"), ("orgAccess", "orgAccess"), ("tags", "tags"), - ("networks", "networks"), - ("authenticationMethod", "authenticationMethod"), ("organizationId", "organizationId"), ("adminId", "adminId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_alerts_profiles.py b/ansible_collections/cisco/meraki/plugins/action/organizations_alerts_profiles.py index cc046ea86..b773a76cc 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_alerts_profiles.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_alerts_profiles.py @@ -31,11 +31,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - type=dict(type="str"), alertCondition=dict(type="dict"), - recipients=dict(type="dict"), - networkTags=dict(type="list"), description=dict(type="str"), + networkTags=dict(type="list"), + recipients=dict(type="dict"), + type=dict(type="str"), organizationId=dict(type="str"), enabled=dict(type="bool"), alertConfigId=dict(type="str"), @@ -54,11 +54,11 @@ class OrganizationsAlertsProfiles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - type=params.get("type"), alertCondition=params.get("alertCondition"), - recipients=params.get("recipients"), - networkTags=params.get("networkTags"), description=params.get("description"), + networkTags=params.get("networkTags"), + recipients=params.get("recipients"), + type=params.get("type"), organization_id=params.get("organizationId"), enabled=params.get("enabled"), alert_config_id=params.get("alertConfigId"), @@ -66,21 +66,21 @@ class OrganizationsAlertsProfiles(object): def create_params(self): new_object_params = {} - if self.new_object.get('type') is not None or self.new_object.get('type') is not None: - new_object_params['type'] = self.new_object.get('type') or \ - self.new_object.get('type') if self.new_object.get('alertCondition') is not None or self.new_object.get('alert_condition') is not None: new_object_params['alertCondition'] = self.new_object.get('alertCondition') or \ self.new_object.get('alert_condition') - if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: - new_object_params['recipients'] = self.new_object.get('recipients') or \ - self.new_object.get('recipients') - if self.new_object.get('networkTags') is not None or self.new_object.get('network_tags') is not None: - new_object_params['networkTags'] = self.new_object.get('networkTags') or \ - self.new_object.get('network_tags') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('networkTags') is not None or self.new_object.get('network_tags') is not None: + new_object_params['networkTags'] = self.new_object.get('networkTags') or \ + self.new_object.get('network_tags') + if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: + new_object_params['recipients'] = self.new_object.get('recipients') or \ + self.new_object.get('recipients') + if self.new_object.get('type') is not None or self.new_object.get('type') is not None: + new_object_params['type'] = self.new_object.get('type') or \ + self.new_object.get('type') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -98,23 +98,23 @@ class OrganizationsAlertsProfiles(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('type') is not None or self.new_object.get('type') is not None: - new_object_params['type'] = self.new_object.get('type') or \ - self.new_object.get('type') if self.new_object.get('alertCondition') is not None or self.new_object.get('alert_condition') is not None: new_object_params['alertCondition'] = self.new_object.get('alertCondition') or \ self.new_object.get('alert_condition') - if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: - new_object_params['recipients'] = self.new_object.get('recipients') or \ - self.new_object.get('recipients') - if self.new_object.get('networkTags') is not None or self.new_object.get('network_tags') is not None: - new_object_params['networkTags'] = self.new_object.get('networkTags') or \ - self.new_object.get('network_tags') if self.new_object.get('description') is not None or self.new_object.get('description') is not None: new_object_params['description'] = self.new_object.get('description') or \ self.new_object.get('description') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('networkTags') is not None or self.new_object.get('network_tags') is not None: + new_object_params['networkTags'] = self.new_object.get('networkTags') or \ + self.new_object.get('network_tags') + if self.new_object.get('recipients') is not None or self.new_object.get('recipients') is not None: + new_object_params['recipients'] = self.new_object.get('recipients') or \ + self.new_object.get('recipients') + if self.new_object.get('type') is not None or self.new_object.get('type') is not None: + new_object_params['type'] = self.new_object.get('type') or \ + self.new_object.get('type') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -163,11 +163,11 @@ class OrganizationsAlertsProfiles(object): requested_obj = self.new_object obj_params = [ - ("type", "type"), ("alertCondition", "alertCondition"), - ("recipients", "recipients"), - ("networkTags", "networkTags"), ("description", "description"), + ("networkTags", "networkTags"), + ("recipients", "recipients"), + ("type", "type"), ("organizationId", "organizationId"), ("enabled", "enabled"), ("alertConfigId", "alertConfigId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_traffic_shaping_vpn_exclusions_by_network_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_traffic_shaping_vpn_exclusions_by_network_info.py new file mode 100644 index 000000000..6aad7552f --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_traffic_shaping_vpn_exclusions_by_network_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( + organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + networkIds=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + + 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) + + response = meraki.exec_meraki( + family="appliance", + function='getOrganizationApplianceTrafficShapingVpnExclusionsByNetwork', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_statuses_overview_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_statuses_overview_info.py new file mode 100644 index 000000000..8180b0eb2 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_statuses_overview_info.py @@ -0,0 +1,90 @@ +#!/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( + organizationId=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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + + 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) + + response = meraki.exec_meraki( + family="appliance", + function='getOrganizationApplianceUplinksStatusesOverview', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_usage_by_network_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_usage_by_network_info.py new file mode 100644 index 000000000..c52e2bac2 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_appliance_uplinks_usage_by_network_info.py @@ -0,0 +1,102 @@ +#!/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( + organizationId=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + + 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) + + response = meraki.exec_meraki( + family="appliance", + function='getOrganizationApplianceUplinksUsageByNetwork', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_branding_policies.py b/ansible_collections/cisco/meraki/plugins/action/organizations_branding_policies.py index 870c0370e..246f94575 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_branding_policies.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_branding_policies.py @@ -32,11 +32,11 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), - enabled=dict(type="bool"), adminSettings=dict(type="dict"), - helpSettings=dict(type="dict"), customLogo=dict(type="dict"), + enabled=dict(type="bool"), + helpSettings=dict(type="dict"), + name=dict(type="str"), organizationId=dict(type="str"), brandingPolicyId=dict(type="str"), )) @@ -54,11 +54,11 @@ class OrganizationsBrandingPolicies(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - enabled=params.get("enabled"), adminSettings=params.get("adminSettings"), - helpSettings=params.get("helpSettings"), customLogo=params.get("customLogo"), + enabled=params.get("enabled"), + helpSettings=params.get("helpSettings"), + name=params.get("name"), organizationId=params.get("organizationId"), brandingPolicyId=params.get("brandingPolicyId"), ) @@ -82,20 +82,20 @@ class OrganizationsBrandingPolicies(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('adminSettings') is not None or self.new_object.get('admin_settings') is not None: new_object_params['adminSettings'] = self.new_object.get('adminSettings') or \ self.new_object.get('admin_settings') - if self.new_object.get('helpSettings') is not None or self.new_object.get('help_settings') is not None: - new_object_params['helpSettings'] = self.new_object.get('helpSettings') or \ - self.new_object.get('help_settings') if self.new_object.get('customLogo') is not None or self.new_object.get('custom_logo') is not None: new_object_params['customLogo'] = self.new_object.get('customLogo') or \ self.new_object.get('custom_logo') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('helpSettings') is not None or self.new_object.get('help_settings') is not None: + new_object_params['helpSettings'] = self.new_object.get('helpSettings') or \ + self.new_object.get('help_settings') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -113,20 +113,20 @@ class OrganizationsBrandingPolicies(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') if self.new_object.get('adminSettings') is not None or self.new_object.get('admin_settings') is not None: new_object_params['adminSettings'] = self.new_object.get('adminSettings') or \ self.new_object.get('admin_settings') - if self.new_object.get('helpSettings') is not None or self.new_object.get('help_settings') is not None: - new_object_params['helpSettings'] = self.new_object.get('helpSettings') or \ - self.new_object.get('help_settings') if self.new_object.get('customLogo') is not None or self.new_object.get('custom_logo') is not None: new_object_params['customLogo'] = self.new_object.get('customLogo') or \ self.new_object.get('custom_logo') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('helpSettings') is not None or self.new_object.get('help_settings') is not None: + new_object_params['helpSettings'] = self.new_object.get('helpSettings') or \ + self.new_object.get('help_settings') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -204,11 +204,11 @@ class OrganizationsBrandingPolicies(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("enabled", "enabled"), ("adminSettings", "adminSettings"), - ("helpSettings", "helpSettings"), ("customLogo", "customLogo"), + ("enabled", "enabled"), + ("helpSettings", "helpSettings"), + ("name", "name"), ("organizationId", "organizationId"), ("brandingPolicyId", "brandingPolicyId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_areas_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_areas_by_device_info.py new file mode 100644 index 000000000..a54a4f830 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_areas_by_device_info.py @@ -0,0 +1,94 @@ +#!/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( + organizationId=dict(type="str"), + serials=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + + 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) + + response = meraki.exec_meraki( + family="camera", + function='getOrganizationCameraBoundariesAreasByDevice', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_lines_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_lines_by_device_info.py new file mode 100644 index 000000000..89f74a210 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_boundaries_lines_by_device_info.py @@ -0,0 +1,94 @@ +#!/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( + organizationId=dict(type="str"), + serials=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + + 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) + + response = meraki.exec_meraki( + family="camera", + function='getOrganizationCameraBoundariesLinesByDevice', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_camera_detections_history_by_boundary_by_interval_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_detections_history_by_boundary_by_interval_info.py new file mode 100644 index 000000000..fd9ef63d5 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_detections_history_by_boundary_by_interval_info.py @@ -0,0 +1,116 @@ +#!/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( + organizationId=dict(type="str"), + boundaryIds=dict(type="list"), + ranges=dict(type="list"), + duration=dict(type="int"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + boundaryTypes=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("boundaryIds") is not None: + new_object["boundaryIds"] = params.get( + "boundaryIds") + if params.get("ranges") is not None: + new_object["ranges"] = params.get( + "ranges") + if params.get("duration") is not None: + new_object["duration"] = params.get( + "duration") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("boundaryTypes") is not None: + new_object["boundaryTypes"] = params.get( + "boundaryTypes") + + 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) + + response = meraki.exec_meraki( + family="camera", + function='getOrganizationCameraDetectionsHistoryByBoundaryByInterval', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_camera_permissions_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_permissions_info.py new file mode 100644 index 000000000..3eb13d08d --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_permissions_info.py @@ -0,0 +1,102 @@ +#!/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( + organizationId=dict(type="str"), + permissionScopeId=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("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("permissionScopeId") is not None: + new_object["permissionScopeId"] = params.get( + "permissionScopeId") + 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("permissionScopeId") + if id: + response = meraki.exec_meraki( + family="camera", + function='getOrganizationCameraPermission', + 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: + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles.py new file mode 100644 index 000000000..222b2503d --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles.py @@ -0,0 +1,252 @@ +#!/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, + meraki_compare_equality, + get_dict_result, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present", "absent"]), + appliedOnDevices=dict(type="list"), + appliedOnNetworks=dict(type="list"), + appliedOrgWide=dict(type="list"), + name=dict(type="str"), + organizationId=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["name", "organizationId"], True), + ("state", "absent", ["name", "organizationId"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class OrganizationsCameraRoles(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + appliedOnDevices=params.get("appliedOnDevices"), + appliedOnNetworks=params.get("appliedOnNetworks"), + appliedOrgWide=params.get("appliedOrgWide"), + name=params.get("name"), + organizationId=params.get("organizationId"), + ) + + def get_all_params(self, name=None, id=None): + new_object_params = {} + if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: + new_object_params['organizationId'] = self.new_object.get('organizationId') or \ + self.new_object.get('organization_id') + return new_object_params + + def create_params(self): + new_object_params = {} + if self.new_object.get('appliedOnDevices') is not None or self.new_object.get('applied_on_devices') is not None: + new_object_params['appliedOnDevices'] = self.new_object.get('appliedOnDevices') or \ + self.new_object.get('applied_on_devices') + if self.new_object.get('appliedOnNetworks') is not None or self.new_object.get('applied_on_networks') is not None: + new_object_params['appliedOnNetworks'] = self.new_object.get('appliedOnNetworks') or \ + self.new_object.get('applied_on_networks') + if self.new_object.get('appliedOrgWide') is not None or self.new_object.get('applied_org_wide') is not None: + new_object_params['appliedOrgWide'] = self.new_object.get('appliedOrgWide') or \ + self.new_object.get('applied_org_wide') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: + new_object_params['organizationId'] = self.new_object.get('organizationId') or \ + self.new_object.get('organization_id') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name method or it is in another action + try: + items = self.meraki.exec_meraki( + family="camera", + function="getOrganizationCameraRoles", + params=self.get_all_params(name=name), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'name', name) + if result is None: + result = items + except Exception as e: + print("Error: ", e) + result = None + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + try: + items = self.meraki.exec_meraki( + family="camera", + function="getOrganizationCameraRoles", + params=self.get_all_params(id=id), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'id', id) + except Exception as e: + print("Error: ", e) + result = None + return result + + def exists(self): + id_exists = False + name_exists = False + prev_obj = None + o_id = self.new_object.get("id") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_id(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("appliedOnDevices", "appliedOnDevices"), + ("appliedOnNetworks", "appliedOnNetworks"), + ("appliedOrgWide", "appliedOrgWide"), + ("name", "name"), + ("organizationId", "organizationId"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="camera", + function="createOrganizationCameraRole", + params=self.create_params(), + op_modifies=True, + ) + return result + + def update(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have update method. What do we do? + return result + + def delete(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have delete method. What do we do? + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = OrganizationsCameraRoles(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + elif state == "absent": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + response = obj.delete() + meraki.object_deleted() + else: + meraki.object_already_absent() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles_info.py new file mode 100644 index 000000000..2a100b4e2 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_camera_roles_info.py @@ -0,0 +1,90 @@ +#!/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( + organizationId=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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + + 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) + + response = meraki.exec_meraki( + family="camera", + function='getOrganizationCameraRoles', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_claim.py b/ansible_collections/cisco/meraki/plugins/action/organizations_claim.py index 5439a5af8..6f3a8ef92 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_claim.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_claim.py @@ -25,9 +25,9 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( + licenses=dict(type="list"), orders=dict(type="list"), serials=dict(type="list"), - licenses=dict(type="list"), organizationId=dict(type="str"), )) @@ -67,9 +67,9 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( + licenses=params.get("licenses"), orders=params.get("orders"), serials=params.get("serials"), - licenses=params.get("licenses"), organizationId=params.get("organizationId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates.py b/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates.py index 09dc845b0..1811392e7 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates.py @@ -32,6 +32,7 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), + copyFromNetworkId=dict(type="str"), name=dict(type="str"), timeZone=dict(type="str"), organizationId=dict(type="str"), @@ -51,6 +52,7 @@ class OrganizationsConfigTemplates(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + copyFromNetworkId=params.get("copyFromNetworkId"), name=params.get("name"), timeZone=params.get("timeZone"), organizationId=params.get("organizationId"), @@ -76,6 +78,9 @@ class OrganizationsConfigTemplates(object): def create_params(self): new_object_params = {} + if self.new_object.get('copyFromNetworkId') is not None or self.new_object.get('copy_from_network_id') is not None: + new_object_params['copyFromNetworkId'] = self.new_object.get('copyFromNetworkId') or \ + self.new_object.get('copy_from_network_id') if self.new_object.get('name') is not None or self.new_object.get('name') is not None: new_object_params['name'] = self.new_object.get('name') or \ self.new_object.get('name') @@ -182,6 +187,7 @@ class OrganizationsConfigTemplates(object): requested_obj = self.new_object obj_params = [ + ("copyFromNetworkId", "copyFromNetworkId"), ("name", "name"), ("timeZone", "timeZone"), ("organizationId", "organizationId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates_switch_profiles_ports.py b/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates_switch_profiles_ports.py index 38cd937fc..82963b4b0 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates_switch_profiles_ports.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_config_templates_switch_profiles_ports.py @@ -32,29 +32,29 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - name=dict(type="str"), - tags=dict(type="list"), - enabled=dict(type="bool"), - poeEnabled=dict(type="bool"), - type=dict(type="str"), - vlan=dict(type="int"), - voiceVlan=dict(type="int"), + accessPolicyNumber=dict(type="int"), + accessPolicyType=dict(type="str"), allowedVlans=dict(type="str"), + daiTrusted=dict(type="bool"), + enabled=dict(type="bool"), + flexibleStackingEnabled=dict(type="bool"), isolationEnabled=dict(type="bool"), - rstpEnabled=dict(type="bool"), - stpGuard=dict(type="str"), linkNegotiation=dict(type="str"), - portScheduleId=dict(type="str"), - udld=dict(type="str"), - accessPolicyType=dict(type="str"), - accessPolicyNumber=dict(type="int"), macAllowList=dict(type="list"), + name=dict(type="str"), + poeEnabled=dict(type="bool"), + portScheduleId=dict(type="str"), + profile=dict(type="dict"), + rstpEnabled=dict(type="bool"), stickyMacAllowList=dict(type="list"), stickyMacAllowListLimit=dict(type="int"), stormControlEnabled=dict(type="bool"), - flexibleStackingEnabled=dict(type="bool"), - daiTrusted=dict(type="bool"), - profile=dict(type="dict"), + stpGuard=dict(type="str"), + tags=dict(type="list"), + type=dict(type="str"), + udld=dict(type="str"), + vlan=dict(type="int"), + voiceVlan=dict(type="int"), organizationId=dict(type="str"), configTemplateId=dict(type="str"), profileId=dict(type="str"), @@ -73,29 +73,29 @@ class OrganizationsConfigTemplatesSwitchProfilesPorts(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), - tags=params.get("tags"), - enabled=params.get("enabled"), - poeEnabled=params.get("poeEnabled"), - type=params.get("type"), - vlan=params.get("vlan"), - voiceVlan=params.get("voiceVlan"), + accessPolicyNumber=params.get("accessPolicyNumber"), + accessPolicyType=params.get("accessPolicyType"), allowedVlans=params.get("allowedVlans"), + daiTrusted=params.get("daiTrusted"), + enabled=params.get("enabled"), + flexibleStackingEnabled=params.get("flexibleStackingEnabled"), isolationEnabled=params.get("isolationEnabled"), - rstpEnabled=params.get("rstpEnabled"), - stpGuard=params.get("stpGuard"), linkNegotiation=params.get("linkNegotiation"), - portScheduleId=params.get("portScheduleId"), - udld=params.get("udld"), - accessPolicyType=params.get("accessPolicyType"), - accessPolicyNumber=params.get("accessPolicyNumber"), macAllowList=params.get("macAllowList"), + name=params.get("name"), + poeEnabled=params.get("poeEnabled"), + portScheduleId=params.get("portScheduleId"), + profile=params.get("profile"), + rstpEnabled=params.get("rstpEnabled"), stickyMacAllowList=params.get("stickyMacAllowList"), stickyMacAllowListLimit=params.get("stickyMacAllowListLimit"), stormControlEnabled=params.get("stormControlEnabled"), - flexibleStackingEnabled=params.get("flexibleStackingEnabled"), - daiTrusted=params.get("daiTrusted"), - profile=params.get("profile"), + stpGuard=params.get("stpGuard"), + tags=params.get("tags"), + type=params.get("type"), + udld=params.get("udld"), + vlan=params.get("vlan"), + voiceVlan=params.get("voiceVlan"), organization_id=params.get("organizationId"), config_template_id=params.get("configTemplateId"), profile_id=params.get("profileId"), @@ -133,53 +133,42 @@ class OrganizationsConfigTemplatesSwitchProfilesPorts(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') - if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: - new_object_params['tags'] = self.new_object.get('tags') or \ - self.new_object.get('tags') - if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: - new_object_params['enabled'] = self.new_object.get('enabled') - if self.new_object.get('poeEnabled') is not None or self.new_object.get('poe_enabled') is not None: - new_object_params['poeEnabled'] = self.new_object.get('poeEnabled') - if self.new_object.get('type') is not None or self.new_object.get('type') is not None: - new_object_params['type'] = self.new_object.get('type') or \ - self.new_object.get('type') - if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: - new_object_params['vlan'] = self.new_object.get('vlan') or \ - self.new_object.get('vlan') - if self.new_object.get('voiceVlan') is not None or self.new_object.get('voice_vlan') is not None: - new_object_params['voiceVlan'] = self.new_object.get('voiceVlan') or \ - self.new_object.get('voice_vlan') + if self.new_object.get('accessPolicyNumber') is not None or self.new_object.get('access_policy_number') is not None: + new_object_params['accessPolicyNumber'] = self.new_object.get('accessPolicyNumber') or \ + self.new_object.get('access_policy_number') + if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: + new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ + self.new_object.get('access_policy_type') if self.new_object.get('allowedVlans') is not None or self.new_object.get('allowed_vlans') is not None: new_object_params['allowedVlans'] = self.new_object.get('allowedVlans') or \ self.new_object.get('allowed_vlans') + if self.new_object.get('daiTrusted') is not None or self.new_object.get('dai_trusted') is not None: + new_object_params['daiTrusted'] = self.new_object.get('daiTrusted') + if self.new_object.get('enabled') is not None or self.new_object.get('enabled') is not None: + new_object_params['enabled'] = self.new_object.get('enabled') + if self.new_object.get('flexibleStackingEnabled') is not None or self.new_object.get('flexible_stacking_enabled') is not None: + new_object_params['flexibleStackingEnabled'] = self.new_object.get('flexibleStackingEnabled') if self.new_object.get('isolationEnabled') is not None or self.new_object.get('isolation_enabled') is not None: new_object_params['isolationEnabled'] = self.new_object.get('isolationEnabled') - if self.new_object.get('rstpEnabled') is not None or self.new_object.get('rstp_enabled') is not None: - new_object_params['rstpEnabled'] = self.new_object.get('rstpEnabled') - if self.new_object.get('stpGuard') is not None or self.new_object.get('stp_guard') is not None: - new_object_params['stpGuard'] = self.new_object.get('stpGuard') or \ - self.new_object.get('stp_guard') if self.new_object.get('linkNegotiation') is not None or self.new_object.get('link_negotiation') is not None: new_object_params['linkNegotiation'] = self.new_object.get('linkNegotiation') or \ self.new_object.get('link_negotiation') - if self.new_object.get('portScheduleId') is not None or self.new_object.get('port_schedule_id') is not None: - new_object_params['portScheduleId'] = self.new_object.get('portScheduleId') or \ - self.new_object.get('port_schedule_id') - if self.new_object.get('udld') is not None or self.new_object.get('udld') is not None: - new_object_params['udld'] = self.new_object.get('udld') or \ - self.new_object.get('udld') - if self.new_object.get('accessPolicyType') is not None or self.new_object.get('access_policy_type') is not None: - new_object_params['accessPolicyType'] = self.new_object.get('accessPolicyType') or \ - self.new_object.get('access_policy_type') - if self.new_object.get('accessPolicyNumber') is not None or self.new_object.get('access_policy_number') is not None: - new_object_params['accessPolicyNumber'] = self.new_object.get('accessPolicyNumber') or \ - self.new_object.get('access_policy_number') if self.new_object.get('macAllowList') is not None or self.new_object.get('mac_allow_list') is not None: new_object_params['macAllowList'] = self.new_object.get('macAllowList') or \ self.new_object.get('mac_allow_list') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('poeEnabled') is not None or self.new_object.get('poe_enabled') is not None: + new_object_params['poeEnabled'] = self.new_object.get('poeEnabled') + if self.new_object.get('portScheduleId') is not None or self.new_object.get('port_schedule_id') is not None: + new_object_params['portScheduleId'] = self.new_object.get('portScheduleId') or \ + self.new_object.get('port_schedule_id') + if self.new_object.get('profile') is not None or self.new_object.get('profile') is not None: + new_object_params['profile'] = self.new_object.get('profile') or \ + self.new_object.get('profile') + if self.new_object.get('rstpEnabled') is not None or self.new_object.get('rstp_enabled') is not None: + new_object_params['rstpEnabled'] = self.new_object.get('rstpEnabled') if self.new_object.get('stickyMacAllowList') is not None or self.new_object.get('sticky_mac_allow_list') is not None: new_object_params['stickyMacAllowList'] = self.new_object.get('stickyMacAllowList') or \ self.new_object.get('sticky_mac_allow_list') @@ -188,13 +177,24 @@ class OrganizationsConfigTemplatesSwitchProfilesPorts(object): self.new_object.get('sticky_mac_allow_list_limit') if self.new_object.get('stormControlEnabled') is not None or self.new_object.get('storm_control_enabled') is not None: new_object_params['stormControlEnabled'] = self.new_object.get('stormControlEnabled') - if self.new_object.get('flexibleStackingEnabled') is not None or self.new_object.get('flexible_stacking_enabled') is not None: - new_object_params['flexibleStackingEnabled'] = self.new_object.get('flexibleStackingEnabled') - if self.new_object.get('daiTrusted') is not None or self.new_object.get('dai_trusted') is not None: - new_object_params['daiTrusted'] = self.new_object.get('daiTrusted') - if self.new_object.get('profile') is not None or self.new_object.get('profile') is not None: - new_object_params['profile'] = self.new_object.get('profile') or \ - self.new_object.get('profile') + if self.new_object.get('stpGuard') is not None or self.new_object.get('stp_guard') is not None: + new_object_params['stpGuard'] = self.new_object.get('stpGuard') or \ + self.new_object.get('stp_guard') + if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: + new_object_params['tags'] = self.new_object.get('tags') or \ + self.new_object.get('tags') + if self.new_object.get('type') is not None or self.new_object.get('type') is not None: + new_object_params['type'] = self.new_object.get('type') or \ + self.new_object.get('type') + if self.new_object.get('udld') is not None or self.new_object.get('udld') is not None: + new_object_params['udld'] = self.new_object.get('udld') or \ + self.new_object.get('udld') + if self.new_object.get('vlan') is not None or self.new_object.get('vlan') is not None: + new_object_params['vlan'] = self.new_object.get('vlan') or \ + self.new_object.get('vlan') + if self.new_object.get('voiceVlan') is not None or self.new_object.get('voice_vlan') is not None: + new_object_params['voiceVlan'] = self.new_object.get('voiceVlan') or \ + self.new_object.get('voice_vlan') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -278,29 +278,29 @@ class OrganizationsConfigTemplatesSwitchProfilesPorts(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), - ("tags", "tags"), - ("enabled", "enabled"), - ("poeEnabled", "poeEnabled"), - ("type", "type"), - ("vlan", "vlan"), - ("voiceVlan", "voiceVlan"), + ("accessPolicyNumber", "accessPolicyNumber"), + ("accessPolicyType", "accessPolicyType"), ("allowedVlans", "allowedVlans"), + ("daiTrusted", "daiTrusted"), + ("enabled", "enabled"), + ("flexibleStackingEnabled", "flexibleStackingEnabled"), ("isolationEnabled", "isolationEnabled"), - ("rstpEnabled", "rstpEnabled"), - ("stpGuard", "stpGuard"), ("linkNegotiation", "linkNegotiation"), - ("portScheduleId", "portScheduleId"), - ("udld", "udld"), - ("accessPolicyType", "accessPolicyType"), - ("accessPolicyNumber", "accessPolicyNumber"), ("macAllowList", "macAllowList"), + ("name", "name"), + ("poeEnabled", "poeEnabled"), + ("portScheduleId", "portScheduleId"), + ("profile", "profile"), + ("rstpEnabled", "rstpEnabled"), ("stickyMacAllowList", "stickyMacAllowList"), ("stickyMacAllowListLimit", "stickyMacAllowListLimit"), ("stormControlEnabled", "stormControlEnabled"), - ("flexibleStackingEnabled", "flexibleStackingEnabled"), - ("daiTrusted", "daiTrusted"), - ("profile", "profile"), + ("stpGuard", "stpGuard"), + ("tags", "tags"), + ("type", "type"), + ("udld", "udld"), + ("vlan", "vlan"), + ("voiceVlan", "voiceVlan"), ("organizationId", "organizationId"), ("configTemplateId", "configTemplateId"), ("profileId", "profileId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_devices_availabilities_change_history_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_devices_availabilities_change_history_info.py new file mode 100644 index 000000000..feee0396e --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_devices_availabilities_change_history_info.py @@ -0,0 +1,136 @@ +#!/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( + organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + serials=dict(type="list"), + productTypes=dict(type="list"), + networkIds=dict(type="list"), + statuses=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("productTypes") is not None: + new_object["productTypes"] = params.get( + "productTypes") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("statuses") is not None: + new_object["statuses"] = params.get( + "statuses") + + 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) + + response = meraki.exec_meraki( + family="organizations", + function='getOrganizationDevicesAvailabilitiesChangeHistory', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_devices_boots_history_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_devices_boots_history_info.py new file mode 100644 index 000000000..53053eb7a --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_devices_boots_history_info.py @@ -0,0 +1,132 @@ +#!/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( + organizationId=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + serials=dict(type="list"), + mostRecentPerDevice=dict(type="bool"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + sortOrder=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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("mostRecentPerDevice") is not None: + new_object["mostRecentPerDevice"] = params.get( + "mostRecentPerDevice") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("sortOrder") is not None: + new_object["sortOrder"] = params.get( + "sortOrder") + + 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) + + response = meraki.exec_meraki( + family="organizations", + function='getOrganizationDevicesBootsHistory', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_early_access_features_opt_ins.py b/ansible_collections/cisco/meraki/plugins/action/organizations_early_access_features_opt_ins.py index 7a952168f..b0ebdf793 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_early_access_features_opt_ins.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_early_access_features_opt_ins.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - shortName=dict(type="str"), limitScopeToNetworks=dict(type="list"), + shortName=dict(type="str"), organizationId=dict(type="str"), optInId=dict(type="str"), )) @@ -51,8 +51,8 @@ class OrganizationsEarlyAccessFeaturesOptIns(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - shortName=params.get("shortName"), limitScopeToNetworks=params.get("limitScopeToNetworks"), + shortName=params.get("shortName"), organizationId=params.get("organizationId"), optInId=params.get("optInId"), ) @@ -76,12 +76,12 @@ class OrganizationsEarlyAccessFeaturesOptIns(object): def create_params(self): new_object_params = {} - if self.new_object.get('shortName') is not None or self.new_object.get('short_name') is not None: - new_object_params['shortName'] = self.new_object.get('shortName') or \ - self.new_object.get('short_name') if self.new_object.get('limitScopeToNetworks') is not None or self.new_object.get('limit_scope_to_networks') is not None: new_object_params['limitScopeToNetworks'] = self.new_object.get('limitScopeToNetworks') or \ self.new_object.get('limit_scope_to_networks') + if self.new_object.get('shortName') is not None or self.new_object.get('short_name') is not None: + new_object_params['shortName'] = self.new_object.get('shortName') or \ + self.new_object.get('short_name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -179,8 +179,8 @@ class OrganizationsEarlyAccessFeaturesOptIns(object): requested_obj = self.new_object obj_params = [ - ("shortName", "shortName"), ("limitScopeToNetworks", "limitScopeToNetworks"), + ("shortName", "shortName"), ("organizationId", "organizationId"), ("optInId", "optInId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_by_device_info.py index 254770a93..942ee2ecb 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_by_device_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_by_device_info.py @@ -34,8 +34,8 @@ argument_spec.update(dict( networkIds=dict(type="list"), serials=dict(type="list"), macs=dict(type="list"), - firmwareUpgradeIds=dict(type="list"), firmwareUpgradeBatchIds=dict(type="list"), + upgradeStatuses=dict(type="list"), )) required_if = [] @@ -99,12 +99,12 @@ class ActionModule(ActionBase): if params.get("macs") is not None: new_object["macs"] = params.get( "macs") - if params.get("firmwareUpgradeIds") is not None: - new_object["firmwareUpgradeIds"] = params.get( - "firmwareUpgradeIds") if params.get("firmwareUpgradeBatchIds") is not None: new_object["firmwareUpgradeBatchIds"] = params.get( "firmwareUpgradeBatchIds") + if params.get("upgradeStatuses") is not None: + new_object["upgradeStatuses"] = params.get( + "upgradeStatuses") return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_info.py index e8e72f6ce..afe4584e9 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_firmware_upgrades_info.py @@ -26,8 +26,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), status=dict(type="list"), - productType=dict(type="list"), + productTypes=dict(type="list"), )) required_if = [] @@ -69,12 +74,25 @@ class ActionModule(ActionBase): if params.get("organizationId") is not None: new_object["organizationId"] = params.get( "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") if params.get("status") is not None: new_object["status"] = params.get( "status") - if params.get("productType") is not None: - new_object["productType"] = params.get( - "productType") + if params.get("productTypes") is not None: + new_object["productTypes"] = params.get( + "productTypes") return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_info.py index e7dba48d4..3a48d1c4b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_info.py @@ -25,6 +25,11 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), organizationId=dict(type="str"), )) @@ -71,6 +76,19 @@ class ActionModule(ActionBase): def get_all(self, params): new_object = {} + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_insight_monitored_media_servers.py b/ansible_collections/cisco/meraki/plugins/action/organizations_insight_monitored_media_servers.py index 14957d943..dbead6d01 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_insight_monitored_media_servers.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_insight_monitored_media_servers.py @@ -32,9 +32,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), address=dict(type="str"), bestEffortMonitoringEnabled=dict(type="bool"), + name=dict(type="str"), organizationId=dict(type="str"), monitoredMediaServerId=dict(type="str"), )) @@ -52,9 +52,9 @@ class OrganizationsInsightMonitoredMediaServers(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), address=params.get("address"), bestEffortMonitoringEnabled=params.get("bestEffortMonitoringEnabled"), + name=params.get("name"), organizationId=params.get("organizationId"), monitoredMediaServerId=params.get("monitoredMediaServerId"), ) @@ -78,14 +78,14 @@ class OrganizationsInsightMonitoredMediaServers(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('address') is not None or self.new_object.get('address') is not None: new_object_params['address'] = self.new_object.get('address') or \ self.new_object.get('address') if self.new_object.get('bestEffortMonitoringEnabled') is not None or self.new_object.get('best_effort_monitoring_enabled') is not None: new_object_params['bestEffortMonitoringEnabled'] = self.new_object.get('bestEffortMonitoringEnabled') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -103,14 +103,14 @@ class OrganizationsInsightMonitoredMediaServers(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('address') is not None or self.new_object.get('address') is not None: new_object_params['address'] = self.new_object.get('address') or \ self.new_object.get('address') if self.new_object.get('bestEffortMonitoringEnabled') is not None or self.new_object.get('best_effort_monitoring_enabled') is not None: new_object_params['bestEffortMonitoringEnabled'] = self.new_object.get('bestEffortMonitoringEnabled') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -188,9 +188,9 @@ class OrganizationsInsightMonitoredMediaServers(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("address", "address"), ("bestEffortMonitoringEnabled", "bestEffortMonitoringEnabled"), + ("name", "name"), ("organizationId", "organizationId"), ("monitoredMediaServerId", "monitoredMediaServerId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_claim.py b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_claim.py index 5bc648b91..e25a3d67b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_claim.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_claim.py @@ -25,9 +25,9 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( + licenses=dict(type="list"), orders=dict(type="list"), serials=dict(type="list"), - licenses=dict(type="list"), organizationId=dict(type="str"), )) @@ -67,9 +67,9 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( + licenses=params.get("licenses"), orders=params.get("orders"), serials=params.get("serials"), - licenses=params.get("licenses"), organizationId=params.get("organizationId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_export_events.py b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_export_events.py index 11cefb220..6a03ab49f 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_export_events.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_export_events.py @@ -26,9 +26,9 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( logEvent=dict(type="str"), - timestamp=dict(type="int"), - targetOS=dict(type="str"), request=dict(type="str"), + targetOS=dict(type="str"), + timestamp=dict(type="int"), organizationId=dict(type="str"), )) @@ -69,9 +69,9 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( logEvent=params.get("logEvent"), - timestamp=params.get("timestamp"), - targetOS=params.get("targetOS"), request=params.get("request"), + targetOS=params.get("targetOS"), + timestamp=params.get("timestamp"), organizationId=params.get("organizationId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_networks_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_networks_info.py index 409b7abdb..bf953f272 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_networks_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_inventory_onboarding_cloud_monitoring_networks_info.py @@ -27,6 +27,7 @@ argument_spec = meraki_argument_spec() argument_spec.update(dict( organizationId=dict(type="str"), deviceType=dict(type="str"), + search=dict(type="str"), perPage=dict(type="int"), total_pages=dict(type="int"), direction=dict(type="str"), @@ -76,6 +77,9 @@ class ActionModule(ActionBase): if params.get("deviceType") is not None: new_object["deviceType"] = params.get( "deviceType") + if params.get("search") is not None: + new_object["search"] = params.get( + "search") if params.get("perPage") is not None: new_object["perPage"] = params.get( "perPage") diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_login_security.py b/ansible_collections/cisco/meraki/plugins/action/organizations_login_security.py index 64f5ea7b4..d231966d9 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_login_security.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_login_security.py @@ -32,19 +32,19 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), - enforcePasswordExpiration=dict(type="bool"), - passwordExpirationDays=dict(type="int"), - enforceDifferentPasswords=dict(type="bool"), - numDifferentPasswords=dict(type="int"), - enforceStrongPasswords=dict(type="bool"), - enforceAccountLockout=dict(type="bool"), accountLockoutAttempts=dict(type="int"), + apiAuthentication=dict(type="dict"), + enforceAccountLockout=dict(type="bool"), + enforceDifferentPasswords=dict(type="bool"), enforceIdleTimeout=dict(type="bool"), - idleTimeoutMinutes=dict(type="int"), - enforceTwoFactorAuth=dict(type="bool"), enforceLoginIpRanges=dict(type="bool"), + enforcePasswordExpiration=dict(type="bool"), + enforceStrongPasswords=dict(type="bool"), + enforceTwoFactorAuth=dict(type="bool"), + idleTimeoutMinutes=dict(type="int"), loginIpRanges=dict(type="list"), - apiAuthentication=dict(type="dict"), + numDifferentPasswords=dict(type="int"), + passwordExpirationDays=dict(type="int"), organizationId=dict(type="str"), )) @@ -60,19 +60,19 @@ class OrganizationsLoginSecurity(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - enforcePasswordExpiration=params.get("enforcePasswordExpiration"), - passwordExpirationDays=params.get("passwordExpirationDays"), - enforceDifferentPasswords=params.get("enforceDifferentPasswords"), - numDifferentPasswords=params.get("numDifferentPasswords"), - enforceStrongPasswords=params.get("enforceStrongPasswords"), - enforceAccountLockout=params.get("enforceAccountLockout"), accountLockoutAttempts=params.get("accountLockoutAttempts"), + apiAuthentication=params.get("apiAuthentication"), + enforceAccountLockout=params.get("enforceAccountLockout"), + enforceDifferentPasswords=params.get("enforceDifferentPasswords"), enforceIdleTimeout=params.get("enforceIdleTimeout"), - idleTimeoutMinutes=params.get("idleTimeoutMinutes"), - enforceTwoFactorAuth=params.get("enforceTwoFactorAuth"), enforceLoginIpRanges=params.get("enforceLoginIpRanges"), + enforcePasswordExpiration=params.get("enforcePasswordExpiration"), + enforceStrongPasswords=params.get("enforceStrongPasswords"), + enforceTwoFactorAuth=params.get("enforceTwoFactorAuth"), + idleTimeoutMinutes=params.get("idleTimeoutMinutes"), loginIpRanges=params.get("loginIpRanges"), - apiAuthentication=params.get("apiAuthentication"), + numDifferentPasswords=params.get("numDifferentPasswords"), + passwordExpirationDays=params.get("passwordExpirationDays"), organization_id=params.get("organizationId"), ) @@ -85,38 +85,38 @@ class OrganizationsLoginSecurity(object): def update_all_params(self): new_object_params = {} - if self.new_object.get('enforcePasswordExpiration') is not None or self.new_object.get('enforce_password_expiration') is not None: - new_object_params['enforcePasswordExpiration'] = self.new_object.get('enforcePasswordExpiration') - if self.new_object.get('passwordExpirationDays') is not None or self.new_object.get('password_expiration_days') is not None: - new_object_params['passwordExpirationDays'] = self.new_object.get('passwordExpirationDays') or \ - self.new_object.get('password_expiration_days') - if self.new_object.get('enforceDifferentPasswords') is not None or self.new_object.get('enforce_different_passwords') is not None: - new_object_params['enforceDifferentPasswords'] = self.new_object.get('enforceDifferentPasswords') - if self.new_object.get('numDifferentPasswords') is not None or self.new_object.get('num_different_passwords') is not None: - new_object_params['numDifferentPasswords'] = self.new_object.get('numDifferentPasswords') or \ - self.new_object.get('num_different_passwords') - if self.new_object.get('enforceStrongPasswords') is not None or self.new_object.get('enforce_strong_passwords') is not None: - new_object_params['enforceStrongPasswords'] = self.new_object.get('enforceStrongPasswords') - if self.new_object.get('enforceAccountLockout') is not None or self.new_object.get('enforce_account_lockout') is not None: - new_object_params['enforceAccountLockout'] = self.new_object.get('enforceAccountLockout') if self.new_object.get('accountLockoutAttempts') is not None or self.new_object.get('account_lockout_attempts') is not None: new_object_params['accountLockoutAttempts'] = self.new_object.get('accountLockoutAttempts') or \ self.new_object.get('account_lockout_attempts') + if self.new_object.get('apiAuthentication') is not None or self.new_object.get('api_authentication') is not None: + new_object_params['apiAuthentication'] = self.new_object.get('apiAuthentication') or \ + self.new_object.get('api_authentication') + if self.new_object.get('enforceAccountLockout') is not None or self.new_object.get('enforce_account_lockout') is not None: + new_object_params['enforceAccountLockout'] = self.new_object.get('enforceAccountLockout') + if self.new_object.get('enforceDifferentPasswords') is not None or self.new_object.get('enforce_different_passwords') is not None: + new_object_params['enforceDifferentPasswords'] = self.new_object.get('enforceDifferentPasswords') if self.new_object.get('enforceIdleTimeout') is not None or self.new_object.get('enforce_idle_timeout') is not None: new_object_params['enforceIdleTimeout'] = self.new_object.get('enforceIdleTimeout') + if self.new_object.get('enforceLoginIpRanges') is not None or self.new_object.get('enforce_login_ip_ranges') is not None: + new_object_params['enforceLoginIpRanges'] = self.new_object.get('enforceLoginIpRanges') + if self.new_object.get('enforcePasswordExpiration') is not None or self.new_object.get('enforce_password_expiration') is not None: + new_object_params['enforcePasswordExpiration'] = self.new_object.get('enforcePasswordExpiration') + if self.new_object.get('enforceStrongPasswords') is not None or self.new_object.get('enforce_strong_passwords') is not None: + new_object_params['enforceStrongPasswords'] = self.new_object.get('enforceStrongPasswords') + if self.new_object.get('enforceTwoFactorAuth') is not None or self.new_object.get('enforce_two_factor_auth') is not None: + new_object_params['enforceTwoFactorAuth'] = self.new_object.get('enforceTwoFactorAuth') if self.new_object.get('idleTimeoutMinutes') is not None or self.new_object.get('idle_timeout_minutes') is not None: new_object_params['idleTimeoutMinutes'] = self.new_object.get('idleTimeoutMinutes') or \ self.new_object.get('idle_timeout_minutes') - if self.new_object.get('enforceTwoFactorAuth') is not None or self.new_object.get('enforce_two_factor_auth') is not None: - new_object_params['enforceTwoFactorAuth'] = self.new_object.get('enforceTwoFactorAuth') - if self.new_object.get('enforceLoginIpRanges') is not None or self.new_object.get('enforce_login_ip_ranges') is not None: - new_object_params['enforceLoginIpRanges'] = self.new_object.get('enforceLoginIpRanges') if self.new_object.get('loginIpRanges') is not None or self.new_object.get('login_ip_ranges') is not None: new_object_params['loginIpRanges'] = self.new_object.get('loginIpRanges') or \ self.new_object.get('login_ip_ranges') - if self.new_object.get('apiAuthentication') is not None or self.new_object.get('api_authentication') is not None: - new_object_params['apiAuthentication'] = self.new_object.get('apiAuthentication') or \ - self.new_object.get('api_authentication') + if self.new_object.get('numDifferentPasswords') is not None or self.new_object.get('num_different_passwords') is not None: + new_object_params['numDifferentPasswords'] = self.new_object.get('numDifferentPasswords') or \ + self.new_object.get('num_different_passwords') + if self.new_object.get('passwordExpirationDays') is not None or self.new_object.get('password_expiration_days') is not None: + new_object_params['passwordExpirationDays'] = self.new_object.get('passwordExpirationDays') or \ + self.new_object.get('password_expiration_days') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -152,7 +152,7 @@ class OrganizationsLoginSecurity(object): id_exists = False name_exists = False o_id = self.new_object.get("id") - name = self.new_object.get("organization_id") + name = self.new_object.get("name") if o_id: prev_obj = self.get_object_by_name(o_id) id_exists = prev_obj is not None and isinstance(prev_obj, dict) @@ -173,18 +173,18 @@ class OrganizationsLoginSecurity(object): requested_obj = self.new_object obj_params = [ - ("enforcePasswordExpiration", "enforcePasswordExpiration"), - ("enforceDifferentPasswords", "enforceDifferentPasswords"), - ("numDifferentPasswords", "numDifferentPasswords"), - ("enforceStrongPasswords", "enforceStrongPasswords"), - ("enforceAccountLockout", "enforceAccountLockout"), ("accountLockoutAttempts", "accountLockoutAttempts"), + ("apiAuthentication", "apiAuthentication"), + ("enforceAccountLockout", "enforceAccountLockout"), + ("enforceDifferentPasswords", "enforceDifferentPasswords"), ("enforceIdleTimeout", "enforceIdleTimeout"), - ("idleTimeoutMinutes", "idleTimeoutMinutes"), - ("enforceTwoFactorAuth", "enforceTwoFactorAuth"), ("enforceLoginIpRanges", "enforceLoginIpRanges"), + ("enforcePasswordExpiration", "enforcePasswordExpiration"), + ("enforceStrongPasswords", "enforceStrongPasswords"), + ("enforceTwoFactorAuth", "enforceTwoFactorAuth"), + ("idleTimeoutMinutes", "idleTimeoutMinutes"), ("loginIpRanges", "loginIpRanges"), - ("apiAuthentication", "apiAuthentication"), + ("numDifferentPasswords", "numDifferentPasswords"), ("organizationId", "organizationId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_networks_combine.py b/ansible_collections/cisco/meraki/plugins/action/organizations_networks_combine.py index c6d337d78..395cd6597 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_networks_combine.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_networks_combine.py @@ -25,9 +25,9 @@ from ansible_collections.cisco.meraki.plugins.plugin_utils.meraki import ( argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( + enrollmentString=dict(type="str"), name=dict(type="str"), networkIds=dict(type="list"), - enrollmentString=dict(type="str"), organizationId=dict(type="str"), )) @@ -67,9 +67,9 @@ class ActionModule(ActionBase): def get_object(self, params): new_object = dict( + enrollmentString=params.get("enrollmentString"), name=params.get("name"), networkIds=params.get("networkIds"), - enrollmentString=params.get("enrollmentString"), organizationId=params.get("organizationId"), ) return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_openapi_spec_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_openapi_spec_info.py index 6ad1215dc..2d6bb35ed 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_openapi_spec_info.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_openapi_spec_info.py @@ -26,6 +26,7 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( organizationId=dict(type="str"), + version=dict(type="int"), )) required_if = [] @@ -67,6 +68,9 @@ class ActionModule(ActionBase): if params.get("organizationId") is not None: new_object["organizationId"] = params.get( "organizationId") + if params.get("version") is not None: + new_object["version"] = params.get( + "version") return new_object diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects.py b/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects.py index 6e49366b2..e412ec4d4 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects.py @@ -32,14 +32,14 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), category=dict(type="str"), - type=dict(type="str"), cidr=dict(type="str"), fqdn=dict(type="str"), - mask=dict(type="str"), - ip=dict(type="str"), groupIds=dict(type="list"), + ip=dict(type="str"), + mask=dict(type="str"), + name=dict(type="str"), + type=dict(type="str"), organizationId=dict(type="str"), policyObjectId=dict(type="str"), )) @@ -57,14 +57,14 @@ class OrganizationsPolicyObjects(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), category=params.get("category"), - type=params.get("type"), cidr=params.get("cidr"), fqdn=params.get("fqdn"), - mask=params.get("mask"), - ip=params.get("ip"), groupIds=params.get("groupIds"), + ip=params.get("ip"), + mask=params.get("mask"), + name=params.get("name"), + type=params.get("type"), organizationId=params.get("organizationId"), policyObjectId=params.get("policyObjectId"), ) @@ -98,30 +98,30 @@ class OrganizationsPolicyObjects(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('category') is not None or self.new_object.get('category') is not None: new_object_params['category'] = self.new_object.get('category') or \ self.new_object.get('category') - if self.new_object.get('type') is not None or self.new_object.get('type') is not None: - new_object_params['type'] = self.new_object.get('type') or \ - self.new_object.get('type') if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: new_object_params['cidr'] = self.new_object.get('cidr') or \ self.new_object.get('cidr') if self.new_object.get('fqdn') is not None or self.new_object.get('fqdn') is not None: new_object_params['fqdn'] = self.new_object.get('fqdn') or \ self.new_object.get('fqdn') - if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: - new_object_params['mask'] = self.new_object.get('mask') or \ - self.new_object.get('mask') - if self.new_object.get('ip') is not None or self.new_object.get('ip') is not None: - new_object_params['ip'] = self.new_object.get('ip') or \ - self.new_object.get('ip') if self.new_object.get('groupIds') is not None or self.new_object.get('group_ids') is not None: new_object_params['groupIds'] = self.new_object.get('groupIds') or \ self.new_object.get('group_ids') + if self.new_object.get('ip') is not None or self.new_object.get('ip') is not None: + new_object_params['ip'] = self.new_object.get('ip') or \ + self.new_object.get('ip') + if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: + new_object_params['mask'] = self.new_object.get('mask') or \ + self.new_object.get('mask') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('type') is not None or self.new_object.get('type') is not None: + new_object_params['type'] = self.new_object.get('type') or \ + self.new_object.get('type') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -139,24 +139,24 @@ class OrganizationsPolicyObjects(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('cidr') is not None or self.new_object.get('cidr') is not None: new_object_params['cidr'] = self.new_object.get('cidr') or \ self.new_object.get('cidr') if self.new_object.get('fqdn') is not None or self.new_object.get('fqdn') is not None: new_object_params['fqdn'] = self.new_object.get('fqdn') or \ self.new_object.get('fqdn') - if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: - new_object_params['mask'] = self.new_object.get('mask') or \ - self.new_object.get('mask') - if self.new_object.get('ip') is not None or self.new_object.get('ip') is not None: - new_object_params['ip'] = self.new_object.get('ip') or \ - self.new_object.get('ip') if self.new_object.get('groupIds') is not None or self.new_object.get('group_ids') is not None: new_object_params['groupIds'] = self.new_object.get('groupIds') or \ self.new_object.get('group_ids') + if self.new_object.get('ip') is not None or self.new_object.get('ip') is not None: + new_object_params['ip'] = self.new_object.get('ip') or \ + self.new_object.get('ip') + if self.new_object.get('mask') is not None or self.new_object.get('mask') is not None: + new_object_params['mask'] = self.new_object.get('mask') or \ + self.new_object.get('mask') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -234,14 +234,14 @@ class OrganizationsPolicyObjects(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("category", "category"), - ("type", "type"), ("cidr", "cidr"), ("fqdn", "fqdn"), - ("mask", "mask"), - ("ip", "ip"), ("groupIds", "groupIds"), + ("ip", "ip"), + ("mask", "mask"), + ("name", "name"), + ("type", "type"), ("organizationId", "organizationId"), ("policyObjectId", "policyObjectId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects_groups.py b/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects_groups.py index ff6b3f852..7de772a5e 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects_groups.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_policy_objects_groups.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - name=dict(type="str"), category=dict(type="str"), + name=dict(type="str"), objectIds=dict(type="list"), organizationId=dict(type="str"), policyObjectGroupId=dict(type="str"), @@ -52,8 +52,8 @@ class OrganizationsPolicyObjectsGroups(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - name=params.get("name"), category=params.get("category"), + name=params.get("name"), objectIds=params.get("objectIds"), organizationId=params.get("organizationId"), policyObjectGroupId=params.get("policyObjectGroupId"), @@ -88,12 +88,12 @@ class OrganizationsPolicyObjectsGroups(object): def create_params(self): new_object_params = {} - if self.new_object.get('name') is not None or self.new_object.get('name') is not None: - new_object_params['name'] = self.new_object.get('name') or \ - self.new_object.get('name') if self.new_object.get('category') is not None or self.new_object.get('category') is not None: new_object_params['category'] = self.new_object.get('category') or \ self.new_object.get('category') + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') if self.new_object.get('objectIds') is not None or self.new_object.get('object_ids') is not None: new_object_params['objectIds'] = self.new_object.get('objectIds') or \ self.new_object.get('object_ids') @@ -197,8 +197,8 @@ class OrganizationsPolicyObjectsGroups(object): requested_obj = self.new_object obj_params = [ - ("name", "name"), ("category", "category"), + ("name", "name"), ("objectIds", "objectIds"), ("organizationId", "organizationId"), ("policyObjectGroupId", "policyObjectGroupId"), diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_saml_idps.py b/ansible_collections/cisco/meraki/plugins/action/organizations_saml_idps.py index e557665b9..196750ebf 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_saml_idps.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_saml_idps.py @@ -32,8 +32,8 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - x509certSha1Fingerprint=dict(type="str"), sloLogoutUrl=dict(type="str"), + x509certSha1Fingerprint=dict(type="str"), organizationId=dict(type="str"), idpId=dict(type="str"), )) @@ -51,8 +51,8 @@ class OrganizationsSamlIdps(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - x509certSha1Fingerprint=params.get("x509certSha1Fingerprint"), sloLogoutUrl=params.get("sloLogoutUrl"), + x509certSha1Fingerprint=params.get("x509certSha1Fingerprint"), organizationId=params.get("organizationId"), idpId=params.get("idpId"), ) @@ -76,12 +76,12 @@ class OrganizationsSamlIdps(object): def create_params(self): new_object_params = {} - if self.new_object.get('x509certSha1Fingerprint') is not None or self.new_object.get('x509cert_sha1_fingerprint') is not None: - new_object_params['x509certSha1Fingerprint'] = self.new_object.get('x509certSha1Fingerprint') or \ - self.new_object.get('x509cert_sha1_fingerprint') if self.new_object.get('sloLogoutUrl') is not None or self.new_object.get('slo_logout_url') is not None: new_object_params['sloLogoutUrl'] = self.new_object.get('sloLogoutUrl') or \ self.new_object.get('slo_logout_url') + if self.new_object.get('x509certSha1Fingerprint') is not None or self.new_object.get('x509cert_sha1_fingerprint') is not None: + new_object_params['x509certSha1Fingerprint'] = self.new_object.get('x509certSha1Fingerprint') or \ + self.new_object.get('x509cert_sha1_fingerprint') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -99,12 +99,12 @@ class OrganizationsSamlIdps(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('x509certSha1Fingerprint') is not None or self.new_object.get('x509cert_sha1_fingerprint') is not None: - new_object_params['x509certSha1Fingerprint'] = self.new_object.get('x509certSha1Fingerprint') or \ - self.new_object.get('x509cert_sha1_fingerprint') if self.new_object.get('sloLogoutUrl') is not None or self.new_object.get('slo_logout_url') is not None: new_object_params['sloLogoutUrl'] = self.new_object.get('sloLogoutUrl') or \ self.new_object.get('slo_logout_url') + if self.new_object.get('x509certSha1Fingerprint') is not None or self.new_object.get('x509cert_sha1_fingerprint') is not None: + new_object_params['x509certSha1Fingerprint'] = self.new_object.get('x509certSha1Fingerprint') or \ + self.new_object.get('x509cert_sha1_fingerprint') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -182,8 +182,8 @@ class OrganizationsSamlIdps(object): requested_obj = self.new_object obj_params = [ - ("x509certSha1Fingerprint", "x509certSha1Fingerprint"), ("sloLogoutUrl", "sloLogoutUrl"), + ("x509certSha1Fingerprint", "x509certSha1Fingerprint"), ("organizationId", "organizationId"), ("idpId", "idpId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_saml_roles.py b/ansible_collections/cisco/meraki/plugins/action/organizations_saml_roles.py index 48dc6dfdb..bfc4a978b 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_saml_roles.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_saml_roles.py @@ -32,10 +32,10 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present", "absent"]), - role=dict(type="str"), + networks=dict(type="list"), orgAccess=dict(type="str"), + role=dict(type="str"), tags=dict(type="list"), - networks=dict(type="list"), organizationId=dict(type="str"), samlRoleId=dict(type="str"), )) @@ -53,10 +53,10 @@ class OrganizationsSamlRoles(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( - role=params.get("role"), + networks=params.get("networks"), orgAccess=params.get("orgAccess"), + role=params.get("role"), tags=params.get("tags"), - networks=params.get("networks"), organizationId=params.get("organizationId"), samlRoleId=params.get("samlRoleId"), ) @@ -80,18 +80,18 @@ class OrganizationsSamlRoles(object): def create_params(self): new_object_params = {} - if self.new_object.get('role') is not None or self.new_object.get('role') is not None: - new_object_params['role'] = self.new_object.get('role') or \ - self.new_object.get('role') + if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: + new_object_params['networks'] = self.new_object.get('networks') or \ + self.new_object.get('networks') if self.new_object.get('orgAccess') is not None or self.new_object.get('org_access') is not None: new_object_params['orgAccess'] = self.new_object.get('orgAccess') or \ self.new_object.get('org_access') + if self.new_object.get('role') is not None or self.new_object.get('role') is not None: + new_object_params['role'] = self.new_object.get('role') or \ + self.new_object.get('role') if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: new_object_params['tags'] = self.new_object.get('tags') or \ self.new_object.get('tags') - if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: - new_object_params['networks'] = self.new_object.get('networks') or \ - self.new_object.get('networks') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -109,18 +109,18 @@ class OrganizationsSamlRoles(object): def update_by_id_params(self): new_object_params = {} - if self.new_object.get('role') is not None or self.new_object.get('role') is not None: - new_object_params['role'] = self.new_object.get('role') or \ - self.new_object.get('role') + if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: + new_object_params['networks'] = self.new_object.get('networks') or \ + self.new_object.get('networks') if self.new_object.get('orgAccess') is not None or self.new_object.get('org_access') is not None: new_object_params['orgAccess'] = self.new_object.get('orgAccess') or \ self.new_object.get('org_access') + if self.new_object.get('role') is not None or self.new_object.get('role') is not None: + new_object_params['role'] = self.new_object.get('role') or \ + self.new_object.get('role') if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: new_object_params['tags'] = self.new_object.get('tags') or \ self.new_object.get('tags') - if self.new_object.get('networks') is not None or self.new_object.get('networks') is not None: - new_object_params['networks'] = self.new_object.get('networks') or \ - self.new_object.get('networks') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -198,10 +198,10 @@ class OrganizationsSamlRoles(object): requested_obj = self.new_object obj_params = [ - ("role", "role"), + ("networks", "networks"), ("orgAccess", "orgAccess"), + ("role", "role"), ("tags", "tags"), - ("networks", "networks"), ("organizationId", "organizationId"), ("samlRoleId", "samlRoleId"), ] diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles.py b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles.py new file mode 100644 index 000000000..4bbf8db98 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles.py @@ -0,0 +1,256 @@ +#!/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, + meraki_compare_equality, + get_dict_result, +) +from ansible_collections.cisco.meraki.plugins.plugin_utils.exceptions import ( + InconsistentParameters, +) + +# Get common arguments specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + state=dict(type="str", default="present", choices=["present", "absent"]), + name=dict(type="str"), + scope=dict(type="str"), + tags=dict(type="list"), + organizationId=dict(type="str"), +)) + +required_if = [ + ("state", "present", ["name", "organizationId"], True), + ("state", "absent", ["name", "organizationId"], True), +] +required_one_of = [] +mutually_exclusive = [] +required_together = [] + + +class OrganizationsSmAdminsRoles(object): + def __init__(self, params, meraki): + self.meraki = meraki + self.new_object = dict( + name=params.get("name"), + scope=params.get("scope"), + tags=params.get("tags"), + organizationId=params.get("organizationId"), + ) + + def get_all_params(self, name=None, id=None): + new_object_params = {} + if self.new_object.get('perPage') is not None or self.new_object.get('per_page') is not None: + new_object_params['perPage'] = self.new_object.get('perPage') or \ + self.new_object.get('per_page') + new_object_params['total_pages'] = -1 + if self.new_object.get('startingAfter') is not None or self.new_object.get('starting_after') is not None: + new_object_params['startingAfter'] = self.new_object.get('startingAfter') or \ + self.new_object.get('starting_after') + if self.new_object.get('endingBefore') is not None or self.new_object.get('ending_before') is not None: + new_object_params['endingBefore'] = self.new_object.get('endingBefore') or \ + self.new_object.get('ending_before') + if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: + new_object_params['organizationId'] = self.new_object.get('organizationId') or \ + self.new_object.get('organization_id') + return new_object_params + + def create_params(self): + new_object_params = {} + if self.new_object.get('name') is not None or self.new_object.get('name') is not None: + new_object_params['name'] = self.new_object.get('name') or \ + self.new_object.get('name') + if self.new_object.get('scope') is not None or self.new_object.get('scope') is not None: + new_object_params['scope'] = self.new_object.get('scope') or \ + self.new_object.get('scope') + if self.new_object.get('tags') is not None or self.new_object.get('tags') is not None: + new_object_params['tags'] = self.new_object.get('tags') or \ + self.new_object.get('tags') + if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: + new_object_params['organizationId'] = self.new_object.get('organizationId') or \ + self.new_object.get('organization_id') + return new_object_params + + def get_object_by_name(self, name): + result = None + # NOTE: Does not have a get by name method or it is in another action + try: + items = self.meraki.exec_meraki( + family="sm", + function="getOrganizationSmAdminsRoles", + params=self.get_all_params(name=name), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'name', name) + if result is None: + result = items + except Exception as e: + print("Error: ", e) + result = None + return result + + def get_object_by_id(self, id): + result = None + # NOTE: Does not have a get by id method or it is in another action + try: + items = self.meraki.exec_meraki( + family="sm", + function="getOrganizationSmAdminsRoles", + params=self.get_all_params(id=id), + ) + if isinstance(items, dict): + if 'response' in items: + items = items.get('response') + result = get_dict_result(items, 'id', id) + except Exception as e: + print("Error: ", e) + result = None + return result + + def exists(self): + id_exists = False + name_exists = False + prev_obj = None + o_id = self.new_object.get("id") + name = self.new_object.get("name") + if o_id: + prev_obj = self.get_object_by_id(o_id) + id_exists = prev_obj is not None and isinstance(prev_obj, dict) + if not id_exists and name: + prev_obj = self.get_object_by_name(name) + name_exists = prev_obj is not None and isinstance(prev_obj, dict) + if name_exists: + _id = prev_obj.get("id") + if id_exists and name_exists and o_id != _id: + raise InconsistentParameters( + "The 'id' and 'name' params don't refer to the same object") + if _id: + self.new_object.update(dict(id=_id)) + it_exists = prev_obj is not None and isinstance(prev_obj, dict) + return (it_exists, prev_obj) + + def requires_update(self, current_obj): + requested_obj = self.new_object + + obj_params = [ + ("name", "name"), + ("scope", "scope"), + ("tags", "tags"), + ("organizationId", "organizationId"), + ] + # Method 1. Params present in request (Ansible) obj are the same as the current (DNAC) params + # If any does not have eq params, it requires update + return any(not meraki_compare_equality(current_obj.get(meraki_param), + requested_obj.get(ansible_param)) + for (meraki_param, ansible_param) in obj_params) + + def create(self): + result = self.meraki.exec_meraki( + family="sm", + function="createOrganizationSmAdminsRole", + params=self.create_params(), + op_modifies=True, + ) + return result + + def update(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have update method. What do we do? + return result + + def delete(self): + id = self.new_object.get("id") + name = self.new_object.get("name") + result = None + # NOTE: Does not have delete method. What do we do? + return result + + +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 = False + 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 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() + + meraki = MERAKI(self._task.args) + obj = OrganizationsSmAdminsRoles(self._task.args, meraki) + + state = self._task.args.get("state") + + response = None + + if state == "present": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + if obj.requires_update(prev_obj): + response = obj.update() + meraki.object_updated() + else: + response = prev_obj + meraki.object_already_present() + else: + response = obj.create() + meraki.object_created() + + elif state == "absent": + (obj_exists, prev_obj) = obj.exists() + if obj_exists: + response = obj.delete() + meraki.object_deleted() + else: + meraki.object_already_absent() + + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles_info.py new file mode 100644 index 000000000..297c64b48 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_admins_roles_info.py @@ -0,0 +1,108 @@ +#!/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( + organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + + 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) + + response = meraki.exec_meraki( + family="sm", + function='getOrganizationSmAdminsRoles', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments.py b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments.py new file mode 100644 index 000000000..8e51a06e0 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments.py @@ -0,0 +1,89 @@ +#!/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 arguements specification +argument_spec = meraki_argument_spec() +# Add arguments specific for this module +argument_spec.update(dict( + items=dict(type="list"), + organizationId=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 = False + 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 = dict( + items=params.get("items"), + organizationId=params.get("organizationId"), + ) + 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() + + meraki = MERAKI(params=self._task.args) + + response = meraki.exec_meraki( + family="sm", + function='updateOrganizationSmSentryPoliciesAssignments', + op_modifies=True, + params=self.get_object(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments_by_network_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments_by_network_info.py new file mode 100644 index 000000000..fdc3bd05d --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_sm_sentry_policies_assignments_by_network_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( + organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + networkIds=dict(type="list"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + + 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) + + response = meraki.exec_meraki( + family="sm", + function='getOrganizationSmSentryPoliciesAssignmentsByNetwork', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_snmp.py b/ansible_collections/cisco/meraki/plugins/action/organizations_snmp.py index aaf676ee7..4641a02e5 100644 --- a/ansible_collections/cisco/meraki/plugins/action/organizations_snmp.py +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_snmp.py @@ -32,13 +32,13 @@ argument_spec = meraki_argument_spec() # Add arguments specific for this module argument_spec.update(dict( state=dict(type="str", default="present", choices=["present"]), + peerIps=dict(type="list"), v2cEnabled=dict(type="bool"), - v3Enabled=dict(type="bool"), v3AuthMode=dict(type="str"), v3AuthPass=dict(type="str"), + v3Enabled=dict(type="bool"), v3PrivMode=dict(type="str"), v3PrivPass=dict(type="str"), - peerIps=dict(type="list"), organizationId=dict(type="str"), )) @@ -54,13 +54,13 @@ class OrganizationsSnmp(object): def __init__(self, params, meraki): self.meraki = meraki self.new_object = dict( + peerIps=params.get("peerIps"), v2cEnabled=params.get("v2cEnabled"), - v3Enabled=params.get("v3Enabled"), v3AuthMode=params.get("v3AuthMode"), v3AuthPass=params.get("v3AuthPass"), + v3Enabled=params.get("v3Enabled"), v3PrivMode=params.get("v3PrivMode"), v3PrivPass=params.get("v3PrivPass"), - peerIps=params.get("peerIps"), organization_id=params.get("organizationId"), ) @@ -73,25 +73,25 @@ class OrganizationsSnmp(object): def update_all_params(self): new_object_params = {} + if self.new_object.get('peerIps') is not None or self.new_object.get('peer_ips') is not None: + new_object_params['peerIps'] = self.new_object.get('peerIps') or \ + self.new_object.get('peer_ips') if self.new_object.get('v2cEnabled') is not None or self.new_object.get('v2c_enabled') is not None: new_object_params['v2cEnabled'] = self.new_object.get('v2cEnabled') - if self.new_object.get('v3Enabled') is not None or self.new_object.get('v3_enabled') is not None: - new_object_params['v3Enabled'] = self.new_object.get('v3Enabled') if self.new_object.get('v3AuthMode') is not None or self.new_object.get('v3_auth_mode') is not None: new_object_params['v3AuthMode'] = self.new_object.get('v3AuthMode') or \ self.new_object.get('v3_auth_mode') if self.new_object.get('v3AuthPass') is not None or self.new_object.get('v3_auth_pass') is not None: new_object_params['v3AuthPass'] = self.new_object.get('v3AuthPass') or \ self.new_object.get('v3_auth_pass') + if self.new_object.get('v3Enabled') is not None or self.new_object.get('v3_enabled') is not None: + new_object_params['v3Enabled'] = self.new_object.get('v3Enabled') if self.new_object.get('v3PrivMode') is not None or self.new_object.get('v3_priv_mode') is not None: new_object_params['v3PrivMode'] = self.new_object.get('v3PrivMode') or \ self.new_object.get('v3_priv_mode') if self.new_object.get('v3PrivPass') is not None or self.new_object.get('v3_priv_pass') is not None: new_object_params['v3PrivPass'] = self.new_object.get('v3PrivPass') or \ self.new_object.get('v3_priv_pass') - if self.new_object.get('peerIps') is not None or self.new_object.get('peer_ips') is not None: - new_object_params['peerIps'] = self.new_object.get('peerIps') or \ - self.new_object.get('peer_ips') if self.new_object.get('organizationId') is not None or self.new_object.get('organization_id') is not None: new_object_params['organizationId'] = self.new_object.get('organizationId') or \ self.new_object.get('organization_id') @@ -148,13 +148,13 @@ class OrganizationsSnmp(object): requested_obj = self.new_object obj_params = [ + ("peerIps", "peerIps"), ("v2cEnabled", "v2cEnabled"), - ("v3Enabled", "v3Enabled"), ("v3AuthMode", "v3AuthMode"), ("v3AuthPass", "v3AuthPass"), + ("v3Enabled", "v3Enabled"), ("v3PrivMode", "v3PrivMode"), ("v3PrivPass", "v3PrivPass"), - ("peerIps", "peerIps"), ("organizationId", "organizationId"), ] # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_summary_top_networks_by_status_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_summary_top_networks_by_status_info.py new file mode 100644 index 000000000..c7091e152 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_summary_top_networks_by_status_info.py @@ -0,0 +1,108 @@ +#!/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( + organizationId=dict(type="str"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + + 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) + + response = meraki.exec_meraki( + family="organizations", + function='getOrganizationSummaryTopNetworksByStatus', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_webhooks_callbacks_statuses_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_webhooks_callbacks_statuses_info.py new file mode 100644 index 000000000..868d02371 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_webhooks_callbacks_statuses_info.py @@ -0,0 +1,102 @@ +#!/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( + organizationId=dict(type="str"), + callbackId=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("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("callbackId") is not None: + new_object["callbackId"] = params.get( + "callbackId") + 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("callbackId") + if id: + response = meraki.exec_meraki( + family="organizations", + function='getOrganizationWebhooksCallbacksStatus', + 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: + # NOTE: Does not have a get all method or it is in another action + response = None + meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module") + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result diff --git a/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_device_info.py new file mode 100644 index 000000000..5d78f5a98 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_device_info.py @@ -0,0 +1,132 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + interval=dict(type="int"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("interval") is not None: + new_object["interval"] = params.get( + "interval") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesChannelUtilizationByDevice', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_network_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_network_info.py new file mode 100644 index 000000000..fb57fd52f --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_by_network_info.py @@ -0,0 +1,132 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + interval=dict(type="int"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("interval") is not None: + new_object["interval"] = params.get( + "interval") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesChannelUtilizationByNetwork', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_device_by_interval_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_device_by_interval_info.py new file mode 100644 index 000000000..9bd73d0b2 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_device_by_interval_info.py @@ -0,0 +1,132 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + interval=dict(type="int"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("interval") is not None: + new_object["interval"] = params.get( + "interval") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesChannelUtilizationHistoryByDeviceByInterval', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_network_by_interval_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_network_by_interval_info.py new file mode 100644 index 000000000..872cc59be --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_channel_utilization_history_by_network_by_interval_info.py @@ -0,0 +1,132 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), + interval=dict(type="int"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + if params.get("interval") is not None: + new_object["interval"] = params.get( + "interval") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesChannelUtilizationHistoryByNetworkByInterval', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_client_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_client_info.py new file mode 100644 index 000000000..772ffac1a --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_client_info.py @@ -0,0 +1,136 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + ssids=dict(type="list"), + bands=dict(type="list"), + macs=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("ssids") is not None: + new_object["ssids"] = params.get( + "ssids") + if params.get("bands") is not None: + new_object["bands"] = params.get( + "bands") + if params.get("macs") is not None: + new_object["macs"] = params.get( + "macs") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesPacketLossByClient', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_device_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_device_info.py new file mode 100644 index 000000000..beef87f14 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_device_info.py @@ -0,0 +1,136 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + ssids=dict(type="list"), + bands=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("ssids") is not None: + new_object["ssids"] = params.get( + "ssids") + if params.get("bands") is not None: + new_object["bands"] = params.get( + "bands") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesPacketLossByDevice', + 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/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_network_info.py b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_network_info.py new file mode 100644 index 000000000..b871a3539 --- /dev/null +++ b/ansible_collections/cisco/meraki/plugins/action/organizations_wireless_devices_packet_loss_by_network_info.py @@ -0,0 +1,136 @@ +#!/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( + organizationId=dict(type="str"), + networkIds=dict(type="list"), + serials=dict(type="list"), + ssids=dict(type="list"), + bands=dict(type="list"), + perPage=dict(type="int"), + total_pages=dict(type="int"), + direction=dict(type="str"), + startingAfter=dict(type="str"), + endingBefore=dict(type="str"), + t0=dict(type="str"), + t1=dict(type="str"), + timespan=dict(type="float"), +)) + +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_all(self, params): + new_object = {} + if params.get("organizationId") is not None: + new_object["organizationId"] = params.get( + "organizationId") + if params.get("networkIds") is not None: + new_object["networkIds"] = params.get( + "networkIds") + if params.get("serials") is not None: + new_object["serials"] = params.get( + "serials") + if params.get("ssids") is not None: + new_object["ssids"] = params.get( + "ssids") + if params.get("bands") is not None: + new_object["bands"] = params.get( + "bands") + if params.get("perPage") is not None: + new_object["perPage"] = params.get( + "perPage") + new_object['total_pages'] = params.get( + "total_pages") or 1 + new_object['direction'] = params.get( + "direction") or "next" + if params.get("startingAfter") is not None: + new_object["startingAfter"] = params.get( + "startingAfter") + if params.get("endingBefore") is not None: + new_object["endingBefore"] = params.get( + "endingBefore") + if params.get("t0") is not None: + new_object["t0"] = params.get( + "t0") + if params.get("t1") is not None: + new_object["t1"] = params.get( + "t1") + if params.get("timespan") is not None: + new_object["timespan"] = params.get( + "timespan") + + 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) + + response = meraki.exec_meraki( + family="wireless", + function='getOrganizationWirelessDevicesPacketLossByNetwork', + params=self.get_all(self._task.args), + ) + self._result.update(dict(meraki_response=response)) + self._result.update(meraki.exit_json()) + return self._result |