-
Notifications
You must be signed in to change notification settings - Fork 40
/
client.go
91 lines (78 loc) · 3.12 KB
/
client.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
package v2022_08_01
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
import (
"fmt"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/image"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/lab"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/labplan"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/schedule"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/skus"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/usages"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/user"
"github.com/hashicorp/go-azure-sdk/resource-manager/labservices/2022-08-01/virtualmachine"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)
type Client struct {
Image *image.ImageClient
Lab *lab.LabClient
LabPlan *labplan.LabPlanClient
Schedule *schedule.ScheduleClient
Skus *skus.SkusClient
Usages *usages.UsagesClient
User *user.UserClient
VirtualMachine *virtualmachine.VirtualMachineClient
}
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
imageClient, err := image.NewImageClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Image client: %+v", err)
}
configureFunc(imageClient.Client)
labClient, err := lab.NewLabClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Lab client: %+v", err)
}
configureFunc(labClient.Client)
labPlanClient, err := labplan.NewLabPlanClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building LabPlan client: %+v", err)
}
configureFunc(labPlanClient.Client)
scheduleClient, err := schedule.NewScheduleClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Schedule client: %+v", err)
}
configureFunc(scheduleClient.Client)
skusClient, err := skus.NewSkusClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Skus client: %+v", err)
}
configureFunc(skusClient.Client)
usagesClient, err := usages.NewUsagesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Usages client: %+v", err)
}
configureFunc(usagesClient.Client)
userClient, err := user.NewUserClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building User client: %+v", err)
}
configureFunc(userClient.Client)
virtualMachineClient, err := virtualmachine.NewVirtualMachineClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building VirtualMachine client: %+v", err)
}
configureFunc(virtualMachineClient.Client)
return &Client{
Image: imageClient,
Lab: labClient,
LabPlan: labPlanClient,
Schedule: scheduleClient,
Skus: skusClient,
Usages: usagesClient,
User: userClient,
VirtualMachine: virtualMachineClient,
}, nil
}