Files
dynamix-golang-sdk/pkg/cloudbroker/session/get.go

47 lines
1.1 KiB
Go
Raw Normal View History

2026-09-04 17:29:39 +04:00
package session
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
)
// GetRequest struct to get Session parameters
type GetRequest struct {
// Storage endpoint provider ID
// Required: true
PublicSessionID string `url:"public_session_id" json:"public_session_id" validate:"required"`
}
// Get gets Session parameters as a RecordSession struct
func (s Session) Get(ctx context.Context, req GetRequest) (*RecordSession, error) {
res, err := s.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordSession{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets Session parameters as an array of bytes
func (s Session) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/session/get"
res, err := s.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}