-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
client.go
54 lines (45 loc) · 1.98 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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package client
import (
"fmt"
"github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/authorizations"
"github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/clusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/datastores"
"github.com/hashicorp/go-azure-sdk/resource-manager/vmware/2022-05-01/privateclouds"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
type Client struct {
AuthorizationClient *authorizations.AuthorizationsClient
ClusterClient *clusters.ClustersClient
PrivateCloudClient *privateclouds.PrivateCloudsClient
DataStoreClient *datastores.DataStoresClient
}
func NewClient(o *common.ClientOptions) (*Client, error) {
authorizationClient, err := authorizations.NewAuthorizationsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Authorization Client: %+v", err)
}
o.Configure(authorizationClient.Client, o.Authorizers.ResourceManager)
clusterClient, err := clusters.NewClustersClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Cluster Client: %+v", err)
}
o.Configure(clusterClient.Client, o.Authorizers.ResourceManager)
privateCloudClient, err := privateclouds.NewPrivateCloudsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Private Cloud Client: %+v", err)
}
o.Configure(privateCloudClient.Client, o.Authorizers.ResourceManager)
dataStoresClient, err := datastores.NewDataStoresClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Data Stores Client: %+v", err)
}
o.Configure(dataStoresClient.Client, o.Authorizers.ResourceManager)
return &Client{
AuthorizationClient: authorizationClient,
ClusterClient: clusterClient,
PrivateCloudClient: privateCloudClient,
DataStoreClient: dataStoresClient,
}, nil
}