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 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 CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type ExtendedUpdateOpts
- type ExtendedUpdateOptsBuilder
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Option
- type UpdateExtendedResult
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type User
- type UserPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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)
Add a user into one group
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"` }
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 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)
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 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"` }
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 or not 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.