-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
client.go
81 lines (69 loc) · 3.47 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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package client
import (
"fmt"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/application"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/applicationgroup"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/desktop"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/hostpool"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/scalingplan"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/sessionhost"
"github.com/hashicorp/go-azure-sdk/resource-manager/desktopvirtualization/2022-02-10-preview/workspace"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
type Client struct {
ApplicationGroupsClient *applicationgroup.ApplicationGroupClient
ApplicationsClient *application.ApplicationClient
DesktopsClient *desktop.DesktopClient
HostPoolsClient *hostpool.HostPoolClient
SessionHostsClient *sessionhost.SessionHostClient
ScalingPlansClient *scalingplan.ScalingPlanClient
WorkspacesClient *workspace.WorkspaceClient
}
func NewClient(o *common.ClientOptions) (*Client, error) {
applicationGroupsClient, err := applicationgroup.NewApplicationGroupClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building ApplicationGroups Client: %+v", err)
}
o.Configure(applicationGroupsClient.Client, o.Authorizers.ResourceManager)
applicationsClient, err := application.NewApplicationClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Applications Client: %+v", err)
}
o.Configure(applicationsClient.Client, o.Authorizers.ResourceManager)
desktopsClient, err := desktop.NewDesktopClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Desktops Client: %+v", err)
}
o.Configure(desktopsClient.Client, o.Authorizers.ResourceManager)
hostPoolsClient, err := hostpool.NewHostPoolClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building HostPools Client: %+v", err)
}
o.Configure(hostPoolsClient.Client, o.Authorizers.ResourceManager)
sessionHostsClient, err := sessionhost.NewSessionHostClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building SessionHost Client: %+v", err)
}
o.Configure(sessionHostsClient.Client, o.Authorizers.ResourceManager)
scalingPlansClient, err := scalingplan.NewScalingPlanClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building ScalingPlan Client: %+v", err)
}
o.Configure(scalingPlansClient.Client, o.Authorizers.ResourceManager)
workspacesClient, err := workspace.NewWorkspaceClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Workspaces Client: %+v", err)
}
o.Configure(workspacesClient.Client, o.Authorizers.ResourceManager)
return &Client{
ApplicationGroupsClient: applicationGroupsClient,
ApplicationsClient: applicationsClient,
DesktopsClient: desktopsClient,
HostPoolsClient: hostPoolsClient,
SessionHostsClient: sessionHostsClient,
ScalingPlansClient: scalingPlansClient,
WorkspacesClient: workspacesClient,
}, nil
}