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.
51 lines
1.4 KiB
51 lines
1.4 KiB
package extnet
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// AddReserveIPRequest struct to reserved address or address poll
|
|
type AddReserveIPRequest struct {
|
|
// AccountID to which a reserved address or address pool is added
|
|
// Required: true
|
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
|
|
|
// ExtNetID from which the address or address pool is reserved
|
|
// Required: true
|
|
ExtNetID uint64 `url:"extnetId" json:"extnetId" validate:"required"`
|
|
|
|
// Field for specifying the number of reserved addresses
|
|
// Required: false
|
|
IPCount uint64 `url:"ipCount,omitempty" json:"ipCount,omitempty"`
|
|
|
|
// List of IPs for specifying the desired address
|
|
// Required: false
|
|
IPs []string `url:"ips,omitempty" json:"ips,omitempty"`
|
|
}
|
|
|
|
// AddReserveIP reserves address or address poll to external network for account ID
|
|
func (e ExtNet) AddReserveIP(ctx context.Context, req AddReserveIPRequest) (bool, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/extnet/addReservedIp"
|
|
|
|
res, err := e.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
|
|
}
|