text
stringlengths 1
93.6k
|
|---|
import urllib3
|
# Edit .env file to specify your Webex site/user details
|
import os
|
from dotenv import load_dotenv
|
load_dotenv()
|
# Change to true to enable output of request/response headers and XML
|
DEBUG = False
|
# The WSDL is a local file in the working directory, see README
|
WSDL_FILE = 'schema/AXLAPI.wsdl'
|
# This class lets you view the incoming and outgoing http headers and XML
|
class MyLoggingPlugin( Plugin ):
|
def egress( self, envelope, http_headers, operation, binding_options ):
|
# Format the request body as pretty printed XML
|
xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode')
|
print( f'\nRequest\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' )
|
def ingress( self, envelope, http_headers, operation ):
|
# Format the response body as pretty printed XML
|
xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode')
|
print( f'\nResponse\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' )
|
# The first step is to create a SOAP client session
|
session = Session()
|
# We avoid certificate verification by default
|
# And disable insecure request warnings to keep the output clear
|
session.verify = False
|
urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning )
|
# To enabled SSL cert checking (recommended for production)
|
# place the CUCM Tomcat cert .pem file in the root of the project
|
# and uncomment the line below
|
# session.verify = 'changeme.pem'
|
# Add Basic Auth credentials
|
session.auth = HTTPBasicAuth( os.getenv( 'AXL_USERNAME' ), os.getenv( 'AXL_PASSWORD' ) )
|
# Create a Zeep transport and set a reasonable timeout value
|
transport = Transport( session = session, timeout = 10 )
|
# strict=False is not always necessary, but it allows zeep to parse imperfect XML
|
settings = Settings( strict = False, xml_huge_tree = True )
|
# If debug output is requested, add the MyLoggingPlugin callback
|
plugin = [ MyLoggingPlugin() ] if DEBUG else [ ]
|
# Create the Zeep client with the specified settings
|
client = Client( WSDL_FILE, settings = settings, transport = transport,
|
plugins = plugin )
|
# Create the Zeep service binding to AXL at the specified CUCM
|
service = client.create_service( '{http://www.cisco.com/AXLAPIService/}AXLAPIBinding',
|
f'https://{os.getenv( "CUCM_ADDRESS" )}:8443/axl/' )
|
# Create a test Region
|
location = {
|
'name': 'testLocation',
|
'relatedLocations': {
|
'relatedLocation': []
|
},
|
'withinAudioBandwidth': '76',
|
'withinVideoBandwidth': '384',
|
'withinImmersiveKbits': '384',
|
'betweenLocations': {
|
'betweenLocation': []
|
}
|
}
|
# Create test relatedLocation object
|
related_location = {
|
'locationName': 'Hub_None',
|
'rsvpSetting': 'No Reservation'
|
}
|
# Create a test betweenLocations
|
between_location = {
|
'locationName': 'Hub_None',
|
'weight': '50',
|
'audioBandwidth': '76',
|
'videoBandwidth': '384',
|
'immersiveBandwidth': '384'
|
}
|
#Insert the relatedLocation and betweenLocation objects into
|
# their respective arrays
|
location['relatedLocations']['relatedLocation'].append( related_location )
|
location['betweenLocations']['betweenLocation'].append( between_location)
|
# Execute the addLocation request
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.