This repository was archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
119 lines (100 loc) · 2.41 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package databricks
import (
"fmt"
"net/http"
)
// ListOrder is a listing order.
type ListOrder string
const (
// Desc is descending.
Desc ListOrder = "DESC"
// Asc is ascending.
Asc = "ASC"
)
// ClientOpt is used for configuring a Client.
type ClientOpt func(*Client) error
// ClientHTTPClient configures the Client's HTTP client.
func ClientHTTPClient(client *http.Client) ClientOpt {
return func(c *Client) error {
c.client = client
return nil
}
}
// Client is a Databricks client.
type Client struct {
client *http.Client
account string
url string
}
// NewClient returns a new Databricks client.
func NewClient(account string, opts ...ClientOpt) (*Client, error) {
c := &Client{
account: account,
url: fmt.Sprintf("https://%s.cloud.databricks.com/api/", account),
client: http.DefaultClient,
}
for _, opt := range opts {
if err := opt(c); err != nil {
return nil, err
}
}
return c, nil
}
// Do is a proxy to the http.Client's Do method.
func (c *Client) Do(req *http.Request) (*http.Response, error) {
return c.client.Do(req)
}
// Cluster returns a ClusterService for the corresponding client.
func (c *Client) Cluster() *ClusterService {
return &ClusterService{
client: *c,
}
}
// DBFS returns a DBFSService for the corresponding client.
func (c *Client) DBFS() *DBFSService {
return &DBFSService{
client: *c,
}
}
// Groups returns a GroupsService for the corresponding client.
func (c *Client) Groups() *GroupsService {
return &GroupsService{
client: *c,
}
}
// Jobs returns a JobsService for the corresponding client.
func (c *Client) Jobs() *JobsService {
return &JobsService{
client: *c,
}
}
// Libraries returns a LibrariesService for the corresponding client.
func (c *Client) Libraries() *LibrariesService {
return &LibrariesService{
client: *c,
}
}
// Profiles returns a ProfilesService for the corresponding client.
func (c *Client) Profiles() *ProfilesService {
return &ProfilesService{
client: *c,
}
}
// Secrets returns a SecretsService for the corresponding client.
func (c *Client) Secrets() *SecretsService {
return &SecretsService{
client: *c,
}
}
// Token returns a TokenService for the corresponding client.
func (c *Client) Token() *TokenService {
return &TokenService{
client: *c,
}
}
// Workspace returns a WorkspaceService for the corresponding client.
func (c *Client) Workspace() *WorkspaceService {
return &WorkspaceService{
client: *c,
}
}