From 4b51cafe713564fb554ed94d1a34c9c6f305c395 Mon Sep 17 00:00:00 2001 From: harture <31417989+harture@users.noreply.github.com> Date: Mon, 30 Sep 2019 15:51:20 +0200 Subject: [PATCH] Update label API --- credentials.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/credentials.go b/credentials.go index 037db92..2eefc30 100644 --- a/credentials.go +++ b/credentials.go @@ -2,6 +2,7 @@ package keycloak import ( "gopkg.in/h2non/gentleman.v2/plugins/body" + "gopkg.in/h2non/gentleman.v2/plugins/headers" "gopkg.in/h2non/gentleman.v2/plugins/url" ) @@ -9,7 +10,8 @@ const ( resetPasswordPath = userIDPath + "/reset-password" credentialsPath = userIDPath + "/credentials" credentialsTypesPath = realmPath + "/credentialTypes" - credentialIDPath = "/:credentialID" + credentialIDPath = credentialsPath + "/:credentialID" + labelPath = credentialIDPath + "/label" moveFirstPath = credentialIDPath + "/moveToFirst" moveAfterPath = credentialIDPath + "/moveAfter/:previousCredentialID" ) @@ -34,9 +36,9 @@ func (c *Client) GetCredentialTypes(accessToken string, realmName string) ([]str return resp, err } -// UpdateCredential updates the credential -func (c *Client) UpdateCredential(accessToken string, realmName string, userID string, credentialID string, credential CredentialRepresentation) error { - return c.put(accessToken, url.Path(credentialIDPath), url.Param("realm", realmName), url.Param("id", userID), url.Param("credentialID", credentialID), body.JSON(credential)) +// UpdateLabelCredential updates the label of credential +func (c *Client) UpdateLabelCredential(accessToken string, realmName string, credentialID string, label string) error { + return c.put(accessToken, url.Path(labelPath), url.Param("realm", realmName), url.Param("credentialID", credentialID), body.String(label), headers.Set("Accept", "application/json"), headers.Set("Content-Type", "text/plain")) } // DeleteCredential deletes the credential