<s> """<STR_LIT>""" <EOL> import copy <EOL> from datetime import datetime <EOL> from com . rackspace . cloud . servers . api . client . entitymanager import EntityManager <EOL> from com . rackspace . cloud . servers . api . client . entitylist import EntityList <EOL> import com . rackspace . cloud . servers . api . client . errors as ClientErrors <EOL> from com . rackspace . cloud . servers . api . client . sharedipgroup import SharedIpGroup <EOL> _bmf = ClientErrors . BadMethodFault ( "<STR_LIT>" ) <EOL> _nie = ClientErrors . NotImplementedException <EOL> class SharedIpGroupManager ( EntityManager ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cloudServersService ) : <EOL> super ( SharedIpGroupManager , self ) . __init__ ( cloudServersService , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def create ( self , ipgroup ) : <EOL> """<STR_LIT>""" <EOL> ret = self . _POST ( ipgroup . asJSON ) <EOL> ipgroup . _manager = self <EOL> def update ( self , ipgroup ) : <EOL> raise _nie <EOL> def refresh ( self , entity ) : <EOL> entity . initFromResultDict ( self . sharedIpGroupDetails ( entity . id ) ) <EOL> entity . _manager = self <EOL> def find ( self , id ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> detailsDict = self . sharedIpGroupDetails ( id ) <EOL> except ClientErrors . CloudServersAPIFault , e : <EOL> if e . code == <NUM_LIT> : <EOL> return None <EOL> else : <EOL> raise <EOL> retSharedIpGroup = SharedIpGroup ( ) <EOL> retSharedIpGroup . initFromResultDict ( detailsDict ) <EOL> retSharedIpGroup . _manager = self <EOL> return retSharedIpGroup <EOL> def sharedIpGroupDetails ( self , id ) : <EOL> """<STR_LIT>""" <EOL> retDict = None <EOL> ret = self . _GET ( id , { "<STR_LIT>" : str ( datetime . now ( ) ) } ) <EOL> try : <EOL> retDict = ret [ "<STR_LIT>" ] <EOL> except KeyError , e : <EOL> retDict = None <EOL> return retDict <EOL> def _wait ( self , sharedIpGroup ) : <EOL> """<STR_LIT>""" <EOL> thisGroup = self . _entityCopies [ sharedIpGroup . id ] <EOL> while sharedIpGroup == thisGroup : <EOL> try : <EOL> self . refresh ( sharedIpGroup ) <EOL> except ClientErrors . OverLimitFault , e : <EOL> self . _sleepUntilRetryAfter_ ( e ) <EOL> except ClientErrors . CloudServersFault : <EOL> pass <EOL> def wait ( self , sharedIpGroup , timeout = None ) : <EOL> """<STR_LIT>""" <EOL> self . _entityCopies [ sharedIpGroup . id ] = copy . copy ( sharedIpGroup ) <EOL> if timeout is None : <EOL> self . _wait ( sharedIpGroup ) <EOL> else : <EOL> result = self . _timeout ( self . _wait , ( sharedIpGroup , ) , timeout_duration = timeout / <NUM_LIT> ) <EOL> def createEntityListFromResponse ( self , response , detail ) : <EOL> ip_groups = response [ "<STR_LIT>" ] <EOL> retList = [ ] <EOL> for g in ip_groups : <EOL> shared = SharedIpGroup ( ) <EOL> shared . initFromResultDict ( g ) <EOL> retList . append ( shared ) <EOL> return EntityList ( retList , detail , self ) </s>
