This commit is contained in:
2024-05-31 13:35:39 +03:00
parent e7c968797b
commit 3393934456
65 changed files with 905 additions and 393 deletions

View File

@@ -71,12 +71,21 @@ func (bdc *BVSDecortClient) CloudBroker() *cloudbroker.CloudBroker {
// DecortApiCall method for sending requests to the platform
func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
values, err := query.Values(params)
if err != nil {
return nil, err
}
var body *bytes.Buffer
var ctype string
body := bytes.NewBufferString(values.Encode())
byteSlice, ok := params.([]byte)
if ok {
body = bytes.NewBuffer(byteSlice)
// ctype = "application/x-iso9660-image"
ctype = "application/octet-stream"
} else {
values, err := query.Values(params)
if err != nil {
return nil, err
}
body = bytes.NewBufferString(values.Encode())
}
req, err := http.NewRequestWithContext(ctx, method, bdc.decortURL+constants.RESTMACHINE+url, body)
if err != nil {
@@ -101,7 +110,7 @@ func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url strin
// perform request
reqCopy := req.Clone(ctx)
respBytes, err := bdc.do(req, "")
respBytes, err := bdc.do(req, ctype)
if err == nil {
return respBytes, nil
}