-
Notifications
You must be signed in to change notification settings - Fork 26
/
client.go
2715 lines (2247 loc) · 85.2 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Go SDK for OpenFGA
*
* API version: 1.x
* Website: https://openfga.dev
* Documentation: https://openfga.dev/docs
* Support: https://openfga.dev/community
* License: [Apache-2.0](https://github.com/openfga/go-sdk/blob/main/LICENSE)
*
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
*/
package client
import (
_context "context"
"encoding/json"
"fmt"
"math"
_nethttp "net/http"
fgaSdk "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/credentials"
internalutils "github.com/openfga/go-sdk/internal/utils"
"golang.org/x/sync/errgroup"
)
var (
_ _context.Context
// Ensure the SdkClient fits OpenFgaClient interface
_ SdkClient = (*OpenFgaClient)(nil)
)
var DEFAULT_MAX_METHOD_PARALLEL_REQS = int32(10)
type ClientConfiguration struct {
fgaSdk.Configuration
// ApiScheme - defines the scheme for the API: http or https
// Deprecated: use ApiUrl instead of ApiScheme and ApiHost
ApiScheme string `json:"api_scheme"`
// ApiHost - defines the host for the API without the scheme e.g. (api.fga.example)
// Deprecated: use ApiUrl instead of ApiScheme and ApiHost
ApiHost string `json:"api_host"`
ApiUrl string `json:"api_url"`
StoreId string `json:"store_id"`
AuthorizationModelId string `json:"authorization_model_id"`
Credentials *credentials.Credentials `json:"credentials"`
DefaultHeaders map[string]string `json:"default_headers"`
UserAgent string `json:"user_agent"`
Debug bool `json:"debug"`
HTTPClient *_nethttp.Client
RetryParams *fgaSdk.RetryParams
}
func newClientConfiguration(cfg *fgaSdk.Configuration) ClientConfiguration {
return ClientConfiguration{
ApiScheme: cfg.ApiScheme,
ApiHost: cfg.ApiHost,
ApiUrl: cfg.ApiUrl,
Credentials: cfg.Credentials,
DefaultHeaders: cfg.DefaultHeaders,
UserAgent: cfg.UserAgent,
Debug: cfg.Debug,
HTTPClient: cfg.HTTPClient,
RetryParams: cfg.RetryParams,
}
}
type OpenFgaClient struct {
config ClientConfiguration
SdkClient
fgaSdk.APIClient
}
func NewSdkClient(cfg *ClientConfiguration) (*OpenFgaClient, error) {
apiConfiguration, err := fgaSdk.NewConfiguration(fgaSdk.Configuration{
ApiScheme: cfg.ApiScheme,
ApiHost: cfg.ApiHost,
ApiUrl: cfg.ApiUrl,
Credentials: cfg.Credentials,
DefaultHeaders: cfg.DefaultHeaders,
UserAgent: cfg.UserAgent,
Debug: cfg.Debug,
HTTPClient: cfg.HTTPClient,
RetryParams: cfg.RetryParams,
})
if err != nil {
return nil, err
}
clientConfig := newClientConfiguration(apiConfiguration)
clientConfig.AuthorizationModelId = cfg.AuthorizationModelId
clientConfig.StoreId = cfg.StoreId
// store id is already validate as part of configuration validation
if cfg.AuthorizationModelId != "" && !internalutils.IsWellFormedUlidString(cfg.AuthorizationModelId) {
return nil, FgaInvalidError{param: "AuthorizationModelId", description: "Expected ULID format"}
}
if cfg.StoreId != "" && !internalutils.IsWellFormedUlidString(cfg.StoreId) {
return nil, FgaInvalidError{param: "StoreId", description: "Expected ULID format"}
}
apiClient := fgaSdk.NewAPIClient(apiConfiguration)
return &OpenFgaClient{
config: clientConfig,
APIClient: *apiClient,
}, nil
}
type ClientRequestOptions struct {
MaxRetry *int `json:"max_retry,omitempty"`
MinWaitInMs *int `json:"min_wait_in_ms,omitempty"`
}
type AuthorizationModelIdOptions struct {
AuthorizationModelId *string `json:"authorization_model_id,omitempty"`
}
type ClientRequestOptionsWithAuthZModelId struct {
ClientRequestOptions
AuthorizationModelIdOptions
}
type ClientTupleKey = fgaSdk.TupleKey
type ClientTupleKeyWithoutCondition = fgaSdk.TupleKeyWithoutCondition
type ClientCheckRequestTupleKey = fgaSdk.CheckRequestTupleKey
type ClientReadRequestTupleKey = fgaSdk.ReadRequestTupleKey
type ClientExpandRequestTupleKey = fgaSdk.ExpandRequestTupleKey
type ClientContextualTupleKey = ClientTupleKey
type ClientPaginationOptions struct {
PageSize *int32 `json:"page_size,omitempty"`
ContinuationToken *string `json:"continuation_token,omitempty"`
}
func getPageSizeFromRequest(options *ClientPaginationOptions) *int32 {
if options == nil {
return nil
}
return options.PageSize
}
func getContinuationTokenFromRequest(options *ClientPaginationOptions) *string {
if options == nil {
return nil
}
return options.ContinuationToken
}
type SdkClient interface {
/* Stores */
/*
* ListStores Get a paginated list of stores.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientListStoresRequestInterface
*/
ListStores(ctx _context.Context) SdkClientListStoresRequestInterface
/*
* ListStoresExecute executes the ListStores request
* @return *ClientListStoresResponse
*/
ListStoresExecute(request SdkClientListStoresRequestInterface) (*ClientListStoresResponse, error)
/*
* CreateStore Create and initialize a store
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientCreateStoreRequestInterface
*/
CreateStore(ctx _context.Context) SdkClientCreateStoreRequestInterface
/*
* CreateStoreExecute executes the CreateStore request
* @return *ClientCreateStoreResponse
*/
CreateStoreExecute(request SdkClientCreateStoreRequestInterface) (*ClientCreateStoreResponse, error)
/*
* GetStore Get information about the current store.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientGetStoreRequestInterface
*/
GetStore(ctx _context.Context) SdkClientGetStoreRequestInterface
/*
* GetStoreExecute executes the GetStore request
* @return *ClientGetStoreResponse
*/
GetStoreExecute(request SdkClientGetStoreRequestInterface) (*ClientGetStoreResponse, error)
/*
* DeleteStore Delete a store.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientDeleteStoreRequestInterface
*/
DeleteStore(ctx _context.Context) SdkClientDeleteStoreRequestInterface
/*
* DeleteStoreExecute executes the DeleteStore request
* @return *ClientDeleteStoreResponse
*/
DeleteStoreExecute(request SdkClientDeleteStoreRequestInterface) (*ClientDeleteStoreResponse, error)
/* Authorization Models */
/*
* ReadAuthorizationModels Read all authorization models in the store.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadAuthorizationModelsRequest
*/
ReadAuthorizationModels(ctx _context.Context) SdkClientReadAuthorizationModelsRequestInterface
/*
* ReadAuthorizationModelsExecute executes the ReadAuthorizationModels request
* @return *ClientReadAuthorizationModelsResponse
*/
ReadAuthorizationModelsExecute(request SdkClientReadAuthorizationModelsRequestInterface) (*ClientReadAuthorizationModelsResponse, error)
/*
* WriteAuthorizationModel Create a new authorization model.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientWriteAuthorizationModelRequest
*/
WriteAuthorizationModel(ctx _context.Context) SdkClientWriteAuthorizationModelRequestInterface
/*
* WriteAuthorizationModelExecute executes the WriteAuthorizationModel request
* @return *ClientWriteAuthorizationModelResponse
*/
WriteAuthorizationModelExecute(request SdkClientWriteAuthorizationModelRequestInterface) (*ClientWriteAuthorizationModelResponse, error)
/*
* ReadAuthorizationModel Read a particular authorization model.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadAuthorizationModelRequestInterface
*/
ReadAuthorizationModel(ctx _context.Context) SdkClientReadAuthorizationModelRequestInterface
/*
* ReadAuthorizationModelExecute executes the ReadAuthorizationModel request
* @return *ClientReadAuthorizationModelResponse
*/
ReadAuthorizationModelExecute(request SdkClientReadAuthorizationModelRequestInterface) (*ClientReadAuthorizationModelResponse, error)
/*
* ReadLatestAuthorizationModel Reads the latest authorization model (note: this ignores the model id in configuration).
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadLatestAuthorizationModelRequestInterface
*/
ReadLatestAuthorizationModel(ctx _context.Context) SdkClientReadLatestAuthorizationModelRequestInterface
/*
* ReadLatestAuthorizationModelExecute executes the ReadLatestAuthorizationModel request
* @return *ClientReadAuthorizationModelResponse
*/
ReadLatestAuthorizationModelExecute(request SdkClientReadLatestAuthorizationModelRequestInterface) (*ClientReadAuthorizationModelResponse, error)
/* Relationship Tuples */
/*
* ReadChanges Reads the list of historical relationship tuple writes and deletes.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadChangesRequestInterface
*/
ReadChanges(ctx _context.Context) SdkClientReadChangesRequestInterface
/*
* ReadChangesExecute executes the ReadChanges request
* @return *ClientReadChangesResponse
*/
ReadChangesExecute(request SdkClientReadChangesRequestInterface) (*ClientReadChangesResponse, error)
/*
* Read Reads the relationship tuples stored in the database. It does not evaluate nor exclude invalid tuples according to the authorization model.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadRequestInterface
*/
Read(ctx _context.Context) SdkClientReadRequestInterface
/*
* ReadExecute executes the Read request
* @return *ClientReadResponse
*/
ReadExecute(request SdkClientReadRequestInterface) (*ClientReadResponse, error)
/*
* Write Create and/or delete relationship tuples to update the system state.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientWriteRequestInterface
*/
Write(ctx _context.Context) SdkClientWriteRequestInterface
/*
* WriteExecute executes the Write request
* @return *ClientWriteResponse
*/
WriteExecute(request SdkClientWriteRequestInterface) (*ClientWriteResponse, error)
/*
* WriteTuples Utility method around Write
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientWriteTuplesRequestInterface
*/
WriteTuples(ctx _context.Context) SdkClientWriteTuplesRequestInterface
/*
* WriteTuplesExecute executes the WriteTuples request
* @return *ClientWriteResponse
*/
WriteTuplesExecute(request SdkClientWriteTuplesRequestInterface) (*ClientWriteResponse, error)
/*
* DeleteTuples Utility method around Write
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientDeleteTuplesRequestInterface
*/
DeleteTuples(ctx _context.Context) SdkClientDeleteTuplesRequestInterface
/*
* DeleteTuplesExecute executes the DeleteTuples request
* @return *ClientWriteResponse
*/
DeleteTuplesExecute(request SdkClientDeleteTuplesRequestInterface) (*ClientWriteResponse, error)
/* Relationship Queries */
/*
* Check Check if a user has a particular relation with an object.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientCheckRequestInterface
*/
Check(ctx _context.Context) SdkClientCheckRequestInterface
/*
* CheckExecute executes the Check request
* @return *ClientCheckResponse
*/
CheckExecute(request SdkClientCheckRequestInterface) (*ClientCheckResponse, error)
/*
* BatchCheck Run a set of [checks](#check). Batch Check will return `allowed: false` if it encounters an error, and will return the error in the body.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientBatchCheckRequestInterface
*/
BatchCheck(ctx _context.Context) SdkClientBatchCheckRequestInterface
/*
* BatchCheckExecute executes the BatchCheck request
* @return *ClientBatchCheckResponse
*/
BatchCheckExecute(request SdkClientBatchCheckRequestInterface) (*ClientBatchCheckResponse, error)
/*
* Expand Expands the relationships in userset tree format.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientExpandRequestInterface
*/
Expand(ctx _context.Context) SdkClientExpandRequestInterface
/*
* ExpandExecute executes the Expand request
* @return *ClientExpandResponse
*/
ExpandExecute(request SdkClientExpandRequestInterface) (*ClientExpandResponse, error)
/*
* ListObjects List the objects of a particular type a user has access to.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientListObjectsRequestInterface
*/
ListObjects(ctx _context.Context) SdkClientListObjectsRequestInterface
/*
* ListObjectsExecute executes the ListObjects request
* @return *ClientListObjectsResponse
*/
ListObjectsExecute(request SdkClientListObjectsRequestInterface) (*ClientListObjectsResponse, error)
/*
* ListRelations List the relations a user has on an object.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientListRelationsRequestInterface
*/
ListRelations(ctx _context.Context) SdkClientListRelationsRequestInterface
/*
* ListRelationsExecute executes the ListRelations request
* @return *ClientListRelationsResponse
*/
ListRelationsExecute(request SdkClientListRelationsRequestInterface) (*ClientListRelationsResponse, error)
/*
* ListUsers List all users of the given type that the object has a relation with
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return ApiListUsersRequest
*/
ListUsers(ctx _context.Context) SdkClientListUsersRequestInterface
/*
* ListUsersExecute executes the request
* @return ListUsersResponse
*/
ListUsersExecute(r SdkClientListUsersRequestInterface) (*ClientListUsersResponse, error)
/* Assertions */
/*
* ReadAssertions Read assertions for a particular authorization model.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientReadAssertionsRequestInterface
*/
ReadAssertions(ctx _context.Context) SdkClientReadAssertionsRequestInterface
/*
* ReadAssertionsExecute executes the ReadAssertions request
* @return *ClientReadAssertionsResponse
*/
ReadAssertionsExecute(request SdkClientReadAssertionsRequestInterface) (*ClientReadAssertionsResponse, error)
/*
* WriteAssertions Update the assertions for a particular authorization model.
* @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @return SdkClientWriteAssertionsRequestInterface
*/
WriteAssertions(ctx _context.Context) SdkClientWriteAssertionsRequestInterface
/*
* WriteAssertionsExecute executes the WriteAssertions request
* @return *ClientWriteAssertionsResponse
*/
WriteAssertionsExecute(request SdkClientWriteAssertionsRequestInterface) (*ClientWriteAssertionsResponse, error)
}
func (client *OpenFgaClient) SetAuthorizationModelId(authorizationModelId string) error {
if authorizationModelId != "" && !internalutils.IsWellFormedUlidString(authorizationModelId) {
return FgaInvalidError{param: "AuthorizationModelId", description: "Expected ULID format"}
}
client.config.AuthorizationModelId = authorizationModelId
return nil
}
func (client *OpenFgaClient) GetAuthorizationModelId() (string, error) {
modelId := client.config.AuthorizationModelId
if modelId != "" && !internalutils.IsWellFormedUlidString(modelId) {
return "", FgaInvalidError{param: "AuthorizationModelId", description: "Expected ULID format"}
}
return modelId, nil
}
func (client *OpenFgaClient) getAuthorizationModelId(authorizationModelId *string) (*string, error) {
modelId := client.config.AuthorizationModelId
if authorizationModelId != nil && *authorizationModelId != "" {
modelId = *authorizationModelId
}
if modelId != "" && !internalutils.IsWellFormedUlidString(modelId) {
return nil, FgaInvalidError{param: "AuthorizationModelId", description: "Expected ULID format"}
}
return &modelId, nil
}
func (client *OpenFgaClient) SetStoreId(storeId string) error {
if storeId != "" && !internalutils.IsWellFormedUlidString(storeId) {
return FgaInvalidError{param: "StoreId", description: "Expected ULID format"}
}
client.config.StoreId = storeId
return nil
}
func (client *OpenFgaClient) GetStoreId() (string, error) {
storeId := client.config.StoreId
if storeId != "" && !internalutils.IsWellFormedUlidString(storeId) {
return "", FgaInvalidError{param: "StoreId", description: "Expected ULID format"}
}
return storeId, nil
}
func (client *OpenFgaClient) getStoreId(storeId *string) (*string, error) {
store := client.config.StoreId
if storeId != nil && *storeId != "" {
store = *storeId
}
if store != "" && !internalutils.IsWellFormedUlidString(store) {
return nil, FgaInvalidError{param: "StoreId", description: "Expected ULID format"}
}
return &store, nil
}
/* Stores */
// / ListStores
type SdkClientListStoresRequest struct {
ctx _context.Context
Client *OpenFgaClient
options *ClientListStoresOptions
}
type SdkClientListStoresRequestInterface interface {
Options(options ClientListStoresOptions) SdkClientListStoresRequestInterface
Execute() (*ClientListStoresResponse, error)
GetContext() _context.Context
GetOptions() *ClientListStoresOptions
}
type ClientListStoresOptions struct {
PageSize *int32 `json:"page_size,omitempty"`
ContinuationToken *string `json:"continuation_token,omitempty"`
}
type ClientListStoresResponse = fgaSdk.ListStoresResponse
func (request *SdkClientListStoresRequest) Options(options ClientListStoresOptions) SdkClientListStoresRequestInterface {
request.options = &options
return request
}
func (request *SdkClientListStoresRequest) Execute() (*ClientListStoresResponse, error) {
return request.Client.ListStoresExecute(request)
}
func (request *SdkClientListStoresRequest) GetContext() _context.Context {
return request.ctx
}
func (request *SdkClientListStoresRequest) GetOptions() *ClientListStoresOptions {
return request.options
}
func (client *OpenFgaClient) ListStoresExecute(request SdkClientListStoresRequestInterface) (*ClientListStoresResponse, error) {
req := client.OpenFgaApi.ListStores(request.GetContext())
pageSize := getPageSizeFromRequest((*ClientPaginationOptions)(request.GetOptions()))
if pageSize != nil {
req = req.PageSize(*pageSize)
}
continuationToken := getContinuationTokenFromRequest((*ClientPaginationOptions)(request.GetOptions()))
if continuationToken != nil {
req = req.ContinuationToken(*continuationToken)
}
data, _, err := req.Execute()
if err != nil {
return nil, err
}
return &data, nil
}
func (client *OpenFgaClient) ListStores(ctx _context.Context) SdkClientListStoresRequestInterface {
return &SdkClientListStoresRequest{
ctx: ctx,
Client: client,
}
}
// / CreateStore
type SdkClientCreateStoreRequest struct {
ctx _context.Context
Client *OpenFgaClient
body *ClientCreateStoreRequest
options *ClientCreateStoreOptions
}
type SdkClientCreateStoreRequestInterface interface {
Options(options ClientCreateStoreOptions) SdkClientCreateStoreRequestInterface
Body(body ClientCreateStoreRequest) SdkClientCreateStoreRequestInterface
Execute() (*ClientCreateStoreResponse, error)
GetContext() _context.Context
GetOptions() *ClientCreateStoreOptions
GetBody() *ClientCreateStoreRequest
}
type ClientCreateStoreRequest struct {
Name string `json:"name"`
}
type ClientCreateStoreOptions struct {
}
type ClientCreateStoreResponse = fgaSdk.CreateStoreResponse
func (request *SdkClientCreateStoreRequest) Options(options ClientCreateStoreOptions) SdkClientCreateStoreRequestInterface {
request.options = &options
return request
}
func (request *SdkClientCreateStoreRequest) Body(body ClientCreateStoreRequest) SdkClientCreateStoreRequestInterface {
request.body = &body
return request
}
func (request *SdkClientCreateStoreRequest) Execute() (*ClientCreateStoreResponse, error) {
return request.Client.CreateStoreExecute(request)
}
func (request *SdkClientCreateStoreRequest) GetContext() _context.Context {
return request.ctx
}
func (request *SdkClientCreateStoreRequest) GetOptions() *ClientCreateStoreOptions {
return request.options
}
func (request *SdkClientCreateStoreRequest) GetBody() *ClientCreateStoreRequest {
return request.body
}
func (client *OpenFgaClient) CreateStoreExecute(request SdkClientCreateStoreRequestInterface) (*ClientCreateStoreResponse, error) {
data, _, err := client.OpenFgaApi.CreateStore(request.GetContext()).Body(fgaSdk.CreateStoreRequest{
Name: request.GetBody().Name,
}).Execute()
if err != nil {
return nil, err
}
return &data, nil
}
func (client *OpenFgaClient) CreateStore(ctx _context.Context) SdkClientCreateStoreRequestInterface {
return &SdkClientCreateStoreRequest{
Client: client,
ctx: ctx,
}
}
// / GetStore
type SdkClientGetStoreRequest struct {
ctx _context.Context
Client *OpenFgaClient
options *ClientGetStoreOptions
}
type SdkClientGetStoreRequestInterface interface {
Options(options ClientGetStoreOptions) SdkClientGetStoreRequestInterface
Execute() (*ClientGetStoreResponse, error)
GetStoreIdOverride() *string
GetContext() _context.Context
GetOptions() *ClientGetStoreOptions
}
type ClientGetStoreOptions struct {
StoreId *string `json:"store_id,omitempty"`
}
type ClientGetStoreResponse = fgaSdk.GetStoreResponse
func (request *SdkClientGetStoreRequest) Options(options ClientGetStoreOptions) SdkClientGetStoreRequestInterface {
request.options = &options
return request
}
func (request *SdkClientGetStoreRequest) GetStoreIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.StoreId
}
func (request *SdkClientGetStoreRequest) Execute() (*ClientGetStoreResponse, error) {
return request.Client.GetStoreExecute(request)
}
func (request *SdkClientGetStoreRequest) GetContext() _context.Context {
return request.ctx
}
func (request *SdkClientGetStoreRequest) GetOptions() *ClientGetStoreOptions {
return request.options
}
func (client *OpenFgaClient) GetStoreExecute(request SdkClientGetStoreRequestInterface) (*ClientGetStoreResponse, error) {
storeId, err := client.getStoreId(request.GetStoreIdOverride())
if err != nil {
return nil, err
}
data, _, err := client.OpenFgaApi.GetStore(request.GetContext(), *storeId).Execute()
if err != nil {
return nil, err
}
return &data, nil
}
func (client *OpenFgaClient) GetStore(ctx _context.Context) SdkClientGetStoreRequestInterface {
return &SdkClientGetStoreRequest{
Client: client,
ctx: ctx,
}
}
// / DeleteStore
type SdkClientDeleteStoreRequest struct {
ctx _context.Context
Client *OpenFgaClient
options *ClientDeleteStoreOptions
}
type SdkClientDeleteStoreRequestInterface interface {
Options(options ClientDeleteStoreOptions) SdkClientDeleteStoreRequestInterface
Execute() (*ClientDeleteStoreResponse, error)
GetStoreIdOverride() *string
GetContext() _context.Context
GetOptions() *ClientDeleteStoreOptions
}
type ClientDeleteStoreOptions struct {
StoreId *string `json:"store_id,omitempty"`
}
type ClientDeleteStoreResponse struct{}
func (request *SdkClientDeleteStoreRequest) Options(options ClientDeleteStoreOptions) SdkClientDeleteStoreRequestInterface {
request.options = &options
return request
}
func (request *SdkClientDeleteStoreRequest) Execute() (*ClientDeleteStoreResponse, error) {
return request.Client.DeleteStoreExecute(request)
}
func (request *SdkClientDeleteStoreRequest) GetStoreIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.StoreId
}
func (request *SdkClientDeleteStoreRequest) GetContext() _context.Context {
return request.ctx
}
func (request *SdkClientDeleteStoreRequest) GetOptions() *ClientDeleteStoreOptions {
return request.options
}
func (client *OpenFgaClient) DeleteStoreExecute(request SdkClientDeleteStoreRequestInterface) (*ClientDeleteStoreResponse, error) {
storeId, err := client.getStoreId(request.GetStoreIdOverride())
if err != nil {
return nil, err
}
_, err = client.OpenFgaApi.DeleteStore(request.GetContext(), *storeId).Execute()
if err != nil {
return nil, err
}
return &ClientDeleteStoreResponse{}, nil
}
func (client *OpenFgaClient) DeleteStore(ctx _context.Context) SdkClientDeleteStoreRequestInterface {
return &SdkClientDeleteStoreRequest{
Client: client,
ctx: ctx,
}
}
/* Authorization Models */
// / ReadAuthorizationModels
type SdkClientReadAuthorizationModelsRequest struct {
ctx _context.Context
Client *OpenFgaClient
options *ClientReadAuthorizationModelsOptions
}
type SdkClientReadAuthorizationModelsRequestInterface interface {
Options(options ClientReadAuthorizationModelsOptions) SdkClientReadAuthorizationModelsRequestInterface
Execute() (*ClientReadAuthorizationModelsResponse, error)
GetStoreIdOverride() *string
GetContext() _context.Context
GetOptions() *ClientReadAuthorizationModelsOptions
}
type ClientReadAuthorizationModelsOptions struct {
PageSize *int32 `json:"page_size,omitempty"`
ContinuationToken *string `json:"continuation_token,omitempty"`
StoreId *string `json:"store_id,omitempty"`
}
type ClientReadAuthorizationModelsResponse = fgaSdk.ReadAuthorizationModelsResponse
func (request *SdkClientReadAuthorizationModelsRequest) Options(options ClientReadAuthorizationModelsOptions) SdkClientReadAuthorizationModelsRequestInterface {
request.options = &options
return request
}
func (request *SdkClientReadAuthorizationModelsRequest) Execute() (*ClientReadAuthorizationModelsResponse, error) {
return request.Client.ReadAuthorizationModelsExecute(request)
}
func (request *SdkClientReadAuthorizationModelsRequest) GetStoreIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.StoreId
}
func (request *SdkClientReadAuthorizationModelsRequest) GetContext() _context.Context {
return request.ctx
}
func (request *SdkClientReadAuthorizationModelsRequest) GetOptions() *ClientReadAuthorizationModelsOptions {
return request.options
}
func (client *OpenFgaClient) ReadAuthorizationModelsExecute(request SdkClientReadAuthorizationModelsRequestInterface) (*ClientReadAuthorizationModelsResponse, error) {
pagingOpts := ClientPaginationOptions{}
if request.GetOptions() != nil {
pagingOpts.PageSize = request.GetOptions().PageSize
pagingOpts.ContinuationToken = request.GetOptions().ContinuationToken
}
storeId, err := client.getStoreId(request.GetStoreIdOverride())
if err != nil {
return nil, err
}
req := client.OpenFgaApi.ReadAuthorizationModels(request.GetContext(), *storeId)
pageSize := getPageSizeFromRequest(&pagingOpts)
if pageSize != nil {
req = req.PageSize(*pageSize)
}
continuationToken := getContinuationTokenFromRequest(&pagingOpts)
if continuationToken != nil {
req = req.ContinuationToken(*continuationToken)
}
data, _, err := req.Execute()
if err != nil {
return nil, err
}
return &data, nil
}
func (client *OpenFgaClient) ReadAuthorizationModels(ctx _context.Context) SdkClientReadAuthorizationModelsRequestInterface {
return &SdkClientReadAuthorizationModelsRequest{
Client: client,
ctx: ctx,
}
}
// / WriteAuthorizationModel
type SdkClientWriteAuthorizationModelRequest struct {
ctx _context.Context
Client *OpenFgaClient
body *ClientWriteAuthorizationModelRequest
options *ClientWriteAuthorizationModelOptions
}
type SdkClientWriteAuthorizationModelRequestInterface interface {
Options(options ClientWriteAuthorizationModelOptions) SdkClientWriteAuthorizationModelRequestInterface
Body(body ClientWriteAuthorizationModelRequest) SdkClientWriteAuthorizationModelRequestInterface
Execute() (*ClientWriteAuthorizationModelResponse, error)
GetStoreIdOverride() *string
GetBody() *ClientWriteAuthorizationModelRequest
GetOptions() *ClientWriteAuthorizationModelOptions
GetContext() _context.Context
}
type ClientWriteAuthorizationModelRequest = fgaSdk.WriteAuthorizationModelRequest
type ClientWriteAuthorizationModelOptions struct {
StoreId *string `json:"store_id,omitempty"`
}
type ClientWriteAuthorizationModelResponse = fgaSdk.WriteAuthorizationModelResponse
func (request *SdkClientWriteAuthorizationModelRequest) Options(options ClientWriteAuthorizationModelOptions) SdkClientWriteAuthorizationModelRequestInterface {
request.options = &options
return request
}
func (request *SdkClientWriteAuthorizationModelRequest) Body(body ClientWriteAuthorizationModelRequest) SdkClientWriteAuthorizationModelRequestInterface {
request.body = &body
return request
}
func (request *SdkClientWriteAuthorizationModelRequest) Execute() (*ClientWriteAuthorizationModelResponse, error) {
return request.Client.WriteAuthorizationModelExecute(request)
}
func (request *SdkClientWriteAuthorizationModelRequest) GetStoreIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.StoreId
}
func (request *SdkClientWriteAuthorizationModelRequest) GetBody() *ClientWriteAuthorizationModelRequest {
return request.body
}
func (request *SdkClientWriteAuthorizationModelRequest) GetOptions() *ClientWriteAuthorizationModelOptions {
return request.options
}
func (request *SdkClientWriteAuthorizationModelRequest) GetContext() _context.Context {
return request.ctx
}
func (client *OpenFgaClient) WriteAuthorizationModelExecute(request SdkClientWriteAuthorizationModelRequestInterface) (*ClientWriteAuthorizationModelResponse, error) {
storeId, err := client.getStoreId(request.GetStoreIdOverride())
if err != nil {
return nil, err
}
data, _, err := client.OpenFgaApi.WriteAuthorizationModel(request.GetContext(), *storeId).Body(*request.GetBody()).Execute()
if err != nil {
return nil, err
}
return &data, nil
}
func (client *OpenFgaClient) WriteAuthorizationModel(ctx _context.Context) SdkClientWriteAuthorizationModelRequestInterface {
return &SdkClientWriteAuthorizationModelRequest{
Client: client,
ctx: ctx,
}
}
// / ReadAuthorizationModel
type SdkClientReadAuthorizationModelRequest struct {
ctx _context.Context
Client *OpenFgaClient
body *ClientReadAuthorizationModelRequest
options *ClientReadAuthorizationModelOptions
}
type SdkClientReadAuthorizationModelRequestInterface interface {
Options(options ClientReadAuthorizationModelOptions) SdkClientReadAuthorizationModelRequestInterface
Body(body ClientReadAuthorizationModelRequest) SdkClientReadAuthorizationModelRequestInterface
Execute() (*ClientReadAuthorizationModelResponse, error)
GetAuthorizationModelIdOverride() *string
GetStoreIdOverride() *string
GetContext() _context.Context
GetBody() *ClientReadAuthorizationModelRequest
GetOptions() *ClientReadAuthorizationModelOptions
}
type ClientReadAuthorizationModelRequest struct {
}
type ClientReadAuthorizationModelOptions struct {
AuthorizationModelId *string `json:"authorization_model_id,omitempty"`
StoreId *string `json:"store_id,omitempty"`
}
type ClientReadAuthorizationModelResponse = fgaSdk.ReadAuthorizationModelResponse
func (request *SdkClientReadAuthorizationModelRequest) Options(options ClientReadAuthorizationModelOptions) SdkClientReadAuthorizationModelRequestInterface {
request.options = &options
return request
}
func (request *SdkClientReadAuthorizationModelRequest) GetAuthorizationModelIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.AuthorizationModelId
}
func (request *SdkClientReadAuthorizationModelRequest) GetStoreIdOverride() *string {
if request.options == nil {
return nil
}
return request.options.StoreId
}
func (request *SdkClientReadAuthorizationModelRequest) Body(body ClientReadAuthorizationModelRequest) SdkClientReadAuthorizationModelRequestInterface {
request.body = &body
return request
}
func (request *SdkClientReadAuthorizationModelRequest) Execute() (*ClientReadAuthorizationModelResponse, error) {
return request.Client.ReadAuthorizationModelExecute(request)
}
func (request *SdkClientReadAuthorizationModelRequest) GetBody() *ClientReadAuthorizationModelRequest {
return request.body
}
func (request *SdkClientReadAuthorizationModelRequest) GetOptions() *ClientReadAuthorizationModelOptions {
return request.options
}
func (request *SdkClientReadAuthorizationModelRequest) GetContext() _context.Context {
return request.ctx
}