NewCollectionRemoveItemsCmd returns a command for removing items from a collection.
()
| 224 | |
| 225 | // NewCollectionRemoveItemsCmd returns a command for removing items from a collection. |
| 226 | func NewCollectionRemoveItemsCmd() *cobra.Command { |
| 227 | return &cobra.Command{ |
| 228 | Use: "remove [collection id] [ioc]...", |
| 229 | Short: "Remove items from a collection.", |
| 230 | Args: cobra.MinimumNArgs(2), |
| 231 | Long: removeCollectionItemsCmdHelp, |
| 232 | Example: removeCollectionItemsExample, |
| 233 | |
| 234 | RunE: func(cmd *cobra.Command, args []string) error { |
| 235 | c, err := NewAPIClient() |
| 236 | if err != nil { |
| 237 | return err |
| 238 | } |
| 239 | relationshipDescriptors := descriptorsFromReader( |
| 240 | utils.StringReaderFromCmdArgs(args[1:])) |
| 241 | for relationshipName, descriptors := range relationshipDescriptors { |
| 242 | url := vt.URL("collections/%s/%s", args[0], relationshipName) |
| 243 | response, err := c.DeleteData(url, descriptors) |
| 244 | if err != nil { |
| 245 | return err |
| 246 | } |
| 247 | if response.Error.Code != "" { |
| 248 | return response.Error |
| 249 | } |
| 250 | } |
| 251 | return nil |
| 252 | }, |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | var deleteCollectionCmdHelp = `Delete a collection. |
| 257 |
no test coverage detected