v16.2.0
This commit is contained in:
46
pkg/cloudbroker/session/get.go
Normal file
46
pkg/cloudbroker/session/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user