Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #12 from joyent/perigrin/316-delete-relay
Browse files Browse the repository at this point in the history
Delete relays
  • Loading branch information
sungo authored Sep 17, 2019
2 parents 1e6c1b4 + ae15e65 commit b0bbe27
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions relays.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,20 @@ func (r *Relays) Register(
return relay
}

func (r *Relays) Delete(identifier string) {
uri := fmt.Sprintf("/relay/%s", url.PathEscape(identifier))
res := r.Do(r.Sling().New().Delete(uri))

if res.StatusCode() != 204 {
// I know this is weird. Like in other places, it should be impossible
// to reach here unless the status code is 204. The API returns 204
// (which gets us here) or 409 (which will explode before it gets here).
// If we got here via some other code, then there's some new behavior
// that we need to know about.
panic(res)
}
}

func init() {
App.Command("relays", "Perform actions against the whole list of relays", func(cmd *cli.Cmd) {
cmd.Command("get", "Get a list of relays", func(cmd *cli.Cmd) {
Expand Down Expand Up @@ -282,6 +296,12 @@ For instance:
))
}
})
cmd.Command("delete rm", "Delete a relay", func(cmd *cli.Cmd) {
cmd.Action = func() {
API.Relays().Delete(*relayArg)
fmt.Println(API.Relays().GetAll())
}
})
})

}

0 comments on commit b0bbe27

Please sign in to comment.