<s> """<STR_LIT>""" <EOL> from copy import deepcopy <EOL> import json <EOL> import xml . etree . ElementTree as ET <EOL> from cafe . engine . models . base import AutoMarshallingModel <EOL> from cloudcafe . networking . lbaas . common . constants import Constants <EOL> class CreateHealthMonitor ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> ROOT_TAG = '<STR_LIT>' <EOL> def __init__ ( self , type_ , tenant_id , delay , timeout , max_retries , <EOL> http_method = None , url_path = None , expected_codes = None , <EOL> admin_state_up = None ) : <EOL> """<STR_LIT>""" <EOL> super ( CreateHealthMonitor , self ) . __init__ ( ) <EOL> self . type_ = type_ <EOL> self . tenant_id = tenant_id <EOL> self . delay = delay <EOL> self . timeout = timeout <EOL> self . max_retries = max_retries <EOL> self . http_method = http_method <EOL> self . url_path = url_path <EOL> self . expected_codes = expected_codes <EOL> self . admin_state_up = admin_state_up <EOL> self . attr_dict = { <EOL> '<STR_LIT:type>' : self . type_ , <EOL> '<STR_LIT>' : self . tenant_id , <EOL> '<STR_LIT>' : self . delay , <EOL> '<STR_LIT>' : self . timeout , <EOL> '<STR_LIT>' : self . max_retries , <EOL> '<STR_LIT>' : self . http_method , <EOL> '<STR_LIT>' : self . url_path , <EOL> '<STR_LIT>' : self . expected_codes , <EOL> '<STR_LIT>' : self . admin_state_up <EOL> } <EOL> def _obj_to_json ( self ) : <EOL> body = self . _remove_empty_values ( deepcopy ( self . attr_dict ) ) <EOL> main_body = { self . ROOT_TAG : body } <EOL> return json . dumps ( main_body ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( self . ROOT_TAG ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> elements_dict = deepcopy ( self . attr_dict ) <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . delay ) <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . timeout ) <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . max_retries ) <EOL> if self . http_method is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . http_method ) <EOL> if self . url_path is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . url_path ) <EOL> if self . expected_codes is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . expected_codes ) <EOL> if self . admin_state_up is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . admin_state_up ) <EOL> element = self . _set_xml_etree_element ( element , elements_dict ) <EOL> xml = "<STR_LIT>" . format ( xml , ET . tostring ( element ) ) <EOL> return xml <EOL> class UpdateHealthMonitor ( AutoMarshallingModel ) : <EOL> """<STR_LIT>""" <EOL> ROOT_TAG = CreateHealthMonitor . ROOT_TAG <EOL> def __init__ ( self , delay = None , timeout = None , max_retries = None , <EOL> http_method = None , url_path = None , expected_codes = None , <EOL> admin_state_up = None ) : <EOL> super ( UpdateHealthMonitor , self ) . __init__ ( ) <EOL> self . delay = delay <EOL> self . timeout = timeout <EOL> self . max_retries = max_retries <EOL> self . http_method = http_method <EOL> self . url_path = url_path <EOL> self . expected_codes = expected_codes <EOL> self . admin_state_up = admin_state_up <EOL> self . attr_dict = { <EOL> '<STR_LIT>' : self . delay , <EOL> '<STR_LIT>' : self . timeout , <EOL> '<STR_LIT>' : self . max_retries , <EOL> '<STR_LIT>' : self . http_method , <EOL> '<STR_LIT>' : self . url_path , <EOL> '<STR_LIT>' : self . expected_codes , <EOL> '<STR_LIT>' : self . admin_state_up <EOL> } <EOL> def _obj_to_json ( self ) : <EOL> body = self . _remove_empty_values ( deepcopy ( self . attr_dict ) ) <EOL> main_body = { self . ROOT_TAG : body } <EOL> return json . dumps ( main_body ) <EOL> def _obj_to_xml ( self ) : <EOL> xml = Constants . XML_HEADER <EOL> element = ET . Element ( self . ROOT_TAG ) <EOL> element . set ( '<STR_LIT>' , Constants . XML_API_NAMESPACE ) <EOL> elements_dict = deepcopy ( self . attr_dict ) <EOL> if self . delay is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . delay ) <EOL> if self . timeout is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . timeout ) <EOL> if self . max_retries is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . max_retries ) <EOL> if self . admin_state_up is not None : <EOL> elements_dict [ '<STR_LIT>' ] = str ( self . admin_state_up ) <EOL> element = self . _set_xml_etree_element ( element , elements_dict ) <EOL> xml = "<STR_LIT>" . format ( xml , ET . tostring ( element ) ) <EOL> return xml </s>
