47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package compute
|
||
|
||
import (
|
||
"context"
|
||
"net/http"
|
||
"strconv"
|
||
|
||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
)
|
||
|
||
// ChangeMACRequest struct to change MAC for network
|
||
type ChangeMACRequest struct {
|
||
// ID of compute instance
|
||
// Required: true
|
||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||
|
||
// Current mac address
|
||
// Required: true
|
||
СurrentMAC string `url:"current_mac_address" json:"current_mac_address" validate:"required"`
|
||
|
||
// the MAC address to which we will change the existing one
|
||
// Required: true
|
||
NewMAC string `url:"new_mac_address" json:"new_mac_address" validate:"required"`
|
||
}
|
||
|
||
// ChangeMAC change MAC for compute instance
|
||
func (c Compute) ChangeMAC(ctx context.Context, req ChangeMACRequest) (bool, error) {
|
||
err := validators.ValidateRequest(req)
|
||
if err != nil {
|
||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||
}
|
||
|
||
url := "/cloudapi/compute/changeMac"
|
||
|
||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||
if err != nil {
|
||
return false, err
|
||
}
|
||
|
||
result, err := strconv.ParseBool(string(res))
|
||
if err != nil {
|
||
return false, err
|
||
}
|
||
|
||
return result, nil
|
||
}
|