NewGetMetricConfigurationCommand returns a cobra command for the `get-metric-configuration` subcommand TODO(oxisto): Can we have something like cl cloud get metric-configuration ?
()
| 237 | // NewGetMetricConfigurationCommand returns a cobra command for the `get-metric-configuration` subcommand |
| 238 | // TODO(oxisto): Can we have something like cl cloud get <id> metric-configuration <id>? |
| 239 | func NewGetMetricConfigurationCommand() *cobra.Command { |
| 240 | cmd := &cobra.Command{ |
| 241 | Use: "get-metric-configuration", |
| 242 | Short: "Retrieves a metric configuration for a specific certification target", |
| 243 | Args: cobra.ExactArgs(2), |
| 244 | RunE: func(cmd *cobra.Command, args []string) error { |
| 245 | var ( |
| 246 | err error |
| 247 | session *cli.Session |
| 248 | client orchestrator.OrchestratorClient |
| 249 | res *assessment.MetricConfiguration |
| 250 | ) |
| 251 | |
| 252 | if session, err = cli.ContinueSession(); err != nil { |
| 253 | fmt.Printf("Error while retrieving the session. Please re-authenticate.\n") |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | client = orchestrator.NewOrchestratorClient(session) |
| 258 | |
| 259 | targetID := args[0] |
| 260 | metricID := args[1] |
| 261 | |
| 262 | res, err = client.GetMetricConfiguration(context.Background(), &orchestrator.GetMetricConfigurationRequest{CertificationTargetId: targetID, MetricId: metricID}) |
| 263 | |
| 264 | return session.HandleResponse(res, err) |
| 265 | }, |
| 266 | ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 267 | return []string{}, cobra.ShellCompDirectiveNoFileComp |
| 268 | }, |
| 269 | } |
| 270 | |
| 271 | return cmd |
| 272 | } |
| 273 | |
| 274 | // NewCloudCommand returns a cobra command for `cloud` subcommands |
| 275 | func NewCloudCommand() *cobra.Command { |