You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dynamix-golang-sdk/pkg/cloudapi/compute/change_mac.go

47 lines
1.1 KiB

1 month ago
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/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
}