feat(api): session recording reapply storage policy

This commit is contained in:
Damian Debkowski authored and Louis Ruch committed 2024-01-16 13:53:44 -08:00
1 parent f26243e9af
commit 9e533912cd
1 file changed
+42
+42
View File
@@ -57,3 +57,45 @@ func (c *Client) Download(ctx context.Context, contentId string, opt ...Option)
}
return resp.HttpResponse().Body, nil
}
// ReApplyStoragePolicy will reapply a storage policy to a session recording.
func (c *Client) ReApplyStoragePolicy(ctx context.Context, contentId string, opt ...Option) (*SessionRecordingReadResult, error) {
switch {
case contentId == "":
return nil, fmt.Errorf("empty content id value passed into download request")
case c.client == nil:
return nil, fmt.Errorf("nil client")
}
opts, apiOpts := getOpts(opt...)
req, err := c.client.NewRequest(ctx, "POST", "session-recordings/"+url.PathEscape(contentId)+":reapply-storage-policy", nil, apiOpts...)
if err != nil {
return nil, fmt.Errorf("error creating reapply storage policy request: %w", err)
}
if len(opts.queryMap) > 0 {
q := url.Values{}
for k, v := range opts.queryMap {
q.Add(k, v)
}
req.URL.RawQuery = q.Encode()
}
resp, err := c.client.Do(req)
if err != nil {
return nil, fmt.Errorf("error performing client request during ReApplyStoragePolicy call: %w", err)
}
target := new(SessionRecordingReadResult)
target.Item = new(SessionRecording)
apiErr, err := resp.Decode(target.Item)
if err != nil {
return nil, fmt.Errorf("error decoding ReApplyStoragePolicy response: %w", err)
}
if apiErr != nil {
return nil, apiErr
}
target.response = resp
return target, nil
}