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/cloudapi/extnet/get_reserved_ip.go

51 lines
1.4 KiB

package extnet
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about reserved address or address poll
type GetReservedIP struct {
// AccountID of the account whose reservation information we want to receive
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Field for specifying the ID of extnet whose reservation information we want to receive
// Required: false
ExtNetID uint64 `url:"extnetId,omitempty" json:"extnetId,omitempty"`
}
// GetReservedIP gets information about reserved address or address poll as a slice of RecordReservedIP struct
func (e ExtNet) GetReservedIP(ctx context.Context, req GetReservedIP) ([]RecordReservedIP, error) {
res, err := e.GetReservedIPRaw(ctx, req)
if err != nil {
return nil, err
}
reservedIP := make([]RecordReservedIP, 0)
err = json.Unmarshal(res, &reservedIP)
if err != nil {
return nil, err
}
return reservedIP, nil
}
// GetRaw gets detailed information about external network as an array of bytes
func (e ExtNet) GetReservedIPRaw(ctx context.Context, req GetReservedIP) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/extnet/getReservedIp"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}