mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-20 15:02:27 +02:00
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'Service()' type class to the 'rivwebpyapi' API. * Modified the 'rivwebpyapi.ListServices()' call to return a list of 'rivwebpyapi.Service' objects. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
0443fd9341
commit
6b923ffbda
@ -22775,3 +22775,7 @@
|
||||
a 'rivwebpyapi.Group' object.
|
||||
* Modified the 'rivwebpyapi.ListGroups()' call to return
|
||||
a list of 'rivwebpyapi.Group' objects.
|
||||
2021-12-12 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added a 'Service()' type class to the 'rivwebpyapi' API.
|
||||
* Modified the 'rivwebpyapi.ListServices()' call to return
|
||||
a list of 'rivwebpyapi.Service' objects.
|
||||
|
@ -238,6 +238,11 @@ SCHEDULER_CODE_FIELDS={
|
||||
'description': 'string'
|
||||
}
|
||||
|
||||
SERVICE_FIELDS={
|
||||
'name': 'string',
|
||||
'description': 'string'
|
||||
}
|
||||
|
||||
class RivWebPyApi_ListHandler(ContentHandler):
|
||||
def __init__(self,base_tag,fields):
|
||||
self.__output=[]
|
||||
@ -441,6 +446,10 @@ class SchedulerCode(RivendellType):
|
||||
def __init__(self,values={}):
|
||||
super().__init__(SCHEDULER_CODE_FIELDS,values)
|
||||
|
||||
class Service(RivendellType):
|
||||
def __init__(self,values={}):
|
||||
super().__init__(SERVICE_FIELDS,values)
|
||||
|
||||
class rivwebpyapi(object):
|
||||
"""
|
||||
Create a 'RivWebPyApi' object for accessing the Web API.
|
||||
@ -1641,7 +1650,8 @@ class rivwebpyapi(object):
|
||||
|
||||
def ListServices(self,trackable):
|
||||
"""
|
||||
Returns a set of Rivendell services (list of dictionaries).
|
||||
Returns a set of Rivendell services
|
||||
(list of rivwebpyapi.Service objects).
|
||||
|
||||
Takes one argument:
|
||||
|
||||
@ -1674,14 +1684,15 @@ class rivwebpyapi(object):
|
||||
#
|
||||
# Generate the output dictionary
|
||||
#
|
||||
fields={
|
||||
'name': 'string',
|
||||
'description': 'string'
|
||||
}
|
||||
handler=RivWebPyApi_ListHandler(base_tag='service',fields=fields)
|
||||
handler=RivWebPyApi_ListHandler(base_tag='service',
|
||||
fields=SERVICE_FIELDS)
|
||||
xml.sax.parseString(r.text,handler)
|
||||
out=handler.output()
|
||||
ret=[]
|
||||
for item in out:
|
||||
ret.append(Service(item))
|
||||
|
||||
return handler.output()
|
||||
return ret
|
||||
|
||||
def ListSystemSettings(self):
|
||||
"""
|
||||
|
@ -72,6 +72,6 @@ except rivwebpyapi.RivWebPyError as err:
|
||||
# Display the services list
|
||||
#
|
||||
for svc in services:
|
||||
print('name: '+svc['name'])
|
||||
print('description: '+svc['description'])
|
||||
for key in svc.values():
|
||||
print(key+': '+str(svc.values()[key]))
|
||||
print('')
|
||||
|
Loading…
x
Reference in New Issue
Block a user