forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
40 lines (33 loc) · 1009 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package backups
import (
"github.com/juju/errors"
"github.com/juju/httprequest"
"github.com/juju/loggo"
"github.com/juju/juju/api/base"
)
var logger = loggo.GetLogger("juju.api.backups")
// Client wraps the backups API for the client.
type Client struct {
base.ClientFacade
facade base.FacadeCaller
client *httprequest.Client
}
// MakeClient is a direct constructor function for a backups client.
func MakeClient(frontend base.ClientFacade, backend base.FacadeCaller, client *httprequest.Client) *Client {
return &Client{
ClientFacade: frontend,
facade: backend,
client: client,
}
}
// NewClient returns a new backups API client.
func NewClient(st base.APICallCloser) (*Client, error) {
frontend, backend := base.NewClientFacade(st, "Backups")
client, err := st.HTTPClient()
if err != nil {
return nil, errors.Trace(err)
}
return MakeClient(frontend, backend, client), nil
}