MCPcopy Create free account
hub / github.com/VirusTotal/vt-cli / NewCollectionUpdateCmd

Function NewCollectionUpdateCmd

cmd/collection.go:174–211  ·  view source on GitHub ↗

NewCollectionUpdateCmd returns a command for adding new items to a collection.

()

Source from the content-addressed store, hash-verified

172
173// NewCollectionUpdateCmd returns a command for adding new items to a collection.
174func NewCollectionUpdateCmd() *cobra.Command {
175 return &cobra.Command{
176 Use: "update [collection id] [ioc]...",
177 Short: "Add new items to a collection.",
178 Args: cobra.MinimumNArgs(2),
179 Long: updateCollectionCmdHelp,
180 Example: updateCollectionExample,
181
182 RunE: func(cmd *cobra.Command, args []string) error {
183 c, err := NewAPIClient()
184 if err != nil {
185 return err
186 }
187 p, err := NewPrinter(cmd)
188 if err != nil {
189 return err
190 }
191
192 collection := vt.NewObjectWithID("collection", args[0])
193 reader := utils.StringReaderFromCmdArgs(args[1:])
194 collection.SetData("raw_items", rawFromReader(reader))
195
196 if err := c.PatchObject(vt.URL("collections/%s", args[0]), collection); err != nil {
197 return err
198 }
199
200 if viper.GetBool("identifiers-only") {
201 fmt.Printf("%s\n", collection.ID())
202 } else {
203 if err := p.PrintObject(collection); err != nil {
204 return err
205 }
206 }
207
208 return nil
209 },
210 }
211}
212
213var removeCollectionItemsCmdHelp = `Remove items from a collection.
214

Callers 1

NewCollectionCmdFunction · 0.85

Calls 5

PrintObjectMethod · 0.95
StringReaderFromCmdArgsFunction · 0.92
rawFromReaderFunction · 0.85
NewAPIClientFunction · 0.70
NewPrinterFunction · 0.70

Tested by

no test coverage detected