-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfga_client.go
More file actions
63 lines (53 loc) · 1.79 KB
/
fga_client.go
File metadata and controls
63 lines (53 loc) · 1.79 KB
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
55
56
57
58
59
60
61
62
63
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
package main
import (
"context"
openfga "github.com/openfga/go-sdk"
. "github.com/openfga/go-sdk/client"
)
// IFgaClient is an interface for OpenFGA client operations used in this service.
type IFgaClient interface {
Read(ctx context.Context, req ClientReadRequest, options ClientReadOptions) (*ClientReadResponse, error)
Write(ctx context.Context, req ClientWriteRequest) (*ClientWriteResponse, error)
BatchCheck(ctx context.Context, request ClientBatchCheckRequest) (*openfga.BatchCheckResponse, error)
ListObjects(
ctx context.Context,
body ClientListObjectsRequest,
options ClientListObjectsOptions,
) (*ClientListObjectsResponse, error)
}
// FgaClient is a wrapper around the OpenFGA client.
type FgaAdapter struct {
OpenFgaClient
}
// BatchCheck executes a batch check request.
func (c FgaAdapter) BatchCheck(
ctx context.Context,
request ClientBatchCheckRequest,
) (*openfga.BatchCheckResponse, error) {
return c.OpenFgaClient.BatchCheck(ctx).Body(request).Execute()
}
// Read executes a read request.
func (c FgaAdapter) Read(
ctx context.Context,
req ClientReadRequest,
options ClientReadOptions,
) (*ClientReadResponse, error) {
return c.OpenFgaClient.Read(ctx).Body(req).Options(options).Execute()
}
// Write executes a write request.
func (c FgaAdapter) Write(
ctx context.Context,
req ClientWriteRequest,
) (*ClientWriteResponse, error) {
return c.OpenFgaClient.Write(ctx).Body(req).Execute()
}
// ListObjects executes a list objects request.
func (c FgaAdapter) ListObjects(
ctx context.Context,
body ClientListObjectsRequest,
options ClientListObjectsOptions,
) (*ClientListObjectsResponse, error) {
return c.OpenFgaClient.ListObjects(ctx).Body(body).Options(options).Execute()
}