Skip to content

Commit cdee50c

Browse files
uc-build-userjwangxx
authored andcommitted
Sync monorepo state at 6910b9f5795b8dce64601f1cbba153a9b910e448
1 parent b1c1234 commit cdee50c

25 files changed

+590
-103
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

3-
## UNPUBLISHED
3+
## 1.2.0 - 09-04-2024
4+
5+
- Add methods for creating, retrieving, updating, and deleting ColumnDataTypes
6+
- Add DataType field to Column that refers to a ColumnDataType
7+
- Add InputDataType and OutputDataType fields to Transformer that refer to ColumnDataTypes
8+
- Update userstore sample to interact with ColumnDataTypes
9+
- Breaking change: Add additional boolean parameter to ListAccessors an ListMutators for requesting all versions
10+
11+
## 1.1.0 - 20-03-2024
412

513
- Breaking change: idp/userstore/ColumnField parameter "Optional" has been changed to "Required", with fields not required by default
614
- Add InputConstraints and OutputConstraints parameters of type idp/userstore/ColumnConstraints to idp/policy/Transformer

authz/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ func (c *Client) CreateObject(ctx context.Context, id, typeID uuid.UUID, alias s
754754
}
755755
return &resp, nil
756756
}, func(in *Object, curr *Object) bool {
757-
return curr.EqualsIgnoringID(in, true) && (id.IsNil() || curr.ID == id)
757+
return curr.EqualsIgnoringID(in) && (id.IsNil() || curr.ID == id)
758758
})
759759
}
760760

authz/models.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ type Object struct {
164164
}
165165

166166
// EqualsIgnoringID returns true if the two objects are equal, ignoring the ID field
167-
func (o *Object) EqualsIgnoringID(other *Object, includeOrg bool) bool {
167+
func (o *Object) EqualsIgnoringID(other *Object) bool {
168168
if o.Alias == nil && other.Alias == nil {
169-
return o.TypeID == other.TypeID && (!includeOrg || o.OrganizationID == other.OrganizationID)
169+
return o.TypeID == other.TypeID && o.OrganizationID == other.OrganizationID
170170
}
171171
if o.Alias == nil || other.Alias == nil {
172172
return false
173173
}
174-
return *o.Alias == *other.Alias && o.TypeID == other.TypeID && (!includeOrg || o.OrganizationID == other.OrganizationID)
174+
return *o.Alias == *other.Alias && o.TypeID == other.TypeID && o.OrganizationID == other.OrganizationID
175175
}
176176

177177
//go:generate genvalidate Object

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
)
2121

