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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## To Be Released

* feat: add support to list container sizes [#234](https://github.com/Scalingo/go-scalingo/pull/234)

## 4.14.3

* feat(cron-task): Add fields to cron tasks model [#231](https://github.com/Scalingo/go-scalingo/pull/231)
Expand Down
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type API interface {
BackupsService
CollaboratorsService
ContainersService
ContainerSizesService
CronTasksService
DeploymentsService
DomainsService
Expand All @@ -36,6 +37,7 @@ type API interface {
RunsService
SignUpService
SourcesService
StacksService
TokensService
UsersService
http.TokenGenerator
Expand Down
14 changes: 0 additions & 14 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ type Container struct {
ContainerSize ContainerSize `json:"container_size"`
}

type ContainerSize struct {
ID string `json:"id"`
HumanCPU string `json:"human_cpu"`
Name string `json:"name"`
HumanName string `json:"human_name"`
Memory int64 `json:"memory"`
Ordinal int `json:"ordinal"`
HourlyPrice int `json:"hourly_price"`
ThirtydaysPrice int `json:"thirtydays_price"`
PidsLimit int `json:"pids_limit,omitempty"`
Swap int64 `json:"swap"`
SKU string `json:"sku,omitempty"`
}

func (c *Client) ContainersStop(appName, containerID string) error {
req := &httpclient.APIRequest{
Method: "POST",
Expand Down
43 changes: 43 additions & 0 deletions container_sizes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package scalingo

import (
"gopkg.in/errgo.v1"

httpclient "github.com/Scalingo/go-scalingo/v4/http"
)

type ContainerSize struct {
ID string `json:"id"`
SKU string `json:"sku,omitempty"`
Name string `json:"name"`
HumanName string `json:"human_name"`
HumanCPU string `json:"human_cpu"`
Memory int `json:"memory"`
PidsLimit int `json:"pids_limit,omitempty"`

HourlyPrice int `json:"hourly_price"`
ThirtydaysPrice int `json:"thirtydays_price"`
Pricings map[string]map[string]string `json:"pricings"`

Swap int `json:"swap"`
Ordinal int `json:"ordinal"`
}

type ContainerSizesService interface {
ContainerSizesList() ([]ContainerSize, error)
}

var _ ContainerSizesService = (*Client)(nil)

func (c *Client) ContainerSizesList() ([]ContainerSize, error) {
req := &httpclient.APIRequest{
Endpoint: "/features/container_sizes",
}

resmap := map[string][]ContainerSize{}
err := c.ScalingoAPI().DoRequest(req, &resmap)
if err != nil {
return nil, errgo.Notef(err, "fail to request Scalingo API to list the container sizes")
}
return resmap["container_sizes"], nil
}