/
projectMembership.go
319 lines (269 loc) · 11.5 KB
/
projectMembership.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
// 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 gitlab
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The `ProjectMembership` resource allows to manage the lifecycle of a users project membersip.
//
// > If a project should grant membership to an entire group use the `ProjectShareGroup` resource instead.
//
// **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/members.html)
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gitlab/sdk/v4/go/gitlab"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := gitlab.NewProjectMembership(ctx, "test", &gitlab.ProjectMembershipArgs{
// AccessLevel: pulumi.String("guest"),
// ProjectId: pulumi.String("12345"),
// UserId: pulumi.Int(1337),
// })
// if err != nil {
// return err
// }
// _, err = gitlab.NewProjectMembership(ctx, "example", &gitlab.ProjectMembershipArgs{
// AccessLevel: pulumi.String("guest"),
// ExpiresAt: pulumi.String("2022-12-31"),
// ProjectId: pulumi.String("67890"),
// UserId: pulumi.Int(1234),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// GitLab project membership can be imported using an id made up of `project_id:user_id`, e.g.
//
// ```sh
//
// $ pulumi import gitlab:index/projectMembership:ProjectMembership test "12345:1337"
//
// ```
type ProjectMembership struct {
pulumi.CustomResourceState
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
AccessLevel pulumi.StringOutput `pulumi:"accessLevel"`
// Expiration date for the project membership. Format: `YYYY-MM-DD`
ExpiresAt pulumi.StringPtrOutput `pulumi:"expiresAt"`
// The id of the project.
ProjectId pulumi.StringOutput `pulumi:"projectId"`
// The id of the user.
UserId pulumi.IntOutput `pulumi:"userId"`
}
// NewProjectMembership registers a new resource with the given unique name, arguments, and options.
func NewProjectMembership(ctx *pulumi.Context,
name string, args *ProjectMembershipArgs, opts ...pulumi.ResourceOption) (*ProjectMembership, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AccessLevel == nil {
return nil, errors.New("invalid value for required argument 'AccessLevel'")
}
if args.ProjectId == nil {
return nil, errors.New("invalid value for required argument 'ProjectId'")
}
if args.UserId == nil {
return nil, errors.New("invalid value for required argument 'UserId'")
}
var resource ProjectMembership
err := ctx.RegisterResource("gitlab:index/projectMembership:ProjectMembership", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProjectMembership gets an existing ProjectMembership 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 GetProjectMembership(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProjectMembershipState, opts ...pulumi.ResourceOption) (*ProjectMembership, error) {
var resource ProjectMembership
err := ctx.ReadResource("gitlab:index/projectMembership:ProjectMembership", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ProjectMembership resources.
type projectMembershipState struct {
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
AccessLevel *string `pulumi:"accessLevel"`
// Expiration date for the project membership. Format: `YYYY-MM-DD`
ExpiresAt *string `pulumi:"expiresAt"`
// The id of the project.
ProjectId *string `pulumi:"projectId"`
// The id of the user.
UserId *int `pulumi:"userId"`
}
type ProjectMembershipState struct {
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
AccessLevel pulumi.StringPtrInput
// Expiration date for the project membership. Format: `YYYY-MM-DD`
ExpiresAt pulumi.StringPtrInput
// The id of the project.
ProjectId pulumi.StringPtrInput
// The id of the user.
UserId pulumi.IntPtrInput
}
func (ProjectMembershipState) ElementType() reflect.Type {
return reflect.TypeOf((*projectMembershipState)(nil)).Elem()
}
type projectMembershipArgs struct {
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
AccessLevel string `pulumi:"accessLevel"`
// Expiration date for the project membership. Format: `YYYY-MM-DD`
ExpiresAt *string `pulumi:"expiresAt"`
// The id of the project.
ProjectId string `pulumi:"projectId"`
// The id of the user.
UserId int `pulumi:"userId"`
}
// The set of arguments for constructing a ProjectMembership resource.
type ProjectMembershipArgs struct {
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
AccessLevel pulumi.StringInput
// Expiration date for the project membership. Format: `YYYY-MM-DD`
ExpiresAt pulumi.StringPtrInput
// The id of the project.
ProjectId pulumi.StringInput
// The id of the user.
UserId pulumi.IntInput
}
func (ProjectMembershipArgs) ElementType() reflect.Type {
return reflect.TypeOf((*projectMembershipArgs)(nil)).Elem()
}
type ProjectMembershipInput interface {
pulumi.Input
ToProjectMembershipOutput() ProjectMembershipOutput
ToProjectMembershipOutputWithContext(ctx context.Context) ProjectMembershipOutput
}
func (*ProjectMembership) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectMembership)(nil)).Elem()
}
func (i *ProjectMembership) ToProjectMembershipOutput() ProjectMembershipOutput {
return i.ToProjectMembershipOutputWithContext(context.Background())
}
func (i *ProjectMembership) ToProjectMembershipOutputWithContext(ctx context.Context) ProjectMembershipOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectMembershipOutput)
}
// ProjectMembershipArrayInput is an input type that accepts ProjectMembershipArray and ProjectMembershipArrayOutput values.
// You can construct a concrete instance of `ProjectMembershipArrayInput` via:
//
// ProjectMembershipArray{ ProjectMembershipArgs{...} }
type ProjectMembershipArrayInput interface {
pulumi.Input
ToProjectMembershipArrayOutput() ProjectMembershipArrayOutput
ToProjectMembershipArrayOutputWithContext(context.Context) ProjectMembershipArrayOutput
}
type ProjectMembershipArray []ProjectMembershipInput
func (ProjectMembershipArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectMembership)(nil)).Elem()
}
func (i ProjectMembershipArray) ToProjectMembershipArrayOutput() ProjectMembershipArrayOutput {
return i.ToProjectMembershipArrayOutputWithContext(context.Background())
}
func (i ProjectMembershipArray) ToProjectMembershipArrayOutputWithContext(ctx context.Context) ProjectMembershipArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectMembershipArrayOutput)
}
// ProjectMembershipMapInput is an input type that accepts ProjectMembershipMap and ProjectMembershipMapOutput values.
// You can construct a concrete instance of `ProjectMembershipMapInput` via:
//
// ProjectMembershipMap{ "key": ProjectMembershipArgs{...} }
type ProjectMembershipMapInput interface {
pulumi.Input
ToProjectMembershipMapOutput() ProjectMembershipMapOutput
ToProjectMembershipMapOutputWithContext(context.Context) ProjectMembershipMapOutput
}
type ProjectMembershipMap map[string]ProjectMembershipInput
func (ProjectMembershipMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectMembership)(nil)).Elem()
}
func (i ProjectMembershipMap) ToProjectMembershipMapOutput() ProjectMembershipMapOutput {
return i.ToProjectMembershipMapOutputWithContext(context.Background())
}
func (i ProjectMembershipMap) ToProjectMembershipMapOutputWithContext(ctx context.Context) ProjectMembershipMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectMembershipMapOutput)
}
type ProjectMembershipOutput struct{ *pulumi.OutputState }
func (ProjectMembershipOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectMembership)(nil)).Elem()
}
func (o ProjectMembershipOutput) ToProjectMembershipOutput() ProjectMembershipOutput {
return o
}
func (o ProjectMembershipOutput) ToProjectMembershipOutputWithContext(ctx context.Context) ProjectMembershipOutput {
return o
}
// The access level for the member. Valid values are: `no one`, `minimal`, `guest`, `reporter`, `developer`, `maintainer`, `owner`, `master`
func (o ProjectMembershipOutput) AccessLevel() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectMembership) pulumi.StringOutput { return v.AccessLevel }).(pulumi.StringOutput)
}
// Expiration date for the project membership. Format: `YYYY-MM-DD`
func (o ProjectMembershipOutput) ExpiresAt() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ProjectMembership) pulumi.StringPtrOutput { return v.ExpiresAt }).(pulumi.StringPtrOutput)
}
// The id of the project.
func (o ProjectMembershipOutput) ProjectId() pulumi.StringOutput {
return o.ApplyT(func(v *ProjectMembership) pulumi.StringOutput { return v.ProjectId }).(pulumi.StringOutput)
}
// The id of the user.
func (o ProjectMembershipOutput) UserId() pulumi.IntOutput {
return o.ApplyT(func(v *ProjectMembership) pulumi.IntOutput { return v.UserId }).(pulumi.IntOutput)
}
type ProjectMembershipArrayOutput struct{ *pulumi.OutputState }
func (ProjectMembershipArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectMembership)(nil)).Elem()
}
func (o ProjectMembershipArrayOutput) ToProjectMembershipArrayOutput() ProjectMembershipArrayOutput {
return o
}
func (o ProjectMembershipArrayOutput) ToProjectMembershipArrayOutputWithContext(ctx context.Context) ProjectMembershipArrayOutput {
return o
}
func (o ProjectMembershipArrayOutput) Index(i pulumi.IntInput) ProjectMembershipOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ProjectMembership {
return vs[0].([]*ProjectMembership)[vs[1].(int)]
}).(ProjectMembershipOutput)
}
type ProjectMembershipMapOutput struct{ *pulumi.OutputState }
func (ProjectMembershipMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectMembership)(nil)).Elem()
}
func (o ProjectMembershipMapOutput) ToProjectMembershipMapOutput() ProjectMembershipMapOutput {
return o
}
func (o ProjectMembershipMapOutput) ToProjectMembershipMapOutputWithContext(ctx context.Context) ProjectMembershipMapOutput {
return o
}
func (o ProjectMembershipMapOutput) MapIndex(k pulumi.StringInput) ProjectMembershipOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ProjectMembership {
return vs[0].(map[string]*ProjectMembership)[vs[1].(string)]
}).(ProjectMembershipOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProjectMembershipInput)(nil)).Elem(), &ProjectMembership{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectMembershipArrayInput)(nil)).Elem(), ProjectMembershipArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectMembershipMapInput)(nil)).Elem(), ProjectMembershipMap{})
pulumi.RegisterOutputType(ProjectMembershipOutput{})
pulumi.RegisterOutputType(ProjectMembershipArrayOutput{})
pulumi.RegisterOutputType(ProjectMembershipMapOutput{})
}