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/sdn/routers/gwport/list.go

48 lines
1.0 KiB

package gwport
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
)
// ListRequest struct to get list of gateway ports
type ListRequest struct {
// Router ID
// Required: true
RouterID string `url:"router_id" json:"router_id" validate:"required"`
}
// List gets gateway port list
func (a GWPort) List(ctx context.Context, req ListRequest) (GatewayPortsList, error) {
res, err := a.ListRaw(ctx, req)
if err != nil {
return nil, err
}
info := []GatewayPort{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return info, nil
}
// GetRaw gets gateway port list as an array of bytes
func (a GWPort) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/router/gateway_port/list"
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}