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
2 changes: 2 additions & 0 deletions internal/namespaces/vpcgw/v1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ func GetCommands() *core.Commands {
human.RegisterMarshalerFunc(vpcgw.GatewayNetworkStatus(""), human.EnumMarshalFunc(gatewayNetworkStatusMarshalSpecs))
human.RegisterMarshalerFunc(vpcgw.GatewayStatus(""), human.EnumMarshalFunc(gatewayStatusMarshalSpecs))

cmds.MustFind("vpc-gw", "gateway-type", "list").Override(vpcgwGatewayTypeListBuilder)

return cmds
}
22 changes: 22 additions & 0 deletions internal/namespaces/vpcgw/v1/custom_gateway_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package vpcgw

import (
"context"

"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1"
)

func vpcgwGatewayTypeListBuilder(c *core.Command) *core.Command {
c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) {
res, err := runner(ctx, argsI)
if err != nil {
return nil, err
}

typesResponse := res.(*vpcgw.ListGatewayTypesResponse)
return typesResponse.Types, nil
})

return c
}
15 changes: 15 additions & 0 deletions internal/namespaces/vpcgw/v1/custom_gateway_type_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package vpcgw

import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"
)

func Test_ListGatewayType(t *testing.T) {
t.Run("Simple", core.Test(&core.TestConfig{
Commands: GetCommands(),
Cmd: "scw vpc-gw gateway-type list",
Check: core.TestCheckGolden(),
}))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.19.5; darwin; amd64) cli-e2e-test
url: https://api.scaleway.com/vpc-gw/v1/zones/fr-par-1/gateway-types
method: GET
response:
body: '{"types":[{"name":"VPC-GW-S", "bandwidth":100000000, "zone":"fr-par-1"},
{"name":"VPC-GW-M", "bandwidth":1000000000, "zone":"fr-par-1"}]}'
headers:
Content-Length:
- "137"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Tue, 28 Mar 2023 13:19:36 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- 623afde2-5a9d-4c65-953d-0331be842ae5
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
NAME BANDWIDTH ZONE
VPC-GW-S 100000000 fr-par-1
VPC-GW-M 1000000000 fr-par-1
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
[
{
"name": "VPC-GW-S",
"bandwidth": 100000000,
"zone": "fr-par-1"
},
{
"name": "VPC-GW-M",
"bandwidth": 1000000000,
"zone": "fr-par-1"
}
]