cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1040
Views
0
Helpful
5
Replies

Trying to extract Line info with AXL and Python

Keith Abbott
Level 1
Level 1

Hi All,

 

I am trying to extract line info from extensions  on call manager 11.5 using python and AXL.

 

I can see the data with the following test code, but I cant get at the data to assign it to variables.

 

    resp2 = service.getPhone(name=mac)
    phone_get = resp2['return'].phone
    lineApp = phone_get.lines.line
    #testtesttest
    for test in lineApp:
        for test2 in test:
            print("test:",test2)

Ive tried various combinations of things like

print(test2[label])

print(test2.label)

print(test2.label.value)

et cetera ad nausium

but havent had any luck

the specific fields Im looking for (among others) are label, display, displayAscii, and e164mask

 

Clearly Im not understanding what data structures are returned for getphone.lines, and how to use them.

 

Can someone put me on the right path before I waste anymore time?

 

thanks for your help

1 Accepted Solution

Accepted Solutions

npetrele
Cisco Employee
Cisco Employee

Here's a sample output of getPhone up to and including the lines.  Notice this:

 

'line': [ {

The [ tells you that what follows is a list. I think if you treat it like a list, you'll get the kind of output you're looking for.

 

 

{
   'return': {
       'phone': {
           'name': 'SEP151515151515',
           'description': 'SEP151515151515',
           'product': 'Cisco 8821',
           'model': 'Cisco 8821',
           'class': 'Phone',
           'protocol': 'SIP',
           'protocolSide': 'User',
           'callingSearchSpaceName': {
               '_value_1': None,
               'uuid': None
           },
           'devicePoolName': {
               '_value_1': 'Default',
               'uuid': '{1B1B9EB6-7803-11D3-BDF0-00108302EAD1}'
           },
           'commonDeviceConfigName': {
               '_value_1': None,
               'uuid': None
           },
           'commonPhoneConfigName': {
               '_value_1': 'Standard Common Phone Profile',
               'uuid': '{AC243D17-98B4-4118-8FEB-5FF2E1B781AC}'
           },
           'networkLocation': 'Use System Default',
           'locationName': {
               '_value_1': 'Hub_None',
               'uuid': '{29C5C1C4-8871-4D1E-8394-0B9181E8C54D}'
           },
           'mediaResourceListName': {
               '_value_1': None,
               'uuid': None
           },
           'networkHoldMohAudioSourceId': None,
           'userHoldMohAudioSourceId': None,
           'automatedAlternateRoutingCssName': {
               '_value_1': None,
               'uuid': None
           },
           'aarNeighborhoodName': {
               '_value_1': None,
               'uuid': None
           },
           'loadInformation': {
               '_value_1': 'sip8821.11-0-4-14',
               'special': 'false'
           },
           'vendorConfig': None,
           'versionStamp': '{1548087040-BA9ED5FB-CE94-4DFE-87FB-674F451AC688}',
           'traceFlag': 'false',
           'mlppDomainId': None,
           'mlppIndicationStatus': 'Default',
           'preemption': 'Default',
           'useTrustedRelayPoint': 'Default',
           'retryVideoCallAsAudio': 'true',
           'securityProfileName': {
               '_value_1': 'Cisco 8821 - Standard SIP Non-Secure Profile',
               'uuid': '{2E1DF068-6CDD-42C9-98E2-AD96983BDB16}'
           },
           'sipProfileName': {
               '_value_1': 'Standard SIP Profile',
               'uuid': '{FCBC7581-4D8D-48F3-917E-00B09FB39213}'
           },
           'cgpnTransformationCssName': {
               '_value_1': None,
               'uuid': None
           },
           'useDevicePoolCgpnTransformCss': 'true',
           'geoLocationName': {
               '_value_1': None,
               'uuid': None
           },
           'geoLocationFilterName': {
               '_value_1': None,
               'uuid': None
           },
           'sendGeoLocation': 'false',
           'lines': {
               'line': [
                   {
                       'index': 1,
                       'label': None,
                       'display': None,
                       'dirn': {
                           'pattern': '1111',
                           'routePartitionName': {
                               '_value_1': None,
                               'uuid': None
                           },
                           'uuid': '{BE4AED9D-18C7-2710-C93A-804B9B635B1C}'
                       },
                       'ringSetting': 'Use System Default',
                       'consecutiveRingSetting': 'Use System Default',
                       'ringSettingIdlePickupAlert': 'Use System Default',
                       'ringSettingActivePickupAlert': 'Use System Default',
                       'displayAscii': None,
                       'e164Mask': None,
                       'dialPlanWizardId': None,
                       'mwlPolicy': 'Use System Policy',
                       'maxNumCalls': 4,
                       'busyTrigger': 2,
                       'callInfoDisplay': {
                           'callerName': 'true',
                           'callerNumber': 'false',
                           'redirectedNumber': 'false',
                           'dialedNumber': 'true'
                       },
                       'recordingProfileName': {
                           '_value_1': None,
                           'uuid': None
                       },
                       'monitoringCssName': {
                           '_value_1': None,
                           'uuid': None
                       },
                       'recordingFlag': 'Call Recording Disabled',
                       'audibleMwi': 'Default',
                       'speedDial': None,
                       'partitionUsage': 'General',
                       'associatedEndusers': {
                           'enduser': [
                               {
                                   'userId': 'johnq'
                               }
                           ]
                       },
                       'missedCallLogging': 'true',
                       'recordingMediaSource': 'Gateway Preferred',
                       'ctiid': None,
                       'uuid': '{ED53A607-6688-B093-3615-B5E0D1C352BA}'
                   }
               ],
               'lineIdentifier': None
           },

View solution in original post

5 Replies 5

npetrele
Cisco Employee
Cisco Employee

Here's a sample output of getPhone up to and including the lines.  Notice this:

 

'line': [ {

The [ tells you that what follows is a list. I think if you treat it like a list, you'll get the kind of output you're looking for.

 

 

{
   'return': {
       'phone': {
           'name': 'SEP151515151515',
           'description': 'SEP151515151515',
           'product': 'Cisco 8821',
           'model': 'Cisco 8821',
           'class': 'Phone',
           'protocol': 'SIP',
           'protocolSide': 'User',
           'callingSearchSpaceName': {
               '_value_1': None,
               'uuid': None
           },
           'devicePoolName': {
               '_value_1': 'Default',
               'uuid': '{1B1B9EB6-7803-11D3-BDF0-00108302EAD1}'
           },
           'commonDeviceConfigName': {
               '_value_1': None,
               'uuid': None
           },
           'commonPhoneConfigName': {
               '_value_1': 'Standard Common Phone Profile',
               'uuid': '{AC243D17-98B4-4118-8FEB-5FF2E1B781AC}'
           },
           'networkLocation': 'Use System Default',
           'locationName': {
               '_value_1': 'Hub_None',
               'uuid': '{29C5C1C4-8871-4D1E-8394-0B9181E8C54D}'
           },
           'mediaResourceListName': {
               '_value_1': None,
               'uuid': None
           },
           'networkHoldMohAudioSourceId': None,
           'userHoldMohAudioSourceId': None,
           'automatedAlternateRoutingCssName': {
               '_value_1': None,
               'uuid': None
           },
           'aarNeighborhoodName': {
               '_value_1': None,
               'uuid': None
           },
           'loadInformation': {
               '_value_1': 'sip8821.11-0-4-14',
               'special': 'false'
           },
           'vendorConfig': None,
           'versionStamp': '{1548087040-BA9ED5FB-CE94-4DFE-87FB-674F451AC688}',
           'traceFlag': 'false',
           'mlppDomainId': None,
           'mlppIndicationStatus': 'Default',
           'preemption': 'Default',
           'useTrustedRelayPoint': 'Default',
           'retryVideoCallAsAudio': 'true',
           'securityProfileName': {
               '_value_1': 'Cisco 8821 - Standard SIP Non-Secure Profile',
               'uuid': '{2E1DF068-6CDD-42C9-98E2-AD96983BDB16}'
           },
           'sipProfileName': {
               '_value_1': 'Standard SIP Profile',
               'uuid': '{FCBC7581-4D8D-48F3-917E-00B09FB39213}'
           },
           'cgpnTransformationCssName': {
               '_value_1': None,
               'uuid': None
           },
           'useDevicePoolCgpnTransformCss': 'true',
           'geoLocationName': {
               '_value_1': None,
               'uuid': None
           },
           'geoLocationFilterName': {
               '_value_1': None,
               'uuid': None
           },
           'sendGeoLocation': 'false',
           'lines': {
               'line': [
                   {
                       'index': 1,
                       'label': None,
                       'display': None,
                       'dirn': {
                           'pattern': '1111',
                           'routePartitionName': {
                               '_value_1': None,
                               'uuid': None
                           },
                           'uuid': '{BE4AED9D-18C7-2710-C93A-804B9B635B1C}'
                       },
                       'ringSetting': 'Use System Default',
                       'consecutiveRingSetting': 'Use System Default',
                       'ringSettingIdlePickupAlert': 'Use System Default',
                       'ringSettingActivePickupAlert': 'Use System Default',
                       'displayAscii': None,
                       'e164Mask': None,
                       'dialPlanWizardId': None,
                       'mwlPolicy': 'Use System Policy',
                       'maxNumCalls': 4,
                       'busyTrigger': 2,
                       'callInfoDisplay': {
                           'callerName': 'true',
                           'callerNumber': 'false',
                           'redirectedNumber': 'false',
                           'dialedNumber': 'true'
                       },
                       'recordingProfileName': {
                           '_value_1': None,
                           'uuid': None
                       },
                       'monitoringCssName': {
                           '_value_1': None,
                           'uuid': None
                       },
                       'recordingFlag': 'Call Recording Disabled',
                       'audibleMwi': 'Default',
                       'speedDial': None,
                       'partitionUsage': 'General',
                       'associatedEndusers': {
                           'enduser': [
                               {
                                   'userId': 'johnq'
                               }
                           ]
                       },
                       'missedCallLogging': 'true',
                       'recordingMediaSource': 'Gateway Preferred',
                       'ctiid': None,
                       'uuid': '{ED53A607-6688-B093-3615-B5E0D1C352BA}'
                   }
               ],
               'lineIdentifier': None
           },

AWESOME!!!

 

Thanks! Thats just the nudge I needed!

 

For those slow of mind like me, the test code to access individual fields within a cisco phone line was:

try:
#    resp2 = service.getPhone(uuid=Tuuid)
    resp2 = service.getPhone(name=mac)
    phone_get = resp2['return'].phone
    lineApp = phone_get.lines.line
    print("L1 Label is:",lineApp[0]['label'])
    print("L2 Label is:",lineApp[1]['label'])

and the result looked like this:

L1 Label is: Jonas Grumby 22041 L1 LTL
L2 Label is: Jonas Grumby L2 LTL

 

Thanks again - I had been beating my head against that for some time, and with your info I got it in about 20 mins of fooling around to get the syntax right.

 

Do you happen to know a good reference site for getting more familiar with the AXL data structures - and python syntax for addressing them? Im pretty much a newb with both and am still not sure about

when to use a   this.that   versus a   this[that]   .

I see now that this[that]  is for an item in a list:  with this.that  , is  that a defined property of this ?

If so, where can I find a reference that will reveal all of those properties for AXL structures?

 

 

thanks

The AXL schema reference is of course the reference for all of the fine detaisl about data structures and fields: https://developer.cisco.com/docs/axl-schema-reference/

How those map to/from Python data structures is a bit of an art, and certainly depends on the mechanism/libraries you are using for interacting with AXL.  Zeep is pretty commonly used and is the basis for a lot of sample code: https://docs.python-zeep.org/en/master/
This repo has several AXL/Zeep samples that can be informative - many address specific issues/foibles with AXL: CiscoDevNet/axl-python-zeep-samples 

I don't now of any AXL/Python/JSON dictionary, but I wrote this learning lab that might be helpful for you:

 

https://developer.cisco.com/learning/lab/python-zeep-axl-lab/step/1

 

Step 9 has a tip on how I learned how to format data for AXL requests and responses.  I hope that helps.

Great thanks.

Im using zeep since that seemed to be what was most recently recommended.

Ive bookmarked the other two links. I had found the schema reference in the past and had lost it again - so Im glad to have that bookmarked now. I will hit the lab as soon as I can - it sounds like just what I need!

 

k