Skip to content

Commit 6ca1e59

Browse files
authored
chore: add api endpoints to get idp field values (#16063)
Supports coder/internal#210
1 parent 303c4a9 commit 6ca1e59

File tree

7 files changed

+359
-0
lines changed

7 files changed

+359
-0
lines changed

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

codersdk/idpsync.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/http"
8+
"net/url"
89
"regexp"
910

1011
"github.com/google/uuid"
@@ -163,3 +164,35 @@ func (c *Client) GetOrganizationAvailableIDPSyncFields(ctx context.Context, orgI
163164
var resp []string
164165
return resp, json.NewDecoder(res.Body).Decode(&resp)
165166
}
167+
168+
func (c *Client) GetIDPSyncFieldValues(ctx context.Context, claimField string) ([]string, error) {
169+
qv := url.Values{}
170+
qv.Add("claimField", claimField)
171+
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/settings/idpsync/field-values?%s", qv.Encode()), nil)
172+
if err != nil {
173+
return nil, xerrors.Errorf("make request: %w", err)
174+
}
175+
defer res.Body.Close()
176+
177+
if res.StatusCode != http.StatusOK {
178+
return nil, ReadBodyAsError(res)
179+
}
180+
var resp []string
181+
return resp, json.NewDecoder(res.Body).Decode(&resp)
182+
}
183+
184+
func (c *Client) GetOrganizationIDPSyncFieldValues(ctx context.Context, orgID string, claimField string) ([]string, error) {
185+
qv := url.Values{}
186+
qv.Add("claimField", claimField)
187+
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/organizations/%s/settings/idpsync/field-values?%s", orgID, qv.Encode()), nil)
188+
if err != nil {
189+
return nil, xerrors.Errorf("make request: %w", err)
190+
}
191+
defer res.Body.Close()
192+
193+
if res.StatusCode != http.StatusOK {
194+
return nil, ReadBodyAsError(res)
195+
}
196+
var resp []string
197+
return resp, json.NewDecoder(res.Body).Decode(&resp)
198+
}

docs/reference/api/enterprise.md

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

enterprise/coderd/coderd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
297297
r.Patch("/", api.patchOrganizationIDPSyncSettings)
298298
})
299299
r.Get("/available-fields", api.deploymentIDPSyncClaimFields)
300+
r.Get("/field-values", api.deploymentIDPSyncClaimFieldValues)
300301
})
301302
})
302303

@@ -311,6 +312,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
311312
r.Patch("/idpsync/groups", api.patchGroupIDPSyncSettings)
312313
r.Get("/idpsync/roles", api.roleIDPSyncSettings)
313314
r.Patch("/idpsync/roles", api.patchRoleIDPSyncSettings)
315+
r.Get("/idpsync/field-values", api.organizationIDPSyncClaimFieldValues)
314316
})
315317
})
316318

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy