commands.py 文件源码

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

项目:koi 作者: openpermissions 项目源码 文件源码
def _get_service(client, organisation_id, name):
    """
    Get service belonging to organisation which matches given service name
    :param client: Accounts Service API Client
    :param organisation_id: Id of Organisation
    :param name: Service Name
    :return: Service Id
    """
    try:
        response = client.accounts.services.get(organisation_id=organisation_id)
    except httpclient.HTTPError as exc:
        if exc.code == 404:
            # If error is a 404 then this means the organisation_id is not recognised. Raise this error immediately
            msg = ('Organisation {} cannot be found. '
                   'Please check organisation_id.'.format(organisation_id))
            raise click.ClickException(click.style(msg, fg='red'))
        else:
            raise exc

    services = [s for s in response['data'] if s['name'] == name]

    if services:
        return services[0]['id']
    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号