Esempio n. 1
0
def c_account(args):
    output = 'With API_ID{0}, API Key={1} lets add {2}!'. format(args.api_id, args.api_key, args.account_name)
    logging.basicConfig(format='%(levelname)s - %(message)s',  level=getattr(logging, args.log.upper()))
    logging.info(output)

    param = {
        "api_id": args.api_id,
        "api_key": args.api_key,
        "email": args.email,
        "parent_id": args.parent_id,
        "ref_id": args.ref_id,
        "user_name": args.user_name,
        "plan_id": args.plan_id,
        "log_level": args.log_level,
        "logs_account_id": args.logs_account_id,
        "account_name": args.account_name
    }
    result = create(param)

    if result.get('res') != 0:
        err = IncapError(result)
        err.log()
    else:
        account = Account(result)
        print(account.log())
Esempio n. 2
0
def r_account(args):
    output = 'Get account status!'
    param = vars(args)
    logging.basicConfig(format='%(levelname)s - %(message)s', level=getattr(logging, args.log.upper()))
    logging.info(output)

    result = read(param)

    if int(result.get('res')) != 0:
        err = IncapError(result)
        err.log()
    else:
        account = Account(result)
        print(account.log())
Esempio n. 3
0
def c_account(args):
    output = 'With API_ID{0}, API Key={1} lets add {2}!'.format(
        args.api_id, args.api_key, args.account_name)
    param = vars(args)
    logging.basicConfig(format='%(levelname)s - %(message)s',
                        level=getattr(logging, args.log.upper()))
    logging.info(output)

    result = create(param)

    if int(result.get('res')) != 0:
        err = IncapError(result)
        err.log()
    else:
        account = Account(result)
        print(account.log())
Esempio n. 4
0
def r_account(args):
    output = 'Get account status!'
    logging.basicConfig(format='%(levelname)s - %(message)s',
                        level=getattr(logging, args.log.upper()))
    logging.info(output)
    param = {
        "api_id": args.api_id,
        "api_key": args.api_key,
        "account_id": args.account_id
    }
    result = read(param)

    if result.get('res') != 0:
        err = IncapError(result)
        err.log()
    else:
        account = Account(result)
        print(account.log())
Esempio n. 5
0
def r_accounts(args):
    output = 'Get accounts!'
    logging.basicConfig(format='%(levelname)s - %(message)s',
                        level=getattr(logging, args.log.upper()))
    print(output)
    param = {
        "api_id": args.api_id,
        "api_key": args.api_key,
        "account_id": args.account_id,
        "page_size": args.page_size,
        "page_num": args.page_num
    }
    result = read(param)

    if result.get('res') != 0:
        err = IncapError(result)
        err.log()
    else:
        for accounts in result['accounts']:
            account = Account(accounts)
            print(account.log())
Esempio n. 6
0
def createAccount(user):
    newAccount = Account(user)
    accounts.append(newAccount)
    return newAccount