Passed
Push — master ( 9579c8...58cabf )
by Tolga
01:25 queued 16s
created

sdk/go/grpc/main.go   A

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 21
dl 0
loc 32
rs 10
c 0
b 0
f 0
1
package main
2
3
import (
4
	"context"
5
	"log"
6
7
	"buf.build/gen/go/permifyco/permify/protocolbuffers/go/base/v1"
8
	pclient "github.com/Permify/permify-go/grpc"
9
	"google.golang.org/grpc"
10
	"google.golang.org/grpc/credentials/insecure"
11
)
12
13
func main() {
14
	client, err := pclient.NewClient(
15
		pclient.Config{
16
			Endpoint: `localhost:3478`,
17
		},
18
		grpc.WithTransportCredentials(insecure.NewCredentials()),
19
	)
20
	if err != nil {
21
		log.Fatalf("failed to create Permify client: %v", err)
22
	}
23
24
	ct, err := client.Tenancy.Create(context.Background(), &basev1.TenantCreateRequest{
25
		Id:   "t1",
26
		Name: "tenant 1",
27
	})
28
	if err != nil {
29
		log.Fatalf("failed to create tenant: %v", err)
30
	}
31
32
	log.Printf("Tenant created: %v", ct)
33
}
34