-
Notifications
You must be signed in to change notification settings - Fork 13
/
CosmosDBDatabaseAccountPatch.go
85 lines (82 loc) · 3.44 KB
/
CosmosDBDatabaseAccountPatch.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
package armcosmos_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/cosmos/armcosmos/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2022-08-15/examples/CosmosDBDatabaseAccountPatch.json
func ExampleDatabaseAccountsClient_BeginUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client, err := armcosmos.NewDatabaseAccountsClient("subid", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := client.BeginUpdate(ctx, "rg1", "ddb1", armcosmos.DatabaseAccountUpdateParameters{
Identity: &armcosmos.ManagedServiceIdentity{
Type: to.Ptr(armcosmos.ResourceIdentityTypeSystemAssignedUserAssigned),
UserAssignedIdentities: map[string]*armcosmos.Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties{
"/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/eu2cgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {},
},
},
Location: to.Ptr("westus"),
Properties: &armcosmos.DatabaseAccountUpdateProperties{
AnalyticalStorageConfiguration: &armcosmos.AnalyticalStorageConfiguration{
SchemaType: to.Ptr(armcosmos.AnalyticalStorageSchemaTypeWellDefined),
},
BackupPolicy: &armcosmos.PeriodicModeBackupPolicy{
Type: to.Ptr(armcosmos.BackupPolicyTypePeriodic),
PeriodicModeProperties: &armcosmos.PeriodicModeProperties{
BackupIntervalInMinutes: to.Ptr[int32](240),
BackupRetentionIntervalInHours: to.Ptr[int32](720),
BackupStorageRedundancy: to.Ptr(armcosmos.BackupStorageRedundancyLocal),
},
},
Capacity: &armcosmos.Capacity{
TotalThroughputLimit: to.Ptr[int32](2000),
},
ConsistencyPolicy: &armcosmos.ConsistencyPolicy{
DefaultConsistencyLevel: to.Ptr(armcosmos.DefaultConsistencyLevelBoundedStaleness),
MaxIntervalInSeconds: to.Ptr[int32](10),
MaxStalenessPrefix: to.Ptr[int64](200),
},
DefaultIdentity: to.Ptr("FirstPartyIdentity"),
EnableAnalyticalStorage: to.Ptr(true),
EnableFreeTier: to.Ptr(false),
EnablePartitionMerge: to.Ptr(true),
IPRules: []*armcosmos.IPAddressOrRange{
{
IPAddressOrRange: to.Ptr("23.43.230.120"),
},
{
IPAddressOrRange: to.Ptr("110.12.240.0/12"),
}},
IsVirtualNetworkFilterEnabled: to.Ptr(true),
NetworkACLBypass: to.Ptr(armcosmos.NetworkACLBypassAzureServices),
NetworkACLBypassResourceIDs: []*string{
to.Ptr("/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName")},
VirtualNetworkRules: []*armcosmos.VirtualNetworkRule{
{
ID: to.Ptr("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"),
IgnoreMissingVNetServiceEndpoint: to.Ptr(false),
}},
},
Tags: map[string]*string{
"dept": to.Ptr("finance"),
},
}, 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
}