(cmd *cobra.Command, args []string)
| 132 | } |
| 133 | |
| 134 | func deleteAgentGroup(cmd *cobra.Command, args []string) { |
| 135 | if len(args) == 0 { |
| 136 | fmt.Fprintln(os.Stderr, "must specify name.\nExample: %s", cmd.Example) |
| 137 | return |
| 138 | } |
| 139 | |
| 140 | server := common.GetServerInfo(cmd) |
| 141 | url := fmt.Sprintf("http://%s:%d/v1/vtap-groups/?name=%s", server.IP, server.Port, args[0]) |
| 142 | // 调用采集器组API,获取lcuuid |
| 143 | response, err := common.CURLPerform("GET", url, nil, "", []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd))}...) |
| 144 | if err != nil { |
| 145 | fmt.Fprintln(os.Stderr, err) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | if len(response.Get("DATA").MustArray()) > 0 { |
| 150 | group := response.Get("DATA").GetIndex(0) |
| 151 | lcuuid := group.Get("LCUUID").MustString() |
| 152 | |
| 153 | url := fmt.Sprintf("http://%s:%d/v1/vtap-groups/%s/", server.IP, server.Port, lcuuid) |
| 154 | _, err := common.CURLPerform("DELETE", url, nil, "", |
| 155 | []common.HTTPOption{common.WithTimeout(common.GetTimeout(cmd)), common.WithORGID(common.GetORGID(cmd))}...) |
| 156 | if err != nil { |
| 157 | fmt.Fprintln(os.Stderr, err) |
| 158 | return |
| 159 | } |
| 160 | } |
| 161 | } |
no test coverage detected