__init__.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pylm-registry 作者: nfqsolutions 项目源码 文件源码
def new_admin_account(uri, master_key, admin_name, key=None):
    """
    Creates a new client account with the master key. The master key is part
    of the static configuration of the registry service.

    :param uri: URI of the registry service
    :param master_key: Master key for the registry service
    :param admin_name: Name of the admin account
    :param key: Key of the admin account
    :return: Key assigned to the admin account. It may be generated automatically
    """
    arguments = {
        'method': 'new_admin',
        'name': admin_name,
    }
    if key:
        arguments['key'] = key

    client = HTTPClient()
    response = client.fetch('{}/admin?{}'.format(
        uri, parse.urlencode(arguments)),
        headers={'Key': master_key}
    )
    if response.code == 200:
        return response.body.decode('utf-8')
    else:
        raise ValueError(response.body.decode('utf-8'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号