def get_resource_by_natural_key(ctx, data, resource_name, resource=None):
    resource_id = None
    obj = None

    # Look up the object by natural key (e.g. cidr)
    obj = ctx.obj.get_single_object(data, resource=resource)

    # If the object was found, get its id
    if obj is not None:
        resource_id = obj['id']

    # If it's not found, error out.
    if resource_id is None:
        raise click.UsageError(
            'No matching %s found; try lookup using option "-i" / "--id".' %
            (resource_name,)
        )

    return resource_id
Attempt to return the reource_id for an object.
dataset/ETHPy150Open dropbox/pynsot/pynsot/commands/callbacks.py/get_resource_by_natural_key