Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/stackit_beta_scf.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ stackit beta scf [flags]

* [stackit beta](./stackit_beta.md) - Contains beta STACKIT CLI commands
* [stackit beta scf organization](./stackit_beta_scf_organization.md) - Provides functionality for STACKIT Cloud Foundry organizations
* [stackit beta scf platform](./stackit_beta_scf_platform.md) - Provides functionality for STACKIT Cloud Foundry platforms

36 changes: 36 additions & 0 deletions docs/stackit_beta_scf_platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## stackit beta scf platform

Provides functionality for STACKIT Cloud Foundry platforms

### Synopsis

Provides functionality for STACKIT Cloud Foundry platforms.

```
stackit beta scf platform [flags]
```

### Options

```
-h, --help Help for "stackit beta scf platform"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf](./stackit_beta_scf.md) - Provides functionality for STACKIT Cloud Foundry
* [stackit beta scf platform describe](./stackit_beta_scf_platform_describe.md) - Shows details of a STACKIT Cloud Foundry platform
* [stackit beta scf platform list](./stackit_beta_scf_platform_list.md) - Lists all STACKIT Cloud Foundry platforms
* [stackit beta scf platform quota](./stackit_beta_scf_platform_quota.md) - Shows quotas of STACKIT Cloud Foundry platforms

43 changes: 43 additions & 0 deletions docs/stackit_beta_scf_platform_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## stackit beta scf platform describe

Shows details of a STACKIT Cloud Foundry platform

### Synopsis

Shows details of a STACKIT Cloud Foundry platform.

```
stackit beta scf platform describe PLATFORM_ID [flags]
```

### Examples

```
Get details of a STACKIT Cloud Foundry platform with ID "xxx"
$ stackit beta scf platform describe xxx

Get details of a STACKIT Cloud Foundry platform with ID "xxx" in JSON format
$ stackit beta scf platform describe xxx --output-format json
```

### Options

```
-h, --help Help for "stackit beta scf platform describe"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf platform](./stackit_beta_scf_platform.md) - Provides functionality for STACKIT Cloud Foundry platforms

44 changes: 44 additions & 0 deletions docs/stackit_beta_scf_platform_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## stackit beta scf platform list

Lists all STACKIT Cloud Foundry platforms

### Synopsis

Lists all STACKIT Cloud Foundry platforms. The number of fetched platforms is limited to 5000.

```
stackit beta scf platform list [flags]
```

### Examples

```
List all STACKIT Cloud Foundry platforms
$ stackit beta scf platform list

List up to 10 STACKIT Cloud Foundry platforms
$ stackit beta scf platform list --limit 10
```

### Options

```
-h, --help Help for "stackit beta scf platform list"
--limit int Maximum number of entries to list
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf platform](./stackit_beta_scf_platform.md) - Provides functionality for STACKIT Cloud Foundry platforms

35 changes: 35 additions & 0 deletions docs/stackit_beta_scf_platform_quota.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## stackit beta scf platform quota

Shows quotas of STACKIT Cloud Foundry platforms

### Synopsis

Shows quotas of STACKIT Cloud Foundry platforms.

```
stackit beta scf platform quota [flags]
```

### Options

```
-h, --help Help for "stackit beta scf platform quota"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf platform](./stackit_beta_scf_platform.md) - Provides functionality for STACKIT Cloud Foundry platforms
* [stackit beta scf platform quota describe](./stackit_beta_scf_platform_quota_describe.md) - Shows details of a STACKIT Cloud Foundry platform quota
* [stackit beta scf platform quota list](./stackit_beta_scf_platform_quota_list.md) - Lists the quotas of a STACKIT Cloud Foundry platform

44 changes: 44 additions & 0 deletions docs/stackit_beta_scf_platform_quota_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## stackit beta scf platform quota describe

Shows details of a STACKIT Cloud Foundry platform quota

### Synopsis

Shows details of a STACKIT Cloud Foundry platform quota.

```
stackit beta scf platform quota describe PLATFORM_ID [flags]
```

### Examples

```
Get details of the quota with ID "yyy" of a STACKIT Cloud Foundry platform with ID "xxx"
$ stackit beta scf platform quota describe xxx --quota-id yyy

Get details of the quota with ID "yyy" of a STACKIT Cloud Foundry platform with ID "xxx" in JSON format
$ stackit beta scf platform quota describe xxx --quota-id yyy --output-format json
```

### Options

