-
Notifications
You must be signed in to change notification settings - Fork 11
/
ValidateRestore.go
75 lines (72 loc) · 3.48 KB
/
ValidateRestore.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
package armdataprotection_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2022-04-01/examples/BackupInstanceOperations/ValidateRestore.json
func ExampleBackupInstancesClient_BeginValidateForRestore() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client, err := armdataprotection.NewBackupInstancesClient("04cf684a-d41f-4550-9f70-7708a3a2283b", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := client.BeginValidateForRestore(ctx,
"000pikumar",
"PratikPrivatePreviewVault1",
"testInstance1",
armdataprotection.ValidateRestoreRequestObject{
RestoreRequestObject: &armdataprotection.AzureBackupRecoveryPointBasedRestoreRequest{
ObjectType: to.Ptr("AzureBackupRecoveryPointBasedRestoreRequest"),
RestoreTargetInfo: &armdataprotection.RestoreTargetInfo{
ObjectType: to.Ptr("RestoreTargetInfo"),
RecoveryOption: to.Ptr(armdataprotection.RecoveryOptionFailIfExists),
RestoreLocation: to.Ptr("southeastasia"),
DatasourceAuthCredentials: &armdataprotection.SecretStoreBasedAuthCredentials{
ObjectType: to.Ptr("SecretStoreBasedAuthCredentials"),
SecretStoreResource: &armdataprotection.SecretStoreResource{
SecretStoreType: to.Ptr(armdataprotection.SecretStoreTypeAzureKeyVault),
URI: to.Ptr("https://samplevault.vault.azure.net/secrets/credentials"),
},
},
DatasourceInfo: &armdataprotection.Datasource{
DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"),
ObjectType: to.Ptr("Datasource"),
ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/targetdb"),
ResourceLocation: to.Ptr(""),
ResourceName: to.Ptr("targetdb"),
ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"),
ResourceURI: to.Ptr(""),
},
DatasourceSetInfo: &armdataprotection.DatasourceSet{
DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"),
ObjectType: to.Ptr("DatasourceSet"),
ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"),
ResourceLocation: to.Ptr(""),
ResourceName: to.Ptr("viveksipgtest"),
ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"),
ResourceURI: to.Ptr(""),
},
},
SourceDataStoreType: to.Ptr(armdataprotection.SourceDataStoreTypeVaultStore),
SourceResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"),
RecoveryPointID: to.Ptr("hardcodedRP"),
},
},
nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to pull the result: %v", err)
}
// TODO: use response item
_ = res
}