@@ -181,6 +181,40 @@ func (enum *ListServersRequestOrderBy) UnmarshalJSON(data []byte) error {
181181 return nil
182182}
183183
184+ type OfferStock string
185+
186+ const (
187+ // OfferStockEmpty is [insert doc].
188+ OfferStockEmpty = OfferStock ("empty" )
189+ // OfferStockLow is [insert doc].
190+ OfferStockLow = OfferStock ("low" )
191+ // OfferStockAvailable is [insert doc].
192+ OfferStockAvailable = OfferStock ("available" )
193+ )
194+
195+ func (enum OfferStock ) String () string {
196+ if enum == "" {
197+ // return default value if empty
198+ return "empty"
199+ }
200+ return string (enum )
201+ }
202+
203+ func (enum OfferStock ) MarshalJSON () ([]byte , error ) {
204+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
205+ }
206+
207+ func (enum * OfferStock ) UnmarshalJSON (data []byte ) error {
208+ tmp := ""
209+
210+ if err := json .Unmarshal (data , & tmp ); err != nil {
211+ return err
212+ }
213+
214+ * enum = OfferStock (OfferStock (tmp ).String ())
215+ return nil
216+ }
217+
184218type RebootServerRequestBootType string
185219
186220const (
@@ -329,6 +363,26 @@ func (enum *ServerStatus) UnmarshalJSON(data []byte) error {
329363 return nil
330364}
331365
366+ // CPU cpu
367+ type CPU struct {
368+ // Name name of the CPU
369+ Name string `json:"name"`
370+ // Cores number of cores of the CPU
371+ Cores uint32 `json:"cores"`
372+ // Threads number of threads of the CPU
373+ Threads uint32 `json:"threads"`
374+
375+ Frequency uint32 `json:"frequency"`
376+ }
377+
378+ // Disk disk
379+ type Disk struct {
380+ // Capacity capacity of the disk in GB
381+ Capacity uint64 `json:"capacity"`
382+ // Type type of the disk
383+ Type string `json:"type"`
384+ }
385+
332386// IP ip
333387type IP struct {
334388 // ID iD of the IP
@@ -349,6 +403,22 @@ type IP struct {
349403 ReverseStatusMessage * string `json:"reverse_status_message"`
350404}
351405
406+ // ListOffersResponse list offers response
407+ type ListOffersResponse struct {
408+ // TotalCount total count of matching offers
409+ TotalCount uint32 `json:"total_count"`
410+ // Offers offers that match filters
411+ Offers []* Offer `json:"offers"`
412+ }
413+
414+ // ListOsResponse list os response
415+ type ListOsResponse struct {
416+ // TotalCount total count of matching OS
417+ TotalCount uint32 `json:"total_count"`
418+ // Os oS that match filters
419+ Os []* Os `json:"os"`
420+ }
421+
352422// ListServerEventsResponse list server events response
353423type ListServerEventsResponse struct {
354424 // TotalCount total count of matching events
@@ -365,6 +435,61 @@ type ListServersResponse struct {
365435 Servers []* Server `json:"servers"`
366436}
367437
438+ // Memory memory
439+ type Memory struct {
440+ Capacity uint64 `json:"capacity"`
441+
442+ Type string `json:"type"`
443+
444+ Frequency uint32 `json:"frequency"`
445+
446+ Ecc bool `json:"ecc"`
447+ }
448+
449+ // Offer offer
450+ type Offer struct {
451+ // ID iD of the offer
452+ ID string `json:"id"`
453+ // Name name of the offer
454+ Name string `json:"name"`
455+ // Stock stock level
456+ //
457+ // Default value: empty
458+ Stock OfferStock `json:"stock"`
459+ // Bandwidth bandwidth available with the offer
460+ Bandwidth uint32 `json:"bandwidth"`
461+ // CommercialRange commercial range of the offer
462+ CommercialRange string `json:"commercial_range"`
463+ // PriceByMinute price of the offer by minutes, this field is deprecated, please use `price_per_sixty_minutes` instead
464+ PriceByMinute * scw.Money `json:"price_by_minute"`
465+ // PriceByMonth price of the offer by months, this field is deprecated, please use `price_per_month` instead
466+ PriceByMonth * scw.Money `json:"price_by_month"`
467+ // PricePerSixtyMinutes price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32)
468+ PricePerSixtyMinutes * scw.Money `json:"price_per_sixty_minutes"`
469+ // PricePerMonth price of the offer per months
470+ PricePerMonth * scw.Money `json:"price_per_month"`
471+ // Disk disks specifications of the offer
472+ Disk []* Disk `json:"disk"`
473+ // Enable true if the offer is currently available
474+ Enable bool `json:"enable"`
475+ // CPU cPU specifications of the offer
476+ CPU []* CPU `json:"cpu"`
477+ // Memory memory specifications of the offer
478+ Memory []* Memory `json:"memory"`
479+ // QuotaName name of the quota associated to the offer
480+ QuotaName string `json:"quota_name"`
481+ }
482+
483+ // Os os
484+ type Os struct {
485+ // ID iD of the OS
486+ ID string `json:"id"`
487+ // Name name of the OS
488+ Name string `json:"name"`
489+ // Version version of the OS
490+ Version string `json:"version"`
491+ }
492+
368493// RemoteServerAccess remote server access
369494type RemoteServerAccess struct {
370495 // URL uRL to access to the server console
@@ -1152,3 +1277,137 @@ func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, er
11521277 }
11531278 return & resp , nil
11541279}
1280+
1281+ type ListOffersRequest struct {
1282+ Zone scw.Zone `json:"-"`
1283+ // Page page number
1284+ Page * int32 `json:"-"`
1285+ // PageSize number of offers per page
1286+ PageSize * uint32 `json:"-"`
1287+ }
1288+
1289+ // ListOffers list offers
1290+ //
1291+ // List all available server offers.
1292+ func (s * API ) ListOffers (req * ListOffersRequest , opts ... scw.RequestOption ) (* ListOffersResponse , error ) {
1293+ var err error
1294+
1295+ if req .Zone == "" {
1296+ defaultZone , _ := s .client .GetDefaultZone ()
1297+ req .Zone = defaultZone
1298+ }
1299+
1300+ defaultPageSize , exist := s .client .GetDefaultPageSize ()
1301+ if (req .PageSize == nil || * req .PageSize == 0 ) && exist {
1302+ req .PageSize = & defaultPageSize
1303+ }
1304+
1305+ query := url.Values {}
1306+ parameter .AddToQuery (query , "page" , req .Page )
1307+ parameter .AddToQuery (query , "page_size" , req .PageSize )
1308+
1309+ if fmt .Sprint (req .Zone ) == "" {
1310+ return nil , errors .New ("field Zone cannot be empty in request" )
1311+ }
1312+
1313+ scwReq := & scw.ScalewayRequest {
1314+ Method : "GET" ,
1315+ Path : "/baremetal/v1alpha1/zones/" + fmt .Sprint (req .Zone ) + "/offers" ,
1316+ Query : query ,
1317+ Headers : http.Header {},
1318+ }
1319+
1320+ var resp ListOffersResponse
1321+
1322+ err = s .client .Do (scwReq , & resp , opts ... )
1323+ if err != nil {
1324+ return nil , err
1325+ }
1326+ return & resp , nil
1327+ }
1328+
1329+ // UnsafeGetTotalCount should not be used
1330+ // Internal usage only
1331+ func (r * ListOffersResponse ) UnsafeGetTotalCount () uint32 {
1332+ return r .TotalCount
1333+ }
1334+
1335+ // UnsafeAppend should not be used
1336+ // Internal usage only
1337+ func (r * ListOffersResponse ) UnsafeAppend (res interface {}) (uint32 , scw.SdkError ) {
1338+ results , ok := res .(* ListOffersResponse )
1339+ if ! ok {
1340+ return 0 , errors .New ("%T type cannot be appended to type %T" , res , r )
1341+ }
1342+
1343+ r .Offers = append (r .Offers , results .Offers ... )
1344+ r .TotalCount += uint32 (len (results .Offers ))
1345+ return uint32 (len (results .Offers )), nil
1346+ }
1347+
1348+ type ListOsRequest struct {
1349+ Zone scw.Zone `json:"-"`
1350+ // Page page number
1351+ Page * int32 `json:"-"`
1352+ // PageSize number of OS per page
1353+ PageSize * uint32 `json:"-"`
1354+ }
1355+
1356+ // ListOs list OS
1357+ //
1358+ // List all available OS that can be install on a baremetal server.
1359+ func (s * API ) ListOs (req * ListOsRequest , opts ... scw.RequestOption ) (* ListOsResponse , error ) {
1360+ var err error
1361+
1362+ if req .Zone == "" {
1363+ defaultZone , _ := s .client .GetDefaultZone ()
1364+ req .Zone = defaultZone
1365+ }
1366+
1367+ defaultPageSize , exist := s .client .GetDefaultPageSize ()
1368+ if (req .PageSize == nil || * req .PageSize == 0 ) && exist {
1369+ req .PageSize = & defaultPageSize
1370+ }
1371+
1372+ query := url.Values {}
1373+ parameter .AddToQuery (query , "page" , req .Page )
1374+ parameter .AddToQuery (query , "page_size" , req .PageSize )
1375+
1376+ if fmt .Sprint (req .Zone ) == "" {
1377+ return nil , errors .New ("field Zone cannot be empty in request" )
1378+ }
1379+
1380+ scwReq := & scw.ScalewayRequest {
1381+ Method : "GET" ,
1382+ Path : "/baremetal/v1alpha1/zones/" + fmt .Sprint (req .Zone ) + "/os" ,
1383+ Query : query ,
1384+ Headers : http.Header {},
1385+ }
1386+
1387+ var resp ListOsResponse
1388+
1389+ err = s .client .Do (scwReq , & resp , opts ... )
1390+ if err != nil {
1391+ return nil , err
1392+ }
1393+ return & resp , nil
1394+ }
1395+
1396+ // UnsafeGetTotalCount should not be used
1397+ // Internal usage only
1398+ func (r * ListOsResponse ) UnsafeGetTotalCount () uint32 {
1399+ return r .TotalCount
1400+ }
1401+
1402+ // UnsafeAppend should not be used
1403+ // Internal usage only
1404+ func (r * ListOsResponse ) UnsafeAppend (res interface {}) (uint32 , scw.SdkError ) {
1405+ results , ok := res .(* ListOsResponse )
1406+ if ! ok {
1407+ return 0 , errors .New ("%T type cannot be appended to type %T" , res , r )
1408+ }
1409+
1410+ r .Os = append (r .Os , results .Os ... )
1411+ r .TotalCount += uint32 (len (results .Os ))
1412+ return uint32 (len (results .Os )), nil
1413+ }
0 commit comments