-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathclient.go
41 lines (35 loc) · 1003 Bytes
/
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
package permifygrpc
import (
"google.golang.org/grpc"
pclient "buf.build/gen/go/permifyco/permify/grpc/go/base/v1/basev1grpc"
)
// Client - Permify client
type Client struct {
Permission pclient.PermissionClient
Schema pclient.SchemaClient
Data pclient.DataClient
Bundle pclient.BundleClient
Tenancy pclient.TenancyClient
Watch pclient.WatchClient
}
// Config - Permify client configuration
type Config struct {
Endpoint string
Cert byte
}
// NewClient - Creates new Permify client
func NewClient(c Config, opts ...grpc.DialOption) (*Client, error) {
conn, err := grpc.NewClient(c.Endpoint, opts...)
if err != nil {
return nil, err
}
// defer conn.Close()
return &Client{
Permission: pclient.NewPermissionClient(conn),
Schema: pclient.NewSchemaClient(conn),
Data: pclient.NewDataClient(conn),
Bundle: pclient.NewBundleClient(conn),
Tenancy: pclient.NewTenancyClient(conn),
Watch: pclient.NewWatchClient(conn),
}, nil
}