/
table_googleworkspace_calendar.go
80 lines (72 loc) · 2.03 KB
/
table_googleworkspace_calendar.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
package googleworkspace
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 tableGoogleWorkspaceCalendar(_ context.Context) *plugin.Table {
return &plugin.Table{
Name: "googleworkspace_calendar",
Description: "Metadata of the specified calendar.",
List: &plugin.ListConfig{
Hydrate: listCalendars,
KeyColumns: plugin.SingleColumn("id"),
ShouldIgnoreError: isNotFoundError([]string{"404"}),
},
Columns: []*plugin.Column{
{
Name: "id",
Description: "Identifier of the calendar.",
Type: proto.ColumnType_STRING,
},
{
Name: "summary",
Description: "Title of the calendar.",
Type: proto.ColumnType_STRING,
},
{
Name: "timezone",
Description: "The time zone of the calendar.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("TimeZone"),
},
{
Name: "description",
Description: "Description of the calendar.",
Type: proto.ColumnType_STRING,
},
{
Name: "etag",
Description: "ETag of the resource.",
Type: proto.ColumnType_STRING,
},
{
Name: "location",
Description: "Geographic location of the calendar as free-form text.",
Type: proto.ColumnType_STRING,
},
{
Name: "conference_properties",
Description: "Describes the conferencing properties for this calendar.",
Type: proto.ColumnType_JSON,
},
},
}
}
//// LIST FUNCTION
func listCalendars(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
// Create service
service, err := CalendarService(ctx, d)
if err != nil {
return nil, err
}
calendarID := d.EqualsQuals["id"].GetStringValue()
resp, err := service.Calendars.Get(calendarID).Do()
if err != nil {
return nil, err
}
d.StreamListItem(ctx, resp)
return nil, nil
}