Skip to content

Commit

Permalink
[CLOUDTRUST-4069] Add support for support-infos endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fperot74 authored Mar 2, 2022
1 parent 111a079 commit eb5ad58
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (

"github.com/cloudtrust/keycloak-client/v2"
"gopkg.in/h2non/gentleman.v2/plugins/body"
"gopkg.in/h2non/gentleman.v2/plugins/query"
"gopkg.in/h2non/gentleman.v2/plugins/url"
)

const (
userPath = "/auth/admin/realms/:realm/users"
adminExtensionAPIPath = "/auth/realms/:realmReq/api/admin/realms/:realm"
adminRootPath = "/auth/realms/:realmReq/api/admin"
adminExtensionAPIPath = adminRootPath + "/realms/:realm"
usersAdminExtensionAPIPath = adminExtensionAPIPath + "/users"
sendEmailAdminExtensionAPIPath = adminExtensionAPIPath + "/send-email"
userCountPath = userPath + "/count"
Expand All @@ -25,7 +27,8 @@ const (
checkSmsConsentCode = sendSmsConsentCode + "/:consent"
sendSMSPath = smsAPI + "/sendSms"
shadowUser = userIDPath + "/federated-identity/:provider"
expiredToUAcceptancePath = "/auth/realms/:realmReq/api/admin/expired-tou-acceptance"
expiredToUAcceptancePath = adminRootPath + "/expired-tou-acceptance"
getSupportInfoPath = adminRootPath + "/support-infos"
)

// GetUsers returns a list of users, filtered according to the query parameters.
Expand Down Expand Up @@ -164,3 +167,10 @@ func (c *Client) GetExpiredTermsOfUseAcceptance(accessToken string) ([]keycloak.
err := c.get(accessToken, &deletableUsers, url.Path(expiredToUAcceptancePath), url.Param("realmReq", "master"))
return deletableUsers, err
}

// GetSupportInfo gets the list of accounts matching a given email address
func (c *Client) GetSupportInfo(accessToken string, email string) ([]keycloak.EmailInfoRepresentation, error) {
var emailInfos []keycloak.EmailInfoRepresentation
err := c.get(accessToken, &emailInfos, url.Path(getSupportInfoPath), url.Param("realmReq", "master"), query.Add("email", email))
return emailInfos, err
}
6 changes: 6 additions & 0 deletions definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,9 @@ type DeletableUserRepresentation struct {
UserID string `json:"userId,omitempty"`
Username string `json:"username,omitempty"`
}

// EmailInfoRepresentation struct
type EmailInfoRepresentation struct {
RealmName *string `json:"realm,omitempty"`
CreationDate *int64 `json:"creationDate,omitempty"`
}

0 comments on commit eb5ad58

Please sign in to comment.