Skip to content

Commit 507f324

Browse files
authored
Onboard Argus Scrape Config: delete command (#235)
* delete command implementation and testing * improve help and log messages * update help * address PR comments * generate docs
1 parent 46c6652 commit 507f324

14 files changed

+498
-96
lines changed

docs/stackit_argus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ stackit argus [flags]
3131
* [stackit](./stackit.md) - Manage STACKIT resources using the command line
3232
* [stackit argus instance](./stackit_argus_instance.md) - Provides functionality for Argus instances
3333
* [stackit argus plans](./stackit_argus_plans.md) - Lists all Argus service plans
34-
* [stackit argus scrape-configs](./stackit_argus_scrape-configs.md) - Provides functionality for scrape configs in Argus.
34+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
3535

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## stackit argus scrape-config
2+
3+
Provides functionality for scrape configurations in Argus
4+
5+
### Synopsis
6+
7+
Provides functionality for scrape configurations in Argus.
8+
9+
```
10+
stackit argus scrape-config [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit argus scrape-config"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty"]
25+
-p, --project-id string Project ID
26+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
27+
```
28+
29+
### SEE ALSO
30+
31+
* [stackit argus](./stackit_argus.md) - Provides functionality for Argus
32+
* [stackit argus scrape-config create](./stackit_argus_scrape-config_create.md) - Creates a scrape configuration for an Argus instance
33+
* [stackit argus scrape-config delete](./stackit_argus_scrape-config_delete.md) - Deletes a scrape configuration from an Argus instance
34+
* [stackit argus scrape-config generate-payload](./stackit_argus_scrape-config_generate-payload.md) - Generates a payload to create/update scrape configurations for an Argus instance
35+
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
## stackit argus scrape-configs create
1+
## stackit argus scrape-config create
22

3-
Creates a Scrape Config job for an Argus instance
3+
Creates a scrape configuration for an Argus instance
44

55
### Synopsis
66

7-
Creates a Scrape Config job for an Argus instance.
7+
Creates a scrape configuration job for an Argus instance.
88
The payload can be provided as a JSON string or a file path prefixed with "@".
99
If no payload is provided, a default payload will be used.
1010
See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_create for information regarding the payload structure.
1111

1212
```
13-
stackit argus scrape-configs create [flags]
13+
stackit argus scrape-config create [flags]
1414
```
1515

1616
### Examples
1717

1818
```
19-
Create a Scrape Config job on Argus instance "xxx" using default configuration
20-
$ stackit argus scrape-configs create
19+
Create a scrape configuration on Argus instance "xxx" using default configuration
20+
$ stackit argus scrape-config create
2121
22-
Create a Scrape Config job on Argus instance "xxx" using an API payload sourced from the file "./payload.json"
23-
$ stackit argus scrape-configs create --payload @./payload.json --instance-id xxx
22+
Create a scrape configuration on Argus instance "xxx" using an API payload sourced from the file "./payload.json"
23+
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
2424
25-
Create a Scrape Config job on Argus instance "xxx" using an API payload provided as a JSON string
26-
$ stackit argus scrape-configs create --payload "{...}" --instance-id xxx
25+
Create a scrape configuration on Argus instance "xxx" using an API payload provided as a JSON string
26+
$ stackit argus scrape-config create --payload "{...}" --instance-id xxx
2727
2828
Generate a payload with default values, and adapt it with custom values for the different configuration options
29-
$ stackit argus scrape-configs generate-payload > ./payload.json
29+
$ stackit argus scrape-config generate-payload > ./payload.json
3030
<Modify payload in file, if needed>
31-
$ stackit argus scrape-configs create --payload @./payload.json --instance-id xxx
31+
$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx
3232
```
3333

3434
### Options
3535

3636
```
37-
-h, --help Help for "stackit argus scrape-configs create"
37+
-h, --help Help for "stackit argus scrape-config create"
3838
--instance-id string Instance ID
39-
--payload string Request payload (JSON). Can be a string or a file path, if prefixed with "@" (example: @./payload.json). If unset, will use a default payload (you can check it by running "stackit argus scrape-configs generate-payload")
39+
--payload string Request payload (JSON). Can be a string or a file path, if prefixed with "@" (example: @./payload.json). If unset, will use a default payload (you can check it by running "stackit argus scrape-config generate-payload")
4040
```
4141

4242
### Options inherited from parent commands
@@ -51,5 +51,5 @@ stackit argus scrape-configs create [flags]
5151

5252
### SEE ALSO
5353

54-
* [stackit argus scrape-configs](./stackit_argus_scrape-configs.md) - Provides functionality for scrape configs in Argus.
54+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
5555

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## stackit argus scrape-config delete
2+
3+
Deletes a scrape configuration from an Argus instance
4+
5+
### Synopsis
6+
7+
Deletes a scrape configuration from an Argus instance.
8+
9+
```
10+
stackit argus scrape-config delete JOB_NAME [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Delete a scrape configuration job with name "my-config" from Argus instance "xxx"
17+
$ stackit argus scrape-config delete my-config --instance-id xxx
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help Help for "stackit argus scrape-config delete"
24+
--instance-id string Instance ID
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
-y, --assume-yes If set, skips all confirmation prompts
31+
--async If set, runs the command asynchronously
32+
-o, --output-format string Output format, one of ["json" "pretty"]
33+
-p, --project-id string Project ID
34+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
35+
```
36+
37+
### SEE ALSO
38+
39+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
40+
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
## stackit argus scrape-configs generate-payload
1+
## stackit argus scrape-config generate-payload
22

3-
Generates a payload to create/update Scrape Configurations for an Argus instance
3+
Generates a payload to create/update scrape configurations for an Argus instance
44

55
### Synopsis
66

7-
Generates a JSON payload with values to be used as --payload input for Scrape Configurations creation or update.
8-
This command can be used to generate a payload to update an existing Scrape Config job or to create a new Scrape Config job.
9-
To update an existing Scrape Config job, provide the job name and the instance ID of the Argus instance.
10-
To obtain a default payload to create a new Scrape Config job, run the command with no flags.
7+
Generates a JSON payload with values to be used as --payload input for scrape configurations creation or update.
8+
This command can be used to generate a payload to update an existing scrape config or to create a new scrape config job.
9+
To update an existing scrape config job, provide the job name and the instance ID of the Argus instance.
10+
To obtain a default payload to create a new scrape config job, run the command with no flags.
1111
Note that some of the default values provided, such as the job name, the metrics path and URL of the targets, should be adapted to your use case.
1212
See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_create for information regarding the payload structure.
1313

1414

1515
```
16-
stackit argus scrape-configs generate-payload [flags]
16+
stackit argus scrape-config generate-payload [flags]
1717
```
1818

1919
### Examples
2020

2121
```
2222
Generate a Create payload with default values, and adapt it with custom values for the different configuration options
23-
$ stackit argus scrape-configs generate-payload > ./payload.json
23+
$ stackit argus scrape-config generate-payload > ./payload.json
2424
<Modify payload in file, if needed>
25-
$ stackit argus scrape-configs create my-config --payload @./payload.json
25+
$ stackit argus scrape-config create my-config --payload @./payload.json
2626
2727
Generate an Update payload with the values of an existing configuration named "my-config" for Argus instance xxx, and adapt it with custom values for the different configuration options
28-
$ stackit argus scrape-configs generate-payload --job-name my-config --instance-id xxx > ./payload.json
28+
$ stackit argus scrape-config generate-payload --job-name my-config --instance-id xxx > ./payload.json
2929
<Modify payload in file>
30-
$ stackit argus scrape-configs update my-config --payload @./payload.json
30+
$ stackit argus scrape-config update my-config --payload @./payload.json
3131
```
3232

3333
### Options
3434

3535
```
36-
-h, --help Help for "stackit argus scrape-configs generate-payload"
36+
-h, --help Help for "stackit argus scrape-config generate-payload"
3737
--instance-id string Instance ID
3838
-n, --job-name string If set, generates an update payload with the current state of the given scrape config. If unset, generates a create payload with default values
3939
```
@@ -50,5 +50,5 @@ stackit argus scrape-configs generate-payload [flags]
5050

5151
### SEE ALSO
5252

53-
* [stackit argus scrape-configs](./stackit_argus_scrape-configs.md) - Provides functionality for scrape configs in Argus.
53+
* [stackit argus scrape-config](./stackit_argus_scrape-config.md) - Provides functionality for scrape configurations in Argus
5454

docs/stackit_argus_scrape-configs.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

internal/cmd/argus/argus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package argus
33
import (
44
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/instance"
55
"github.com/stackitcloud/stackit-cli/internal/cmd/argus/plans"
6-
scrapeconfigs "github.com/stackitcloud/stackit-cli/internal/cmd/argus/scrape-configs"
6+
scrapeconfig "github.com/stackitcloud/stackit-cli/internal/cmd/argus/scrape-config"
77
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
88
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
99
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
@@ -26,5 +26,5 @@ func NewCmd(p *print.Printer) *cobra.Command {
2626
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
2727
cmd.AddCommand(plans.NewCmd(p))
2828
cmd.AddCommand(instance.NewCmd(p))
29-
cmd.AddCommand(scrapeconfigs.NewCmd(p))
29+
cmd.AddCommand(scrapeconfig.NewCmd(p))
3030
}

internal/cmd/argus/scrape-configs/create/create.go renamed to internal/cmd/argus/scrape-config/create/create.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ type inputModel struct {
3434
func NewCmd(p *print.Printer) *cobra.Command {
3535
cmd := &cobra.Command{
3636
Use: "create",
37-
Short: "Creates a Scrape Config job for an Argus instance",
37+
Short: "Creates a scrape configuration for an Argus instance",
3838
Long: fmt.Sprintf("%s\n%s\n%s\n%s",
39-
"Creates a Scrape Config job for an Argus instance.",
39+
"Creates a scrape configuration job for an Argus instance.",
4040
"The payload can be provided as a JSON string or a file path prefixed with \"@\".",
4141
"If no payload is provided, a default payload will be used.",
4242
"See https://docs.api.stackit.cloud/documentation/argus/version/v1#tag/scrape-config/operation/v1_projects_instances_scrapeconfigs_create for information regarding the payload structure.",
4343
),
4444
Args: args.NoArgs,
4545
Example: examples.Build(
4646
examples.NewExample(
47-
`Create a Scrape Config job on Argus instance "xxx" using default configuration`,
48-
"$ stackit argus scrape-configs create"),
47+
`Create a scrape configuration on Argus instance "xxx" using default configuration`,
48+
"$ stackit argus scrape-config create"),
4949
examples.NewExample(
50-
`Create a Scrape Config job on Argus instance "xxx" using an API payload sourced from the file "./payload.json"`,
51-
"$ stackit argus scrape-configs create --payload @./payload.json --instance-id xxx"),
50+
`Create a scrape configuration on Argus instance "xxx" using an API payload sourced from the file "./payload.json"`,
51+
"$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx"),
5252
examples.NewExample(
53-
`Create a Scrape Config job on Argus instance "xxx" using an API payload provided as a JSON string`,
54-
`$ stackit argus scrape-configs create --payload "{...}" --instance-id xxx`),
53+
`Create a scrape configuration on Argus instance "xxx" using an API payload provided as a JSON string`,
54+
`$ stackit argus scrape-config create --payload "{...}" --instance-id xxx`),
5555
examples.NewExample(
5656
`Generate a payload with default values, and adapt it with custom values for the different configuration options`,
57-
`$ stackit argus scrape-configs generate-payload > ./payload.json`,
57+
`$ stackit argus scrape-config generate-payload > ./payload.json`,
5858
`<Modify payload in file, if needed>`,
59-
`$ stackit argus scrape-configs create --payload @./payload.json --instance-id xxx`),
59+
`$ stackit argus scrape-config create --payload @./payload.json --instance-id xxx`),
6060
),
6161
RunE: func(cmd *cobra.Command, args []string) error {
6262
ctx := context.Background()
@@ -77,7 +77,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
7777
}
7878

7979
if !model.AssumeYes {
80-
prompt := fmt.Sprintf("Are you sure you want to create a Scrape Config job on Argus instance %q?", instanceLabel)
80+
prompt := fmt.Sprintf("Are you sure you want to create a scrape configuration on Argus instance %q?", instanceLabel)
8181
err = p.PromptForConfirmation(prompt)
8282
if err != nil {
8383
return err
@@ -97,7 +97,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
9797
req := buildRequest(ctx, model, apiClient)
9898
_, err = req.Execute()
9999
if err != nil {
100-
return fmt.Errorf("create Scrape Config job: %w", err)
100+
return fmt.Errorf("create scrape configuration: %w", err)
101101
}
102102

103103
jobName := model.Payload.JobName
@@ -108,7 +108,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
108108
s.Start("Creating scrape config")
109109
_, err = wait.CreateScrapeConfigWaitHandler(ctx, apiClient, model.InstanceId, *jobName, model.ProjectId).WaitWithContext(ctx)
110110
if err != nil {
111-
return fmt.Errorf("wait for Scrape Config job creation: %w", err)
111+
return fmt.Errorf("wait for scrape configuration creation: %w", err)
112112
}
113113
s.Stop()
114114
}
@@ -117,7 +117,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
117117
if model.Async {
118118
operationState = "Triggered creation of"
119119
}
120-
p.Outputf("%s Scrape Config job with name %q for Argus instance %q\n", operationState, *jobName, instanceLabel)
120+
p.Outputf("%s scrape configuration with name %q for Argus instance %q\n", operationState, *jobName, instanceLabel)
121121
return nil
122122
},
123123
}
@@ -126,7 +126,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
126126
}
127127

128128
func configureFlags(cmd *cobra.Command) {
129-
cmd.Flags().Var(flags.ReadFromFileFlag(), payloadFlag, `Request payload (JSON). Can be a string or a file path, if prefixed with "@" (example: @./payload.json). If unset, will use a default payload (you can check it by running "stackit argus scrape-configs generate-payload")`)
129+
cmd.Flags().Var(flags.ReadFromFileFlag(), payloadFlag, `Request payload (JSON). Can be a string or a file path, if prefixed with "@" (example: @./payload.json). If unset, will use a default payload (you can check it by running "stackit argus scrape-config generate-payload")`)
130130
cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "Instance ID")
131131

132132
err := flags.MarkFlagsRequired(cmd, instanceIdFlag)

internal/cmd/argus/scrape-configs/create/create_test.go renamed to internal/cmd/argus/scrape-config/create/create_test.go

File renamed without changes.

0 commit comments

Comments
 (0)