<s> import six <EOL> from . . client import Client <EOL> from . resource import Resource <EOL> from . icon import Icon <EOL> from . ftpinfo import FtpInfo <EOL> from . diskplan import DiskPlan <EOL> from . server import Server <EOL> from . . enums . escope import EScope <EOL> from . . enums . eavailability import EAvailability <EOL> from ... errors . httpexception import HttpException <EOL> from ... errors . saklientexception import SaklientException <EOL> from ... util import Util <EOL> import saklient <EOL> str = six . text_type <EOL> class Archive ( Resource ) : <EOL> def _api_path ( self ) : <EOL> return "<STR_LIT>" <EOL> def _root_key ( self ) : <EOL> return "<STR_LIT>" <EOL> def _root_key_m ( self ) : <EOL> return "<STR_LIT>" <EOL> def _class_name ( self ) : <EOL> return "<STR_LIT>" <EOL> def _id ( self ) : <EOL> return self . get_id ( ) <EOL> def save ( self ) : <EOL> return self . _save ( ) <EOL> def reload ( self ) : <EOL> return self . _reload ( ) <EOL> def __init__ ( self , client , obj , wrapped = False ) : <EOL> super ( Archive , self ) . __init__ ( client ) <EOL> Util . validate_type ( client , "<STR_LIT>" ) <EOL> Util . validate_type ( wrapped , "<STR_LIT:bool>" ) <EOL> self . api_deserialize ( obj , wrapped ) <EOL> def get_is_available ( self ) : <EOL> return self . get_availability ( ) == EAvailability . available <EOL> is_available = property ( get_is_available , None , None ) <EOL> def get_size_gib ( self ) : <EOL> sizeMib = self . get_size_mib ( ) <EOL> return None if sizeMib is None else sizeMib >> <NUM_LIT:10> <EOL> def set_size_gib ( self , sizeGib ) : <EOL> Util . validate_type ( sizeGib , "<STR_LIT:int>" ) <EOL> self . set_size_mib ( None if sizeGib is None else sizeGib * <NUM_LIT> ) <EOL> return sizeGib <EOL> size_gib = property ( get_size_gib , set_size_gib , None ) <EOL> def get_source ( self ) : <EOL> return self . _source <EOL> def set_source ( self , source ) : <EOL> Util . validate_type ( source , "<STR_LIT>" ) <EOL> self . _source = source <EOL> return source <EOL> source = property ( get_source , set_source , None ) <EOL> def get_ftp_info ( self ) : <EOL> return self . _ftp_info <EOL> ftp_info = property ( get_ftp_info , None , None ) <EOL> def _on_after_api_deserialize ( self , r , root ) : <EOL> if root is not None : <EOL> if ( "<STR_LIT>" in root if isinstance ( root , dict ) else hasattr ( root , "<STR_LIT>" ) ) : <EOL> ftp = ( root [ "<STR_LIT>" ] if "<STR_LIT>" in root else None ) <EOL> if ftp is not None : <EOL> self . _ftp_info = FtpInfo ( ftp ) <EOL> if r is not None : <EOL> if ( "<STR_LIT>" in r if isinstance ( r , dict ) else hasattr ( r , "<STR_LIT>" ) ) : <EOL> s = ( r [ "<STR_LIT>" ] if "<STR_LIT>" in r else None ) <EOL> if s is not None : <EOL> id = ( s [ "<STR_LIT>" ] if "<STR_LIT>" in s else None ) <EOL> if id is not None : <EOL> self . _source = Archive ( self . _client , s ) <EOL> if ( "<STR_LIT>" in r if isinstance ( r , dict ) else hasattr ( r , "<STR_LIT>" ) ) : <EOL> s = ( r [ "<STR_LIT>" ] if "<STR_LIT>" in r else None ) <EOL> if s is not None : <EOL> id = ( s [ "<STR_LIT>" ] if "<STR_LIT>" in s else None ) <EOL> if id is not None : <EOL> self . _source = Resource . create_with ( "<STR_LIT>" , self . _client , s ) <EOL> def _on_after_api_serialize ( self , r , withClean ) : <EOL> Util . validate_type ( withClean , "<STR_LIT:bool>" ) <EOL> if r is None : <EOL> return <EOL> if self . _source is not None : <EOL> if self . _source . _class_name ( ) == "<STR_LIT>" : <EOL> s = self . _source . api_serialize ( True ) if withClean else { <EOL> '<STR_LIT>' : self . _source . _id ( ) <EOL> } <EOL> r [ "<STR_LIT>" ] = s <EOL> else : <EOL> if self . _source . _class_name ( ) == "<STR_LIT>" : <EOL> s = self . _source . api_serialize ( True ) if withClean else { <EOL> '<STR_LIT>' : self . _source . _id ( ) <EOL> } <EOL> r [ "<STR_LIT>" ] = s <EOL> else : <EOL> self . _source = None <EOL> Util . validate_type ( self . _source , "<STR_LIT>" , True ) <EOL> def open_ftp ( self , reset = False ) : <EOL> Util . validate_type ( reset , "<STR_LIT:bool>" ) <EOL> path = self . _api_path ( ) + "<STR_LIT:/>" + Util . url_encode ( self . _id ( ) ) + "<STR_LIT>" <EOL> q = { } <EOL> Util . set_by_path ( q , "<STR_LIT>" , reset ) <EOL> result = self . _client . request ( "<STR_LIT>" , path , q ) <EOL> self . _on_after_api_deserialize ( None , result ) <EOL> return self <EOL> def close_ftp ( self ) : <EOL> path = self . _api_path ( ) + "<STR_LIT:/>" + Util . url_encode ( self . _id ( ) ) + "<STR_LIT>" <EOL> self . _client . request ( "<STR_LIT>" , path ) <EOL> self . _ftp_info = None <EOL> return self <EOL> def sleep_while_copying ( self , timeoutSec = <NUM_LIT> ) : <EOL> Util . validate_type ( timeoutSec , "<STR_LIT:int>" ) <EOL> step = <NUM_LIT:3> <EOL> while ( <NUM_LIT:0> < timeoutSec ) : <EOL> try : <EOL> self . reload ( ) <EOL> except saklient . errors . httpexception . HttpException : <EOL> pass <EOL> a = self . get_availability ( ) <EOL> if a == EAvailability . available : <EOL> return True <EOL> if a != EAvailability . migrating : <EOL> timeoutSec = <NUM_LIT:0> <EOL> timeoutSec -= step <EOL> if <NUM_LIT:0> < timeoutSec : <EOL> Util . sleep ( step ) <EOL> return False <EOL> def get_id ( self ) : <EOL> return self . m_id <EOL> id = property ( get_id , None , None ) <EOL> def get_scope ( self ) : <EOL> return self . m_scope <EOL> scope = property ( get_scope , None , None ) <EOL> def get_name ( self ) : <EOL> return self . m_name <EOL> def set_name ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT:str>" ) <EOL> self . m_name = v <EOL> self . n_name = True <EOL> return self . m_name <EOL> name = property ( get_name , set_name , None ) <EOL> def get_description ( self ) : <EOL> return self . m_description <EOL> def set_description ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT:str>" ) <EOL> self . m_description = v <EOL> self . n_description = True <EOL> return self . m_description <EOL> description = property ( get_description , set_description , None ) <EOL> def get_tags ( self ) : <EOL> self . n_tags = True <EOL> return self . m_tags <EOL> def set_tags ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT:list>" ) <EOL> self . m_tags = v <EOL> self . n_tags = True <EOL> return self . m_tags <EOL> tags = property ( get_tags , set_tags , None ) <EOL> def get_icon ( self ) : <EOL> return self . m_icon <EOL> def set_icon ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT>" ) <EOL> self . m_icon = v <EOL> self . n_icon = True <EOL> return self . m_icon <EOL> icon = property ( get_icon , set_icon , None ) <EOL> def get_display_order ( self ) : <EOL> return self . m_display_order <EOL> def set_display_order ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT:int>" ) <EOL> self . m_display_order = v <EOL> self . n_display_order = True <EOL> return self . m_display_order <EOL> display_order = property ( get_display_order , set_display_order , None ) <EOL> def get_size_mib ( self ) : <EOL> return self . m_size_mib <EOL> def set_size_mib ( self , v ) : <EOL> Util . validate_type ( v , "<STR_LIT:int>" ) <EOL> if not self . is_new : <EOL> raise SaklientException ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT>" ) <EOL> self . m_size_mib = v <EOL> self . n_size_mib = True <EOL> return self . m_size_mib <EOL> size_mib = property ( get_size_mib , set_size_mib , None ) <EOL> def get_service_class ( self ) : <EOL> return self . m_service_class <EOL> service_class = property ( get_service_class , None , None ) <EOL> def get_plan ( self ) : <EOL> return self . m_plan <EOL> plan = property ( get_plan , None , None ) <EOL> def get_availability ( self ) : <EOL> return self . m_availability <EOL> availability = property ( get_availability , None , None ) <EOL> def api_deserialize_impl ( self , r ) : <EOL> self . is_new = r is None <EOL> if self . is_new : <EOL> r = { <EOL> } <EOL> self . is_incomplete = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_id = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_id = None <EOL> self . is_incomplete = True <EOL> self . n_id = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_scope = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_scope = None <EOL> self . is_incomplete = True <EOL> self . n_scope = False <EOL> if Util . exists_path ( r , "<STR_LIT:Name>" ) : <EOL> self . m_name = None if Util . get_by_path ( r , "<STR_LIT:Name>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT:Name>" ) ) <EOL> else : <EOL> self . m_name = None <EOL> self . is_incomplete = True <EOL> self . n_name = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_description = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_description = None <EOL> self . is_incomplete = True <EOL> self . n_description = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> if Util . get_by_path ( r , "<STR_LIT>" ) is None : <EOL> self . m_tags = [ ] <EOL> else : <EOL> self . m_tags = [ ] <EOL> for t in Util . get_by_path ( r , "<STR_LIT>" ) : <EOL> v1 = None <EOL> v1 = None if t is None else str ( t ) <EOL> self . m_tags . append ( v1 ) <EOL> else : <EOL> self . m_tags = None <EOL> self . is_incomplete = True <EOL> self . n_tags = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_icon = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else Icon ( self . _client , Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_icon = None <EOL> self . is_incomplete = True <EOL> self . n_icon = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_display_order = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else int ( str ( Util . get_by_path ( r , "<STR_LIT>" ) ) ) <EOL> else : <EOL> self . m_display_order = None <EOL> self . is_incomplete = True <EOL> self . n_display_order = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_size_mib = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else int ( str ( Util . get_by_path ( r , "<STR_LIT>" ) ) ) <EOL> else : <EOL> self . m_size_mib = None <EOL> self . is_incomplete = True <EOL> self . n_size_mib = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_service_class = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_service_class = None <EOL> self . is_incomplete = True <EOL> self . n_service_class = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_plan = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else DiskPlan ( self . _client , Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_plan = None <EOL> self . is_incomplete = True <EOL> self . n_plan = False <EOL> if Util . exists_path ( r , "<STR_LIT>" ) : <EOL> self . m_availability = None if Util . get_by_path ( r , "<STR_LIT>" ) is None else str ( Util . get_by_path ( r , "<STR_LIT>" ) ) <EOL> else : <EOL> self . m_availability = None <EOL> self . is_incomplete = True <EOL> self . n_availability = False <EOL> def api_serialize_impl ( self , withClean = False ) : <EOL> Util . validate_type ( withClean , "<STR_LIT:bool>" ) <EOL> missing = [ ] <EOL> ret = { <EOL> } <EOL> if withClean or self . n_id : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_id ) <EOL> if withClean or self . n_scope : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_scope ) <EOL> if withClean or self . n_name : <EOL> Util . set_by_path ( ret , "<STR_LIT:Name>" , self . m_name ) <EOL> else : <EOL> if self . is_new : <EOL> missing . append ( "<STR_LIT:name>" ) <EOL> if withClean or self . n_description : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_description ) <EOL> if withClean or self . n_tags : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , [ ] ) <EOL> for r1 in self . m_tags : <EOL> v = None <EOL> v = r1 <EOL> ( ret [ "<STR_LIT>" ] if "<STR_LIT>" in ret else None ) . append ( v ) <EOL> if withClean or self . n_icon : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , ( None if self . m_icon is None else self . m_icon . api_serialize ( withClean ) ) if withClean else ( { <EOL> '<STR_LIT>' : "<STR_LIT:0>" <EOL> } if self . m_icon is None else self . m_icon . api_serialize_id ( ) ) ) <EOL> if withClean or self . n_display_order : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_display_order ) <EOL> if withClean or self . n_size_mib : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_size_mib ) <EOL> if withClean or self . n_service_class : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_service_class ) <EOL> if withClean or self . n_plan : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , ( None if self . m_plan is None else self . m_plan . api_serialize ( withClean ) ) if withClean else ( { <EOL> '<STR_LIT>' : "<STR_LIT:0>" <EOL> } if self . m_plan is None else self . m_plan . api_serialize_id ( ) ) ) <EOL> if withClean or self . n_availability : <EOL> Util . set_by_path ( ret , "<STR_LIT>" , self . m_availability ) <EOL> if len ( missing ) > <NUM_LIT:0> : <EOL> raise SaklientException ( "<STR_LIT>" , "<STR_LIT>" + "<STR_LIT:U+002CU+0020>" . join ( missing ) ) <EOL> return ret </s>
