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.
decort-golang-sdk/pkg/cloudbroker/extnet/ips_include.go

43 lines
991 B

3 years ago
package extnet
import (
"context"
"net/http"
"strconv"
3 years ago
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
3 years ago
)
2 years ago
// IPsIncludeRequest struct to include list of IPs
3 years ago
type IPsIncludeRequest struct {
// ID of external network
// Required: true
3 years ago
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
3 years ago
// List of IPs for include to external network
// Required: true
3 years ago
IPs []string `url:"ips" json:"ips" validate:"min=1"`
3 years ago
}
2 years ago
// IPsInclude includes list of IPs to external network pool
3 years ago
func (e ExtNet) IPsInclude(ctx context.Context, req IPsIncludeRequest) (bool, error) {
3 years ago
err := validators.ValidateRequest(req)
3 years ago
if err != nil {
2 years ago
return false, validators.ValidationErrors(validators.GetErrors(err))
3 years ago
}
url := "/cloudbroker/extnet/ipsInclude"
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
}