/
getVolumeSnapshot.go
212 lines (187 loc) · 8.25 KB
/
getVolumeSnapshot.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
// *** 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/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Volume snapshots are saved instances of a block storage volume. Use this data
// source to retrieve the ID of a DigitalOcean volume snapshot for use in other
// resources.
//
// ## Example Usage
//
// Get the volume snapshot:
//
// ```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.LookupVolumeSnapshot(ctx, &GetVolumeSnapshotArgs{
// MostRecent: pulumi.BoolRef(true),
// NameRegex: pulumi.StringRef("^web"),
// Region: pulumi.StringRef("nyc3"),
// }, nil)
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// Reuse the data about a volume snapshot to create a new volume based on it:
//
// ```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 {
// snapshot, err := digitalocean.LookupVolumeSnapshot(ctx, &GetVolumeSnapshotArgs{
// NameRegex: pulumi.StringRef("^web"),
// Region: pulumi.StringRef("nyc3"),
// MostRecent: pulumi.BoolRef(true),
// }, nil)
// if err != nil {
// return err
// }
// _, err = digitalocean.NewVolume(ctx, "foobar", &digitalocean.VolumeArgs{
// Region: pulumi.String("nyc3"),
// Size: pulumi.Int(100),
// SnapshotId: pulumi.String(snapshot.Id),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
func LookupVolumeSnapshot(ctx *pulumi.Context, args *LookupVolumeSnapshotArgs, opts ...pulumi.InvokeOption) (*LookupVolumeSnapshotResult, error) {
var rv LookupVolumeSnapshotResult
err := ctx.Invoke("digitalocean:index/getVolumeSnapshot:getVolumeSnapshot", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getVolumeSnapshot.
type LookupVolumeSnapshotArgs struct {
// If more than one result is returned, use the most recent volume snapshot.
MostRecent *bool `pulumi:"mostRecent"`
// The name of the volume snapshot.
Name *string `pulumi:"name"`
// A regex string to apply to the volume snapshot list returned by DigitalOcean. This allows more advanced filtering not supported from the DigitalOcean API. This filtering is done locally on what DigitalOcean returns.
NameRegex *string `pulumi:"nameRegex"`
// A "slug" representing a DigitalOcean region (e.g. `nyc1`). If set, only volume snapshots available in the region will be returned.
Region *string `pulumi:"region"`
}
// A collection of values returned by getVolumeSnapshot.
type LookupVolumeSnapshotResult struct {
// The date and time the volume snapshot was created.
CreatedAt string `pulumi:"createdAt"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
MinDiskSize int `pulumi:"minDiskSize"`
MostRecent *bool `pulumi:"mostRecent"`
Name *string `pulumi:"name"`
NameRegex *string `pulumi:"nameRegex"`
Region *string `pulumi:"region"`
// A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
Regions []string `pulumi:"regions"`
// The billable size of the volume snapshot in gigabytes.
Size float64 `pulumi:"size"`
// A list of the tags associated to the volume snapshot.
Tags []string `pulumi:"tags"`
// The ID of the volume from which the volume snapshot originated.
VolumeId string `pulumi:"volumeId"`
}
func LookupVolumeSnapshotOutput(ctx *pulumi.Context, args LookupVolumeSnapshotOutputArgs, opts ...pulumi.InvokeOption) LookupVolumeSnapshotResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupVolumeSnapshotResult, error) {
args := v.(LookupVolumeSnapshotArgs)
r, err := LookupVolumeSnapshot(ctx, &args, opts...)
return *r, err
}).(LookupVolumeSnapshotResultOutput)
}
// A collection of arguments for invoking getVolumeSnapshot.
type LookupVolumeSnapshotOutputArgs struct {
// If more than one result is returned, use the most recent volume snapshot.
MostRecent pulumi.BoolPtrInput `pulumi:"mostRecent"`
// The name of the volume snapshot.
Name pulumi.StringPtrInput `pulumi:"name"`
// A regex string to apply to the volume snapshot list returned by DigitalOcean. This allows more advanced filtering not supported from the DigitalOcean API. This filtering is done locally on what DigitalOcean returns.
NameRegex pulumi.StringPtrInput `pulumi:"nameRegex"`
// A "slug" representing a DigitalOcean region (e.g. `nyc1`). If set, only volume snapshots available in the region will be returned.
Region pulumi.StringPtrInput `pulumi:"region"`
}
func (LookupVolumeSnapshotOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupVolumeSnapshotArgs)(nil)).Elem()
}
// A collection of values returned by getVolumeSnapshot.
type LookupVolumeSnapshotResultOutput struct{ *pulumi.OutputState }
func (LookupVolumeSnapshotResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupVolumeSnapshotResult)(nil)).Elem()
}
func (o LookupVolumeSnapshotResultOutput) ToLookupVolumeSnapshotResultOutput() LookupVolumeSnapshotResultOutput {
return o
}
func (o LookupVolumeSnapshotResultOutput) ToLookupVolumeSnapshotResultOutputWithContext(ctx context.Context) LookupVolumeSnapshotResultOutput {
return o
}
// The date and time the volume snapshot was created.
func (o LookupVolumeSnapshotResultOutput) CreatedAt() pulumi.StringOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) string { return v.CreatedAt }).(pulumi.StringOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o LookupVolumeSnapshotResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) string { return v.Id }).(pulumi.StringOutput)
}
// The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
func (o LookupVolumeSnapshotResultOutput) MinDiskSize() pulumi.IntOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) int { return v.MinDiskSize }).(pulumi.IntOutput)
}
func (o LookupVolumeSnapshotResultOutput) MostRecent() pulumi.BoolPtrOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) *bool { return v.MostRecent }).(pulumi.BoolPtrOutput)
}
func (o LookupVolumeSnapshotResultOutput) Name() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) *string { return v.Name }).(pulumi.StringPtrOutput)
}
func (o LookupVolumeSnapshotResultOutput) NameRegex() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) *string { return v.NameRegex }).(pulumi.StringPtrOutput)
}
func (o LookupVolumeSnapshotResultOutput) Region() pulumi.StringPtrOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) *string { return v.Region }).(pulumi.StringPtrOutput)
}
// A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
func (o LookupVolumeSnapshotResultOutput) Regions() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) []string { return v.Regions }).(pulumi.StringArrayOutput)
}
// The billable size of the volume snapshot in gigabytes.
func (o LookupVolumeSnapshotResultOutput) Size() pulumi.Float64Output {
return o.ApplyT(func(v LookupVolumeSnapshotResult) float64 { return v.Size }).(pulumi.Float64Output)
}
// A list of the tags associated to the volume snapshot.
func (o LookupVolumeSnapshotResultOutput) Tags() pulumi.StringArrayOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) []string { return v.Tags }).(pulumi.StringArrayOutput)
}
// The ID of the volume from which the volume snapshot originated.
func (o LookupVolumeSnapshotResultOutput) VolumeId() pulumi.StringOutput {
return o.ApplyT(func(v LookupVolumeSnapshotResult) string { return v.VolumeId }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupVolumeSnapshotResultOutput{})
}