2727
2828NA = "N/A"
2929UNKOWN = "UNKNOWN"
30+ PARENT_ID_KEY = "parentId"
3031ID_KEY = "id"
3132NAME_KEY = "name"
3233DESCRIPTION_KEY = "description"
3637END_TIME_KEY = "end"
3738IS_FINAL_KEY = "final"
3839COMPATIBLE_PROVIDERS_KEY = "compatibleProviders"
40+ CONFIGURATION_KEY = "configuration"
3941
4042
4143# pylint: disable=too-few-public-methods,too-many-instance-attributes
@@ -50,6 +52,14 @@ def __init__(self, params):
5052 Constructor
5153 '''
5254
55+ # Output provider's parent ID
56+ if PARENT_ID_KEY in params :
57+ # pylint: disable=invalid-name
58+ self .parent_id = params .get (PARENT_ID_KEY )
59+ del params [PARENT_ID_KEY ]
60+ else : # pragma: no cover
61+ self .parent_id = None
62+
5363 # Output provider's ID
5464 if ID_KEY in params :
5565 # pylint: disable=invalid-name
@@ -117,6 +127,14 @@ def __init__(self, params):
117127 else :
118128 self .compatible_providers = []
119129
130+ # Configuration used to create this data provider.
131+ if CONFIGURATION_KEY in params :
132+ self .configuration = Configuration (params .get (CONFIGURATION_KEY ))
133+ del params [CONFIGURATION_KEY ]
134+ else :
135+ self .configuration = []
136+
137+
120138 def __repr__ (self ):
121139 return 'OutputDescriptor(id={}, name={}, description={}, type={})' .format (self .id , self .name , self .description , obj .type )
122140
@@ -126,16 +144,24 @@ def to_json(self):
126144class OutputDescriptorEncoder (json .JSONEncoder ):
127145 def default (self , obj ):
128146 if isinstance (obj , OutputDescriptor ):
129- return {
130- ID_KEY : obj .id ,
131- NAME_KEY : obj .name ,
132- DESCRIPTION_KEY : obj .description ,
133- TYPE_KEY : obj .type ,
134- # Hide non-TSP fields
135- # QUERY_PARAMETERS_KEY: obj.query_parameters,
136- # START_TIME_KEY: obj.start,
137- # END_TIME_KEY: obj.end,
138- # IS_FINAL_KEY: obj.final,
139- # COMPATIBLE_PROVIDERS_KEY: obj.compatible_providers
140- }
147+ result = {}
148+ # optinal parent_id
149+ if obj .parent_id is not None :
150+ result [PARENT_ID_KEY ] = obj .parent_id
151+
152+ result [ID_KEY ] = obj .id
153+ result [NAME_KEY ] = obj .name
154+ result [DESCRIPTION_KEY ] = obj .description
155+ result [TYPE_KEY ] = obj .type
156+ # Hide non-TSP fields
157+ # result[QUERY_PARAMETERS_KEY] = obj.query_parameters
158+ # result[START_TIME_KEY] = obj.start
159+ # result[END_TIME_KEY] = obj.end
160+ # result[IS_FINAL_KEY] = obj.final
161+ # result[COMPATIBLE_PROVIDERS_KEY] = obj.compatible_providers
162+
163+ # optional configuration
164+ if isinstance (obj .configuration , Configuration ):
165+ result [CONFIGURATION_KEY ] = ConfigurationEncoder ().default (obj .configuration )
166+ return result
141167 return super ().default (obj )
0 commit comments