Package: metax-api
Leviathan Metax python3 API v2.0APImodule structuremetax/
├── api.py
├── db
│    ├── __main__.py
│    ├── __init__.py
│    ├── friends.py
│    ├── get.py
│    ├── delete.py
│    ├── keys.py
│    ├── listener.py
│    ├── copy.py
│    ├── metax_base.py
│    ├── metax_info.py
│    ├── pair.py
│    ├── peers.py
│    ├── save.py
│    ├── send_to.py
│    ├── share.py
│    └── update.py
│
├── __main__.py
├── __init__.py
├── errors.py
├── request.py
├── requirements.txt
└── types.pyMethodsis valid uuid        -metax.db.metax_base:Base::is_valid_uuidvalidate             -metax.db.metax_base:Base::validatecopy                 -metax.db.copy:Copy::copydelete               -metax.db.delete:Delete::deleteadd friend           -metax.db.friends:Friends::add_friendget friend list      -metax.db.copy:Friends::get_friends_listget                  -metax.db.get:Get::getget user keys        -metax.db.keys:Keys::get_user_keysget user public key  -metax.db.keys:Keys::get_user_public_keyregenerate user key  -metax.db.keys:Keys::regenerate_user_keyregiseter listeners  -metax.db.listeners:Listeners::register_listenerunregister listeners -metax.db.listeners:Listeners::unregister_listenerlisteners            -metax.db.listeners:Listeners::listenersset metax info       -metax.db.metax_info:MetaxInfo::set_metax_infoget metax info       -metax.db.metax_info:MetaxInfo::get_metax_infodump user info       -metax.db.metax_info:MetaxInfo::dump_user_infostart_pairing        -metax.db.pair:Pair::start_pairingcancel_pairing       -metax.db.pair:Pair::cancel_pairingget pairing peers    -metax.db.pair:Pair::get_pairing_peerspeers                -metax.db.peers:Peers::peersreconnect_to_peers   -metax.db.peers:Peers::reconnect_to_peerssave                 -metax.db.save:Save:savesend to              -metax.db.send_to:SendTo::send_toshare                -metax.db.share.Share::shareaccept_share         -metax.db.share.Share::accept_shareupdate               -metax.db.update:Update::updatemetax                -metax.api.metax-metax::Metaxcrud                 -metax.api.crud-metax::CRUDStatementsNODE         -metax.types.NODEFORM         -metax.types.FORMEXPIRE       -metax.types.EXPIREENCRYPT      -metax.types.ENCRYPTENCRYPTED    -metax.types.ENCRYPTEDNO_ENCRYPTED -metax.types.NO_ENCRYPTEDSECURE       -metax.types.SECURENO_SECURE    -metax.types.NO_SECUREGET          -metax.types.GETPOST         -metax.types.POSTUPDATE       -metax.types.UPDATEDELETE       -metax.types.DELETEANY          -metax.types.ANYReturn TypesEvent -metax.db.listeners:Event:Statements:type   -str- event typetarget -str- file listener uuid in other events is a noneevent  -str- raw event received from serverMethods:This Class Without any methodResponse -metax.request:Response:Statements:status        -int- Status code of requestdata          -byte- response from serveras_string     -str- unicode decoded data response from serversuccess       -bool- return true if request is successraw           -get- resuqest/response dataMethods:json          -return dict object of response contenttext          -return the string object od response contentUsageis_valid_uuid:frommetax.db.metax_baseimportBase# all other reqest types extend Base class methods and statementsfrommetax.typesimportNO_SECUREbase=Base('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"# valid uuiduuid2="066177b7-58ef-4371-8784-6aaf2fe3802c0"# length of last segment is large than mustprint(base.is_valid_uuid(uuid))# trueprint(base.is_valid_uuid(uuid2))# falsevalidate:frommetax.db.metax_baseimportBase# all other reqest types extend Base class methods and statementsfrommetax.typesimportNO_SECUREbase=Base('localhost',8001,NO_SECURE)resp1="{\"uuid\":\"066177b7-58ef-4371-8784-6af2fe3802c0\"}"# valid responseresp2="{\"error\":\"Getting file failed\"}"# invalid responseprint(base.is_valid_uuid(resp1))# Nothingprint(base.is_valid_uuid(resp2))# Error type` metax.errors.GettingFileFiledErrorcopy:frommetax.db.copyimportCopyfrommetax.typesimportNO_SECUREbase=Copy('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"# valid uuidprint(base.copy(uuid))# return a new uuid or errordelete:frommetax.db.deleteimportDeletefrommetax.typesimportNO_SECUREbase=Delete('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"# valid uuidprint(base.delete(uuid))# return deleted uuid or erroradd friend:frommetax.db.friendsimportFriendsfrommetax.typesimportNO_SECUREbase=Friends('localhost',8001,NO_SECURE)friend_key="PUBLIC_RSA_KEY"print(base.add_friend(friend_key))get friend list:frommetax.db.friendsimportFriendsfrommetax.typesimportNO_SECUREbase=Friends('localhost',8001,NO_SECURE)print(base.get_friends_list())get:frommetax.db.getimportGetfrommetax.typesimportNO_SECUREbase=Get('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"# valid uuidprint(base.get(uuid))get user key:frommetax.db.keysimportKeysfrommetax.typesimportNO_SECUREbase=Keys('localhost',8001,NO_SECURE)print(base.get_user_keys())get user public key:frommetax.db.keysimportKeysfrommetax.typesimportNO_SECUREbase=Keys('localhost',8001,NO_SECURE)print(base.get_user_public_key())regenerate user key:frommetax.db.keysimportKeysfrommetax.typesimportNO_SECUREbase=Keys('localhost',8001,NO_SECURE)print(base.regenerate_user_key())regiseter listeners:frommetax.db.listenersimportListenersfrommetax.typesimportNO_SECUREdefcb(event):print(event.type)base=Listeners('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"print(base.register_listener(uuid,cb))set metax info:frommetax.db.metax_infoimportMetaxInfofrommetax.typesimportNO_SECUREbase=MetaxInfo('localhost',8001,NO_SECURE)uuid="066177b7-58ef-4371-8784-6af2fe3802c0"print(base.set_metax_info(uuid))get metax info:frommetax.db.metax_infoimportMetaxInfofrommetax.typesimportNO_SECUREbase=MetaxInfo('localhost',8001,NO_SECURE)print(base.get_metax_info())dump user info:frommetax.db.metax_infoimportMetaxInfofrommetax.typesimportNO_SECUREbase=MetaxInfo('localhost',8001,NO_SECURE)print(base.dump_user_info())start pairing:frommetax.db.pairimportPairfrommetax.typesimportNO_SECUREbase=Pair('localhost',8001,NO_SECURE)print(base.start_pairing(timeout=5))cancel pairing:frommetax.db.pairimportPairfrommetax.typesimportNO_SECUREbase=Pair('localhost',8001,NO_SECURE)print(base.cancel_pairing())get pairing peers:frommetax.db.pairimportPairfrommetax.typesimportNO_SECUREbase=Pair('localhost',8001,NO_SECURE)print(base.get_pairing_peers())peers:frommetax.db.peersimportPeersfrommetax.typesimportNO_SECUREbase=Peers('localhost',8001,NO_SECURE)print(base.peers())reconnect to peers:frommetax.db.peersimportPeersfrommetax.typesimportNO_SECUREbase=Peers('localhost',8001,NO_SECURE)print(base.reconnect_to_peers())save:frommetax.db.saveimportSavefrommetax.typesimportNO_SECUREbase=Save('localhost',8001,NO_SECURE)print(base.save("data ot nothing to create empty file"))send to:frommetax.db.send_toimportSendTofrommetax.typesimportNO_SECUREbase=SendTo('localhost',8001,NO_SECURE)print(base.send_to("PUBLIC_KEY","DATA TO SEND"))share:frommetax.db.shareimportSharefrommetax.typesimportNO_SECUREbase=Share('localhost',8001,NO_SECURE)print(base.send_to("UUID","PUBLIC_KEY"))accept share:frommetax.db.shareimportSharefrommetax.typesimportNO_SECUREbase=Share('localhost',8001,NO_SECURE)print(base.accept_share("UUID","PUBLIC_KEY","IV"))update:frommetax.db.updateimportUpdatefrommetax.typesimportNO_SECUREbase=Update('localhost',8001,NO_SECURE)print(base.update("UUID","New Content"))Metax:frommetaximportMetaxfrommetax.typesimportNO_SECUREbase=Metax('localhost',8001,NO_SECURE)print(base.save("Data"))# new file uuidprint(base.update("UUID","New Content").success)print(base.get("UUID"))# resposne# Metax class Extend all classes for request to metax web apiCRUD:frommetaximportCRUDfrommetax.typesimportNO_SECUREbase=CRUD('localhost',8001,NO_SECURE)print(base.save("Data"))# new file uuidprint(base.update("UUID","New Content").success)print(base.get("UUID"))# resposneprint(base.delete("UUID"))# resposne# CRUD class extends only (C)reate (R)ead (D)elete (U)pdate requests to metax web apiRequirementsPython 3.7+Pip Packagesrequestswebsocket-clientcommands to install all in ubuntu:sudo apt install python3 python3-dev python3-pippython3 -m pip install requirements.txt # orpython3 -m pip install requests websocket-client==0.37.0OtherDefinition 'headers'CopyclassCopy(Base):def__init__(self,*args,**kwargs):...defcopy(self,uuid:str,**query_params:dict)->Response:...DeleteclassDelete(Base):def__init__(self,*args,**kwargs):...defdelete(self,uuid:str,**query_params:dict)->Response:...FriendsclassFriends(Base):def__init__(self,*args,**kwargs):...defadd_friend(self,key:str,username:str,**query_params:dict)->Response:...defget_friends_list(self,**query_params:dict)->Response:...GetclassGet(Base):def__init__(self,*args,**kwargs):...defget(self,uuid:str,**query_params:dict)->Response:...KeysclassKeys(Base):def__init__(self,*args,**kwargs):...defget_user_keys(self,**query_params:dict)->Response:...defget_user_public_key(self,**query_params:dict)->Response:...defregenerate_user_key(self,**query_params:dict)->Response:...ListenersclassListener(Base):__listeners=[]any_event=lambda*a,**k:...def__init__(self,*args,**kwargs):...deflisteners(self)->list:...defregister_listener(self,uuid:str,callback:callable,type_:str=ANY,**query_params:dict)->Response:...defunregister_listener(self,uuid:str,**query_params:dict)->Response:...definit_registers(self,*args:list,**kwargs:dict)->None:defevent(self,response:self)->None:...defon_ws_message(self,socket:WebSocketApp,message:str)->None:...BaseclassBase:def__init__(self,host:str,port:int,secure:bool=False):...defvalidate(self,response:Response)->None:...defis_valid_uuid(self,uuid:str)->bool:...Metax InfoclassMetaxInfo(Base):def__init__(self,*args:list,**kwargs:dict):...defset_metax_info(self,uuid:str,**query_params:dict)->Response:...defget_metax_info(self,**query_params:dict)->Response:...defdump_user_info(self,**query_params:dict)->Response:...PairclassPair(Base):def__init__(self,*args,**kwargs):...defstart_pairing(self,timeout:int,**query_params:dict)->Response:...defcancel_pairing(self,**query_params:dict)->Response:...defget_pairing_peers(self,**query_params:dict)->Response:...PeersclassPeers(Base):def__init__(self,*args,**kwargs):...defpeers(self,**query_params:dict)->Response:...defreconnect_to_peers(self,**query_params:dict)->Response:...SaveclassSave(Base):def__init__(self,*args,**kwargs):...defsave(self,data:str='',type:str=NODE,**query_params:dict)->Response:...SendToclassSendTo(Base):def__init__(self,*args,**kwargs):...defsend_to(self,key:str,data:str,**query_params:dict)->Response:...ShareclassShare(Base):def__init__(self,*args,**kwargs):...defshare(self,uuid:str,key:str,**query_params:dict)->Response:...defaccept_share(self,uuid:str,key:str,iv:str,**query_params:dict)->Response:...UpdateclassUpdate(Base):def__init__(self,*args,**kwargs):...defupdate(self,uuid:str,data:str,type:str=NODE,**query_params:dict)->Response:...