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/webhosting/v1alpha1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ func GetCommands() *core.Commands {
human.RegisterMarshalerFunc(webhosting.DNSRecordsStatus(""), human.EnumMarshalFunc(hostingDNSMarshalSpecs))
human.RegisterMarshalerFunc(webhosting.NameserverStatus(""), human.EnumMarshalFunc(nameserverMarshalSpecs))

cmds.MustFind("webhosting", "offer", "list").Override(webhostingOfferListBuilder)

return cmds
}
17 changes: 17 additions & 0 deletions internal/namespaces/webhosting/v1alpha1/custom_offer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package webhosting

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

func webhostingOfferListBuilder(c *core.Command) *core.Command {
c.View = &core.View{
Sections: []*core.ViewSection{

{
FieldName: "Offers",
Title: "Offers",
},
},
}

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

import (
"testing"

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

func Test_ListOffer(t *testing.T) {
t.Run("Simple", core.Test(&core.TestConfig{
Commands: GetCommands(),
Cmd: "scw webhosting offer list",
Check: core.TestCheckGolden(),
}))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
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/webhosting/v1alpha1/regions/fr-par/offers?only_options=false&order_by=price_asc&without_options=false
method: GET
response:
body: '{"offers":[{"id":"e500237a-a9e9-11ec-b909-0242ac120002", "billing_operation_path":"/webhosting/backup/fr-par",
"product":{"name":"backup", "option":true, "email_accounts_quota":0, "email_storage_quota":0,
"databases_quota":0, "hosting_storage_quota":0, "support_included":false, "v_cpu":0,
"ram":0}, "price":{"currency_code":"EUR", "units":2, "nanos":990000000}, "available":true,
"quota_warnings":[]}, {"id":"f5c2ae8f-7625-4bca-b711-b44bb3d08694", "billing_operation_path":"/webhosting/lite/fr-par",
"product":{"name":"lite", "option":false, "email_accounts_quota":1, "email_storage_quota":5,
"databases_quota":1, "hosting_storage_quota":10, "support_included":true, "v_cpu":1,
"ram":1}, "price":{"currency_code":"EUR", "units":5, "nanos":990000000}, "available":true,
"quota_warnings":[]}, {"id":"d86c61a0-a9e9-11ec-b909-0242ac120002", "billing_operation_path":"/webhosting/personal/fr-par",
"product":{"name":"essential", "option":false, "email_accounts_quota":2, "email_storage_quota":5,
"databases_quota":-1, "hosting_storage_quota":50, "support_included":true, "v_cpu":2,
"ram":1}, "price":{"currency_code":"EUR", "units":9, "nanos":990000000}, "available":true,
"quota_warnings":[]}, {"id":"de2426b4-a9e9-11ec-b909-0242ac120002", "billing_operation_path":"/webhosting/professional/fr-par",
"product":{"name":"performance", "option":false, "email_accounts_quota":10,
"email_storage_quota":5, "databases_quota":-1, "hosting_storage_quota":100,
"support_included":true, "v_cpu":4, "ram":2}, "price":{"currency_code":"EUR",
"units":18, "nanos":990000000}, "available":true, "quota_warnings":[]}, {"id":"e1c1e6c6-a9e9-11ec-b909-0242ac120002",
"billing_operation_path":"/webhosting/ecommerce/fr-par", "product":{"name":"ecommerce",
"option":false, "email_accounts_quota":25, "email_storage_quota":5, "databases_quota":-1,
"hosting_storage_quota":250, "support_included":true, "v_cpu":8, "ram":8}, "price":{"currency_code":"EUR",
"units":29, "nanos":990000000}, "available":true, "quota_warnings":[]}]}'
headers:
Content-Length:
- "2002"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Tue, 28 Mar 2023 12:32:25 GMT
Server:
- Scaleway API-Gateway
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- d471ce2b-9726-4f8a-9518-4112558dc493
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
Offers:
ID BILLING OPERATION PATH PRICE AVAILABLE QUOTA WARNINGS
e500237a-a9e9-11ec-b909-0242ac120002 /webhosting/backup/fr-par € 2.99 true []
f5c2ae8f-7625-4bca-b711-b44bb3d08694 /webhosting/lite/fr-par € 5.99 true []
d86c61a0-a9e9-11ec-b909-0242ac120002 /webhosting/personal/fr-par € 9.99 true []
de2426b4-a9e9-11ec-b909-0242ac120002 /webhosting/professional/fr-par € 18.99 true []
e1c1e6c6-a9e9-11ec-b909-0242ac120002 /webhosting/ecommerce/fr-par € 29.99 true []
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
{
"offers": [
{
"id": "e500237a-a9e9-11ec-b909-0242ac120002",
"billing_operation_path": "/webhosting/backup/fr-par",
"product": {
"name": "backup",
"option": true,
"email_accounts_quota": 0,
"email_storage_quota": 0,
"databases_quota": 0,
"hosting_storage_quota": 0,
"support_included": false,
"v_cpu": 0,
"ram": 0
},
"price": {
"currency_code": "EUR",
"units": 2,
"nanos": 990000000
},
"available": true,
"quota_warnings": []
},
{
"id": "f5c2ae8f-7625-4bca-b711-b44bb3d08694",
"billing_operation_path": "/webhosting/lite/fr-par",
"product": {
"name": "lite",
"option": false,
"email_accounts_quota": 1,
"email_storage_quota": 5,
"databases_quota": 1,
"hosting_storage_quota": 10,
"support_included": true,
"v_cpu": 1,
"ram": 1
},
"price": {
"currency_code": "EUR",
"units": 5,
"nanos": 990000000
},
"available": true,
"quota_warnings": []
},
{
"id": "d86c61a0-a9e9-11ec-b909-0242ac120002",
"billing_operation_path": "/webhosting/personal/fr-par",
"product": {
"name": "essential",
"option": false,
"email_accounts_quota": 2,
"email_storage_quota": 5,
"databases_quota": -1,
"hosting_storage_quota": 50,
"support_included": true,
"v_cpu": 2,
"ram": 1
},
"price": {
"currency_code": "EUR",
"units": 9,
"nanos": 990000000
},
"available": true,
"quota_warnings": []
},
{
"id": "de2426b4-a9e9-11ec-b909-0242ac120002",
"billing_operation_path": "/webhosting/professional/fr-par",
"product": {
"name": "performance",
"option": false,
"email_accounts_quota": 10,
"email_storage_quota": 5,
"databases_quota": -1,
"hosting_storage_quota": 100,
"support_included": true,
"v_cpu": 4,
"ram": 2
},
"price": {
"currency_code": "EUR",
"units": 18,
"nanos": 990000000
},
"available": true,
"quota_warnings": []
},
{
"id": "e1c1e6c6-a9e9-11ec-b909-0242ac120002",
"billing_operation_path": "/webhosting/ecommerce/fr-par",
"product": {
"name": "ecommerce",
"option": false,
"email_accounts_quota": 25,
"email_storage_quota": 5,
"databases_quota": -1,
"hosting_storage_quota": 250,
"support_included": true,
"v_cpu": 8,
"ram": 8
},
"price": {
"currency_code": "EUR",
"units": 29,
"nanos": 990000000
},
"available": true,
"quota_warnings": []
}
]
}