-
Notifications
You must be signed in to change notification settings - Fork 11
/
ScalingPlan_Create.go
78 lines (74 loc) · 3.78 KB
/
ScalingPlan_Create.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
package armdesktopvirtualization_test
import (
"context"
"log"
"time"
"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/desktopvirtualization/armdesktopvirtualization"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2021-07-12/examples/ScalingPlan_Create.json
func ExampleScalingPlansClient_Create() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client, err := armdesktopvirtualization.NewScalingPlansClient("daefabc0-95b4-48b3-b645-8a753a63c4fa", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := client.Create(ctx,
"resourceGroup1",
"scalingPlan1",
armdesktopvirtualization.ScalingPlan{
Location: to.Ptr("centralus"),
Tags: map[string]*string{
"tag1": to.Ptr("value1"),
"tag2": to.Ptr("value2"),
},
Properties: &armdesktopvirtualization.ScalingPlanProperties{
Description: to.Ptr("des1"),
ExclusionTag: to.Ptr("value"),
FriendlyName: to.Ptr("friendly"),
HostPoolReferences: []*armdesktopvirtualization.ScalingHostPoolReference{
{
HostPoolArmPath: to.Ptr("/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1"),
ScalingPlanEnabled: to.Ptr(true),
}},
HostPoolType: to.Ptr(armdesktopvirtualization.HostPoolTypePersonal),
Schedules: []*armdesktopvirtualization.ScalingSchedule{
{
Name: to.Ptr("schedule1"),
DaysOfWeek: []*armdesktopvirtualization.ScalingScheduleDaysOfWeekItem{
to.Ptr(armdesktopvirtualization.ScalingScheduleDaysOfWeekItemMonday),
to.Ptr(armdesktopvirtualization.ScalingScheduleDaysOfWeekItemTuesday),
to.Ptr(armdesktopvirtualization.ScalingScheduleDaysOfWeekItemWednesday),
to.Ptr(armdesktopvirtualization.ScalingScheduleDaysOfWeekItemThursday),
to.Ptr(armdesktopvirtualization.ScalingScheduleDaysOfWeekItemFriday)},
OffPeakLoadBalancingAlgorithm: to.Ptr(armdesktopvirtualization.SessionHostLoadBalancingAlgorithmDepthFirst),
OffPeakStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-10T20:00:00.000Z"); return t }()),
PeakLoadBalancingAlgorithm: to.Ptr(armdesktopvirtualization.SessionHostLoadBalancingAlgorithmBreadthFirst),
PeakStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-10T08:00:00.000Z"); return t }()),
RampDownCapacityThresholdPct: to.Ptr[int32](50),
RampDownForceLogoffUsers: to.Ptr(true),
RampDownLoadBalancingAlgorithm: to.Ptr(armdesktopvirtualization.SessionHostLoadBalancingAlgorithmDepthFirst),
RampDownMinimumHostsPct: to.Ptr[int32](20),
RampDownNotificationMessage: to.Ptr("message"),
RampDownStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-10T18:00:00.000Z"); return t }()),
RampDownWaitTimeMinutes: to.Ptr[int32](30),
RampUpCapacityThresholdPct: to.Ptr[int32](80),
RampUpLoadBalancingAlgorithm: to.Ptr(armdesktopvirtualization.SessionHostLoadBalancingAlgorithmDepthFirst),
RampUpMinimumHostsPct: to.Ptr[int32](20),
RampUpStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-11-10T06:00:00.000Z"); return t }()),
}},
TimeZone: to.Ptr(""),
},
},
nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// TODO: use response item
_ = res
}