MCPcopy Create free account
hub / github.com/clouditor/clouditor / NewGetMetricConfigurationCommand

Function NewGetMetricConfigurationCommand

cli/commands/cloud/cloud.go:239–272  ·  view source on GitHub ↗

NewGetMetricConfigurationCommand returns a cobra command for the `get-metric-configuration` subcommand TODO(oxisto): Can we have something like cl cloud get metric-configuration ?

()

Source from the content-addressed store, hash-verified

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>?
239func 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
275func NewCloudCommand() *cobra.Command {

Callers 2

AddCommandsFunction · 0.85

Calls 4

ContinueSessionFunction · 0.92
NewOrchestratorClientFunction · 0.92
HandleResponseMethod · 0.80

Tested by 1