cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1634
Views
10
Helpful
2
Replies

Removing member from line group via API - Python

JasunKAR
Level 1
Level 1

Howdy!
I'm trying to write a script to remove a member from a line group via the API using python.  I can get it to remove a member but it doesn't seem to actually "save" my change.  I can go into the http and see the member removed, but when I query the line group via getLineGroup it shows the lineSelect out of sequence. 

 

For example:  I have 5 members in a group.  I run the script to get the 5 members and add their extensions to a dictionary.  I check the length of the dictionary to get 0 1 2 3 4 which is the lineselectorder in the response.  I then pass that to my updateLineGroup (removeMembers) and it works.  However after that the line select is no longer in displaying properly.  


When I run another getLineGroup now the line select of the one I removed is missing, but they do not reorder.  So in the response may be 0 1 3 4 and now my script breaks because the len no longer lines up with the users in the group.  It doesn't adjust itself until I go into the https interface and manually save the line group.  Then it realigns to 0 1 2 3 when I do a len on the list.  

 

There isn't a saveLineGroup like there is apply in the wsdl.  Has anyone else accomplished this above?  Hopefully I expressed my challenge clearly.

See screenshot of example.  Yellow circles shows post removed line and then a getlineGroup where we see "1" is no longer in the list and will not reorder until you go manually save the line group in the admin http interface. 

  LG_Members_OOR.jpg
Current script I'm using.  Possibly not the right way to go about this   

phoneBook=[]

print('')
lineGroup=input('Enter Line Group: ')
userExt=input('Enter Line to Remove: ')

resp = service.getLineGroup(name = lineGroup)
lineGroupMembers=resp['return']['lineGroup']['members']['member']

for x in lineGroupMembers:
    phoneExt=x['directoryNumber']['pattern']
    phoneBook.append(phoneExt)

lineIndex=phoneBook.index(userExt)

resp = service.updateLineGroup(name = lineGroup, removeMembers = {'member': {'lineSelectionOrder': lineIndex, 'directoryNumber': {'pattern': userExt, 'routePartitionName': 'GLOBAL_DN_PT'} } })

print(resp)

2 Replies 2

dstaudt
Cisco Employee
Cisco Employee

I think I am able to reproduce the behaviour you describe on my v14 lab system.  Using <updateLineGroup> with a <removeMembers> list results in 'holes' in the lineSelectionOrder of the remaining members.  I'm not sure that those holes are necessarily illegal/invalid (if there are actual problems with the behaviour of the Line Group at run time due to this, let me know), though I see how they can be confusing for your scripts.

My suggestions would be to either change your script so that it is able to handle lineSelectionOrder 'holes' better, or perhaps change your <updateLineGroup> request so that it submits the entire list of members you want (including their new, sequential lineSelectionOrder values) in a <members> list, instead of specifying only the one to remove in <removeMembers>.  

Howdy!  Thanks for the reply.

 

And that is exactly what I was thinking I may need to do and why I was building a list out of the response.  I wanted to use the list to remove everything from the group, remove the number I want removed from the LG, then submit the new list without the number I want removed and re-add everything back.

 

I'll try that route.  What I'm afraid of is the list isn't actually saved   I haven't done any testing on that theory which I will do.

 

Thanks again!  I'll come back here and post again with my results in case others have this issue.