/
getGroup.go
191 lines (173 loc) · 6.59 KB
/
getGroup.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
// 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"
)
// The `Group` data source helps search for a group by its name and retrieve the ID of the matching group and other associated attributes.
//
// ## Example Usage
//
// The below example illustrates fetching the ID of a group (and IDs of users who belong to the group, if any) using the required arguments.
//
// ```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 {
// foo, err := newrelic.GetAuthenticationDomain(ctx, &newrelic.GetAuthenticationDomainArgs{
// Name: "Test Authentication Domain",
// }, nil)
// if err != nil {
// return err
// }
// _, err = newrelic.LookupGroup(ctx, &newrelic.LookupGroupArgs{
// AuthenticationDomainId: foo.Id,
// Name: "Test Group",
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Additional Examples
//
// The following example demonstrates utilizing attributes exported by this data source.
//
// In order to directly reference the attributes `id` and `userIds` from this data source, you can use the syntax `data.newrelic_group.foo.id` and `data.newrelic_group.foo.user_ids`, respectively. However, if you need to assign these values to local variables and perform further processing (such as conditionally formatting the `userIds` attribute as shown in the example below), consider using the provided configuration. These variables can then be accessed elsewhere using the syntax `local.id` and `local.user_id`, respectively.
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
// "github.com/pulumi/pulumi-std/sdk/go/std"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// foo, err := newrelic.GetAuthenticationDomain(ctx, &newrelic.GetAuthenticationDomainArgs{
// Name: "Test Authentication Domain",
// }, nil)
// if err != nil {
// return err
// }
// fooGetGroup, err := newrelic.LookupGroup(ctx, &newrelic.LookupGroupArgs{
// AuthenticationDomainId: foo.Id,
// Name: "Test Group",
// }, nil)
// if err != nil {
// return err
// }
// _ := fooGetGroup.Id
// var tmp0 *string
// if len(fooGetGroup.UserIds) > 0 {
// tmp0 = std.Join(ctx, &std.JoinArgs{
// Separator: ", ",
// Input: fooGetGroup.UserIds,
// }, nil).Result
// } else {
// tmp0 = ""
// }
// _ := tmp0
// return nil
// })
// }
//
// ```
func LookupGroup(ctx *pulumi.Context, args *LookupGroupArgs, opts ...pulumi.InvokeOption) (*LookupGroupResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupGroupResult
err := ctx.Invoke("newrelic:index/getGroup:getGroup", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getGroup.
type LookupGroupArgs struct {
// The ID of the authentication domain the group to be searched for belongs to.
AuthenticationDomainId string `pulumi:"authenticationDomainId"`
// The name of the group to search for.
//
// > **NOTE** The ID of an authentication domain can be retrieved using its name, via the data source `getAuthenticationDomain`, as shown in the example above. Head over to the documentation of this data source for more details and examples.
Name string `pulumi:"name"`
}
// A collection of values returned by getGroup.
type LookupGroupResult struct {
AuthenticationDomainId string `pulumi:"authenticationDomainId"`
// The ID of the fetched matching group.
Id string `pulumi:"id"`
Name string `pulumi:"name"`
// IDs of users who belong to the group. In the absence of any users in the group, the value of this attribute would be an empty list.
UserIds []string `pulumi:"userIds"`
}
func LookupGroupOutput(ctx *pulumi.Context, args LookupGroupOutputArgs, opts ...pulumi.InvokeOption) LookupGroupResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupGroupResult, error) {
args := v.(LookupGroupArgs)
r, err := LookupGroup(ctx, &args, opts...)
var s LookupGroupResult
if r != nil {
s = *r
}
return s, err
}).(LookupGroupResultOutput)
}
// A collection of arguments for invoking getGroup.
type LookupGroupOutputArgs struct {
// The ID of the authentication domain the group to be searched for belongs to.
AuthenticationDomainId pulumi.StringInput `pulumi:"authenticationDomainId"`
// The name of the group to search for.
//
// > **NOTE** The ID of an authentication domain can be retrieved using its name, via the data source `getAuthenticationDomain`, as shown in the example above. Head over to the documentation of this data source for more details and examples.
Name pulumi.StringInput `pulumi:"name"`
}
func (LookupGroupOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupGroupArgs)(nil)).Elem()
}
// A collection of values returned by getGroup.
type LookupGroupResultOutput struct{ *pulumi.OutputState }
func (LookupGroupResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupGroupResult)(nil)).Elem()
}
func (o LookupGroupResultOutput) ToLookupGroupResultOutput() LookupGroupResultOutput {
return o
}
func (o LookupGroupResultOutput) ToLookupGroupResultOutputWithContext(ctx context.Context) LookupGroupResultOutput {
return o
}
func (o LookupGroupResultOutput) AuthenticationDomainId() pulumi.StringOutput {
return o.ApplyT(func(v LookupGroupResult) string { return v.AuthenticationDomainId }).(pulumi.StringOutput)
}
// The ID of the fetched matching group.
func (o LookupGroupResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupGroupResult) string { return v.Id }).(pulumi.StringOutput)
}
func (o LookupGroupResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v LookupGroupResult) string { return v.Name }).(pulumi.StringOutput)
}
// IDs of users who belong to the group. In the absence of any users in the group, the value of this attribute would be an empty list.
func (o LookupGroupResultOutput) UserIds() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupGroupResult) []string { return v.UserIds }).(pulumi.StringArrayOutput)
}
func init() {
pulumi.RegisterOutputType(LookupGroupResultOutput{})
}