-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathdatabase_catalog.go
More file actions
51 lines (41 loc) · 1.11 KB
/
database_catalog.go
File metadata and controls
51 lines (41 loc) · 1.11 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
package resources
import (
"context"
"net/url"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/database"
)
type DatabaseCatalog struct {
BaseResource
database.DatabaseCatalog
}
func (d *DatabaseCatalog) Exists(ctx context.Context, w *databricks.WorkspaceClient, name string) (bool, error) {
_, err := w.Database.GetDatabaseCatalog(ctx, database.GetDatabaseCatalogRequest{Name: name})
if err != nil {
log.Debugf(ctx, "database Catalog %s does not exist", name)
return false, err
}
return true, nil
}
func (d *DatabaseCatalog) ResourceDescription() ResourceDescription {
return ResourceDescription{
SingularName: "database_catalog",
PluralName: "database_catalogs",
SingularTitle: "Database catalog",
PluralTitle: "Database catalogs",
}
}
func (d *DatabaseCatalog) GetName() string {
return d.Name
}
func (d *DatabaseCatalog) GetURL() string {
return d.URL
}
func (d *DatabaseCatalog) InitializeURL(baseURL url.URL) {
if d.Name == "" {
return
}
baseURL.Path = "explore/data/" + d.Name
d.URL = baseURL.String()
}