Add CreatePPUser message

This commit is contained in:
clerie 2022-06-16 21:29:21 +02:00
parent 428c4b8661
commit deba76228b
4 changed files with 40 additions and 0 deletions

View File

@ -52,6 +52,23 @@ class OMMClient2:
r = self.connection.request(m) r = self.connection.request(m)
r.raise_on_error() r.raise_on_error()
def create_user(self, num):
"""
Create PP user
:param num: User number
"""
t = types.PPUserType()
t.num = num
m = messages.CreatePPUser()
m.childs.user = [t]
r = self.connection.request(m)
r.raise_on_error()
if r.childs.user is None:
return None
return r.childs.user[0]
def get_account(self, id): def get_account(self, id):
""" """
Get account Get account

View File

@ -134,6 +134,7 @@ def response_type(c):
RESPONSE_TYPES[c.__name__] = c RESPONSE_TYPES[c.__name__] = c
return c return c
from .createppuser import CreatePPUser, CreatePPUserResp
from .getaccount import GetAccount, GetAccountResp from .getaccount import GetAccount, GetAccountResp
from .getppdev import GetPPDev, GetPPDevResp from .getppdev import GetPPDev, GetPPDevResp
from .getppuser import GetPPUser, GetPPUserResp from .getppuser import GetPPUser, GetPPUserResp

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
from . import Request, Response, request_type, response_type
from ..types import PPUserType
@request_type
class CreatePPUser(Request):
CHILDS = {
"user": PPUserType,
}
@response_type
class CreatePPUserResp(Response):
CHILDS = {
"user": PPUserType,
}

4
ommcli
View File

@ -68,6 +68,10 @@ if __name__ == "__main__":
parser_exit = subparsers.add_parser("exit") parser_exit = subparsers.add_parser("exit")
parser_exit.set_defaults(func=exit) parser_exit.set_defaults(func=exit)
parser_get_account = subparsers.add_parser("create_user")
parser_get_account.add_argument("num")
parser_get_account.set_defaults(func=c.create_user, format=format_child_type)
parser_get_account = subparsers.add_parser("get_account") parser_get_account = subparsers.add_parser("get_account")
parser_get_account.add_argument("id", type=int) parser_get_account.add_argument("id", type=int)
parser_get_account.set_defaults(func=c.get_account, format=format_child_type) parser_get_account.set_defaults(func=c.get_account, format=format_child_type)