/
mysql.go
33 lines (27 loc) · 952 Bytes
/
mysql.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
//go:generate mockgen -destination=./mocks/my_sql.go -package=mocks . MySQLServerClient,MySQLConfigurationClient
package services
import (
"context"
"github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2020-01-01/mysql"
"github.com/Azure/go-autorest/autorest"
)
type MySQL struct {
Servers MySQLServerClient
Configuration MySQLConfigurationClient
}
type MySQLServerClient interface {
List(ctx context.Context) (result mysql.ServerListResult, err error)
}
type MySQLConfigurationClient interface {
ListByServer(ctx context.Context, resourceGroupName string, serverName string) (result mysql.ConfigurationListResult, err error)
}
func NewMySQLClient(subscriptionId string, auth autorest.Authorizer) MySQL {
servers := mysql.NewServersClient(subscriptionId)
servers.Authorizer = auth
conf := mysql.NewConfigurationsClient(subscriptionId)
conf.Authorizer = auth
return MySQL{
Servers: servers,
Configuration: conf,
}
}