Files
dynamix-golang-sdk/pkg/cloudbroker/sep/add_consumer_nodes.go

44 lines
1.0 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package sep
import (
"context"
2026-07-17 16:22:51 +04:00
"encoding/json"
2025-09-23 14:34:24 +03:00
"net/http"
2026-06-05 17:30:36 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
2025-09-23 14:34:24 +03:00
)
// AddConsumerNodesRequest struct to add consumer nodes
type AddConsumerNodesRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// List of nodes IDs
// Required: true
ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids" validate:"min=1"`
}
// AddConsumerNodes adds consumer nodes to SEP parameters
2026-07-17 16:22:51 +04:00
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) ([]uint64, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
2026-07-17 16:22:51 +04:00
list := []uint64{}
2025-09-23 14:34:24 +03:00
if err != nil {
2026-07-17 16:22:51 +04:00
return list, validators.ValidationErrors(validators.GetErrors(err))
2025-09-23 14:34:24 +03:00
}
url := "/cloudbroker/sep/addConsumerNodes"
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
2026-07-17 16:22:51 +04:00
return list, err
2025-09-23 14:34:24 +03:00
}
2026-07-17 16:22:51 +04:00
err = json.Unmarshal(res, &list)
2025-09-23 14:34:24 +03:00
if err != nil {
2026-07-17 16:22:51 +04:00
return nil, err
2025-09-23 14:34:24 +03:00
}
2026-07-17 16:22:51 +04:00
return list, nil
2025-09-23 14:34:24 +03:00
}