2222
retract (
23+
v0.8.5
2324
v0.8.4
2425
v0.8.3
2526
v0.8.2

idp/client.go

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"net/url"
8+
"strconv"
89
"strings"
910
"time"
1011

@@ -23,6 +24,7 @@ import (
2324
type options struct {
2425
ifNotExists bool
2526
includeAuthN bool
27+
debug bool
2628
organizationID uuid.UUID
2729
userID uuid.UUID
2830
dataRegion region.DataRegion
@@ -55,6 +57,13 @@ func IncludeAuthN() Option {
5557
})
5658
}
5759

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+
5867
// OrganizationID returns an Option that will cause the client to use the specified organization ID for the request
5968
func OrganizationID(organizationID uuid.UUID) Option {
6069
return optFunc(func(opts *options) {
@@ -236,6 +245,110 @@ func (c *Client) DeleteUser(ctx context.Context, id uuid.UUID) error {
236245
return ucerr.Wrap(c.client.Delete(ctx, requestURL.String(), nil))
237246
}
238247

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+
239352
// CreateColumnRequest is the request body for creating a new column
240353
// TODO: should this support multiple at once before we ship this API?
241354
type CreateColumnRequest struct {
@@ -782,7 +895,7 @@ type ListAccessorsResponse struct {
782895
}
783896

784897
// 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) {
786899
options := c.options
787900
for _, opt := range opts {
788901
opt.apply(&options)
@@ -793,6 +906,7 @@ func (c *Client) ListAccessors(ctx context.Context, opts ...Option) (*ListAccess
793906
}
794907

795908
query := pager.Query()
909+
query.Add("versioned", strconv.FormatBool(versioned))
796910

797911
var res ListAccessorsResponse
798912
if err := c.client.Get(ctx, fmt.Sprintf("%s?%s", paths.ListAccessorsPath, query.Encode()), &res); err != nil {
@@ -893,7 +1007,7 @@ type ListMutatorsResponse struct {
8931007
}
8941008

8951009
// 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) {
8971011
options := c.options
8981012
for _, opt := range opts {
8991013
opt.apply(&options)
@@ -904,6 +1018,7 @@ func (c *Client) ListMutators(ctx context.Context, opts ...Option) (*ListMutator
9041018
}
9051019

9061020
query := pager.Query()
1021+
query.Add("versioned", strconv.FormatBool(versioned))
9071022

9081023
var res ListMutatorsResponse
9091024
if err := c.client.Get(ctx, fmt.Sprintf("%s?%s", paths.ListMutatorsPath, query.Encode()), &res); err != nil {
@@ -939,13 +1054,15 @@ type ExecuteAccessorRequest struct {
9391054
AccessorID uuid.UUID `json:"accessor_id" validate:"notnil"` // the accessor that specifies what data to access
9401055
Context policy.ClientContext `json:"context"` // context that is provided to the accessor Access Policy
9411056
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
9421058
}
9431059

9441060
//go:generate genvalidate ExecuteAccessorRequest
9451061

9461062
// ExecuteAccessorResponse is the response body for accessing user data
9471063
type ExecuteAccessorResponse struct {
948-
Data []string `json:"data"`
1064+
Data []string `json:"data"`
1065+
Debug map[string]interface{} `json:"debug,omitempty"`
9491066
pagination.ResponseFields
9501067
}
9511068

@@ -966,6 +1083,7 @@ func (c *Client) ExecuteAccessor(ctx context.Context, accessorID uuid.UUID, clie
9661083
AccessorID: accessorID,
9671084
Context: clientContext,
9681085
SelectorValues: selectorValues,
1086+
Debug: options.debug,
9691087
}
9701088

9711089
var res ExecuteAccessorResponse
@@ -985,6 +1103,8 @@ const MutatorColumnCurrentValue = "UCCUR-7f55f479-3822-4976-a8a9-b789d5c6f152"
9851103
// ValueAndPurposes is a tuple for specifying the value and the purpose to store for a user column
9861104
type ValueAndPurposes struct {
9871105
Value any `json:"value"`
1106+
ValueAdditions any `json:"value_additions"`
1107+
ValueDeletions any `json:"value_deletions"`
9881108
PurposeAdditions []userstore.ResourceID `json:"purpose_additions"`
9891109
PurposeDeletions []userstore.ResourceID `json:"purpose_deletions"`
9901110
}
@@ -1239,3 +1359,22 @@ func (c *Client) DownloadPythonSDK(ctx context.Context) (string, error) {
12391359

12401360
return sdk, nil
12411361
}
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+
}

idp/paths/data_type_paths.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package paths
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/gofrs/uuid"
7+
)
8+
9+
// DataTypePath is the path constant for interacting with data types
10+
var DataTypePath = fmt.Sprintf("%s/%s", BaseConfigPath, "datatypes")
11+
12+
// DataTypePathForID returns the data type path for a specific data type id
13+
func DataTypePathForID(dataTypeID uuid.UUID) string {
14+
return fmt.Sprintf("%s/%v", DataTypePath, dataTypeID)
15+
}

idp/paths/paths.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,31 @@ var (
153153
TestTransformer = fmt.Sprintf("%s/actions/test", BaseTransformerPath)
154154
ExecuteTransformer = fmt.Sprintf("%s/actions/execute", BaseTransformerPath)
155155

156+
BaseDataMappingPath = "/userstore/datamapping"
157+
158+
CreateDataSourcePath = fmt.Sprintf("%s/datasource", BaseDataMappingPath)
159+
singleDataSourcePath = func(id uuid.UUID) string {
160+
return fmt.Sprintf("%s/%s", CreateDataSourcePath, id)
161+
}
162+
DeleteDataSourcePath = singleDataSourcePath
163+
GetDataSourcePath = singleDataSourcePath
164+
UpdateDataSourcePath = singleDataSourcePath
165+
ListDataSourcesPath = CreateDataSourcePath
166+
167+
CreateDataSourceElementPath = fmt.Sprintf("%s/element", BaseDataMappingPath)
168+
singleDataSourceElementPath = func(id uuid.UUID) string {
169+
return fmt.Sprintf("%s/%s", CreateDataSourceElementPath, id)
170+
}
171+
DeleteDataSourceElementPath = singleDataSourceElementPath
172+
GetDataSourceElementPath = singleDataSourceElementPath
173+
UpdateDataSourceElementPath = singleDataSourceElementPath
174+
ListDataSourceElementsPath = CreateDataSourceElementPath
175+
156176
DownloadGolangSDKPath = fmt.Sprintf("%s/download/codegensdk.go", UserStoreBasePath)
157177
DownloadPythonSDKPath = fmt.Sprintf("%s/download/codegensdk.py", UserStoreBasePath)
158178
DownloadTypescriptSDKPath = fmt.Sprintf("%s/download/codegensdk.ts", UserStoreBasePath)
179+
180+
ExternalOIDCIssuersPath = fmt.Sprintf("%s/oidcissuers", UserStoreBasePath)
159181
)
160182

161183
// StripUserstoreBase makes the URLs functional for handler setup

0 commit comments

Comments
 (0)