5
5
"fmt"
6
6
"io"
7
7
"net/url"
8
+ "strconv"
8
9
"strings"
9
10
"time"
10
11
@@ -23,6 +24,7 @@ import (
23
24
type options struct {
24
25
ifNotExists bool
25
26
includeAuthN bool
27
+ debug bool
26
28
organizationID uuid.UUID
27
29
userID uuid.UUID
28
30
dataRegion region.DataRegion
@@ -55,6 +57,13 @@ func IncludeAuthN() Option {
55
57
})
56
58
}
57
59
60
+ // Debug returns an Option that will cause the client to return debug information, if available
61
+ func Debug () Option {
62
+ return optFunc (func (opts * options ) {
63
+ opts .debug = true
64
+ })
65
+ }
66
+
58
67
// OrganizationID returns an Option that will cause the client to use the specified organization ID for the request
59
68
func OrganizationID (organizationID uuid.UUID ) Option {
60
69
return optFunc (func (opts * options ) {
@@ -236,6 +245,110 @@ func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error {
236
245
return ucerr .Wrap (c .client .Delete (ctx , requestURL .String (), nil ))
237
246
}
238
247
248
+ // CreateDataTypeRequest is the request body for creating a new data type
249
+ type CreateDataTypeRequest struct {
250
+ DataType userstore.ColumnDataType `json:"data_type"`
251
+ }
252
+
253
+ //go:generate genvalidate CreateDataTypeRequest
254
+
255
+ // CreateDataType creates a new data type for the associated tenant
256
+ func (c * Client ) CreateDataType (
257
+ ctx context.Context ,
258
+ dataType userstore.ColumnDataType ,
259
+ opts ... Option ,
260
+ ) (* userstore.ColumnDataType , error ) {
261
+ options := c .options
262
+ for _ , opt := range opts {
263
+ opt .apply (& options )
264
+ }
265
+
266
+ req := CreateDataTypeRequest {
267
+ DataType : dataType ,
268
+ }
269
+
270
+ var resp userstore.ColumnDataType
271
+ if options .ifNotExists {
272
+ exists , existingID , err := c .client .CreateIfNotExists (ctx , paths .DataTypePath , req , & resp )
273
+ if err != nil {
274
+ return nil , ucerr .Wrap (err )
275
+ }
276
+ if exists {
277
+ resp = req .DataType
278
+ resp .ID = existingID
279
+ }
280
+ } else {
281
+ if err := c .client .Post (ctx , paths .DataTypePath , req , & resp ); err != nil {
282
+ return nil , ucerr .Wrap (err )
283
+ }
284
+ }
285
+
286
+ return & resp , nil
287
+ }
288
+
289
+ // DeleteDataType deletes the data type specified by the data type ID for the associated tenant
290
+ func (c * Client ) DeleteDataType (ctx context.Context , dataTypeID uuid.UUID ) error {
291
+ return ucerr .Wrap (c .client .Delete (ctx , paths .DataTypePathForID (dataTypeID ), nil ))
292
+ }
293
+
294
+ // GetDataType returns the data type specified by the data type ID for the associated tenant
295
+ func (c * Client ) GetDataType (ctx context.Context , dataTypeID uuid.UUID ) (* userstore.ColumnDataType , error ) {
296
+ var resp userstore.ColumnDataType
297
+ if err := c .client .Get (ctx , paths .DataTypePathForID (dataTypeID ), & resp ); err != nil {
298
+ return nil , ucerr .Wrap (err )
299
+ }
300
+
301
+ return & resp , nil
302
+ }
303
+
304
+ // ListDataTypesResponse is the paginated response struct for listing data types
305
+ type ListDataTypesResponse struct {
306
+ Data []userstore.ColumnDataType `json:"data"`
307
+ pagination.ResponseFields
308
+ }
309
+
310
+ // ListDataTypes lists all data types for the associated tenant
311
+ func (c * Client ) ListDataTypes (ctx context.Context , opts ... Option ) (* ListDataTypesResponse , error ) {
312
+ options := c .options
313
+ for _ , opt := range opts {
314
+ opt .apply (& options )
315
+ }
316
+
317
+ pager , err := pagination .ApplyOptions (options .paginationOptions ... )
318
+ if err != nil {
319
+ return nil , ucerr .Wrap (err )
320
+ }
321
+ query := pager .Query ()
322
+
323
+ var res ListDataTypesResponse
324
+ if err := c .client .Get (ctx , fmt .Sprintf ("%s?%s" , paths .DataTypePath , query .Encode ()), & res ); err != nil {
325
+ return nil , ucerr .Wrap (err )
326
+ }
327
+
328
+ return & res , nil
329
+ }
330
+
331
+ // UpdateDataTypeRequest is the request body for updating a data type
332
+ type UpdateDataTypeRequest struct {
333
+ DataType userstore.ColumnDataType `json:"data_type"`
334
+ }
335
+
336
+ //go:generate genvalidate UpdateDataTypeRequest
337
+
338
+ // UpdateDataType updates the data type specified by the data type ID with the specified data for the associated tenant
339
+ func (c * Client ) UpdateDataType (ctx context.Context , dataTypeID uuid.UUID , updatedDataType userstore.ColumnDataType ) (* userstore.ColumnDataType , error ) {
340
+ req := UpdateDataTypeRequest {
341
+ DataType : updatedDataType ,
342
+ }
343
+
344
+ var resp userstore.ColumnDataType
345
+ if err := c .client .Put (ctx , paths .DataTypePathForID (dataTypeID ), req , & resp ); err != nil {
346
+ return nil , ucerr .Wrap (err )
347
+ }
348
+
349
+ return & resp , nil
350
+ }
351
+
239
352
// CreateColumnRequest is the request body for creating a new column
240
353
// TODO: should this support multiple at once before we ship this API?
241
354
type CreateColumnRequest struct {
@@ -782,7 +895,7 @@ type ListAccessorsResponse struct {
782
895
}
783
896
784
897
// ListAccessors lists all the available accessors for the associated tenant
785
- func (c * Client ) ListAccessors (ctx context.Context , opts ... Option ) (* ListAccessorsResponse , error ) {
898
+ func (c * Client ) ListAccessors (ctx context.Context , versioned bool , opts ... Option ) (* ListAccessorsResponse , error ) {
786
899
options := c .options
787
900
for _ , opt := range opts {
788
901
opt .apply (& options )
@@ -793,6 +906,7 @@ func (c *Client) ListAccessors(ctx context.Context, opts ...Option) (*ListAccess
793
906
}
794
907
795
908
query := pager .Query ()
909
+ query .Add ("versioned" , strconv .FormatBool (versioned ))
796
910
797
911
var res ListAccessorsResponse
798
912
if err := c .client .Get (ctx , fmt .Sprintf ("%s?%s" , paths .ListAccessorsPath , query .Encode ()), & res ); err != nil {
@@ -893,7 +1007,7 @@ type ListMutatorsResponse struct {
893
1007
}
894
1008
895
1009
// ListMutators lists all the available mutators for the associated tenant
896
- func (c * Client ) ListMutators (ctx context.Context , opts ... Option ) (* ListMutatorsResponse , error ) {
1010
+ func (c * Client ) ListMutators (ctx context.Context , versioned bool , opts ... Option ) (* ListMutatorsResponse , error ) {
897
1011
options := c .options
898
1012
for _ , opt := range opts {
899
1013
opt .apply (& options )
@@ -904,6 +1018,7 @@ func (c *Client) ListMutators(ctx context.Context, opts ...Option) (*ListMutator
904
1018
}
905
1019
906
1020
query := pager .Query ()
1021
+ query .Add ("versioned" , strconv .FormatBool (versioned ))
907
1022
908
1023
var res ListMutatorsResponse
909
1024
if err := c .client .Get (ctx , fmt .Sprintf ("%s?%s" , paths .ListMutatorsPath , query .Encode ()), & res ); err != nil {
@@ -939,13 +1054,15 @@ type ExecuteAccessorRequest struct {
939
1054
AccessorID uuid.UUID `json:"accessor_id" validate:"notnil"` // the accessor that specifies what data to access
940
1055
Context policy.ClientContext `json:"context"` // context that is provided to the accessor Access Policy
941
1056
SelectorValues userstore.UserSelectorValues `json:"selector_values"` // the values to use for the selector
1057
+ Debug bool `json:"debug,omitempty"` // whether to include debug information in the response
942
1058
}
943
1059
944
1060
//go:generate genvalidate ExecuteAccessorRequest
945
1061
946
1062
// ExecuteAccessorResponse is the response body for accessing user data
947
1063
type ExecuteAccessorResponse struct {
948
- Data []string `json:"data"`
1064
+ Data []string `json:"data"`
1065
+ Debug map [string ]interface {} `json:"debug,omitempty"`
949
1066
pagination.ResponseFields
950
1067
}
951
1068
@@ -966,6 +1083,7 @@ func (c *Client) ExecuteAccessor(ctx context.Context, accessorID uuid.UUID, clie
966
1083
AccessorID : accessorID ,
967
1084
Context : clientContext ,
968
1085
SelectorValues : selectorValues ,
1086
+ Debug : options .debug ,
969
1087
}
970
1088
971
1089
var res ExecuteAccessorResponse
@@ -985,6 +1103,8 @@ const MutatorColumnCurrentValue = "UCCUR-7f55f479-3822-4976-a8a9-b789d5c6f152"
985
1103
// ValueAndPurposes is a tuple for specifying the value and the purpose to store for a user column
986
1104
type ValueAndPurposes struct {
987
1105
Value any `json:"value"`
1106
+ ValueAdditions any `json:"value_additions"`
1107
+ ValueDeletions any `json:"value_deletions"`
988
1108
PurposeAdditions []userstore.ResourceID `json:"purpose_additions"`
989
1109
PurposeDeletions []userstore.ResourceID `json:"purpose_deletions"`
990
1110
}
@@ -1239,3 +1359,22 @@ func (c *Client) DownloadPythonSDK(ctx context.Context) (string, error) {
1239
1359
1240
1360
return sdk , nil
1241
1361
}
1362
+
1363
+ // GetExternalOIDCIssuers returns the list of external OIDC issuers for JWT tokens for the tenant
1364
+ func (c * Client ) GetExternalOIDCIssuers (ctx context.Context ) ([]string , error ) {
1365
+ var resp []string
1366
+ if err := c .client .Get (ctx , paths .ExternalOIDCIssuersPath , & resp ); err != nil {
1367
+ return nil , ucerr .Wrap (err )
1368
+ }
1369
+
1370
+ return resp , nil
1371
+ }
1372
+
1373
+ // UpdateExternalOIDCIssuers updates the list of external OIDC issuers for JWT tokens for the tenant
1374
+ func (c * Client ) UpdateExternalOIDCIssuers (ctx context.Context , issuers []string ) error {
1375
+ if err := c .client .Put (ctx , paths .ExternalOIDCIssuersPath , issuers , nil ); err != nil {
1376
+ return ucerr .Wrap (err )
1377
+ }
1378
+
1379
+ return nil
1380
+ }
0 commit comments