<s> """<STR_LIT>""" <EOL> from django . views import generic <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . api . rest import urls <EOL> from openstack_dashboard . api . rest import utils as rest_utils <EOL> @ urls . register <EOL> class SecurityGroups ( generic . View ) : <EOL> """<STR_LIT>""" <EOL> url_regex = r'<STR_LIT>' <EOL> @ rest_utils . ajax ( ) <EOL> def get ( self , request ) : <EOL> """<STR_LIT>""" <EOL> security_groups = api . network . security_group_list ( request ) <EOL> return { '<STR_LIT>' : [ sg . to_dict ( ) for sg in security_groups ] } <EOL> @ urls . register <EOL> class FloatingIP ( generic . View ) : <EOL> """<STR_LIT>""" <EOL> url_regex = r'<STR_LIT>' <EOL> @ rest_utils . ajax ( data_required = True ) <EOL> def post ( self , request ) : <EOL> """<STR_LIT>""" <EOL> pool = request . DATA [ '<STR_LIT>' ] <EOL> result = api . network . tenant_floating_ip_allocate ( request , pool ) <EOL> return result . to_dict ( ) <EOL> @ rest_utils . ajax ( data_required = True ) <EOL> def patch ( self , request ) : <EOL> """<STR_LIT>""" <EOL> address = request . DATA [ '<STR_LIT>' ] <EOL> port = request . DATA . get ( '<STR_LIT>' ) <EOL> if port is None : <EOL> api . network . floating_ip_disassociate ( request , address ) <EOL> else : <EOL> api . network . floating_ip_associate ( request , address , port ) <EOL> @ urls . register <EOL> class FloatingIPs ( generic . View ) : <EOL> """<STR_LIT>""" <EOL> url_regex = r'<STR_LIT>' <EOL> @ rest_utils . ajax ( ) <EOL> def get ( self , request ) : <EOL> """<STR_LIT>""" <EOL> result = api . network . tenant_floating_ip_list ( request ) <EOL> return { '<STR_LIT>' : [ ip . to_dict ( ) for ip in result ] } <EOL> @ urls . register <EOL> class FloatingIPPools ( generic . View ) : <EOL> """<STR_LIT>""" <EOL> url_regex = r'<STR_LIT>' <EOL> @ rest_utils . ajax ( ) <EOL> def get ( self , request ) : <EOL> """<STR_LIT>""" <EOL> result = api . network . floating_ip_pools_list ( request ) <EOL> return { '<STR_LIT>' : [ p . to_dict ( ) for p in result ] } </s>
