-
Notifications
You must be signed in to change notification settings - Fork 2
/
table_databricks_iam_current_user.go
106 lines (94 loc) · 2.7 KB
/
table_databricks_iam_current_user.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
package databricks
import (
"context"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)
//// TABLE DEFINITION
func tableDatabricksIAMCurrentUser(_ context.Context) *plugin.Table {
return &plugin.Table{
Name: "databricks_iam_current_user",
Description: "Gets details for the current user of the workspace.",
List: &plugin.ListConfig{
Hydrate: getIAMCurrentUser,
},
Columns: databricksAccountColumns([]*plugin.Column{
{
Name: "id",
Description: "Databricks user ID.",
Type: proto.ColumnType_STRING,
},
{
Name: "user_name",
Description: "Email address of the Databricks user.",
Type: proto.ColumnType_STRING,
},
{
Name: "active",
Description: "Whether the user is active.",
Type: proto.ColumnType_BOOL,
},
{
Name: "display_name",
Description: "String that represents a concatenation of given and family names.",
Type: proto.ColumnType_STRING,
},
{
Name: "external_id",
Description: "External ID of the user.",
Type: proto.ColumnType_STRING,
},
// JSON fields
{
Name: "emails",
Description: "All the emails associated with the Databricks user.",
Type: proto.ColumnType_JSON,
},
{
Name: "entitlements",
Description: "All the entitlements associated with the Databricks user.",
Type: proto.ColumnType_JSON,
},
{
Name: "groups",
Description: "All the groups the user belongs to.",
Type: proto.ColumnType_JSON,
},
{
Name: "name",
Description: "Name of the user.",
Type: proto.ColumnType_JSON,
},
{
Name: "roles",
Description: "All the roles associated with the Databricks user.",
Type: proto.ColumnType_JSON,
},
// Standard Steampipe columns
{
Name: "title",
Description: "The title of the resource.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("DisplayName"),
},
}),
}
}
//// LIST FUNCTION
func getIAMCurrentUser(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
logger := plugin.Logger(ctx)
// Create client
client, err := getWorkspaceClient(ctx, d)
if err != nil {
logger.Error("databricks_iam_current_user.getIAMCurrentUser", "connection_error", err)
return nil, err
}
user, err := client.CurrentUser.Me(ctx)
if err != nil {
logger.Error("databricks_iam_current_user.getIAMCurrentUser", "api_error", err)
return nil, err
}
d.StreamListItem(ctx, user)
return nil, nil
}