/
apiAccessKey.go
339 lines (286 loc) · 13.9 KB
/
apiAccessKey.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
// 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 newrelic
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this resource to programmatically create and manage the following types of keys:
// - [User API keys](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#user-api-key)
// - License (or ingest) keys, including:
// - General [license key](https://docs.newrelic.com/docs/accounts/install-new-relic/account-setup/license-key) used for APM
// - [Browser license key](https://docs.newrelic.com/docs/browser/new-relic-browser/configuration/copy-browser-monitoring-license-key-app-id)
//
// Please visit the New Relic article ['Use NerdGraph to manage license keys and User API keys'](https://docs.newrelic.com/docs/apis/nerdgraph/examples/use-nerdgraph-manage-license-keys-user-keys)
// for more information.
//
// > **IMPORTANT!**
// Please be very careful when updating existing `ApiAccessKey` resources as only `newrelic_api_access_key.name`
// and `newrelic_api_access_key.notes` are updatable. All other resource attributes will force a resource recreation which will
// invalidate the previous API key(s).
//
// ## Example Usage
//
// > **WARNING:** Creating 'Ingest - License' and 'Ingest - Browser' keys using this resource is restricted to 'core' or 'full platform' New Relic user accounts. If you've signed up as a 'basic' user with New Relic, or have been added as a 'basic' user to your organization on New Relic, you would not be able to use your account to create 'Ingest' keys. If you see the message `"You do not have permission to create this key"` in the response of the API called by this resource, it could be owing to the aforementioned. For more insights into user account types on New Relic and associated privileges, please check out this [page](https://docs.newrelic.com/docs/accounts/accounts-billing/new-relic-one-user-management/user-type/#api-access).
//
// ## Import
//
// Existing API access keys can be imported using a composite ID of `<api_access_key_id>:<key_type>`. `<key_type>`
// will be either `INGEST` or `USER`.
//
// For example:
//
// ```sh
// $ pulumi import newrelic:index/apiAccessKey:ApiAccessKey foobar "1234567:INGEST"
// ```
type ApiAccessKey struct {
pulumi.CustomResourceState
// The New Relic account ID of the account you wish to create the API access key.
AccountId pulumi.IntOutput `pulumi:"accountId"`
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
IngestType pulumi.StringOutput `pulumi:"ingestType"`
// The actual API key. This attribute is masked and not be visible in your terminal, CI, etc.
Key pulumi.StringOutput `pulumi:"key"`
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
KeyType pulumi.StringOutput `pulumi:"keyType"`
// The name of the key.
Name pulumi.StringOutput `pulumi:"name"`
// Any notes about this ingest key.
Notes pulumi.StringOutput `pulumi:"notes"`
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
UserId pulumi.IntOutput `pulumi:"userId"`
}
// NewApiAccessKey registers a new resource with the given unique name, arguments, and options.
func NewApiAccessKey(ctx *pulumi.Context,
name string, args *ApiAccessKeyArgs, opts ...pulumi.ResourceOption) (*ApiAccessKey, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AccountId == nil {
return nil, errors.New("invalid value for required argument 'AccountId'")
}
if args.KeyType == nil {
return nil, errors.New("invalid value for required argument 'KeyType'")
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"key",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource ApiAccessKey
err := ctx.RegisterResource("newrelic:index/apiAccessKey:ApiAccessKey", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetApiAccessKey gets an existing ApiAccessKey resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetApiAccessKey(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ApiAccessKeyState, opts ...pulumi.ResourceOption) (*ApiAccessKey, error) {
var resource ApiAccessKey
err := ctx.ReadResource("newrelic:index/apiAccessKey:ApiAccessKey", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ApiAccessKey resources.
type apiAccessKeyState struct {
// The New Relic account ID of the account you wish to create the API access key.
AccountId *int `pulumi:"accountId"`
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
IngestType *string `pulumi:"ingestType"`
// The actual API key. This attribute is masked and not be visible in your terminal, CI, etc.
Key *string `pulumi:"key"`
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
KeyType *string `pulumi:"keyType"`
// The name of the key.
Name *string `pulumi:"name"`
// Any notes about this ingest key.
Notes *string `pulumi:"notes"`
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
UserId *int `pulumi:"userId"`
}
type ApiAccessKeyState struct {
// The New Relic account ID of the account you wish to create the API access key.
AccountId pulumi.IntPtrInput
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
IngestType pulumi.StringPtrInput
// The actual API key. This attribute is masked and not be visible in your terminal, CI, etc.
Key pulumi.StringPtrInput
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
KeyType pulumi.StringPtrInput
// The name of the key.
Name pulumi.StringPtrInput
// Any notes about this ingest key.
Notes pulumi.StringPtrInput
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
UserId pulumi.IntPtrInput
}
func (ApiAccessKeyState) ElementType() reflect.Type {
return reflect.TypeOf((*apiAccessKeyState)(nil)).Elem()
}
type apiAccessKeyArgs struct {
// The New Relic account ID of the account you wish to create the API access key.
AccountId int `pulumi:"accountId"`
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
IngestType *string `pulumi:"ingestType"`
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
KeyType string `pulumi:"keyType"`
// The name of the key.
Name *string `pulumi:"name"`
// Any notes about this ingest key.
Notes *string `pulumi:"notes"`
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
UserId *int `pulumi:"userId"`
}
// The set of arguments for constructing a ApiAccessKey resource.
type ApiAccessKeyArgs struct {
// The New Relic account ID of the account you wish to create the API access key.
AccountId pulumi.IntInput
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
IngestType pulumi.StringPtrInput
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
KeyType pulumi.StringInput
// The name of the key.
Name pulumi.StringPtrInput
// Any notes about this ingest key.
Notes pulumi.StringPtrInput
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
UserId pulumi.IntPtrInput
}
func (ApiAccessKeyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*apiAccessKeyArgs)(nil)).Elem()
}
type ApiAccessKeyInput interface {
pulumi.Input
ToApiAccessKeyOutput() ApiAccessKeyOutput
ToApiAccessKeyOutputWithContext(ctx context.Context) ApiAccessKeyOutput
}
func (*ApiAccessKey) ElementType() reflect.Type {
return reflect.TypeOf((**ApiAccessKey)(nil)).Elem()
}
func (i *ApiAccessKey) ToApiAccessKeyOutput() ApiAccessKeyOutput {
return i.ToApiAccessKeyOutputWithContext(context.Background())
}
func (i *ApiAccessKey) ToApiAccessKeyOutputWithContext(ctx context.Context) ApiAccessKeyOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApiAccessKeyOutput)
}
// ApiAccessKeyArrayInput is an input type that accepts ApiAccessKeyArray and ApiAccessKeyArrayOutput values.
// You can construct a concrete instance of `ApiAccessKeyArrayInput` via:
//
// ApiAccessKeyArray{ ApiAccessKeyArgs{...} }
type ApiAccessKeyArrayInput interface {
pulumi.Input
ToApiAccessKeyArrayOutput() ApiAccessKeyArrayOutput
ToApiAccessKeyArrayOutputWithContext(context.Context) ApiAccessKeyArrayOutput
}
type ApiAccessKeyArray []ApiAccessKeyInput
func (ApiAccessKeyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ApiAccessKey)(nil)).Elem()
}
func (i ApiAccessKeyArray) ToApiAccessKeyArrayOutput() ApiAccessKeyArrayOutput {
return i.ToApiAccessKeyArrayOutputWithContext(context.Background())
}
func (i ApiAccessKeyArray) ToApiAccessKeyArrayOutputWithContext(ctx context.Context) ApiAccessKeyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApiAccessKeyArrayOutput)
}
// ApiAccessKeyMapInput is an input type that accepts ApiAccessKeyMap and ApiAccessKeyMapOutput values.
// You can construct a concrete instance of `ApiAccessKeyMapInput` via:
//
// ApiAccessKeyMap{ "key": ApiAccessKeyArgs{...} }
type ApiAccessKeyMapInput interface {
pulumi.Input
ToApiAccessKeyMapOutput() ApiAccessKeyMapOutput
ToApiAccessKeyMapOutputWithContext(context.Context) ApiAccessKeyMapOutput
}
type ApiAccessKeyMap map[string]ApiAccessKeyInput
func (ApiAccessKeyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ApiAccessKey)(nil)).Elem()
}
func (i ApiAccessKeyMap) ToApiAccessKeyMapOutput() ApiAccessKeyMapOutput {
return i.ToApiAccessKeyMapOutputWithContext(context.Background())
}
func (i ApiAccessKeyMap) ToApiAccessKeyMapOutputWithContext(ctx context.Context) ApiAccessKeyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApiAccessKeyMapOutput)
}
type ApiAccessKeyOutput struct{ *pulumi.OutputState }
func (ApiAccessKeyOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ApiAccessKey)(nil)).Elem()
}
func (o ApiAccessKeyOutput) ToApiAccessKeyOutput() ApiAccessKeyOutput {
return o
}
func (o ApiAccessKeyOutput) ToApiAccessKeyOutputWithContext(ctx context.Context) ApiAccessKeyOutput {
return o
}
// The New Relic account ID of the account you wish to create the API access key.
func (o ApiAccessKeyOutput) AccountId() pulumi.IntOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.IntOutput { return v.AccountId }).(pulumi.IntOutput)
}
// Required if `keyType = INGEST`. Valid options are `BROWSER` or `LICENSE`, case-sensitive.
func (o ApiAccessKeyOutput) IngestType() pulumi.StringOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.StringOutput { return v.IngestType }).(pulumi.StringOutput)
}
// The actual API key. This attribute is masked and not be visible in your terminal, CI, etc.
func (o ApiAccessKeyOutput) Key() pulumi.StringOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.StringOutput { return v.Key }).(pulumi.StringOutput)
}
// What type of API key to create. Valid options are `INGEST` or `USER`, case-sensitive.
func (o ApiAccessKeyOutput) KeyType() pulumi.StringOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.StringOutput { return v.KeyType }).(pulumi.StringOutput)
}
// The name of the key.
func (o ApiAccessKeyOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Any notes about this ingest key.
func (o ApiAccessKeyOutput) Notes() pulumi.StringOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.StringOutput { return v.Notes }).(pulumi.StringOutput)
}
// Required if `keyType = USER`. The New Relic user ID yous wish to create the API access key for in an account.
func (o ApiAccessKeyOutput) UserId() pulumi.IntOutput {
return o.ApplyT(func(v *ApiAccessKey) pulumi.IntOutput { return v.UserId }).(pulumi.IntOutput)
}
type ApiAccessKeyArrayOutput struct{ *pulumi.OutputState }
func (ApiAccessKeyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ApiAccessKey)(nil)).Elem()
}
func (o ApiAccessKeyArrayOutput) ToApiAccessKeyArrayOutput() ApiAccessKeyArrayOutput {
return o
}
func (o ApiAccessKeyArrayOutput) ToApiAccessKeyArrayOutputWithContext(ctx context.Context) ApiAccessKeyArrayOutput {
return o
}
func (o ApiAccessKeyArrayOutput) Index(i pulumi.IntInput) ApiAccessKeyOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ApiAccessKey {
return vs[0].([]*ApiAccessKey)[vs[1].(int)]
}).(ApiAccessKeyOutput)
}
type ApiAccessKeyMapOutput struct{ *pulumi.OutputState }
func (ApiAccessKeyMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ApiAccessKey)(nil)).Elem()
}
func (o ApiAccessKeyMapOutput) ToApiAccessKeyMapOutput() ApiAccessKeyMapOutput {
return o
}
func (o ApiAccessKeyMapOutput) ToApiAccessKeyMapOutputWithContext(ctx context.Context) ApiAccessKeyMapOutput {
return o
}
func (o ApiAccessKeyMapOutput) MapIndex(k pulumi.StringInput) ApiAccessKeyOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ApiAccessKey {
return vs[0].(map[string]*ApiAccessKey)[vs[1].(string)]
}).(ApiAccessKeyOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ApiAccessKeyInput)(nil)).Elem(), &ApiAccessKey{})
pulumi.RegisterInputType(reflect.TypeOf((*ApiAccessKeyArrayInput)(nil)).Elem(), ApiAccessKeyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ApiAccessKeyMapInput)(nil)).Elem(), ApiAccessKeyMap{})
pulumi.RegisterOutputType(ApiAccessKeyOutput{})
pulumi.RegisterOutputType(ApiAccessKeyArrayOutput{})
pulumi.RegisterOutputType(ApiAccessKeyMapOutput{})
}