/
funcs.go
71 lines (50 loc) · 2.88 KB
/
funcs.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
package plugin
import (
"context"
)
/*
HydrateFunc is a function that gathers data to build table rows.
Typically this would make an API call and return the raw API output.
List and Get are special hydrate functions.
- List returns data for all rows. Almost all tables will have a List function.
- Get returns data for a single row. In order to filter as cheaply as possible a Get function should be implemented if the API supports fetching single items by key.
A column may require data not returned by the List or Get calls and an additional API
call will be required. A HydrateFunc that wraps this API call can be specified in the [Column] definition.
You could do this the hard way by looping through the List API results and enriching each item
by making an additional API call. However the SDK does all this for you.
*/
type HydrateFunc func(context.Context, *QueryData, *HydrateData) (interface{}, error)
/*
Deprecated
*/
type MatrixItemFunc func(context.Context, *Connection) []map[string]interface{}
/*
MatrixItemMapFunc is a callback function which may be implemented by the plugin to provide a map of [matrix_items] to execute the query with.
[matrix_items] are a powerful way of executing the same query multiple times in parallel for a set of parameters.
Plugin examples:
- Declaration of [MatrixItemMapFunc] and its [implementation].
[MatrixItemMapFunc]: https://github.com/turbot/steampipe-plugin-aws/blob/c5fbf38df19667f60877c860cf8ad39816ff658f/aws/table_aws_acm_certificate.go#L36
[implementation]: https://github.com/turbot/steampipe-plugin-aws/blob/c5fbf38df19667f60877c860cf8ad39816ff658f/aws/multi_region.go#L63
*/
type MatrixItemMapFunc func(context.Context, *QueryData) []map[string]interface{}
// ErrorPredicate is a function type which accepts error as an input and returns a boolean value.
type ErrorPredicate func(error) bool
/*
ErrorPredicateWithContext is a function type which accepts context, query data, hydrate data and error as an input and returns a boolean value.
Plugin examples:
- [aws]
- [azure]
[aws]: https://github.com/turbot/steampipe-plugin-aws/blob/010ec0762c273b4549b4369fe05d61ec1ce24a9b/aws/errors.go#L14
[azure]: https://github.com/turbot/steampipe-plugin-azure/blob/85d6f373f85726a9f045f907509d9fd82ace9e41/azure/errors.go#L11
*/
type ErrorPredicateWithContext func(context.Context, *QueryData, *HydrateData, error) bool
/*
TableMapFunc is callback function which can be used to populate [plugin.Plugin.TableMap]
and allows the connection config to be used in the table creation
(connection config is not available at plugin creation time).
This callback function should be implemented by the plugin writer for dynamic plugins.
Plugin examples:
- [csv]
[csv]: https://github.com/turbot/steampipe-plugin-csv/blob/fa8c9809f4ebbfa2738e9ecd136da8b89a87f6eb/csv/plugin.go#L25
*/
type TableMapFunc func(ctx context.Context, d *TableMapData) (map[string]*Table, error)