users

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 3

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

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

Create requests a creation of the user.

func Get added in v1.9.0

Get returns a single user by its id.

func List

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL