-
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.
- Loading branch information
1 parent
da6529b
commit cffd310
Showing
2 changed files
with
134 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,64 @@ | ||
package users | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
) | ||
|
||
// UpdateAdminOpts provides options used to update user as administrator | ||
type UpdateAdminOpts struct { | ||
// Id is the IAM user ID | ||
Id string `json:"-"` | ||
|
||
// Name is the name of the new user. | ||
Name string `json:"name,omitempty"` | ||
|
||
// Password is the password of the new user. | ||
Password string `json:"password,omitempty"` | ||
|
||
// Email address with a maximum of 255 characters | ||
Email string `json:"email,omitempty"` | ||
|
||
// AreaCode is a country code, must be used together with Phone. | ||
AreaCode string `json:"areacode,omitempty"` | ||
|
||
// Phone is a mobile number with a maximum of 32 digits, must be used together with AreaCode. | ||
Phone string `json:"phone,omitempty"` | ||
|
||
// Description is a description of the user. | ||
Description string `json:"description,omitempty"` | ||
|
||
// AccessMode is the access type for IAM user | ||
AccessMode string `json:"access_mode,omitempty"` | ||
|
||
// Enabled sets the user status to enabled or disabled. | ||
Enabled *bool `json:"enabled,omitempty"` | ||
|
||
// PwdStatus Indicates whether the user must change their password at the first login. | ||
PwdStatus *bool `json:"pwd_status,omitempty"` | ||
|
||
// XuserType is the type of the user in the external system. | ||
XuserType string `json:"xuser_type"` | ||
|
||
// XuserId is the ID of the user in the external system. | ||
XuserId string `json:"xuser_id"` | ||
} | ||
|
||
func ModifyUserAdmin(client *golangsdk.ServiceClient, opts UpdateAdminOpts) (*User, error) { | ||
b, err := build.RequestBody(opts, "user") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// PUT /v3.0/OS-USER/users/{user_id} | ||
raw, err := client.Put(client.ServiceURL("OS-USER", "users", opts.Id), b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res User | ||
return &res, extract.IntoStructPtr(raw.Body, &res, "user") | ||
} |