~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/api/backups/download.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package backups
 
5
 
 
6
import (
 
7
        "io"
 
8
        "net/http"
 
9
 
 
10
        "github.com/juju/errors"
 
11
        "github.com/juju/httprequest"
 
12
 
 
13
        "github.com/juju/juju/apiserver/params"
 
14
)
 
15
 
 
16
type downloadParams struct {
 
17
        httprequest.Route `httprequest:"GET /backups"`
 
18
        Body              params.BackupsDownloadArgs `httprequest:",body"`
 
19
}
 
20
 
 
21
// Download returns an io.ReadCloser for the given backup id.
 
22
func (c *Client) Download(id string) (io.ReadCloser, error) {
 
23
        // Send the request.
 
24
        var resp *http.Response
 
25
        err := c.client.Call(
 
26
                &downloadParams{
 
27
                        Body: params.BackupsDownloadArgs{
 
28
                                ID: id,
 
29
                        },
 
30
                },
 
31
                &resp,
 
32
        )
 
33
        if err != nil {
 
34
                return nil, errors.Trace(err)
 
35
        }
 
36
        return resp.Body, nil
 
37
}