<s> """<STR_LIT>""" <EOL> import json <EOL> from cafe . engine . models . base import ( <EOL> AutoMarshallingModel , AutoMarshallingListModel ) <EOL> from cloudcafe . compute . common . equality_tools import EqualityTools <EOL> from cloudcafe . images . common . models . links import Links <EOL> class Version ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , id_ = None , links = None , status = None ) : <EOL> super ( Version , self ) . __init__ ( ) <EOL> self . id_ = id_ <EOL> self . links = links <EOL> self . status = status <EOL> def __eq__ ( self , other ) : <EOL> return EqualityTools . are_objects_equal ( self , other ) <EOL> def __ne__ ( self , other ) : <EOL> return not self . __eq__ ( other ) <EOL> @ classmethod <EOL> def _json_to_obj ( cls , serialized_str ) : <EOL> json_dict = json . loads ( serialized_str ) <EOL> return cls . _dict_to_obj ( json_dict ) <EOL> @ classmethod <EOL> def _dict_to_obj ( cls , json_dict ) : <EOL> links = None <EOL> if '<STR_LIT>' in json_dict : <EOL> links = Links . _list_to_obj ( json_dict . get ( '<STR_LIT>' ) ) <EOL> version = Version ( id_ = json_dict . get ( '<STR_LIT:id>' ) , links = links , <EOL> status = json_dict . get ( '<STR_LIT:status>' ) ) <EOL> return version <EOL> def _obj_to_json ( self ) : <EOL> obj_dict = { } <EOL> obj_dict [ '<STR_LIT:id>' ] = self . id_ <EOL> obj_dict [ '<STR_LIT>' ] = self . links <EOL> obj_dict [ '<STR_LIT:status>' ] = self . status <EOL> return json . dumps ( obj_dict ) <EOL> @ classmethod <EOL> def _xml_to_obj ( cls , serialized_str ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def _obj_to_xml ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> class Versions ( AutoMarshallingListModel ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , versions = None ) : <EOL> self . extend ( versions or [ ] ) <EOL> @ classmethod <EOL> def _json_to_obj ( cls , serialized_str ) : <EOL> json_dict = json . loads ( serialized_str ) <EOL> return cls . _list_to_obj ( json_dict . get ( '<STR_LIT>' ) ) <EOL> @ classmethod <EOL> def _list_to_obj ( cls , dict_list ) : <EOL> versions = Versions ( ) <EOL> for version_dict in dict_list : <EOL> versions . append ( Version . _dict_to_obj ( version_dict ) ) <EOL> return versions </s>
