cisco-en-programmability / dnacentersdk

Cisco DNA Center Python SDK
https://dnacentersdk.readthedocs.io/en/latest/
MIT License
70 stars 31 forks source link

tag.py def updates_tag_membership incorrectly requires a List for memberToTags #155

Open cottersb opened 1 month ago

cottersb commented 1 month ago

Prerequisites

Describe the bug updates_tag_membership in 2.3.5.3 and prior versions is looking for a List for the variable memberToTags.

Expected behavior This is incorrect as API calls are expecting an Object not a List.

Screenshots 2.3.5.5: Non-working:

{
    "memberToTags": [
        {
            "220ca4a4-66cd-4559-a1e0-a1b8b7e6f27d": [
                "376ad2f5-2361-4616-ad44-360fb4938126",
                "5390a6a6-0c29-4711-8cd9-99ce48503434",
                "7b2acb8e-1c67-432d-96b7-96058ceb3957"
            ]
        }
    ],
    "memberType": "template"
}

{
    "response": {
        "errorCode": "BadRequest",
        "message": "Input data is not in proper format",
        "detail": "Input data is invalid"
    },
    "version": "1.0"
} 

Working:

{
    "memberToTags": {
            "220ca4a4-66cd-4559-a1e0-a1b8b7e6f27d": [
                "376ad2f5-2361-4616-ad44-360fb4938126",
                "5390a6a6-0c29-4711-8cd9-99ce48503434",
                "7b2acb8e-1c67-432d-96b7-96058ceb3957"
            ]
    },
    "memberType": "template"
}

{
    "response": {
        "taskId": "8c0e9a5a-1eb7-472b-8840-f4fd2cc6f56d",
        "url": "/api/v1/task/8c0e9a5a-1eb7-472b-8840-f4fd2cc6f56d"
    },
    "version": "1.0"
} 

Environment (please complete the following information):

Additional context This appears to be fixed in the 2.3.7.6 portion of the SDK based on the code changes I see but haven't tested. Fix should be back ported to previous versions.

dnacentersdk/api/v2_3_7_6/tag.py

    def update_tag_membership(self,
                              memberToTags=None,
                              memberType=None,
                              headers=None,
                              payload=None,
                              active_validation=True,
                              **request_parameters):
        """Update tag membership. As part of the request payload through this API, only the specified members are added /
        retained to the given input tags. Possible values of memberType attribute in the request payload can be
        queried by using the /tag/member/type API .

        Args:
            memberToTags(object): Tag's memberToTags.