Skip to content

Commit

Permalink
Merge pull request #47 from megaport/fix/update-mve-cost-centre
Browse files Browse the repository at this point in the history
fix: support cost_centre in both creating/updating MVE
  • Loading branch information
mega-alex authored Jun 21, 2024
2 parents 0e5f3a0 + 5df40a5 commit b8dc09b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mve.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type BuyMVERequest struct {
Vnics []MVENetworkInterface
DiversityZone string
PromoCode string
CostCentre string

WaitForProvision bool // Wait until the MVE provisions before returning
WaitForTime time.Duration // How long to wait for the MVE to provision if WaitForProvision is true (default is 5 minutes)
Expand All @@ -63,6 +64,7 @@ type ModifyMVERequest struct {
MVEID string
Name string
MarketplaceVisibility *bool
CostCentre string

WaitForUpdate bool // Wait until the MCVEupdates before returning
WaitForTime time.Duration // How long to wait for the MVE to update if WaitForUpdate is true (default is 5 minutes)
Expand Down Expand Up @@ -94,6 +96,7 @@ func (svc *MVEServiceOp) BuyMVE(ctx context.Context, req *BuyMVERequest) (*BuyMV
Name: req.Name,
Term: req.Term,
PromoCode: req.PromoCode,
CostCentre: req.CostCentre,
ProductType: strings.ToUpper(PRODUCT_MVE),
DiversityZone: req.DiversityZone,
}
Expand Down Expand Up @@ -260,10 +263,15 @@ func (svc *MVEServiceOp) ModifyMVE(ctx context.Context, req *ModifyMVERequest) (
modifyProductReq := &ModifyProductRequest{
ProductID: req.MVEID,
ProductType: PRODUCT_MVE,
Name: req.Name,
CostCentre: "",
MarketplaceVisibility: PtrTo(false),
}
if req.Name != "" {
modifyProductReq.Name = req.Name
}
if req.CostCentre != "" {
modifyProductReq.CostCentre = req.CostCentre
}

_, err := svc.Client.ProductService.ModifyProduct(ctx, modifyProductReq)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions mve_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type MVEOrderConfig struct {
ProductType string `json:"productType"`
DiversityZone string `json:"diversityZone"`
PromoCode string `json:"promoCode,omitempty"`
CostCentre string `json:"costCentre,omitempty"`
NetworkInterfaces []MVENetworkInterface `json:"vnics"`
VendorConfig VendorConfig `json:"vendorConfig"`
}
Expand Down Expand Up @@ -152,6 +153,7 @@ type MVE struct {
ContractEndDate *Time `json:"contractEndDate"`
ContractTermMonths int `json:"contractTermMonths"`
AttributeTags map[string]string `json:"attributeTags"`
CostCentre string `json:"costCentre"`
Virtual bool `json:"virtual"`
BuyoutPort bool `json:"buyoutPort"`
Locked bool `json:"locked"`
Expand Down

0 comments on commit b8dc09b

Please sign in to comment.