Documentation ¶
Overview ¶
Package users provides the ability to retrieve and manage users through the Resell v2 API.
Example of getting a single user referenced by its id
user, _, err := users.Get(context, resellClient, userID) if err != nil { log.Fatal(err) } fmt.Println(user)
Example of getting all users
allUsers, _, err := users.List(ctx, resellClient) if err != nil { log.Fatal(err) } for _, user := range allUsers { fmt.Println(user) }
Example of creating a single user
userCreateOpts := users.UserOpts{ Name: "user0", Password: "verysecret", } createdUser, _, err := users.Create(ctx, resellClient, userCreateOpts) if err != nil { log.Fatal(err) } fmt.Println(createdUser)
Example of updating a single user
userEnabled := false userUpdateOpts := users.UserOpts{ Name: "user1", Password: "moresecret", Enabled: &userEnabled, } updatedUser, _, err := users.Update(ctx, resellClient, createdUser.ID, userUpdateOpts) if err != nil { log.Fatal(err) } fmt.Println(updatedUser)
Example of deleting a single user
_, err = users.Delete(context, resellClient, createdUser.ID) if err != nil { log.Fatal(err) }
Index ¶
- func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
- type User
- func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts UserOpts) (*User, *selvpcclient.ResponseResult, error)
- func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*User, *selvpcclient.ResponseResult, error)
- func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*User, *selvpcclient.ResponseResult, error)
- func Update(ctx context.Context, client *selvpcclient.ServiceClient, id string, ...) (*User, *selvpcclient.ResponseResult, error)
- type UserOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
Delete deletes a single user by its id.
Types ¶
type User ¶
type User struct { // ID is a unique id of a user. ID string `json:"id"` // Name represents the human-readable name of a user. Name string `json:"name"` // Enabled shows if user is active or it was disabled. Enabled bool `json:"enabled"` }
User represents a single user of the Identity service project.
func Create ¶
func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts UserOpts) (*User, *selvpcclient.ResponseResult, error)
Create requests a creation of the user.
func Get ¶
func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*User, *selvpcclient.ResponseResult, error)
Get returns a single user by its id.
func List ¶
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*User, *selvpcclient.ResponseResult, error)
List gets a list of users in the current domain.
func Update ¶
func Update(ctx context.Context, client *selvpcclient.ServiceClient, id string, updateOpts UserOpts) (*User, *selvpcclient.ResponseResult, error)
Update requests an update of the user referenced by its id.
type UserOpts ¶
type UserOpts struct { // Name represents the name of a user. Name string `json:"name,omitempty"` // Password represents a user's password. Password string `json:"password,omitempty"` // Enabled shows if user is active or it needs to be disabled. Enabled *bool `json:"enabled,omitempty"` }
UserOpts represents options for the user Create and Update requests.
Click to show internal directories.
Click to hide internal directories.