Esempio n. 1
0
def get(opt, conf, username=None, arg=None):
    """
    Просмотр аккаунтов
    fs-api # все аккаунты
    fs-api --start=10 --limit=15 # все аккаунты с 10 по 25
    fs-api -s diller # все аккаунты для диллера diller
    fs-api -u <username> # просмотр аккаунта username
    """
    url = "{2}://{0}{1}".format(
        conf.get(opt.section, "host"), conf.get(opt.section, "pref"), conf.get(opt.section, "protocol")
    )
    con = Connection(
        url, username=conf.get(opt.section, "user"), password=conf.get(opt.section, "passwd"), path_cache=PATH_CACHE
    )
    args = {"start": opt.start, "limit": opt.limit}
    if username is not None:
        mod_query = "/account/{0}/".format(username)
        res = con.search(mod_query, args)
        # print("res:{0}".format(res))
        if res:
            view(res.get("accounts"))
        else:
            print("No account: {0}; status: {1}".format(username, con.status))
    else:
        mod_query = "/account/"
        res = con.search(mod_query, args)
        # print(con.response)
        # print("res:{0}".format(res))
        if res:
            print("count: {0}".format(res.get("count")))
            print("next: {0}".format(res.get("next")))
            print("previous: {0}".format(res.get("previous")))

            accounts = res.get("accounts")
            for a in accounts:
                if a.get("enabled"):
                    enabled = "enabled"
                else:
                    enabled = "disabled"
                print(
                    "cash: {0}; tariff: [{4}] {5};  username: {1}({3}) {2}".format(
                        a.get("cash"),
                        a.get("accountcode").get("username"),
                        enabled,
                        a.get("accountcode").get("email"),
                        a.get("tariff").get("id"),
                        a.get("tariff").get("name"),
                    )
                )
        else:
            print("No account, status: {0}".format(con.status))
Esempio n. 2
0
def get(opt, conf, arg=None):
    """
    просмотр номера телефона
    fs-api -c endpoint -u <username> # все телефонные номера для аккаунта username
    fs-api -c endpoint -u <username> --start=10 --limit=15 # все телефоны с 10 по 25
    """
    # TODO: доделать пока неработает
    url = "{2}://{0}{1}".format(conf.get(opt.section, 'host'),conf.get(opt.section, 'pref'),conf.get(opt.section, 'protocol'))
    con = Connection(url, username=conf.get(opt.section, 'user'), password=conf.get(opt.section, 'passwd'), path_cache=PATH_CACHE)
    args={'start': opt.start, 'limit': opt.limit}
    if opt.username is not None:
        mod_query = "/endpoint/{0}/".format(opt.username)
        res = con.search(mod_query, args)
        #print("res:{0}".format(res))
        if res:
            view(res.get("accounts"))
        else:
            print('No account: {0}; status: {1}'.format(username,con.status))
    else:
        mod_query = "/endpoint/"
        res = con.search(mod_query, args)
        #print(con.response)
        #print("res:{0}".format(res))
        if res:
            print("count: {0}".format(res.get("count")))
            print("next: {0}".format(res.get("next")))
            print("previous: {0}".format(res.get("previous")))

            accounts = res.get("accounts")
            for a in accounts:
                if a.get('enabled'):
                    enabled = 'enabled'
                else:
                    enabled = 'disabled'
                print("phone: {0}; password: {1}({2})".format(a.get("uid"), a.get('password'), enabled))
        else:
            print('No endpoint, status: {0}'.format(con.status))