-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathsql_warehouses.go
More file actions
71 lines (56 loc) · 1.63 KB
/
sql_warehouses.go
File metadata and controls
71 lines (56 loc) · 1.63 KB
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
package resources
import (
"context"
"net/url"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/marshal"
"github.com/databricks/databricks-sdk-go/service/sql"
)
type SqlWarehousePermissionLevel string
type SqlWarehousePermission struct {
Level SqlWarehousePermissionLevel `json:"level"`
UserName string `json:"user_name,omitempty"`
ServicePrincipalName string `json:"service_principal_name,omitempty"`
GroupName string `json:"group_name,omitempty"`
}
type SqlWarehouse struct {
BaseResource
Permissions []SqlWarehousePermission `json:"permissions,omitempty"`
sql.CreateWarehouseRequest
}
func (sw *SqlWarehouse) UnmarshalJSON(b []byte) error {
return marshal.Unmarshal(b, sw)
}
func (sw SqlWarehouse) MarshalJSON() ([]byte, error) {
return marshal.Marshal(sw)
}
func (sw *SqlWarehouse) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) {
_, err := w.Warehouses.GetById(ctx, id)
if err != nil {
log.Debugf(ctx, "sql warehouse %s does not exist", id)
return false, err
}
return true, nil
}
func (*SqlWarehouse) ResourceDescription() ResourceDescription {
return ResourceDescription{
SingularName: "sql_warehouse",
PluralName: "sql_warehouses",
SingularTitle: "Sql Warehouse",
PluralTitle: "SQL Warehouses",
}
}
func (sw *SqlWarehouse) InitializeURL(baseURL url.URL) {
if sw.ID == "" {
return
}
baseURL.Path = "sql/warehouses/" + sw.ID
sw.URL = baseURL.String()
}
func (sw *SqlWarehouse) GetName() string {
return sw.Name
}
func (sw *SqlWarehouse) GetURL() string {
return sw.URL
}