```
-h, --help Help for "stackit beta scf platform quota describe"
--quota-id string The UUID of the quota
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf platform quota](./stackit_beta_scf_platform_quota.md) - Shows quotas of STACKIT Cloud Foundry platforms

43 changes: 43 additions & 0 deletions docs/stackit_beta_scf_platform_quota_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## stackit beta scf platform quota list

Lists the quotas of a STACKIT Cloud Foundry platform

### Synopsis

Lists the quotas of a STACKIT Cloud Foundry platform.

```
stackit beta scf platform quota list PLATFORM_ID [flags]
```

### Examples

```
List the quotas of a STACKIT Cloud Foundry platform with ID "xxx"
$ stackit beta scf platform quota list xxx

List the quotas of a STACKIT Cloud Foundry platform with ID "xxx" in JSON format
$ stackit beta scf platform quota list xxx --output-format json
```

### Options

```
-h, --help Help for "stackit beta scf platform quota list"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, (one of: [json, pretty, none, yaml])
-p, --project-id string Project ID
--region string Target region for region-specific requests
--verbosity string Verbosity of the CLI, (one of: [debug, info, warning, error]) (default "info")
```

### SEE ALSO

* [stackit beta scf platform quota](./stackit_beta_scf_platform_quota.md) - Shows quotas of STACKIT Cloud Foundry platforms

114 changes: 114 additions & 0 deletions internal/cmd/beta/scf/platform/describe/describe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package describe

import (
"context"
"fmt"

"github.com/spf13/cobra"
scf "github.com/stackitcloud/stackit-sdk-go/services/scf/v1api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/services/scf/client"
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
)

const (
platformIdArg = "PLATFORM_ID"
)

type inputModel struct {
*globalflags.GlobalFlagModel
PlatformId string
}

func NewCmd(p *types.CmdParams) *cobra.Command {
cmd := &cobra.Command{
Use: fmt.Sprintf("describe %s", platformIdArg),
Short: "Shows details of a STACKIT Cloud Foundry platform",
Long: "Shows details of a STACKIT Cloud Foundry platform.",
Args: args.SingleArg(platformIdArg, utils.ValidateUUID),
Example: examples.Build(
examples.NewExample(
`Get details of a STACKIT Cloud Foundry platform with ID "xxx"`,
`$ stackit beta scf platform describe xxx`),
examples.NewExample(
`Get details of a STACKIT Cloud Foundry platform with ID "xxx" in JSON format`,
`$ stackit beta scf platform describe xxx --output-format json`),
),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
model, err := parseInput(p.Printer, cmd, args)
if err != nil {
return err
}

// Configure API client
apiClient, err := client.ConfigureClient(p.Printer, p.CliVersion)
if err != nil {
return err
}

// Call API
req := buildRequest(ctx, model, apiClient.DefaultAPI)
resp, err := req.Execute()
if err != nil {
return fmt.Errorf("get STACKIT Cloud Foundry platform: %w", err)
}

return outputResult(p.Printer, model.OutputFormat, resp)
},
}
return cmd
}

func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
platformId := inputArgs[0]

globalFlags := globalflags.Parse(p, cmd)
if globalFlags.ProjectId == "" {
return nil, &cliErr.ProjectIdError{}
}

model := inputModel{
GlobalFlagModel: globalFlags,
PlatformId: platformId,
}

p.DebugInputModel(model)
return &model, nil
}

func buildRequest(ctx context.Context, model *inputModel, apiClient scf.DefaultAPI) scf.ApiGetPlatformRequest {
return apiClient.GetPlatform(ctx, model.ProjectId, model.Region, model.PlatformId)
}

func outputResult(p *print.Printer, outputFormat string, platform *scf.Platforms) error {
return p.OutputResult(outputFormat, platform, func() error {
if platform == nil {
return fmt.Errorf("received nil response, could not display details")
}

table := tables.NewTable()
table.SetHeader("Attribute", "Value")

table.AddRow("ID", platform.GetGuid())
table.AddRow("Name", platform.GetDisplayName())
table.AddRow("System ID", platform.GetSystemId())
table.AddRow("Region", platform.GetRegion())
table.AddRow("API URL", platform.GetApiUrl())
table.AddRow("Console URL", utils.PtrString(platform.ConsoleUrl))

err := table.Display(p)
if err != nil {
return fmt.Errorf("render table: %w", err)
}

return nil
})
}
Loading
Loading