<s> """<STR_LIT>""" <EOL> from urlparse import urlparse <EOL> from cafe . engine . http . client import AutoMarshallingHTTPClient <EOL> from cloudcafe . compute . flavors_api . models . flavor import Flavor , CreateFlavor , Flavors , FlavorMins <EOL> from cloudcafe . compute . flavors_api . models . flavor_extra_specs import FlavorExtraSpecs <EOL> from cloudcafe . compute . flavors_api . models . flavor_access import ( <EOL> AddTenantFlavorAccess , FlavorAccessList , RemoveTenantFlavorAccess ) <EOL> class FlavorsClient ( AutoMarshallingHTTPClient ) : <EOL> def __init__ ( self , url , auth_token , serialize_format = None , <EOL> deserialize_format = None ) : <EOL> """<STR_LIT>""" <EOL> super ( FlavorsClient , self ) . __init__ ( serialize_format , <EOL> deserialize_format ) <EOL> self . auth_token = auth_token <EOL> self . default_headers [ '<STR_LIT>' ] = auth_token <EOL> ct = '<STR_LIT>' . join ( [ '<STR_LIT>' , self . serialize_format ] ) <EOL> accept = '<STR_LIT>' . join ( [ '<STR_LIT>' , self . deserialize_format ] ) <EOL> self . default_headers [ '<STR_LIT:Content-Type>' ] = ct <EOL> self . default_headers [ '<STR_LIT>' ] = accept <EOL> self . url = url <EOL> def create_flavor ( self , name = None , ram = None , vcpus = None , <EOL> disk = None , id = None , is_public = None , <EOL> requestslib_kwargs = None ) : <EOL> request = CreateFlavor ( name = name , ram = ram , vcpus = vcpus , <EOL> disk = disk , id = id , is_public = is_public ) <EOL> url = '<STR_LIT>' . format ( base_url = self . url ) <EOL> resp = self . request ( '<STR_LIT:POST>' , url , <EOL> response_entity_type = Flavor , <EOL> request_entity = request , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return resp <EOL> def delete_flavor ( self , flavor_id , requestslib_kwargs = None ) : <EOL> url = '<STR_LIT>' . format ( <EOL> base_url = self . url , flavor_id = flavor_id ) <EOL> resp = self . request ( '<STR_LIT>' , url , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return resp <EOL> def list_flavors ( self , min_disk = None , min_ram = None , marker = None , <EOL> limit = None , requestslib_kwargs = None ) : <EOL> '''<STR_LIT>''' <EOL> url = '<STR_LIT>' . format ( base_url = self . url ) <EOL> params = { '<STR_LIT>' : min_disk , '<STR_LIT>' : min_ram , '<STR_LIT>' : marker , <EOL> '<STR_LIT>' : limit } <EOL> flavor_response = self . request ( '<STR_LIT:GET>' , url , params = params , <EOL> response_entity_type = FlavorMins , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return flavor_response <EOL> def list_flavors_with_detail ( self , min_disk = None , min_ram = None , <EOL> marker = None , limit = None , <EOL> requestslib_kwargs = None ) : <EOL> '''<STR_LIT>''' <EOL> url = '<STR_LIT>' . format ( base_url = self . url ) <EOL> params = { '<STR_LIT>' : min_disk , '<STR_LIT>' : min_ram , '<STR_LIT>' : marker , <EOL> '<STR_LIT>' : limit } <EOL> flavor_response = self . request ( '<STR_LIT:GET>' , url , params = params , <EOL> response_entity_type = Flavors , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return flavor_response <EOL> def get_flavor_details ( self , flavor_id , requestslib_kwargs = None ) : <EOL> '''<STR_LIT>''' <EOL> url_new = str ( flavor_id ) <EOL> url_scheme = urlparse ( url_new ) . scheme <EOL> url = url_new if url_scheme else '<STR_LIT>' . format ( base_url = self . url , <EOL> flavor_id = flavor_id ) <EOL> flavor_response = self . request ( '<STR_LIT:GET>' , url , requestslib_kwargs , <EOL> response_entity_type = Flavor , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return flavor_response <EOL> def get_flavor_extra_specs ( self , flavor_id , requestslib_kwargs = None ) : <EOL> url_new = str ( flavor_id ) <EOL> url_scheme = urlparse ( url_new ) . scheme <EOL> url = url_new if url_scheme else '<STR_LIT>' . format ( <EOL> base_url = self . url , flavor_id = flavor_id ) <EOL> response = self . request ( '<STR_LIT:GET>' , url , requestslib_kwargs , <EOL> response_entity_type = FlavorExtraSpecs , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return response <EOL> def list_flavor_access ( self , flavor_id , requestslib_kwargs = None ) : <EOL> url = '<STR_LIT>' . format ( <EOL> base_url = self . url , flavor_id = flavor_id ) <EOL> response = self . request ( <EOL> '<STR_LIT:GET>' , url , response_entity_type = FlavorAccessList , <EOL> requestslib_kwargs = requestslib_kwargs ) <EOL> return response <EOL> def add_tenant_access ( self , tenant , flavor_id , requestslib_kwargs = None ) : <EOL> request = AddTenantFlavorAccess ( tenant = tenant ) <EOL> url = '<STR_LIT>' . format ( <EOL> base_url = self . url , flavor_id = flavor_id ) <EOL> response = self . request ( <EOL> '<STR_LIT:POST>' , url , response_entity_type = FlavorAccessList , <EOL> request_entity = request , requestslib_kwargs = requestslib_kwargs ) <EOL> return response <EOL> def remove_tenant_access ( self , tenant , flavor_id , <EOL> requestslib_kwargs = None ) : <EOL> request = RemoveTenantFlavorAccess ( tenant = tenant ) <EOL> url = '<STR_LIT>' . format ( <EOL> base_url = self . url , flavor_id = flavor_id ) <EOL> response = self . request ( <EOL> '<STR_LIT>' , url , response_entity_type = FlavorAccessList , <EOL> request_entity = request , requestslib_kwargs = requestslib_kwargs ) <EOL> return response </s>
