/
userGpgKey.go
315 lines (265 loc) · 10.7 KB
/
userGpgKey.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
// 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 `UserGpgKey` resource allows to manage the lifecycle of a GPG key assigned to the current user or a specific user.
//
// > Managing GPG keys for arbitrary users requires admin privileges.
//
// **Upstream API**: [GitLab REST API docs](https://docs.gitlab.com/ee/api/users.html#get-a-specific-gpg-key)
//
// ## 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 {
// exampleUser, err := gitlab.LookupUser(ctx, &gitlab.LookupUserArgs{
// Username: pulumi.StringRef("example-user"),
// }, nil)
// if err != nil {
// return err
// }
// _, err = gitlab.NewUserGpgKey(ctx, "exampleUserGpgKey", &gitlab.UserGpgKeyArgs{
// UserId: *pulumi.String(exampleUser.Id),
// Key: pulumi.String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"),
// })
// if err != nil {
// return err
// }
// _, err = gitlab.NewUserGpgKey(ctx, "exampleUserUserGpgKey", &gitlab.UserGpgKeyArgs{
// Key: pulumi.String("-----BEGIN PGP PUBLIC KEY BLOCK-----\n...\n-----END PGP PUBLIC KEY BLOCK-----"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// You can import a GPG key for a specific user using an id made up of `{user-id}:{key}`, e.g.
//
// ```sh
//
// $ pulumi import gitlab:index/userGpgKey:UserGpgKey example 42:1
//
// ```
//
// Alternatively, you can import a GPG key for the current user using an id made up of `{key}`, e.g.
//
// ```sh
//
// $ pulumi import gitlab:index/userGpgKey:UserGpgKey example_user 1
//
// ```
type UserGpgKey struct {
pulumi.CustomResourceState
// The time when this key was created in GitLab.
CreatedAt pulumi.StringOutput `pulumi:"createdAt"`
// The armored GPG public key.
Key pulumi.StringOutput `pulumi:"key"`
// The ID of the GPG key.
KeyId pulumi.IntOutput `pulumi:"keyId"`
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
UserId pulumi.IntPtrOutput `pulumi:"userId"`
}
// NewUserGpgKey registers a new resource with the given unique name, arguments, and options.
func NewUserGpgKey(ctx *pulumi.Context,
name string, args *UserGpgKeyArgs, opts ...pulumi.ResourceOption) (*UserGpgKey, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Key == nil {
return nil, errors.New("invalid value for required argument 'Key'")
}
var resource UserGpgKey
err := ctx.RegisterResource("gitlab:index/userGpgKey:UserGpgKey", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetUserGpgKey gets an existing UserGpgKey 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 GetUserGpgKey(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *UserGpgKeyState, opts ...pulumi.ResourceOption) (*UserGpgKey, error) {
var resource UserGpgKey
err := ctx.ReadResource("gitlab:index/userGpgKey:UserGpgKey", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering UserGpgKey resources.
type userGpgKeyState struct {
// The time when this key was created in GitLab.
CreatedAt *string `pulumi:"createdAt"`
// The armored GPG public key.
Key *string `pulumi:"key"`
// The ID of the GPG key.
KeyId *int `pulumi:"keyId"`
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
UserId *int `pulumi:"userId"`
}
type UserGpgKeyState struct {
// The time when this key was created in GitLab.
CreatedAt pulumi.StringPtrInput
// The armored GPG public key.
Key pulumi.StringPtrInput
// The ID of the GPG key.
KeyId pulumi.IntPtrInput
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
UserId pulumi.IntPtrInput
}
func (UserGpgKeyState) ElementType() reflect.Type {
return reflect.TypeOf((*userGpgKeyState)(nil)).Elem()
}
type userGpgKeyArgs struct {
// The armored GPG public key.
Key string `pulumi:"key"`
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
UserId *int `pulumi:"userId"`
}
// The set of arguments for constructing a UserGpgKey resource.
type UserGpgKeyArgs struct {
// The armored GPG public key.
Key pulumi.StringInput
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
UserId pulumi.IntPtrInput
}
func (UserGpgKeyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*userGpgKeyArgs)(nil)).Elem()
}
type UserGpgKeyInput interface {
pulumi.Input
ToUserGpgKeyOutput() UserGpgKeyOutput
ToUserGpgKeyOutputWithContext(ctx context.Context) UserGpgKeyOutput
}
func (*UserGpgKey) ElementType() reflect.Type {
return reflect.TypeOf((**UserGpgKey)(nil)).Elem()
}
func (i *UserGpgKey) ToUserGpgKeyOutput() UserGpgKeyOutput {
return i.ToUserGpgKeyOutputWithContext(context.Background())
}
func (i *UserGpgKey) ToUserGpgKeyOutputWithContext(ctx context.Context) UserGpgKeyOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserGpgKeyOutput)
}
// UserGpgKeyArrayInput is an input type that accepts UserGpgKeyArray and UserGpgKeyArrayOutput values.
// You can construct a concrete instance of `UserGpgKeyArrayInput` via:
//
// UserGpgKeyArray{ UserGpgKeyArgs{...} }
type UserGpgKeyArrayInput interface {
pulumi.Input
ToUserGpgKeyArrayOutput() UserGpgKeyArrayOutput
ToUserGpgKeyArrayOutputWithContext(context.Context) UserGpgKeyArrayOutput
}
type UserGpgKeyArray []UserGpgKeyInput
func (UserGpgKeyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserGpgKey)(nil)).Elem()
}
func (i UserGpgKeyArray) ToUserGpgKeyArrayOutput() UserGpgKeyArrayOutput {
return i.ToUserGpgKeyArrayOutputWithContext(context.Background())
}
func (i UserGpgKeyArray) ToUserGpgKeyArrayOutputWithContext(ctx context.Context) UserGpgKeyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserGpgKeyArrayOutput)
}
// UserGpgKeyMapInput is an input type that accepts UserGpgKeyMap and UserGpgKeyMapOutput values.
// You can construct a concrete instance of `UserGpgKeyMapInput` via:
//
// UserGpgKeyMap{ "key": UserGpgKeyArgs{...} }
type UserGpgKeyMapInput interface {
pulumi.Input
ToUserGpgKeyMapOutput() UserGpgKeyMapOutput
ToUserGpgKeyMapOutputWithContext(context.Context) UserGpgKeyMapOutput
}
type UserGpgKeyMap map[string]UserGpgKeyInput
func (UserGpgKeyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserGpgKey)(nil)).Elem()
}
func (i UserGpgKeyMap) ToUserGpgKeyMapOutput() UserGpgKeyMapOutput {
return i.ToUserGpgKeyMapOutputWithContext(context.Background())
}
func (i UserGpgKeyMap) ToUserGpgKeyMapOutputWithContext(ctx context.Context) UserGpgKeyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserGpgKeyMapOutput)
}
type UserGpgKeyOutput struct{ *pulumi.OutputState }
func (UserGpgKeyOutput) ElementType() reflect.Type {
return reflect.TypeOf((**UserGpgKey)(nil)).Elem()
}
func (o UserGpgKeyOutput) ToUserGpgKeyOutput() UserGpgKeyOutput {
return o
}
func (o UserGpgKeyOutput) ToUserGpgKeyOutputWithContext(ctx context.Context) UserGpgKeyOutput {
return o
}
// The time when this key was created in GitLab.
func (o UserGpgKeyOutput) CreatedAt() pulumi.StringOutput {
return o.ApplyT(func(v *UserGpgKey) pulumi.StringOutput { return v.CreatedAt }).(pulumi.StringOutput)
}
// The armored GPG public key.
func (o UserGpgKeyOutput) Key() pulumi.StringOutput {
return o.ApplyT(func(v *UserGpgKey) pulumi.StringOutput { return v.Key }).(pulumi.StringOutput)
}
// The ID of the GPG key.
func (o UserGpgKeyOutput) KeyId() pulumi.IntOutput {
return o.ApplyT(func(v *UserGpgKey) pulumi.IntOutput { return v.KeyId }).(pulumi.IntOutput)
}
// The ID of the user to add the GPG key to. If this field is omitted, this resource manages a GPG key for the current user. Otherwise, this resource manages a GPG key for the speicifed user, and an admin token is required.
func (o UserGpgKeyOutput) UserId() pulumi.IntPtrOutput {
return o.ApplyT(func(v *UserGpgKey) pulumi.IntPtrOutput { return v.UserId }).(pulumi.IntPtrOutput)
}
type UserGpgKeyArrayOutput struct{ *pulumi.OutputState }
func (UserGpgKeyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserGpgKey)(nil)).Elem()
}
func (o UserGpgKeyArrayOutput) ToUserGpgKeyArrayOutput() UserGpgKeyArrayOutput {
return o
}
func (o UserGpgKeyArrayOutput) ToUserGpgKeyArrayOutputWithContext(ctx context.Context) UserGpgKeyArrayOutput {
return o
}
func (o UserGpgKeyArrayOutput) Index(i pulumi.IntInput) UserGpgKeyOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserGpgKey {
return vs[0].([]*UserGpgKey)[vs[1].(int)]
}).(UserGpgKeyOutput)
}
type UserGpgKeyMapOutput struct{ *pulumi.OutputState }
func (UserGpgKeyMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserGpgKey)(nil)).Elem()
}
func (o UserGpgKeyMapOutput) ToUserGpgKeyMapOutput() UserGpgKeyMapOutput {
return o
}
func (o UserGpgKeyMapOutput) ToUserGpgKeyMapOutputWithContext(ctx context.Context) UserGpgKeyMapOutput {
return o
}
func (o UserGpgKeyMapOutput) MapIndex(k pulumi.StringInput) UserGpgKeyOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserGpgKey {
return vs[0].(map[string]*UserGpgKey)[vs[1].(string)]
}).(UserGpgKeyOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*UserGpgKeyInput)(nil)).Elem(), &UserGpgKey{})
pulumi.RegisterInputType(reflect.TypeOf((*UserGpgKeyArrayInput)(nil)).Elem(), UserGpgKeyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*UserGpgKeyMapInput)(nil)).Elem(), UserGpgKeyMap{})
pulumi.RegisterOutputType(UserGpgKeyOutput{})
pulumi.RegisterOutputType(UserGpgKeyArrayOutput{})
pulumi.RegisterOutputType(UserGpgKeyMapOutput{})
}