X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0ad80a1594e583be9821feb8369e8dc4f619ab65..6ddd57f1da6139b76db95ad16cccbb95eab01e5d:/sdk/go/arvados/keep_service.go diff --git a/sdk/go/arvados/keep_service.go b/sdk/go/arvados/keep_service.go index a2263d1791..eb7988422d 100644 --- a/sdk/go/arvados/keep_service.go +++ b/sdk/go/arvados/keep_service.go @@ -104,6 +104,24 @@ func (s *KeepService) Mounts(c *Client) ([]KeepMount, error) { return mounts, nil } +// Touch updates the timestamp on the given block. +func (s *KeepService) Touch(ctx context.Context, c *Client, blk string) error { + req, err := http.NewRequest("TOUCH", s.url(blk), nil) + if err != nil { + return err + } + resp, err := c.Do(req.WithContext(ctx)) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + body, _ := ioutil.ReadAll(resp.Body) + return fmt.Errorf("%s %s: %s", resp.Proto, resp.Status, body) + } + return nil +} + // Untrash moves/copies the given block out of trash. func (s *KeepService) Untrash(ctx context.Context, c *Client, blk string) error { req, err := http.NewRequest("PUT", s.url("untrash/"+blk), nil) @@ -122,21 +140,21 @@ func (s *KeepService) Untrash(ctx context.Context, c *Client, blk string) error return nil } -// Index returns an unsorted list of blocks at the given mount point. -func (s *KeepService) IndexMount(c *Client, mountUUID string, prefix string) ([]KeepServiceIndexEntry, error) { - return s.index(c, s.url("mounts/"+mountUUID+"/blocks?prefix="+prefix)) +// IndexMount returns an unsorted list of blocks at the given mount point. +func (s *KeepService) IndexMount(ctx context.Context, c *Client, mountUUID string, prefix string) ([]KeepServiceIndexEntry, error) { + return s.index(ctx, c, s.url("mounts/"+mountUUID+"/blocks?prefix="+prefix)) } // Index returns an unsorted list of blocks that can be retrieved from // this server. -func (s *KeepService) Index(c *Client, prefix string) ([]KeepServiceIndexEntry, error) { - return s.index(c, s.url("index/"+prefix)) +func (s *KeepService) Index(ctx context.Context, c *Client, prefix string) ([]KeepServiceIndexEntry, error) { + return s.index(ctx, c, s.url("index/"+prefix)) } -func (s *KeepService) index(c *Client, url string) ([]KeepServiceIndexEntry, error) { - req, err := http.NewRequest("GET", url, nil) +func (s *KeepService) index(ctx context.Context, c *Client, url string) ([]KeepServiceIndexEntry, error) { + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err != nil { - return nil, fmt.Errorf("NewRequest(%v): %v", url, err) + return nil, fmt.Errorf("NewRequestWithContext(%v): %v", url, err) } resp, err := c.Do(req) if err != nil {