/
serviceLevel.go
455 lines (402 loc) · 16.8 KB
/
serviceLevel.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
// 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"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this resource to create, update, and delete New Relic Service Level Indicators and Objectives.
//
// A New Relic User API key is required to provision this resource. Set the `apiKey`
// attribute in the `provider` block or the `NEW_RELIC_API_KEY` environment
// variable with your User API key.
//
// Important:
// - Only roles that provide [permissions](https://docs.newrelic.com/docs/accounts/accounts-billing/new-relic-one-user-management/new-relic-one-user-model-understand-user-structure/) to create events to metric rules can create SLI/SLOs.
// - Only [Full users](https://docs.newrelic.com/docs/accounts/accounts-billing/new-relic-one-user-management/new-relic-one-user-model-understand-user-structure/#user-type) can view SLI/SLOs.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-newrelic/sdk/v4/go/newrelic"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := newrelic.NewServiceLevel(ctx, "foo", &newrelic.ServiceLevelArgs{
// Description: pulumi.String("Proportion of requests that are served faster than a threshold."),
// Events: &ServiceLevelEventsArgs{
// AccountId: pulumi.Int(12345678),
// GoodEvents: &ServiceLevelEventsGoodEventsArgs{
// From: pulumi.String("Transaction"),
// Where: pulumi.String("appName = 'Example application' AND (transactionType= 'Web') AND duration < 0.1"),
// },
// ValidEvents: &ServiceLevelEventsValidEventsArgs{
// From: pulumi.String("Transaction"),
// Where: pulumi.String("appName = 'Example application' AND (transactionType='Web')"),
// },
// },
// Guid: pulumi.String("MXxBUE18QVBQTElDQVRJT058MQ"),
// Objective: &ServiceLevelObjectiveArgs{
// Target: pulumi.Float64(99),
// TimeWindow: &ServiceLevelObjectiveTimeWindowArgs{
// Rolling: &ServiceLevelObjectiveTimeWindowRollingArgs{
// Count: pulumi.Int(7),
// Unit: pulumi.String("DAY"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ## Additional Example
//
// Service level with tags:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-newrelic/sdk/v4/go/newrelic"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// mySyntheticMonitorServiceLevel, err := newrelic.NewServiceLevel(ctx, "mySyntheticMonitorServiceLevel", &newrelic.ServiceLevelArgs{
// Guid: pulumi.String("MXxBUE18QVBQTElDQVRJT058MQ"),
// Description: pulumi.String("Proportion of successful synthetic checks."),
// Events: &ServiceLevelEventsArgs{
// AccountId: pulumi.Int(12345678),
// ValidEvents: &ServiceLevelEventsValidEventsArgs{
// From: pulumi.String("SyntheticCheck"),
// Where: pulumi.String("entityGuid = 'MXxBUE18QVBQTElDQVRJT058MQ'"),
// },
// GoodEvents: &ServiceLevelEventsGoodEventsArgs{
// From: pulumi.String("SyntheticCheck"),
// Where: pulumi.String("entityGuid = 'MXxBUE18QVBQTElDQVRJT058MQ' AND result='SUCCESS'"),
// },
// },
// Objective: &ServiceLevelObjectiveArgs{
// Target: pulumi.Float64(99),
// TimeWindow: &ServiceLevelObjectiveTimeWindowArgs{
// Rolling: &ServiceLevelObjectiveTimeWindowRollingArgs{
// Count: pulumi.Int(7),
// Unit: pulumi.String("DAY"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = newrelic.NewEntityTags(ctx, "mySyntheticMonitorServiceLevelTags", &newrelic.EntityTagsArgs{
// Guid: mySyntheticMonitorServiceLevel.SliGuid,
// Tags: EntityTagsTagArray{
// &EntityTagsTagArgs{
// Key: pulumi.String("user_journey"),
// Values: pulumi.StringArray{
// pulumi.String("authentication"),
// pulumi.String("sso"),
// },
// },
// &EntityTagsTagArgs{
// Key: pulumi.String("owner"),
// Values: pulumi.StringArray{
// pulumi.String("identityTeam"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// # For up-to-date documentation about the tagging resource, please check EntityTags
//
// ## Import
//
// # New Relic Service Levels can be imported using a concatenated string of the format
//
// `<account_id>:<sli_id>:<guid>`, where the `guid` is the entity the SLI relates to. Examplebash
//
// ```sh
//
// $ pulumi import newrelic:index/serviceLevel:ServiceLevel foo 12345678:4321:MXxBUE18QVBQTElDQVRJT058MQ
//
// ```
type ServiceLevel struct {
pulumi.CustomResourceState
// The description of the SLI.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
Events ServiceLevelEventsOutput `pulumi:"events"`
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
Guid pulumi.StringOutput `pulumi:"guid"`
// A short name for the SLI that will help anyone understand what it is about.
Name pulumi.StringOutput `pulumi:"name"`
// The objective of the SLI, only one can be defined.
// See Objective below for details.
Objective ServiceLevelObjectiveOutput `pulumi:"objective"`
// The unique entity identifier of the Service Level Indicator in New Relic.
SliGuid pulumi.StringOutput `pulumi:"sliGuid"`
// The unique entity identifier of the Service Level Indicator.
SliId pulumi.StringOutput `pulumi:"sliId"`
}
// NewServiceLevel registers a new resource with the given unique name, arguments, and options.
func NewServiceLevel(ctx *pulumi.Context,
name string, args *ServiceLevelArgs, opts ...pulumi.ResourceOption) (*ServiceLevel, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Events == nil {
return nil, errors.New("invalid value for required argument 'Events'")
}
if args.Guid == nil {
return nil, errors.New("invalid value for required argument 'Guid'")
}
if args.Objective == nil {
return nil, errors.New("invalid value for required argument 'Objective'")
}
var resource ServiceLevel
err := ctx.RegisterResource("newrelic:index/serviceLevel:ServiceLevel", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetServiceLevel gets an existing ServiceLevel 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 GetServiceLevel(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ServiceLevelState, opts ...pulumi.ResourceOption) (*ServiceLevel, error) {
var resource ServiceLevel
err := ctx.ReadResource("newrelic:index/serviceLevel:ServiceLevel", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ServiceLevel resources.
type serviceLevelState struct {
// The description of the SLI.
Description *string `pulumi:"description"`
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
Events *ServiceLevelEvents `pulumi:"events"`
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
Guid *string `pulumi:"guid"`
// A short name for the SLI that will help anyone understand what it is about.
Name *string `pulumi:"name"`
// The objective of the SLI, only one can be defined.
// See Objective below for details.
Objective *ServiceLevelObjective `pulumi:"objective"`
// The unique entity identifier of the Service Level Indicator in New Relic.
SliGuid *string `pulumi:"sliGuid"`
// The unique entity identifier of the Service Level Indicator.
SliId *string `pulumi:"sliId"`
}
type ServiceLevelState struct {
// The description of the SLI.
Description pulumi.StringPtrInput
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
Events ServiceLevelEventsPtrInput
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
Guid pulumi.StringPtrInput
// A short name for the SLI that will help anyone understand what it is about.
Name pulumi.StringPtrInput
// The objective of the SLI, only one can be defined.
// See Objective below for details.
Objective ServiceLevelObjectivePtrInput
// The unique entity identifier of the Service Level Indicator in New Relic.
SliGuid pulumi.StringPtrInput
// The unique entity identifier of the Service Level Indicator.
SliId pulumi.StringPtrInput
}
func (ServiceLevelState) ElementType() reflect.Type {
return reflect.TypeOf((*serviceLevelState)(nil)).Elem()
}
type serviceLevelArgs struct {
// The description of the SLI.
Description *string `pulumi:"description"`
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
Events ServiceLevelEvents `pulumi:"events"`
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
Guid string `pulumi:"guid"`
// A short name for the SLI that will help anyone understand what it is about.
Name *string `pulumi:"name"`
// The objective of the SLI, only one can be defined.
// See Objective below for details.
Objective ServiceLevelObjective `pulumi:"objective"`
}
// The set of arguments for constructing a ServiceLevel resource.
type ServiceLevelArgs struct {
// The description of the SLI.
Description pulumi.StringPtrInput
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
Events ServiceLevelEventsInput
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
Guid pulumi.StringInput
// A short name for the SLI that will help anyone understand what it is about.
Name pulumi.StringPtrInput
// The objective of the SLI, only one can be defined.
// See Objective below for details.
Objective ServiceLevelObjectiveInput
}
func (ServiceLevelArgs) ElementType() reflect.Type {
return reflect.TypeOf((*serviceLevelArgs)(nil)).Elem()
}
type ServiceLevelInput interface {
pulumi.Input
ToServiceLevelOutput() ServiceLevelOutput
ToServiceLevelOutputWithContext(ctx context.Context) ServiceLevelOutput
}
func (*ServiceLevel) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceLevel)(nil)).Elem()
}
func (i *ServiceLevel) ToServiceLevelOutput() ServiceLevelOutput {
return i.ToServiceLevelOutputWithContext(context.Background())
}
func (i *ServiceLevel) ToServiceLevelOutputWithContext(ctx context.Context) ServiceLevelOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceLevelOutput)
}
// ServiceLevelArrayInput is an input type that accepts ServiceLevelArray and ServiceLevelArrayOutput values.
// You can construct a concrete instance of `ServiceLevelArrayInput` via:
//
// ServiceLevelArray{ ServiceLevelArgs{...} }
type ServiceLevelArrayInput interface {
pulumi.Input
ToServiceLevelArrayOutput() ServiceLevelArrayOutput
ToServiceLevelArrayOutputWithContext(context.Context) ServiceLevelArrayOutput
}
type ServiceLevelArray []ServiceLevelInput
func (ServiceLevelArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ServiceLevel)(nil)).Elem()
}
func (i ServiceLevelArray) ToServiceLevelArrayOutput() ServiceLevelArrayOutput {
return i.ToServiceLevelArrayOutputWithContext(context.Background())
}
func (i ServiceLevelArray) ToServiceLevelArrayOutputWithContext(ctx context.Context) ServiceLevelArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceLevelArrayOutput)
}
// ServiceLevelMapInput is an input type that accepts ServiceLevelMap and ServiceLevelMapOutput values.
// You can construct a concrete instance of `ServiceLevelMapInput` via:
//
// ServiceLevelMap{ "key": ServiceLevelArgs{...} }
type ServiceLevelMapInput interface {
pulumi.Input
ToServiceLevelMapOutput() ServiceLevelMapOutput
ToServiceLevelMapOutputWithContext(context.Context) ServiceLevelMapOutput
}
type ServiceLevelMap map[string]ServiceLevelInput
func (ServiceLevelMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ServiceLevel)(nil)).Elem()
}
func (i ServiceLevelMap) ToServiceLevelMapOutput() ServiceLevelMapOutput {
return i.ToServiceLevelMapOutputWithContext(context.Background())
}
func (i ServiceLevelMap) ToServiceLevelMapOutputWithContext(ctx context.Context) ServiceLevelMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceLevelMapOutput)
}
type ServiceLevelOutput struct{ *pulumi.OutputState }
func (ServiceLevelOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceLevel)(nil)).Elem()
}
func (o ServiceLevelOutput) ToServiceLevelOutput() ServiceLevelOutput {
return o
}
func (o ServiceLevelOutput) ToServiceLevelOutputWithContext(ctx context.Context) ServiceLevelOutput {
return o
}
// The description of the SLI.
func (o ServiceLevelOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ServiceLevel) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// The events that define the NRDB data for the SLI/SLO calculations.
// See Events below for details.
func (o ServiceLevelOutput) Events() ServiceLevelEventsOutput {
return o.ApplyT(func(v *ServiceLevel) ServiceLevelEventsOutput { return v.Events }).(ServiceLevelEventsOutput)
}
// The GUID of the entity (e.g, APM Service, Browser application, Workload, etc.) that you want to relate this SLI to. Note that changing the GUID will force a new resource.
func (o ServiceLevelOutput) Guid() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceLevel) pulumi.StringOutput { return v.Guid }).(pulumi.StringOutput)
}
// A short name for the SLI that will help anyone understand what it is about.
func (o ServiceLevelOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceLevel) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The objective of the SLI, only one can be defined.
// See Objective below for details.
func (o ServiceLevelOutput) Objective() ServiceLevelObjectiveOutput {
return o.ApplyT(func(v *ServiceLevel) ServiceLevelObjectiveOutput { return v.Objective }).(ServiceLevelObjectiveOutput)
}
// The unique entity identifier of the Service Level Indicator in New Relic.
func (o ServiceLevelOutput) SliGuid() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceLevel) pulumi.StringOutput { return v.SliGuid }).(pulumi.StringOutput)
}
// The unique entity identifier of the Service Level Indicator.
func (o ServiceLevelOutput) SliId() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceLevel) pulumi.StringOutput { return v.SliId }).(pulumi.StringOutput)
}
type ServiceLevelArrayOutput struct{ *pulumi.OutputState }
func (ServiceLevelArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ServiceLevel)(nil)).Elem()
}
func (o ServiceLevelArrayOutput) ToServiceLevelArrayOutput() ServiceLevelArrayOutput {
return o
}
func (o ServiceLevelArrayOutput) ToServiceLevelArrayOutputWithContext(ctx context.Context) ServiceLevelArrayOutput {
return o
}
func (o ServiceLevelArrayOutput) Index(i pulumi.IntInput) ServiceLevelOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ServiceLevel {
return vs[0].([]*ServiceLevel)[vs[1].(int)]
}).(ServiceLevelOutput)
}
type ServiceLevelMapOutput struct{ *pulumi.OutputState }
func (ServiceLevelMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ServiceLevel)(nil)).Elem()
}
func (o ServiceLevelMapOutput) ToServiceLevelMapOutput() ServiceLevelMapOutput {
return o
}
func (o ServiceLevelMapOutput) ToServiceLevelMapOutputWithContext(ctx context.Context) ServiceLevelMapOutput {
return o
}
func (o ServiceLevelMapOutput) MapIndex(k pulumi.StringInput) ServiceLevelOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ServiceLevel {
return vs[0].(map[string]*ServiceLevel)[vs[1].(string)]
}).(ServiceLevelOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ServiceLevelInput)(nil)).Elem(), &ServiceLevel{})
pulumi.RegisterInputType(reflect.TypeOf((*ServiceLevelArrayInput)(nil)).Elem(), ServiceLevelArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ServiceLevelMapInput)(nil)).Elem(), ServiceLevelMap{})
pulumi.RegisterOutputType(ServiceLevelOutput{})
pulumi.RegisterOutputType(ServiceLevelArrayOutput{})
pulumi.RegisterOutputType(ServiceLevelMapOutput{})
}