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

Method getPutCommand

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

Source from the content-addressed store, hash-verified

148}
149
150func (gohanClientCLI *GohanClientCLI) getPutCommand(s *schema.Schema) gohanCommand {
151 return gohanCommand{
152 Name: fmt.Sprintf("%s set", s.ID),
153 Schema: s,
154 Action: func(args []string) (string, error) {
155 if len(args) < 1 {
156 return "", fmt.Errorf("Wrong number of arguments")
157 }
158 argsMap, err := gohanClientCLI.handleArguments(args[:len(args)-1], s)
159 if err != nil {
160 return "", err
161 }
162 parsedArgs, err := gohanClientCLI.handleRelationArguments(s, argsMap)
163 if err != nil {
164 return "", err
165 }
166 opts := gophercloud.RequestOpts{
167 JSONBody: parsedArgs,
168 OkCodes: []int{200, 201, 202, 400},
169 }
170 id, err := gohanClientCLI.getResourceID(s, args[len(args)-1])
171 if err != nil {
172 return "", err
173 }
174 url := fmt.Sprintf("%s%s/%s", gohanClientCLI.opts.gohanEndpointURL, s.URL, id)
175 result, err := gohanClientCLI.request("PUT", url, &opts)
176 return gohanClientCLI.formatOutput(s, result), err
177 },
178 }
179}
180
181func (gohanClientCLI *GohanClientCLI) getDeleteCommand(s *schema.Schema) gohanCommand {
182 return gohanCommand{

Callers 2

getCommandsMethod · 0.95
client_test.goFile · 0.80

Calls 6

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

Tested by

no test coverage detected