/
projectResources.go
283 lines (237 loc) · 9.48 KB
/
projectResources.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
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package digitalocean
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Assign resources to a DigitalOcean Project. This is useful if you need to assign resources
// managed via this provider to a DigitalOcean Project managed outside of the provider.
//
// The following resource types can be associated with a project:
//
// * Database Clusters
// * Domains
// * Droplets
// * Floating IP
// * Kubernetes Cluster
// * Load Balancers
// * Spaces Bucket
// * Volume
//
// ## Example Usage
//
// The following example assigns a droplet to a Project managed outside of the provider:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.LookupProject(ctx, &GetProjectArgs{
// Name: pulumi.StringRef("playground"),
// }, nil)
// if err != nil {
// return err
// }
// foobar, err := digitalocean.NewDroplet(ctx, "foobar", &digitalocean.DropletArgs{
// Size: pulumi.String("s-1vcpu-1gb"),
// Image: pulumi.String("centos-7-x64"),
// Region: pulumi.String("nyc3"),
// })
// if err != nil {
// return err
// }
// _, err = digitalocean.NewProjectResources(ctx, "barfoo", &digitalocean.ProjectResourcesArgs{
// Project: pulumi.Any(data.Digitalocean_project.Foo.Id),
// Resources: pulumi.StringArray{
// foobar.DropletUrn,
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Importing this resource is not supported.
type ProjectResources struct {
pulumi.CustomResourceState
// the ID of the project
Project pulumi.StringOutput `pulumi:"project"`
// a list of uniform resource names (URNs) for the resources associated with the project
Resources pulumi.StringArrayOutput `pulumi:"resources"`
}
// NewProjectResources registers a new resource with the given unique name, arguments, and options.
func NewProjectResources(ctx *pulumi.Context,
name string, args *ProjectResourcesArgs, opts ...pulumi.ResourceOption) (*ProjectResources, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Project == nil {
return nil, errors.New("invalid value for required argument 'Project'")
}
if args.Resources == nil {
return nil, errors.New("invalid value for required argument 'Resources'")
}
var resource ProjectResources
err := ctx.RegisterResource("digitalocean:index/projectResources:ProjectResources", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetProjectResources gets an existing ProjectResources 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 GetProjectResources(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ProjectResourcesState, opts ...pulumi.ResourceOption) (*ProjectResources, error) {
var resource ProjectResources
err := ctx.ReadResource("digitalocean:index/projectResources:ProjectResources", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ProjectResources resources.
type projectResourcesState struct {
// the ID of the project
Project *string `pulumi:"project"`
// a list of uniform resource names (URNs) for the resources associated with the project
Resources []string `pulumi:"resources"`
}
type ProjectResourcesState struct {
// the ID of the project
Project pulumi.StringPtrInput
// a list of uniform resource names (URNs) for the resources associated with the project
Resources pulumi.StringArrayInput
}
func (ProjectResourcesState) ElementType() reflect.Type {
return reflect.TypeOf((*projectResourcesState)(nil)).Elem()
}
type projectResourcesArgs struct {
// the ID of the project
Project string `pulumi:"project"`
// a list of uniform resource names (URNs) for the resources associated with the project
Resources []string `pulumi:"resources"`
}
// The set of arguments for constructing a ProjectResources resource.
type ProjectResourcesArgs struct {
// the ID of the project
Project pulumi.StringInput
// a list of uniform resource names (URNs) for the resources associated with the project
Resources pulumi.StringArrayInput
}
func (ProjectResourcesArgs) ElementType() reflect.Type {
return reflect.TypeOf((*projectResourcesArgs)(nil)).Elem()
}
type ProjectResourcesInput interface {
pulumi.Input
ToProjectResourcesOutput() ProjectResourcesOutput
ToProjectResourcesOutputWithContext(ctx context.Context) ProjectResourcesOutput
}
func (*ProjectResources) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectResources)(nil)).Elem()
}
func (i *ProjectResources) ToProjectResourcesOutput() ProjectResourcesOutput {
return i.ToProjectResourcesOutputWithContext(context.Background())
}
func (i *ProjectResources) ToProjectResourcesOutputWithContext(ctx context.Context) ProjectResourcesOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectResourcesOutput)
}
// ProjectResourcesArrayInput is an input type that accepts ProjectResourcesArray and ProjectResourcesArrayOutput values.
// You can construct a concrete instance of `ProjectResourcesArrayInput` via:
//
// ProjectResourcesArray{ ProjectResourcesArgs{...} }
type ProjectResourcesArrayInput interface {
pulumi.Input
ToProjectResourcesArrayOutput() ProjectResourcesArrayOutput
ToProjectResourcesArrayOutputWithContext(context.Context) ProjectResourcesArrayOutput
}
type ProjectResourcesArray []ProjectResourcesInput
func (ProjectResourcesArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectResources)(nil)).Elem()
}
func (i ProjectResourcesArray) ToProjectResourcesArrayOutput() ProjectResourcesArrayOutput {
return i.ToProjectResourcesArrayOutputWithContext(context.Background())
}
func (i ProjectResourcesArray) ToProjectResourcesArrayOutputWithContext(ctx context.Context) ProjectResourcesArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectResourcesArrayOutput)
}
// ProjectResourcesMapInput is an input type that accepts ProjectResourcesMap and ProjectResourcesMapOutput values.
// You can construct a concrete instance of `ProjectResourcesMapInput` via:
//
// ProjectResourcesMap{ "key": ProjectResourcesArgs{...} }
type ProjectResourcesMapInput interface {
pulumi.Input
ToProjectResourcesMapOutput() ProjectResourcesMapOutput
ToProjectResourcesMapOutputWithContext(context.Context) ProjectResourcesMapOutput
}
type ProjectResourcesMap map[string]ProjectResourcesInput
func (ProjectResourcesMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectResources)(nil)).Elem()
}
func (i ProjectResourcesMap) ToProjectResourcesMapOutput() ProjectResourcesMapOutput {
return i.ToProjectResourcesMapOutputWithContext(context.Background())
}
func (i ProjectResourcesMap) ToProjectResourcesMapOutputWithContext(ctx context.Context) ProjectResourcesMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ProjectResourcesMapOutput)
}
type ProjectResourcesOutput struct{ *pulumi.OutputState }
func (ProjectResourcesOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ProjectResources)(nil)).Elem()
}
func (o ProjectResourcesOutput) ToProjectResourcesOutput() ProjectResourcesOutput {
return o
}
func (o ProjectResourcesOutput) ToProjectResourcesOutputWithContext(ctx context.Context) ProjectResourcesOutput {
return o
}
type ProjectResourcesArrayOutput struct{ *pulumi.OutputState }
func (ProjectResourcesArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ProjectResources)(nil)).Elem()
}
func (o ProjectResourcesArrayOutput) ToProjectResourcesArrayOutput() ProjectResourcesArrayOutput {
return o
}
func (o ProjectResourcesArrayOutput) ToProjectResourcesArrayOutputWithContext(ctx context.Context) ProjectResourcesArrayOutput {
return o
}
func (o ProjectResourcesArrayOutput) Index(i pulumi.IntInput) ProjectResourcesOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ProjectResources {
return vs[0].([]*ProjectResources)[vs[1].(int)]
}).(ProjectResourcesOutput)
}
type ProjectResourcesMapOutput struct{ *pulumi.OutputState }
func (ProjectResourcesMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ProjectResources)(nil)).Elem()
}
func (o ProjectResourcesMapOutput) ToProjectResourcesMapOutput() ProjectResourcesMapOutput {
return o
}
func (o ProjectResourcesMapOutput) ToProjectResourcesMapOutputWithContext(ctx context.Context) ProjectResourcesMapOutput {
return o
}
func (o ProjectResourcesMapOutput) MapIndex(k pulumi.StringInput) ProjectResourcesOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ProjectResources {
return vs[0].(map[string]*ProjectResources)[vs[1].(string)]
}).(ProjectResourcesOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ProjectResourcesInput)(nil)).Elem(), &ProjectResources{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectResourcesArrayInput)(nil)).Elem(), ProjectResourcesArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ProjectResourcesMapInput)(nil)).Elem(), ProjectResourcesMap{})
pulumi.RegisterOutputType(ProjectResourcesOutput{})
pulumi.RegisterOutputType(ProjectResourcesArrayOutput{})
pulumi.RegisterOutputType(ProjectResourcesMapOutput{})
}