Skip to content

Commit d8646fc

Browse files
scaleway-botprotobuf-ci-cd
andauthored
feat(product_catalog): add block storage properties to admin and public api (scaleway#2624)
Co-authored-by: protobuf-ci-cd <[email protected]>
1 parent bd2b866 commit d8646fc

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

api/product_catalog/v2alpha1/product_catalog_sdk.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,15 @@ type PublicCatalogProductPropertiesAppleSilicon struct {
402402
Range string `json:"range"`
403403
}
404404

405+
// PublicCatalogProductPropertiesBlockStorage: public catalog product properties block storage.
406+
type PublicCatalogProductPropertiesBlockStorage struct {
407+
// MinVolumeSize: the minimum size of storage volume for this product in bytes.
408+
MinVolumeSize scw.Size `json:"min_volume_size"`
409+
410+
// MaxVolumeSize: the maximum size of storage volume for this product in bytes.
411+
MaxVolumeSize scw.Size `json:"max_volume_size"`
412+
}
413+
405414
// PublicCatalogProductPropertiesDedibox: public catalog product properties dedibox.
406415
type PublicCatalogProductPropertiesDedibox struct {
407416
// Range: the range of the Dedibox server.
@@ -482,20 +491,24 @@ type PublicCatalogProductProperties struct {
482491
Hardware *PublicCatalogProductPropertiesHardware `json:"hardware"`
483492

484493
// Dedibox: the properties of Dedibox products.
485-
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance must be set.
494+
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance, BlockStorage must be set.
486495
Dedibox *PublicCatalogProductPropertiesDedibox `json:"dedibox,omitempty"`
487496

488497
// ElasticMetal: the properties of Elastic Metal products.
489-
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance must be set.
498+
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance, BlockStorage must be set.
490499
ElasticMetal *PublicCatalogProductPropertiesElasticMetal `json:"elastic_metal,omitempty"`
491500

492501
// AppleSilicon: the properties of Apple Silicon products.
493-
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance must be set.
502+
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance, BlockStorage must be set.
494503
AppleSilicon *PublicCatalogProductPropertiesAppleSilicon `json:"apple_silicon,omitempty"`
495504

496505
// Instance: the properties of Instance products.
497-
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance must be set.
506+
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance, BlockStorage must be set.
498507
Instance *PublicCatalogProductPropertiesInstance `json:"instance,omitempty"`
508+
509+
// BlockStorage: the properties of Block Storage products.
510+
// Precisely one of Dedibox, ElasticMetal, AppleSilicon, Instance, BlockStorage must be set.
511+
BlockStorage *PublicCatalogProductPropertiesBlockStorage `json:"block_storage,omitempty"`
499512
}
500513

501514
// PublicCatalogProductUnitOfMeasure: public catalog product unit of measure.

scw/client.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package scw
22

33
import (
4+
"context"
45
"crypto/tls"
56
"encoding/json"
67
"fmt"
@@ -201,17 +202,17 @@ func (c *Client) do(req *ScalewayRequest, res any) (sdkErr error) {
201202
logger.Debugf("creating %s request on %s\n", req.Method, url.String())
202203

203204
// build request
204-
httpRequest, err := http.NewRequest(req.Method, url.String(), req.Body)
205+
ctx := req.ctx
206+
if ctx == nil {
207+
ctx = context.Background()
208+
}
209+
httpRequest, err := http.NewRequestWithContext(ctx, req.Method, url.String(), req.Body)
205210
if err != nil {
206211
return errors.Wrap(err, "could not create request")
207212
}
208213

209214
httpRequest.Header = req.getAllHeaders(req.auth, c.userAgent, false)
210215

211-
if req.ctx != nil {
212-
httpRequest = httpRequest.WithContext(req.ctx)
213-
}
214-
215216
// execute request
216217
httpResponse, err := c.httpClient.Do(httpRequest)
217218
if err != nil {

0 commit comments

Comments
 (0)