/
backup.go
270 lines (229 loc) · 17.9 KB
/
backup.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
// Code generated by the Pulumi SDK Generator DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package v1
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-google-native/sdk/go/google/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Starts creating a new Cloud Spanner Backup. The returned backup long-running operation will have a name of the format `projects//instances//backups//operations/` and can be used to track creation of the backup. The metadata field type is CreateBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the creation and delete the backup. There can be only one pending backup creation per database. Backup creation of different databases can run concurrently.
type Backup struct {
pulumi.CustomResourceState
// Required. The id of the backup to be created. The `backup_id` appended to `parent` forms the full backup name of the form `projects//instances//backups/`.
BackupId pulumi.StringOutput `pulumi:"backupId"`
// The time the CreateBackup request is received. If the request does not specify `version_time`, the `version_time` of the backup will be equivalent to the `create_time`.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// Required for the CreateBackup operation. Name of the database from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects//instances//databases/`.
Database pulumi.StringOutput `pulumi:"database"`
// The database dialect information for the backup.
DatabaseDialect pulumi.StringOutput `pulumi:"databaseDialect"`
// Required. The encryption type of the backup.
EncryptionConfigEncryptionType pulumi.StringOutput `pulumi:"encryptionConfigEncryptionType"`
// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
EncryptionConfigKmsKeyName pulumi.StringPtrOutput `pulumi:"encryptionConfigKmsKeyName"`
// The encryption information for the backup.
EncryptionInfo EncryptionInfoResponseOutput `pulumi:"encryptionInfo"`
// Required for the CreateBackup operation. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days from the time the CreateBackup request is processed. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
ExpireTime pulumi.StringOutput `pulumi:"expireTime"`
InstanceId pulumi.StringOutput `pulumi:"instanceId"`
// The max allowed expiration time of the backup, with microseconds granularity. A backup's expiration time can be configured in multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or copying an existing backup, the expiration time specified must be less than `Backup.max_expire_time`.
MaxExpireTime pulumi.StringOutput `pulumi:"maxExpireTime"`
// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
Name pulumi.StringOutput `pulumi:"name"`
Project pulumi.StringOutput `pulumi:"project"`
// The names of the destination backups being created by copying this source backup. The backup names are of the form `projects//instances//backups/`. Referencing backups may exist in different instances. The existence of any referencing backup prevents the backup from being deleted. When the copy operation is done (either successfully completed or cancelled or the destination backup is deleted), the reference to the backup is removed.
ReferencingBackups pulumi.StringArrayOutput `pulumi:"referencingBackups"`
// The names of the restored databases that reference the backup. The database names are of the form `projects//instances//databases/`. Referencing databases may exist in different instances. The existence of any referencing database prevents the backup from being deleted. When a restored database from the backup enters the `READY` state, the reference to the backup is removed.
ReferencingDatabases pulumi.StringArrayOutput `pulumi:"referencingDatabases"`
// Size of the backup in bytes.
SizeBytes pulumi.StringOutput `pulumi:"sizeBytes"`
// The current state of the backup.
State pulumi.StringOutput `pulumi:"state"`
// The backup will contain an externally consistent copy of the database at the timestamp specified by `version_time`. If `version_time` is not specified, the system will set `version_time` to the `create_time` of the backup.
VersionTime pulumi.StringOutput `pulumi:"versionTime"`
}
// NewBackup registers a new resource with the given unique name, arguments, and options.
func NewBackup(ctx *pulumi.Context,
name string, args *BackupArgs, opts ...pulumi.ResourceOption) (*Backup, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.BackupId == nil {
return nil, errors.New("invalid value for required argument 'BackupId'")
}
if args.EncryptionConfigEncryptionType == nil {
return nil, errors.New("invalid value for required argument 'EncryptionConfigEncryptionType'")
}
if args.InstanceId == nil {
return nil, errors.New("invalid value for required argument 'InstanceId'")
}
replaceOnChanges := pulumi.ReplaceOnChanges([]string{
"backupId",
"encryptionConfigEncryptionType",
"instanceId",
"project",
})
opts = append(opts, replaceOnChanges)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Backup
err := ctx.RegisterResource("google-native:spanner/v1:Backup", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBackup gets an existing Backup 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 GetBackup(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BackupState, opts ...pulumi.ResourceOption) (*Backup, error) {
var resource Backup
err := ctx.ReadResource("google-native:spanner/v1:Backup", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Backup resources.
type backupState struct {
}
type BackupState struct {
}
func (BackupState) ElementType() reflect.Type {
return reflect.TypeOf((*backupState)(nil)).Elem()
}
type backupArgs struct {
// Required. The id of the backup to be created. The `backup_id` appended to `parent` forms the full backup name of the form `projects//instances//backups/`.
BackupId string `pulumi:"backupId"`
// Required for the CreateBackup operation. Name of the database from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects//instances//databases/`.
Database *string `pulumi:"database"`
// Required. The encryption type of the backup.
EncryptionConfigEncryptionType string `pulumi:"encryptionConfigEncryptionType"`
// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
EncryptionConfigKmsKeyName *string `pulumi:"encryptionConfigKmsKeyName"`
// Required for the CreateBackup operation. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days from the time the CreateBackup request is processed. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
ExpireTime *string `pulumi:"expireTime"`
InstanceId string `pulumi:"instanceId"`
// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
Name *string `pulumi:"name"`
Project *string `pulumi:"project"`
// The backup will contain an externally consistent copy of the database at the timestamp specified by `version_time`. If `version_time` is not specified, the system will set `version_time` to the `create_time` of the backup.
VersionTime *string `pulumi:"versionTime"`
}
// The set of arguments for constructing a Backup resource.
type BackupArgs struct {
// Required. The id of the backup to be created. The `backup_id` appended to `parent` forms the full backup name of the form `projects//instances//backups/`.
BackupId pulumi.StringInput
// Required for the CreateBackup operation. Name of the database from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects//instances//databases/`.
Database pulumi.StringPtrInput
// Required. The encryption type of the backup.
EncryptionConfigEncryptionType pulumi.StringInput
// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
EncryptionConfigKmsKeyName pulumi.StringPtrInput
// Required for the CreateBackup operation. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days from the time the CreateBackup request is processed. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
ExpireTime pulumi.StringPtrInput
InstanceId pulumi.StringInput
// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
Name pulumi.StringPtrInput
Project pulumi.StringPtrInput
// The backup will contain an externally consistent copy of the database at the timestamp specified by `version_time`. If `version_time` is not specified, the system will set `version_time` to the `create_time` of the backup.
VersionTime pulumi.StringPtrInput
}
func (BackupArgs) ElementType() reflect.Type {
return reflect.TypeOf((*backupArgs)(nil)).Elem()
}
type BackupInput interface {
pulumi.Input
ToBackupOutput() BackupOutput
ToBackupOutputWithContext(ctx context.Context) BackupOutput
}
func (*Backup) ElementType() reflect.Type {
return reflect.TypeOf((**Backup)(nil)).Elem()
}
func (i *Backup) ToBackupOutput() BackupOutput {
return i.ToBackupOutputWithContext(context.Background())
}
func (i *Backup) ToBackupOutputWithContext(ctx context.Context) BackupOutput {
return pulumi.ToOutputWithContext(ctx, i).(BackupOutput)
}
type BackupOutput struct{ *pulumi.OutputState }
func (BackupOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Backup)(nil)).Elem()
}
func (o BackupOutput) ToBackupOutput() BackupOutput {
return o
}
func (o BackupOutput) ToBackupOutputWithContext(ctx context.Context) BackupOutput {
return o
}
// Required. The id of the backup to be created. The `backup_id` appended to `parent` forms the full backup name of the form `projects//instances//backups/`.
func (o BackupOutput) BackupId() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.BackupId }).(pulumi.StringOutput)
}
// The time the CreateBackup request is received. If the request does not specify `version_time`, the `version_time` of the backup will be equivalent to the `create_time`.
func (o BackupOutput) CreateTime() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.CreateTime }).(pulumi.StringOutput)
}
// Required for the CreateBackup operation. Name of the database from which this backup was created. This needs to be in the same instance as the backup. Values are of the form `projects//instances//databases/`.
func (o BackupOutput) Database() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.Database }).(pulumi.StringOutput)
}
// The database dialect information for the backup.
func (o BackupOutput) DatabaseDialect() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.DatabaseDialect }).(pulumi.StringOutput)
}
// Required. The encryption type of the backup.
func (o BackupOutput) EncryptionConfigEncryptionType() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.EncryptionConfigEncryptionType }).(pulumi.StringOutput)
}
// Optional. The Cloud KMS key that will be used to protect the backup. This field should be set only when encryption_type is `CUSTOMER_MANAGED_ENCRYPTION`. Values are of the form `projects//locations//keyRings//cryptoKeys/`.
func (o BackupOutput) EncryptionConfigKmsKeyName() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Backup) pulumi.StringPtrOutput { return v.EncryptionConfigKmsKeyName }).(pulumi.StringPtrOutput)
}
// The encryption information for the backup.
func (o BackupOutput) EncryptionInfo() EncryptionInfoResponseOutput {
return o.ApplyT(func(v *Backup) EncryptionInfoResponseOutput { return v.EncryptionInfo }).(EncryptionInfoResponseOutput)
}
// Required for the CreateBackup operation. The expiration time of the backup, with microseconds granularity that must be at least 6 hours and at most 366 days from the time the CreateBackup request is processed. Once the `expire_time` has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.
func (o BackupOutput) ExpireTime() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.ExpireTime }).(pulumi.StringOutput)
}
func (o BackupOutput) InstanceId() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.InstanceId }).(pulumi.StringOutput)
}
// The max allowed expiration time of the backup, with microseconds granularity. A backup's expiration time can be configured in multiple APIs: CreateBackup, UpdateBackup, CopyBackup. When updating or copying an existing backup, the expiration time specified must be less than `Backup.max_expire_time`.
func (o BackupOutput) MaxExpireTime() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.MaxExpireTime }).(pulumi.StringOutput)
}
// Output only for the CreateBackup operation. Required for the UpdateBackup operation. A globally unique identifier for the backup which cannot be changed. Values are of the form `projects//instances//backups/a-z*[a-z0-9]` The final segment of the name must be between 2 and 60 characters in length. The backup is stored in the location(s) specified in the instance configuration of the instance containing the backup, identified by the prefix of the backup name of the form `projects//instances/`.
func (o BackupOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
func (o BackupOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// The names of the destination backups being created by copying this source backup. The backup names are of the form `projects//instances//backups/`. Referencing backups may exist in different instances. The existence of any referencing backup prevents the backup from being deleted. When the copy operation is done (either successfully completed or cancelled or the destination backup is deleted), the reference to the backup is removed.
func (o BackupOutput) ReferencingBackups() pulumi.StringArrayOutput {
return o.ApplyT(func(v *Backup) pulumi.StringArrayOutput { return v.ReferencingBackups }).(pulumi.StringArrayOutput)
}
// The names of the restored databases that reference the backup. The database names are of the form `projects//instances//databases/`. Referencing databases may exist in different instances. The existence of any referencing database prevents the backup from being deleted. When a restored database from the backup enters the `READY` state, the reference to the backup is removed.
func (o BackupOutput) ReferencingDatabases() pulumi.StringArrayOutput {
return o.ApplyT(func(v *Backup) pulumi.StringArrayOutput { return v.ReferencingDatabases }).(pulumi.StringArrayOutput)
}
// Size of the backup in bytes.
func (o BackupOutput) SizeBytes() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.SizeBytes }).(pulumi.StringOutput)
}
// The current state of the backup.
func (o BackupOutput) State() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.State }).(pulumi.StringOutput)
}
// The backup will contain an externally consistent copy of the database at the timestamp specified by `version_time`. If `version_time` is not specified, the system will set `version_time` to the `create_time` of the backup.
func (o BackupOutput) VersionTime() pulumi.StringOutput {
return o.ApplyT(func(v *Backup) pulumi.StringOutput { return v.VersionTime }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BackupInput)(nil)).Elem(), &Backup{})
pulumi.RegisterOutputType(BackupOutput{})
}