generated from pulumi/pulumi-tf-provider-boilerplate
/
getDataSource.go
217 lines (191 loc) · 8.4 KB
/
getDataSource.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package grafana
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Get details about a Grafana Datasource querying by either name, uid or ID
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "encoding/json"
//
// "github.com/lbrlabs/pulumi-grafana/sdk/go/grafana"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// tmpJSON0, err := json.Marshal(map[string]interface{}{
// "httpMethod": "POST",
// "prometheusType": "Mimir",
// "prometheusVersion": "2.4.0",
// })
// if err != nil {
// return err
// }
// json0 := string(tmpJSON0)
// tmpJSON1, err := json.Marshal(map[string]interface{}{
// "basicAuthPassword": "password",
// })
// if err != nil {
// return err
// }
// json1 := string(tmpJSON1)
// prometheus, err := grafana.NewDataSource(ctx, "prometheus", &grafana.DataSourceArgs{
// Type: pulumi.String("prometheus"),
// Uid: pulumi.String("prometheus-ds-test-uid"),
// Url: pulumi.String("https://my-instance.com"),
// BasicAuthEnabled: pulumi.Bool(true),
// BasicAuthUsername: pulumi.String("username"),
// JsonDataEncoded: pulumi.String(json0),
// SecureJsonDataEncoded: pulumi.String(json1),
// })
// if err != nil {
// return err
// }
// _ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
// Name: prometheus.Name,
// }, nil)
// _ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
// Id: prometheus.ID(),
// }, nil)
// _ = grafana.LookupDataSourceOutput(ctx, grafana.GetDataSourceOutputArgs{
// Uid: prometheus.Uid,
// }, nil)
// return nil
// })
// }
//
// ```
func LookupDataSource(ctx *pulumi.Context, args *LookupDataSourceArgs, opts ...pulumi.InvokeOption) (*LookupDataSourceResult, error) {
opts = pkgInvokeDefaultOpts(opts)
var rv LookupDataSourceResult
err := ctx.Invoke("grafana:index/getDataSource:getDataSource", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getDataSource.
type LookupDataSourceArgs struct {
// The ID of this resource.
Id *string `pulumi:"id"`
Name *string `pulumi:"name"`
Uid *string `pulumi:"uid"`
}
// A collection of values returned by getDataSource.
type LookupDataSourceResult struct {
// The method by which Grafana will access the data source: `proxy` or `direct`.
AccessMode string `pulumi:"accessMode"`
// Whether to enable basic auth for the data source.
BasicAuthEnabled bool `pulumi:"basicAuthEnabled"`
// Basic auth username.
BasicAuthUsername string `pulumi:"basicAuthUsername"`
// (Required by some data source types) The name of the database to use on the selected data source server.
DatabaseName string `pulumi:"databaseName"`
// The ID of this resource.
Id string `pulumi:"id"`
// Whether to set the data source as default. This should only be `true` to a single data source.
IsDefault bool `pulumi:"isDefault"`
// Serialized JSON string containing the json data. This attribute can be used to pass configuration options to the data source. To figure out what options a datasource has available, see its docs or inspect the network data when saving it from the Grafana UI. Note that keys in this map are usually camelCased.
JsonDataEncoded string `pulumi:"jsonDataEncoded"`
Name string `pulumi:"name"`
// The data source type. Must be one of the supported data source keywords.
Type string `pulumi:"type"`
Uid string `pulumi:"uid"`
// The URL for the data source. The type of URL required varies depending on the chosen data source type.
Url string `pulumi:"url"`
// (Required by some data source types) The username to use to authenticate to the data source.
Username string `pulumi:"username"`
}
func LookupDataSourceOutput(ctx *pulumi.Context, args LookupDataSourceOutputArgs, opts ...pulumi.InvokeOption) LookupDataSourceResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupDataSourceResult, error) {
args := v.(LookupDataSourceArgs)
r, err := LookupDataSource(ctx, &args, opts...)
var s LookupDataSourceResult
if r != nil {
s = *r
}
return s, err
}).(LookupDataSourceResultOutput)
}
// A collection of arguments for invoking getDataSource.
type LookupDataSourceOutputArgs struct {
// The ID of this resource.
Id pulumi.StringPtrInput `pulumi:"id"`
Name pulumi.StringPtrInput `pulumi:"name"`
Uid pulumi.StringPtrInput `pulumi:"uid"`
}
func (LookupDataSourceOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDataSourceArgs)(nil)).Elem()
}
// A collection of values returned by getDataSource.
type LookupDataSourceResultOutput struct{ *pulumi.OutputState }
func (LookupDataSourceResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupDataSourceResult)(nil)).Elem()
}
func (o LookupDataSourceResultOutput) ToLookupDataSourceResultOutput() LookupDataSourceResultOutput {
return o
}
func (o LookupDataSourceResultOutput) ToLookupDataSourceResultOutputWithContext(ctx context.Context) LookupDataSourceResultOutput {
return o
}
// The method by which Grafana will access the data source: `proxy` or `direct`.
func (o LookupDataSourceResultOutput) AccessMode() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.AccessMode }).(pulumi.StringOutput)
}
// Whether to enable basic auth for the data source.
func (o LookupDataSourceResultOutput) BasicAuthEnabled() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDataSourceResult) bool { return v.BasicAuthEnabled }).(pulumi.BoolOutput)
}
// Basic auth username.
func (o LookupDataSourceResultOutput) BasicAuthUsername() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.BasicAuthUsername }).(pulumi.StringOutput)
}
// (Required by some data source types) The name of the database to use on the selected data source server.
func (o LookupDataSourceResultOutput) DatabaseName() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.DatabaseName }).(pulumi.StringOutput)
}
// The ID of this resource.
func (o LookupDataSourceResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Id }).(pulumi.StringOutput)
}
// Whether to set the data source as default. This should only be `true` to a single data source.
func (o LookupDataSourceResultOutput) IsDefault() pulumi.BoolOutput {
return o.ApplyT(func(v LookupDataSourceResult) bool { return v.IsDefault }).(pulumi.BoolOutput)
}
// Serialized JSON string containing the json data. This attribute can be used to pass configuration options to the data source. To figure out what options a datasource has available, see its docs or inspect the network data when saving it from the Grafana UI. Note that keys in this map are usually camelCased.
func (o LookupDataSourceResultOutput) JsonDataEncoded() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.JsonDataEncoded }).(pulumi.StringOutput)
}
func (o LookupDataSourceResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Name }).(pulumi.StringOutput)
}
// The data source type. Must be one of the supported data source keywords.
func (o LookupDataSourceResultOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Type }).(pulumi.StringOutput)
}
func (o LookupDataSourceResultOutput) Uid() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Uid }).(pulumi.StringOutput)
}
// The URL for the data source. The type of URL required varies depending on the chosen data source type.
func (o LookupDataSourceResultOutput) Url() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Url }).(pulumi.StringOutput)
}
// (Required by some data source types) The username to use to authenticate to the data source.
func (o LookupDataSourceResultOutput) Username() pulumi.StringOutput {
return o.ApplyT(func(v LookupDataSourceResult) string { return v.Username }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupDataSourceResultOutput{})
}