How can you load redirects for a node to delete them? (redirect api) I'm trying to create a module which creates a redirect when a node is unpublished and removes it if the node is published again.

The redirect module API, has functions for doing both redirect_save and redirect_delete.

However I can't work out how to load all the redirects for a specific node in order to delete them, I think you might be able to use redirect_load_by_source but I can't work out how to get it to function correctly.

Has anyone tackled this sort of problem before?
Asked a question to soon. Solved it by digging around in the redirect module tables. Here's an example of what a couple rows look like.

+-----+---------------------------------------------+----------+-----+---------------------------------------------------------------+----------------+-----------+------------------+----------+-------------+-------+------------+
| rid | hash                                        | type     | uid | source                                                        | source_options | redirect  | redirect_options | language | status_code | count | access     |
+-----+---------------------------------------------+----------+-----+---------------------------------------------------------------+----------------+-----------+------------------+----------+-------------+-------+------------+
|   2 | FLzM1K67ig-cItlqDDOPhWjLytEuRwdnvXW9e7Nk7TA | redirect |   0 | mypath/nodetype/node-title                                    | a:0:{}         | node/1275 | a:0:{}           | und      |           0 |   108 | 1410048251 |
|   3 | WUltm2RBISR13aRoShkSvOIvZSAgoA8Wn5miIvUIS9w | redirect |   0 | mypath/nodetype/node-title2                                   | a:0:{}         | node/1276 | a:0:{}           | und      |           0 |     5 | 1409544283 |


As you can probably now see it's fairly obvious that $source is referring to the redirect that was created. This does appear to mean it's not possible to look up all the redirects related to one node, not a problem in my case but perhaps a problem for someone else in the future.