mirror of https://github.com/databricks/cli.git
Add dashboards to summary output
This commit is contained in:
parent
43f9155de5
commit
5fb35e358f
|
@ -85,6 +85,12 @@ func TestInitializeURLs(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Dashboards: map[string]*resources.Dashboard{
|
||||
"dashboard1": {
|
||||
ID: "01ef8d56871e1d50ae30ce7375e42478",
|
||||
DisplayName: "My special dashboard",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -99,6 +105,7 @@ func TestInitializeURLs(t *testing.T) {
|
|||
"qualityMonitor1": "https://mycompany.databricks.com/explore/data/catalog/schema/qualityMonitor1?o=123456",
|
||||
"schema1": "https://mycompany.databricks.com/explore/data/catalog/schema?o=123456",
|
||||
"cluster1": "https://mycompany.databricks.com/compute/clusters/1017-103929-vlr7jzcf?o=123456",
|
||||
"dashboard1": "https://mycompany.databricks.com/dashboardsv3/01ef8d56871e1d50ae30ce7375e42478/published?o=123456",
|
||||
}
|
||||
|
||||
initializeForWorkspace(b, "123456", "https://mycompany.databricks.com/")
|
||||
|
|
|
@ -78,6 +78,7 @@ func (r *Resources) AllResources() []ResourceGroup {
|
|||
collectResourceMap(descriptions["quality_monitors"], r.QualityMonitors),
|
||||
collectResourceMap(descriptions["schemas"], r.Schemas),
|
||||
collectResourceMap(descriptions["clusters"], r.Clusters),
|
||||
collectResourceMap(descriptions["dashboards"], r.Dashboards),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,5 +177,11 @@ func SupportedResources() map[string]ResourceDescription {
|
|||
SingularTitle: "Cluster",
|
||||
PluralTitle: "Clusters",
|
||||
},
|
||||
"dashboards": {
|
||||
SingularName: "dashboard",
|
||||
PluralName: "dashboards",
|
||||
SingularTitle: "Dashboard",
|
||||
PluralTitle: "Dashboards",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package resources
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"github.com/databricks/cli/libs/log"
|
||||
"github.com/databricks/databricks-sdk-go"
|
||||
|
@ -13,6 +15,7 @@ type Dashboard struct {
|
|||
ID string `json:"id,omitempty" bundle:"readonly"`
|
||||
Permissions []Permission `json:"permissions,omitempty"`
|
||||
ModifiedStatus ModifiedStatus `json:"modified_status,omitempty" bundle:"internal"`
|
||||
URL string `json:"url,omitempty" bundle:"internal"`
|
||||
|
||||
// ===========================
|
||||
// === BEGIN OF API FIELDS ===
|
||||
|
@ -50,12 +53,12 @@ type Dashboard struct {
|
|||
FilePath string `json:"file_path,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Dashboard) UnmarshalJSON(b []byte) error {
|
||||
return marshal.Unmarshal(b, s)
|
||||
func (r *Dashboard) UnmarshalJSON(b []byte) error {
|
||||
return marshal.Unmarshal(b, r)
|
||||
}
|
||||
|
||||
func (s Dashboard) MarshalJSON() ([]byte, error) {
|
||||
return marshal.Marshal(s)
|
||||
func (r Dashboard) MarshalJSON() ([]byte, error) {
|
||||
return marshal.Marshal(r)
|
||||
}
|
||||
|
||||
func (*Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id string) (bool, error) {
|
||||
|
@ -63,7 +66,7 @@ func (*Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
|||
DashboardId: id,
|
||||
})
|
||||
if err != nil {
|
||||
log.Debugf(ctx, "Dashboard %s does not exist", id)
|
||||
log.Debugf(ctx, "dashboard %s does not exist", id)
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
|
@ -72,3 +75,20 @@ func (*Dashboard) Exists(ctx context.Context, w *databricks.WorkspaceClient, id
|
|||
func (*Dashboard) TerraformResourceName() string {
|
||||
return "databricks_dashboard"
|
||||
}
|
||||
|
||||
func (r *Dashboard) InitializeURL(baseURL url.URL) {
|
||||
if r.ID == "" {
|
||||
return
|
||||
}
|
||||
|
||||
baseURL.Path = fmt.Sprintf("dashboardsv3/%s/published", r.ID)
|
||||
r.URL = baseURL.String()
|
||||
}
|
||||
|
||||
func (r *Dashboard) GetName() string {
|
||||
return r.DisplayName
|
||||
}
|
||||
|
||||
func (r *Dashboard) GetURL() string {
|
||||
return r.URL
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue