<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete(ctx, resource, id):
 """Delete given device model or instance. """

    session, api_url, project_id = build_client_from_context(ctx)
    url = '/'.join([api_url, resource, id])
    r = session.delete(url)
    if r.status_code != 200:
        raise failed_request_exception('failed to delete resource', r)
    click.echo(r.text)