/
client.go
50 lines (40 loc) · 1.58 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache v2.0 License.
package cluster
import (
"context"
"github.com/microsoft/moc-sdk-for-go/services/cloud"
"github.com/microsoft/moc/pkg/auth"
)
type Service interface {
Get(context.Context, string, string) (*[]cloud.Cluster, error)
GetNodes(context.Context, string, string) (*[]cloud.Node, error)
Load(context.Context, string, string, *cloud.Cluster) (*cloud.Cluster, error)
Unload(context.Context, string, string) error
}
type ClusterClient struct {
internal Service
}
func NewClusterClient(cloudFQDN string, authorizer auth.Authorizer) (*ClusterClient, error) {
c, err := newClusterClient(cloudFQDN, authorizer)
if err != nil {
return nil, err
}
return &ClusterClient{internal: c}, nil
}
// Get methods invokes the client Get method
func (c *ClusterClient) Get(ctx context.Context, location, name string) (*[]cloud.Cluster, error) {
return c.internal.Get(ctx, location, name)
}
// GetNodes methods invokes the client GetNodes method
func (c *ClusterClient) GetNodes(ctx context.Context, location, name string) (*[]cloud.Node, error) {
return c.internal.GetNodes(ctx, location, name)
}
// Load methods invokes create or update on the client
func (c *ClusterClient) Load(ctx context.Context, location, name string, cloud *cloud.Cluster) (*cloud.Cluster, error) {
return c.internal.Load(ctx, location, name, cloud)
}
// Unload methods invokes delete of the cloud resource
func (c *ClusterClient) Unload(ctx context.Context, location, name string) error {
return c.internal.Unload(ctx, location, name)
}