/
getApplication.go
157 lines (139 loc) · 4.92 KB
/
getApplication.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
// 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/pulumi/pulumi-newrelic/sdk/v5/go/newrelic/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// #### DEPRECATED! Use at your own risk. Use the `getEntity` data source instead. This feature may be removed in the next major release
//
// Use this data source to get information about a specific application in New Relic that already exists.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// app, err := newrelic.GetApplication(ctx, &newrelic.GetApplicationArgs{
// Name: "my-app",
// }, nil)
// if err != nil {
// return err
// }
// foo, err := newrelic.NewAlertPolicy(ctx, "foo", &newrelic.AlertPolicyArgs{
// Name: pulumi.String("foo"),
// })
// if err != nil {
// return err
// }
// _, err = newrelic.NewAlertCondition(ctx, "foo", &newrelic.AlertConditionArgs{
// PolicyId: foo.ID(),
// Name: pulumi.String("foo"),
// Type: pulumi.String("apm_app_metric"),
// Entities: pulumi.IntArray{
// pulumi.String(app.Id),
// },
// Metric: pulumi.String("apdex"),
// RunbookUrl: pulumi.String("https://www.example.com"),
// Terms: newrelic.AlertConditionTermArray{
// &newrelic.AlertConditionTermArgs{
// Duration: pulumi.Int(5),
// Operator: pulumi.String("below"),
// Priority: pulumi.String("critical"),
// Threshold: pulumi.Float64(0.75),
// TimeFunction: pulumi.String("all"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
func GetApplication(ctx *pulumi.Context, args *GetApplicationArgs, opts ...pulumi.InvokeOption) (*GetApplicationResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetApplicationResult
err := ctx.Invoke("newrelic:index/getApplication:getApplication", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getApplication.
type GetApplicationArgs struct {
// The name of the application in New Relic.
Name string `pulumi:"name"`
}
// A collection of values returned by getApplication.
type GetApplicationResult struct {
// A list of host IDs associated with the application.
HostIds []int `pulumi:"hostIds"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// A list of instance IDs associated with the application.
InstanceIds []int `pulumi:"instanceIds"`
Name string `pulumi:"name"`
}
func GetApplicationOutput(ctx *pulumi.Context, args GetApplicationOutputArgs, opts ...pulumi.InvokeOption) GetApplicationResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetApplicationResult, error) {
args := v.(GetApplicationArgs)
r, err := GetApplication(ctx, &args, opts...)
var s GetApplicationResult
if r != nil {
s = *r
}
return s, err
}).(GetApplicationResultOutput)
}
// A collection of arguments for invoking getApplication.
type GetApplicationOutputArgs struct {
// The name of the application in New Relic.
Name pulumi.StringInput `pulumi:"name"`
}
func (GetApplicationOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetApplicationArgs)(nil)).Elem()
}
// A collection of values returned by getApplication.
type GetApplicationResultOutput struct{ *pulumi.OutputState }
func (GetApplicationResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetApplicationResult)(nil)).Elem()
}
func (o GetApplicationResultOutput) ToGetApplicationResultOutput() GetApplicationResultOutput {
return o
}
func (o GetApplicationResultOutput) ToGetApplicationResultOutputWithContext(ctx context.Context) GetApplicationResultOutput {
return o
}
// A list of host IDs associated with the application.
func (o GetApplicationResultOutput) HostIds() pulumi.IntArrayOutput {
return o.ApplyT(func(v GetApplicationResult) []int { return v.HostIds }).(pulumi.IntArrayOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetApplicationResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetApplicationResult) string { return v.Id }).(pulumi.StringOutput)
}
// A list of instance IDs associated with the application.
func (o GetApplicationResultOutput) InstanceIds() pulumi.IntArrayOutput {
return o.ApplyT(func(v GetApplicationResult) []int { return v.InstanceIds }).(pulumi.IntArrayOutput)
}
func (o GetApplicationResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v GetApplicationResult) string { return v.Name }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetApplicationResultOutput{})
}