How to assign factory value of created simpletype object using python suds?

I am working with the Cisco AXL library using python suds. I am trying to call a function where I need to use simpleType, which is a special instance of a string with a name restriction.

I create my object using factory after parsing the WSDL:

uuid = client.factory.create('ns0:XUUID') 

This is an instance of the following XUUID, defined as follows in the XSD accompanying the WSDL:

  <xsd:simpleType name="XUUID"> <xsd:restriction base="xsd:string"> <xsd:pattern value="\{........-....-....-....-............\}"/> </xsd:restriction> </xsd:simpleType> 

I want to set the value of my uuid object, I tried all of the following without success:

  uuid.setText('{900AAAAC-E454-0B7E-07FD-FD67D48FF50E}') uuid.set('{900AAAAC-E454-0B7E-07FD-FD67D48FF50E}') 

It is clear that if it were complexType with additional elements, I could set them, for example. Person.name, as in the foam documentation. I cannot figure out how to set the value for this object.

The imprint of the dir (uuid) object suggests that I may be wrong.

  ['__contains__', '__delattr__', '__doc__', '__getitem__', '__init__', '__iter__', '__keylist__', '__len__', '__metadata__', '__module__', '__printer__', '__repr__', '__setattr__', '__setitem__', '__str__', '__unicode__'] 

In case I missed something basic or used the foam completely wrong, I will explain a little more context below.

I am trying to call the following function from WSDL:

  <operation name="getDevicePool"> <input message="s0:getDevicePoolIn"/> <output message="s0:getDevicePoolOut"/> </operation> <message name="getDevicePoolIn"> <part element="xsd1:getDevicePool" name="axlParams"/> </message> 

It, in turn, refers to the following XSD elements:

  <xsd:element name='getDevicePool' type='axlapi:GetDevicePoolReq'></xsd:element> <xsd:complexType name='GetDevicePoolReq'> <xsd:sequence> <xsd:choice> <xsd:element name='name' type='axlapi:String100'></xsd:element> <xsd:element name='uuid' type='axlapi:XUUID'></xsd:element></xsd:choice> <xsd:element name='returnedTags' type='axlapi:RDevicePool' minOccurs='0'></xsd:element></xsd:sequence><xsd:attribute use='optional' name='sequence' type='xsd:unsignedLong'></xsd:attribute></xsd:complexType> 

I tried an approach that worked well with another function from WSDL:

  searchCriteria = { 'callManagerGroupName':'Default' } devicePools = client.service.listDevicePool(searchCriteria) 

But this did not work, I believe that this is because I need my UUID search string for type XUUID.

+4
source share
1 answer

Factory created objects are assigned values ​​through the attributes of the object. As an example from my own code:

 >>> api = gcs.provider.get_api() >>> client = api.get_client(api.API_DOMAIN) >>> ident = client.factory.create('ns0:Identification') >>> ident (Identification){ token = None user = None userPasswd = None oper = None operPasswd = None language = None } >>> ident.user = 'Jeremy' >>> ident (Identification){ token = None user = "Jeremy" userPasswd = None oper = None operPasswd = None language = None } >>> setattr(ident, 'user', 'Lewis') >>> ident (Identification){ token = None user = "Lewis" userPasswd = None oper = None operPasswd = None language = None } 

You should be able to print the uuid object to see what is called an attribute, and then just assign a value.

+1
source

Source: https://habr.com/ru/post/1442521/


All Articles