Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb256b20

Browse files
authored
feat: add endpoint for partial updates to org sync field and assign_default (#16337)
1 parent6c90aef commitb256b20

File tree

9 files changed

+337
-4
lines changed

9 files changed

+337
-4
lines changed

‎coderd/apidoc/docs.go

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎codersdk/idpsync.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,25 @@ func (c *Client) PatchOrganizationIDPSyncSettings(ctx context.Context, req Organ
144144
returnresp,json.NewDecoder(res.Body).Decode(&resp)
145145
}
146146

147+
typePatchOrganizationIDPSyncConfigRequeststruct {
148+
Fieldstring`json:"field"`
149+
AssignDefaultbool`json:"assign_default"`
150+
}
151+
152+
func (c*Client)PatchOrganizationIDPSyncConfig(ctx context.Context,reqPatchOrganizationIDPSyncConfigRequest) (OrganizationSyncSettings,error) {
153+
res,err:=c.Request(ctx,http.MethodPatch,"/api/v2/settings/idpsync/organization/config",req)
154+
iferr!=nil {
155+
returnOrganizationSyncSettings{},xerrors.Errorf("make request: %w",err)
156+
}
157+
deferres.Body.Close()
158+
159+
ifres.StatusCode!=http.StatusOK {
160+
returnOrganizationSyncSettings{},ReadBodyAsError(res)
161+
}
162+
varrespOrganizationSyncSettings
163+
returnresp,json.NewDecoder(res.Body).Decode(&resp)
164+
}
165+
147166
// If the same mapping is present in both Add and Remove, Remove will take presidence.
148167
typePatchOrganizationIDPSyncMappingRequeststruct {
149168
Add []IDPSyncMapping[uuid.UUID]

‎docs/reference/api/enterprise.md

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/reference/api/schemas.md

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎enterprise/coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
295295
r.Route("/organization",func(r chi.Router) {
296296
r.Get("/",api.organizationIDPSyncSettings)
297297
r.Patch("/",api.patchOrganizationIDPSyncSettings)
298+
r.Patch("/config",api.patchOrganizationIDPSyncConfig)
298299
r.Patch("/mapping",api.patchOrganizationIDPSyncMapping)
299300
})
300301

‎enterprise/coderd/idpsync.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,75 @@ func (api *API) patchOrganizationIDPSyncSettings(rw http.ResponseWriter, r *http
319319
})
320320
}
321321

322+
// @Summary Update organization IdP Sync config
323+
// @ID update-organization-idp-sync-config
324+
// @Security CoderSessionToken
325+
// @Produce json
326+
// @Accept json
327+
// @Tags Enterprise
328+
// @Success 200 {object} codersdk.OrganizationSyncSettings
329+
// @Param request body codersdk.PatchOrganizationIDPSyncConfigRequest true "New config values"
330+
// @Router /settings/idpsync/organization/config [patch]
331+
func (api*API)patchOrganizationIDPSyncConfig(rw http.ResponseWriter,r*http.Request) {
332+
ctx:=r.Context()
333+
auditor:=*api.AGPL.Auditor.Load()
334+
aReq,commitAudit:=audit.InitRequest[idpsync.OrganizationSyncSettings](rw,&audit.RequestParams{
335+
Audit:auditor,
336+
Log:api.Logger,
337+
Request:r,
338+
Action:database.AuditActionWrite,
339+
})
340+
defercommitAudit()
341+
342+
if!api.Authorize(r,policy.ActionUpdate,rbac.ResourceIdpsyncSettings) {
343+
httpapi.Forbidden(rw)
344+
return
345+
}
346+
347+
varreq codersdk.PatchOrganizationIDPSyncConfigRequest
348+
if!httpapi.Read(ctx,rw,r,&req) {
349+
return
350+
}
351+
352+
varsettings*idpsync.OrganizationSyncSettings
353+
//nolint:gocritic // Requires system context to update runtime config
354+
sysCtx:=dbauthz.AsSystemRestricted(ctx)
355+
err:=database.ReadModifyUpdate(api.Database,func(tx database.Store)error {
356+
existing,err:=api.IDPSync.OrganizationSyncSettings(sysCtx,tx)
357+
iferr!=nil {
358+
returnerr
359+
}
360+
aReq.Old=*existing
361+
362+
err=api.IDPSync.UpdateOrganizationSyncSettings(sysCtx,tx, idpsync.OrganizationSyncSettings{
363+
Field:req.Field,
364+
AssignDefault:req.AssignDefault,
365+
Mapping:existing.Mapping,
366+
})
367+
iferr!=nil {
368+
returnerr
369+
}
370+
371+
settings,err=api.IDPSync.OrganizationSyncSettings(sysCtx,tx)
372+
iferr!=nil {
373+
returnerr
374+
}
375+
376+
returnnil
377+
})
378+
iferr!=nil {
379+
httpapi.InternalServerError(rw,err)
380+
return
381+
}
382+
383+
aReq.New=*settings
384+
httpapi.Write(ctx,rw,http.StatusOK, codersdk.OrganizationSyncSettings{
385+
Field:settings.Field,
386+
Mapping:settings.Mapping,
387+
AssignDefault:settings.AssignDefault,
388+
})
389+
}
390+
322391
// @Summary Update organization IdP Sync mapping
323392
// @ID update-organization-idp-sync-mapping
324393
// @Security CoderSessionToken

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp