-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IAM]: root user pwd change What this PR does / why we need it Added function to change root user password. Reviewed-by: Artem Sh. Reviewed-by: Anton Sidelnikov
- Loading branch information
1 parent
d52d70e
commit 9c5bb50
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package users | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
) | ||
|
||
type ChangePasswordOpts struct { | ||
UserId string `json:"-"` | ||
OriginalPassword string `json:"original_password"` | ||
NewPassword string `json:"password"` | ||
} | ||
|
||
func ChangePassword(client *golangsdk.ServiceClient, opts ChangePasswordOpts) error { | ||
b, err := build.RequestBody(opts, "user") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = client.Post(client.ServiceURL("users", opts.UserId, "password"), b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{204}, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |