'Build and return a role assignment link with provided attributes.
Provided attributes are expected to contain: domain_id or project_id,
user_id or group_id, role_id and, optionally, inherited_to_projects.'

def build_role_assignment_link(self, **attribs):

    if attribs.get('domain_id'):
        link = ('/domains/' + attribs['domain_id'])
    else:
        link = ('/projects/' + attribs['project_id'])
    if attribs.get('user_id'):
        link += ('/users/' + attribs['user_id'])
    else:
        link += ('/groups/' + attribs['group_id'])
    link += ('/roles/' + attribs['role_id'])
    if attribs.get('inherited_to_projects'):
        return ('/OS-INHERIT%s/inherited_to_projects' % link)
    return link
