@@ -273,6 +273,41 @@ type ScalewayImages struct {
273273 Images []ScalewayImage `json:"images,omitempty"`
274274}
275275
276+ // ProductNetworkInterface gives interval and external allowed bandwidth
277+ type ProductNetworkInterface struct {
278+ InternalBandwidth uint64 `json:"internal_bandwidth,omitempty"`
279+ InternetBandwidth uint64 `json:"internet_bandwidth,omitempty"`
280+ }
281+
282+ // ProductNetwork lists all the network interfaces
283+ type ProductNetwork struct {
284+ Interfaces []ProductNetworkInterface `json:"interfaces,omitempty"`
285+ TotalInternalBandwidth uint64 `json:"sum_internal_bandwidth,omitempty"`
286+ TotalInternetBandwidth uint64 `json:"sum_internet_bandwidth,omitempty"`
287+ IPv6_Support bool `json:"ipv6_support,omitempty"`
288+ }
289+
290+ // ProductVolumeConstraint contains any volume constraint that the offer has
291+ type ProductVolumeConstraint struct {
292+ MinSize uint64 `json:"min_size,omitempty"`
293+ MaxSize uint64 `json:"max_size,omitempty"`
294+ }
295+
296+ // ProductServerOffer represents a specific offer
297+ type ProductServer struct {
298+ Arch string `json:"arch,omitempty"`
299+ Ncpus uint64 `json:"ncpus,omitempty"`
300+ Ram uint64 `json:"ram,omitempty"`
301+ Baremetal bool `json:"baremetal,omitempty"`
302+ VolumesConstraint ProductVolumeConstraint `json:"volumes_constraint,omitempty"`
303+ Network ProductNetwork `json:"network,omitempty"`
304+ }
305+
306+ // Products holds a map of all Scaleway servers
307+ type ScalewayProductsServers struct {
308+ Servers map [string ]ProductServer `json:"servers"`
309+ }
310+
276311// ScalewaySnapshot represents a Scaleway Snapshot
277312type ScalewaySnapshot struct {
278313 // Identifier is a unique identifier for the snapshot
@@ -2781,3 +2816,24 @@ func (s *ScalewayAPI) ResolveTTYUrl() string {
27812816 }
27822817 return ""
27832818}
2819+
2820+ // GetProductServers Fetches all the server type and their constraints from the Products API
2821+ func (s * ScalewayAPI ) GetProductsServers () (* ScalewayProductsServers , error ) {
2822+ resp , err := s .GetResponsePaginate (s .computeAPI , "products/servers" , url.Values {})
2823+ if err != nil {
2824+ return nil , err
2825+ }
2826+ defer resp .Body .Close ()
2827+
2828+ body , err := s .handleHTTPError ([]int {http .StatusOK }, resp )
2829+ if err != nil {
2830+ return nil , err
2831+ }
2832+
2833+ var productServers ScalewayProductsServers
2834+ if err = json .Unmarshal (body , & productServers ); err != nil {
2835+ return nil , err
2836+ }
2837+
2838+ return & productServers , nil
2839+ }
0 commit comments