MCPcopy Create free account
hub / github.com/cloudwan/gohan / getDeleteCommand

Method getDeleteCommand

cli/client/commands.go:181–202  ·  view source on GitHub ↗
(s *schema.Schema)

Source from the content-addressed store, hash-verified

179}
180
181func (gohanClientCLI *GohanClientCLI) getDeleteCommand(s *schema.Schema) gohanCommand {
182 return gohanCommand{
183 Name: fmt.Sprintf("%s delete", s.ID),
184 Schema: s,
185 Action: func(args []string) (string, error) {
186 if len(args) < 1 {
187 return "", fmt.Errorf("Wrong number of arguments")
188 }
189 _, err := gohanClientCLI.handleArguments(args[:len(args)-1], s)
190 if err != nil {
191 return "", err
192 }
193 id, err := gohanClientCLI.getResourceID(s, args[len(args)-1])
194 if err != nil {
195 return "", err
196 }
197 url := fmt.Sprintf("%s%s/%s", gohanClientCLI.opts.gohanEndpointURL, s.URL, id)
198 result, err := gohanClientCLI.request("DELETE", url, nil)
199 return gohanClientCLI.formatOutput(s, result), err
200 },
201 }
202}
203
204// Assumes gohan client is called as follows:
205// gohan client [common_params...] [action_input] [resource_id]

Callers 2

getCommandsMethod · 0.95
client_test.goFile · 0.80

Calls 5

handleArgumentsMethod · 0.95
getResourceIDMethod · 0.95
requestMethod · 0.95
formatOutputMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected