Files
dynamix-golang-sdk/pkg/cloudapi/vins/vnfdev_restart.go
T

78 lines
1.7 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package vins
import (
"context"
2026-09-15 17:42:23 +03:00
"encoding/json"
2025-09-23 14:34:24 +03:00
"net/http"
"strconv"
2026-08-21 18:12:55 +04:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
2025-09-23 14:34:24 +03:00
)
// VNFDevRestartRequest struct for reboot VINSes primary VNF device
type VNFDevRestartRequest struct {
// VINS ID
// Required: true
VINSID uint64 `url:"vinsId" json:"vinsId" validate:"required"`
}
2026-09-15 17:42:23 +03:00
type asyncWrapperVNFDevRestartRequest struct {
VNFDevRestartRequest
2026-10-09 16:28:36 +03:00
AsyncMode bool `url:"async_mode"`
2026-09-15 17:42:23 +03:00
}
2025-09-23 14:34:24 +03:00
// VNFDevRestart reboots VINSes primary VNF device
func (v VINS) VNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/vins/vnfdevRestart"
2026-09-15 17:42:23 +03:00
syncReq := asyncWrapperVNFDevRestartRequest{
VNFDevRestartRequest: req,
AsyncMode: false,
}
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
2025-09-23 14:34:24 +03:00
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}
2026-09-15 17:42:23 +03:00
// VNFDevRestart reboots VINSes primary VNF device in async mode
func (v VINS) AsyncVNFDevRestart(ctx context.Context, req VNFDevRestartRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/vins/vnfdevRestart"
asyncReq := asyncWrapperVNFDevRestartRequest{
VNFDevRestartRequest: req,
AsyncMode: true,
}
result, err := v.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
if err != nil {
return "", err
}
var resp string
err = json.Unmarshal(result, &resp)
if err != nil {
return "", err
}
return resp, nil
}