Documentation
¶
Overview ¶
Package users manages and retrieves Users in the OpenStack Identity Service.
Example to List Users
listOpts := users.ListOpts{
DomainID: "default",
}
allPages, err := users.List(identityClient, listOpts).AllPages()
if err != nil {
panic(err)
}
allUsers, err := users.ExtractUsers(allPages)
if err != nil {
panic(err)
}
for _, user := range allUsers {
fmt.Printf("%+v\n", user)
}
Example to Create a User
projectID := "a99e9b4e620e4db09a2dfb6e42a01e66"
createOpts := users.CreateOpts{
Name: "username",
DomainID: "default",
DefaultProjectID: projectID,
Enabled: golangsdk.Enabled,
Password: "supersecret",
Extra: map[string]interface{}{
"email": "username@example.com",
}
}
user, err := users.Create(identityClient, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Update a User
userID := "0fe36e73809d46aeae6705c39077b1b3"
updateOpts := users.UpdateOpts{
Enabled: golangsdk.Disabled,
}
user, err := users.Update(identityClient, userID, updateOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete a User
userID := "0fe36e73809d46aeae6705c39077b1b3"
err := users.Delete(identityClient, userID).ExtractErr()
if err != nil {
panic(err)
}
Example to List Groups a User Belongs To
userID := "0fe36e73809d46aeae6705c39077b1b3"
allPages, err := users.ListGroups(identityClient, userID).AllPages()
if err != nil {
panic(err)
}
allGroups, err := groups.ExtractGroups(allPages)
if err != nil {
panic(err)
}
for _, group := range allGroups {
fmt.Printf("%+v\n", group)
}
Example to List Projects a User Belongs To
userID := "0fe36e73809d46aeae6705c39077b1b3"
allPages, err := users.ListProjects(identityClient, userID).AllPages()
if err != nil {
panic(err)
}
allProjects, err := projects.ExtractProjects(allPages)
if err != nil {
panic(err)
}
for _, project := range allProjects {
fmt.Printf("%+v\n", project)
}
Example to List Users in a Group
groupID := "bede500ee1124ae9b0006ff859758b3a"
listOpts := users.ListOpts{
DomainID: "default",
}
allPages, err := users.ListInGroup(identityClient, groupID, listOpts).AllPages()
if err != nil {
panic(err)
}
allUsers, err := users.ExtractUsers(allPages)
if err != nil {
panic(err)
}
for _, user := range allUsers {
fmt.Printf("%+v\n", user)
}
Index ¶
- func CreateBindingDevice(client *golangsdk.ServiceClient, opts BindMfaDevice) (err error)
- func DeleteBindingDevice(client *golangsdk.ServiceClient, opts UnbindMfaDevice) (err error)
- func DeleteMfaDevice(client *golangsdk.ServiceClient, opts DeleteMfaDeviceOpts) (err error)
- func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListGroups(client *golangsdk.ServiceClient, userID string) pagination.Pager
- func ListInGroup(client *golangsdk.ServiceClient, groupID string, opts ListOptsBuilder) pagination.Pager
- func ListProjects(client *golangsdk.ServiceClient, userID string) pagination.Pager
- type AddMembershipResult
- type BindMfaDevice
- type CreateMfaDeviceOpts
- type CreateMfaDeviceResponse
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteMfaDeviceOpts
- type DeleteResult
- type ExtendedUpdateOpts
- type ExtendedUpdateOptsBuilder
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Option
- type UnbindMfaDevice
- type UpdateExtendedResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type User
- type UserPage
- type WelcomeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateBindingDevice ¶ added in v0.5.25
func CreateBindingDevice(client *golangsdk.ServiceClient, opts BindMfaDevice) (err error)
func DeleteBindingDevice ¶ added in v0.5.25
func DeleteBindingDevice(client *golangsdk.ServiceClient, opts UnbindMfaDevice) (err error)
func DeleteMfaDevice ¶ added in v0.5.25
func DeleteMfaDevice(client *golangsdk.ServiceClient, opts DeleteMfaDeviceOpts) (err error)
func List ¶
func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager
List enumerates the Users to which the current token has access.
func ListGroups ¶
func ListGroups(client *golangsdk.ServiceClient, userID string) pagination.Pager
ListGroups enumerates groups user belongs to.
func ListInGroup ¶
func ListInGroup(client *golangsdk.ServiceClient, groupID string, opts ListOptsBuilder) pagination.Pager
ListInGroup enumerates users that belong to a group.
func ListProjects ¶
func ListProjects(client *golangsdk.ServiceClient, userID string) pagination.Pager
ListProjects enumerates groups user belongs to.
Types ¶
type AddMembershipResult ¶
type AddMembershipResult struct {
golangsdk.ErrResult
}
func AddToGroup ¶
func AddToGroup(client *golangsdk.ServiceClient, groupID string, userID string) (r AddMembershipResult)
AddToGroup add a user into one group
type BindMfaDevice ¶ added in v0.5.25
type BindMfaDevice struct {
// ID of the user to whom you will bind the virtual MFA device.
UserId string `json:"user_id"`
// Serial number of the virtual MFA device.
SerialNumber string `json:"serial_number"`
// Verification code 1.
AuthenticationCodeFirst string `json:"authentication_code_first"`
// Verification code 2.
AuthenticationCodeSecond string `json:"authentication_code_second"`
}
type CreateMfaDeviceOpts ¶ added in v0.5.25
type CreateMfaDeviceResponse ¶ added in v0.5.25
type CreateMfaDeviceResponse struct {
// Serial number of the MFA device.
SerialNumber string `json:"serial_number"`
// Base32 seed, which a third-party system can use to generate a CAPTCHA code.
Base32StringSeed string `json:"base32_string_seed"`
}
func CreateMfaDevice ¶ added in v0.5.25
func CreateMfaDevice(client *golangsdk.ServiceClient, opts CreateMfaDeviceOpts) (*CreateMfaDeviceResponse, error)
type CreateOpts ¶
type CreateOpts struct {
// Name is the name of the new user.
Name string `json:"name" required:"true"`
// DefaultProjectID is the ID of the default project of the user.
DefaultProjectID string `json:"default_project_id,omitempty"`
// DomainID is the ID of the domain the user belongs to.
DomainID string `json:"domain_id,omitempty"`
// Enabled sets the user status to enabled or disabled.
Enabled *bool `json:"enabled,omitempty"`
// Password is the password of the new user.
Password string `json:"password,omitempty"`
// Description is a description of the user.
Description string `json:"description,omitempty"`
// Email is the email of the user.
Email string `json:"email,omitempty"`
}
CreateOpts provides options used to create a user.
func (CreateOpts) ToUserCreateMap ¶
func (opts CreateOpts) ToUserCreateMap() (map[string]interface{}, error)
ToUserCreateMap formats a CreateOpts into a create request.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response from a Create operation. Call its Extract method to interpret it as a User.
func Create ¶
func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create creates a new User.
type DeleteMfaDeviceOpts ¶ added in v0.5.25
type DeleteResult ¶
type DeleteResult struct {
golangsdk.ErrResult
}
DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.
func Delete ¶
func Delete(client *golangsdk.ServiceClient, userID string) (r DeleteResult)
Delete deletes a user.
func RemoveFromGroup ¶
func RemoveFromGroup(client *golangsdk.ServiceClient, groupID string, userID string) (r DeleteResult)
RemoveFromGroup remove user from group
type ExtendedUpdateOpts ¶ added in v0.1.0
type ExtendedUpdateOpts struct {
// Name is the name of the user.
Name string `json:"name,omitempty"`
/*Password of the user. The password must meet the following requirements:
- Can contain 6 to 32 characters. The default minimum password length is 6 characters.
- Must contain at least two of the following character types: uppercase letters, lowercase letters, digits, and special characters.
- Must meet the requirements of the password policy configured on the account settings page.
- Must be different from the old password.
*/
Password string `json:"password,omitempty"`
// Enabled is whether or not the user is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Description is a description of the user.
Description *string `json:"description,omitempty"`
// Email is the email of the user
Email string `json:"email,omitempty"`
// AreaCode is country code
AreaCode string `json:"areacode,omitempty"`
// Phone is mobile number, which can contain a maximum of 32 digits.
// The mobile number must be used together with a country code.
Phone string `json:"phone,omitempty"`
// Whether password reset is required at first login
PwdResetRequired *bool `json:"pwd_status,omitempty"`
// XUserType is Type of the IAM user in the external system.
XUserType string `json:"xuser_type,omitempty"`
// XUserID is ID of the IAM user in the external system.
XUserID string `json:"xuser_id,omitempty"`
}
ExtendedUpdateOpts allows modifying User information (including e-mail address and mobile number)
func (ExtendedUpdateOpts) ToUserUpdateMap ¶ added in v0.1.0
func (opts ExtendedUpdateOpts) ToUserUpdateMap() (map[string]interface{}, error)
type ExtendedUpdateOptsBuilder ¶ added in v0.1.0
ExtendedUpdateOptsBuilder allows extensions to add additional parameters to the ExtendedUpdate request.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response from a Get operation. Call its Extract method to interpret it as a User.
type ListOpts ¶
type ListOpts struct {
// DomainID filters the response by a domain ID.
DomainID string `q:"domain_id"`
// Enabled filters the response by enabled users.
Enabled *bool `q:"enabled"`
// Name filters the response by username.
Name string `q:"name"`
}
ListOpts provides options to filter the List results.
func (ListOpts) ToUserListQuery ¶
ToUserListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request
type Option ¶
type Option string
Option is a specific option defined at the API to enable features on a user account.
const ( IgnoreChangePasswordUponFirstUse Option = "ignore_change_password_upon_first_use" IgnorePasswordExpiry Option = "ignore_password_expiry" IgnoreLockoutFailureAttempts Option = "ignore_lockout_failure_attempts" MultiFactorAuthRules Option = "multi_factor_auth_rules" MultiFactorAuthEnabled Option = "multi_factor_auth_enabled" )
type UnbindMfaDevice ¶ added in v0.5.25
type UnbindMfaDevice struct {
// ID of the user from whom you will unbind the MFA device.
UserId string `json:"user_id"`
// Administrator: Set this parameter to any value, because verification is not required.
// IAM user: Enter the MFA verification code.
AuthenticationCode string `json:"authentication_code"`
// Serial number of the MFA device.
SerialNumber string `json:"serial_number"`
}
type UpdateExtendedResult ¶ added in v0.1.0
type UpdateExtendedResult struct {
// contains filtered or unexported fields
}
UpdateExtendedResult is the response from an UpdateExtended operation. Call its Extract method to interpret it as a User.
func ExtendedUpdate ¶ added in v0.1.0
func ExtendedUpdate(client *golangsdk.ServiceClient, userID string, opts ExtendedUpdateOpts) (r UpdateExtendedResult)
type UpdateOpts ¶
type UpdateOpts struct {
// Name is the name of the new user.
Name string `json:"name,omitempty"`
// DefaultProjectID is the ID of the default project of the user.
DefaultProjectID string `json:"default_project_id,omitempty"`
// DomainID is the ID of the domain the user belongs to.
DomainID string `json:"domain_id,omitempty"`
// Enabled sets the user status to enabled or disabled.
Enabled *bool `json:"enabled,omitempty"`
// Password is the password of the new user.
Password string `json:"password,omitempty"`
// Description is a description of the user.
Description *string `json:"description,omitempty"`
// Email is the email of the user.
Email string `json:"email,omitempty"`
}
UpdateOpts provides options for updating a user account.
func (UpdateOpts) ToUserUpdateMap ¶
func (opts UpdateOpts) ToUserUpdateMap() (map[string]interface{}, error)
ToUserUpdateMap formats a UpdateOpts into an update request.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult is the response from an Update operation. Call its Extract method to interpret it as a User.
func Update ¶
func Update(client *golangsdk.ServiceClient, userID string, opts UpdateOptsBuilder) (r UpdateResult)
Update updates an existing User.
type User ¶
type User struct {
// DefaultProjectID is the ID of the default project of the user.
DefaultProjectID string `json:"default_project_id"`
// Description is a description of the user.
Description string `json:"description"`
// DomainID is the domain ID the user belongs to.
DomainID string `json:"domain_id"`
// Enabled is whether the user is enabled.
Enabled bool `json:"enabled"`
// ID is the unique ID of the user.
ID string `json:"id"`
// Links contains referencing links to the user.
Links map[string]interface{} `json:"links"`
// Name is the name of the user.
Name string `json:"name"`
// PasswordExpiresAt is the timestamp when the user's password expires.
PasswordExpiresAt time.Time `json:"-"`
// Email is the email of the user
Email string `json:"email,omitempty"`
// AreaCode is country code
AreaCode string `json:"areacode,omitempty"`
// Phone is mobile number, which can contain a maximum of 32 digits.
// The mobile number must be used together with a country code.
Phone string `json:"phone,omitempty"`
// Whether password reset is required at first login
PwdResetRequired bool `json:"pwd_status,omitempty"`
// XUserType is Type of the IAM user in the external system.
XUserType string `json:"xuser_type,omitempty"`
// XUserID is ID of the IAM user in the external system.
XUserID string `json:"xuser_id,omitempty"`
}
User represents a User in the OpenStack Identity Service.
func ExtractUsers ¶
func ExtractUsers(r pagination.Page) ([]User, error)
ExtractUsers returns a slice of Users contained in a single page of results.
func (*User) UnmarshalJSON ¶
type UserPage ¶
type UserPage struct {
pagination.LinkedPageBase
}
UserPage is a single page of User results.
func (UserPage) NextPageURL ¶
NextPageURL extracts the "next" link from the links section of the result.
type WelcomeResult ¶ added in v0.4.0
type WelcomeResult struct {
golangsdk.ErrResult
}
func SendWelcomeEmail ¶ added in v0.4.0
func SendWelcomeEmail(client *golangsdk.ServiceClient, userID string) (r WelcomeResult)
SendWelcomeEmail sends a welcome email to a user.