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.
58 lines
1.5 KiB
58 lines
1.5 KiB
package vins
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// IPReserveRequest struct for IP reserve
|
|
type IPReserveRequest struct {
|
|
// VINS ID
|
|
// Required: true
|
|
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
|
|
|
|
// Type of the reservation
|
|
// Should be one of:
|
|
// - DHCP
|
|
// - VIP
|
|
// - EXCLUDE
|
|
// Required: true
|
|
Type string `url:"type" json:"type" validate:"vinsType"`
|
|
|
|
// IP address to use. Non-empty string is required for type "EXCLUDE".
|
|
// Ignored for types "DHCP" and "VIP".
|
|
// Required: false
|
|
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
|
|
|
// MAC address to associate with IP reservation.
|
|
// Ignored for type "EXCLUDE",
|
|
// non-empty string is required for "DHCP" and "VIP"
|
|
// Required: false
|
|
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
|
|
|
// ID of the compute, associated with this reservation of type "DHCP".
|
|
// Ignored for other types
|
|
// Required: false
|
|
ComputeID uint64 `url:"computeId,omitempty" json:"computeId,omitempty"`
|
|
}
|
|
|
|
// IPReserve creates reservation on ViNS DHCP
|
|
func (v VINS) IPReserve(ctx context.Context, req IPReserveRequest) (string, error) {
|
|
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/vins/ipReserve"
|
|
|
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(res), nil
|
|
}
|