- Notifications
You must be signed in to change notification settings - Fork929
feat: add endpoint for partial updates to org sync mapping#16316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,6 +12,15 @@ import ( | ||
"golang.org/x/xerrors" | ||
) | ||
// constraining to `uuid.UUID | string` here would be nice but `make gen` will | ||
// yell at you for it. | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
type IDPSyncMapping[ResourceIdType uuid.UUID | string] struct { | ||
// The IdP claim the user has | ||
Given string | ||
// The ID of the Coder resource the user should be added to | ||
Gets ResourceIdType | ||
} | ||
type GroupSyncSettings struct { | ||
// Field is the name of the claim field that specifies what groups a user | ||
// should be in. If empty, no groups will be synced. | ||
@@ -137,6 +146,26 @@ func (c *Client) PatchOrganizationIDPSyncSettings(ctx context.Context, req Organ | ||
return resp, json.NewDecoder(res.Body).Decode(&resp) | ||
} | ||
// If the same mapping is present in both Add and Remove, Remove will take presidence. | ||
type PatchOrganizationIDPSyncMappingRequest struct { | ||
Add []IDPSyncMapping[uuid.UUID] | ||
Remove []IDPSyncMapping[uuid.UUID] | ||
} | ||
func (c *Client) PatchOrganizationIDPSyncMapping(ctx context.Context, req PatchOrganizationIDPSyncMappingRequest) (OrganizationSyncSettings, error) { | ||
res, err := c.Request(ctx, http.MethodPatch, "/api/v2/settings/idpsync/organization/mapping", req) | ||
if err != nil { | ||
return OrganizationSyncSettings{}, xerrors.Errorf("make request: %w", err) | ||
} | ||
defer res.Body.Close() | ||
if res.StatusCode != http.StatusOK { | ||
return OrganizationSyncSettings{}, ReadBodyAsError(res) | ||
} | ||
var resp OrganizationSyncSettings | ||
return resp, json.NewDecoder(res.Body).Decode(&resp) | ||
} | ||
func (c *Client) GetAvailableIDPSyncFields(ctx context.Context) ([]string, error) { | ||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/settings/idpsync/available-fields", nil) | ||
if err != nil { | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.