This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboards.go
107 lines (102 loc) · 3.35 KB
/
dashboards.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
package services
import (
"context"
datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
"github.com/andrewthetechie/cq-provider-datadog/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
//go:generate cq-gen --resource dashboards --config ./resources/services/v1/dashboards.hcl --output .
func Dashboards() *schema.Table {
return &schema.Table{
Name: "datadog_dashboards",
Description: "Dashboard A dashboard is Datadog’s tool for visually tracking, analyzing, and displaying key performance metrics, which enable you to monitor the health of your infrastructure.",
Multiplex: client.AccountMultiplex,
Resolver: fetchDashboards,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"id"}},
Columns: []schema.Column{
{
Name: "account_name",
Description: "The name of this datadog account from your config.",
Type: schema.TypeString,
Resolver: client.ResolveAccountName,
},
{
Name: "author_handle",
Description: "Identifier of the dashboard author.",
Type: schema.TypeString,
},
{
Name: "created_at",
Description: "Creation date of the dashboard.",
Type: schema.TypeTimestamp,
},
{
Name: "id",
Description: "ID of the dashboard.",
Type: schema.TypeString,
},
{
Name: "is_read_only",
Description: "Whether this dashboard is read-only",
Type: schema.TypeBool,
},
{
Name: "layout_type",
Description: "Layout type of the dashboard.",
Type: schema.TypeString,
},
{
Name: "modified_at",
Description: "Modification date of the dashboard.",
Type: schema.TypeTimestamp,
},
{
Name: "notify_list",
Description: "List of handles of users to notify when changes are made to this dashboard.",
Type: schema.TypeStringArray,
},
{
Name: "reflow_type",
Description: "Reflow type for a **new dashboard layout** dashboard",
Type: schema.TypeString,
},
{
Name: "restricted_roles",
Description: "A list of role identifiers",
Type: schema.TypeStringArray,
},
{
Name: "title",
Description: "Title of the dashboard.",
Type: schema.TypeString,
},
{
Name: "url",
Description: "The URL of the dashboard.",
Type: schema.TypeString,
},
{
Name: "additional_properties",
Type: schema.TypeJSON,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchDashboards(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
logger := c.Logger()
logger.Debug("in fetchDashboards")
// TODO: multiplexing
apiClient := datadog.NewAPIClient(&c.MultiPlexedAccount.V1Config)
resp, r, err := apiClient.DashboardsApi.ListDashboards(c.MultiPlexedAccount.V1Context)
logger.Debug(r.Status)
if err != nil {
return diag.FromError(err, diag.ACCESS)
}
res <- resp.Dashboards
return nil
}