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

52 lines
1.2 KiB

package gwport
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about gateway port
type GetRequest struct {
// Router ID
// Required: true
RouterID string `url:"router_id" json:"router_id" validate:"required"`
// Gateway port ID
// Required: true
GatewayPortID string `url:"gateway_port_id" json:"gateway_port_id" validate:"required"`
}
// Get gets gateway port details as a GatewayPort struct
func (a GWPort) Get(ctx context.Context, req GetRequest) (*GatewayPort, error) {
res, err := a.GetRaw(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 details as an array of bytes
func (a GWPort) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/router/gateway_port/get"
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}